@tiptap/vue-2 2.0.0-beta.21 → 2.0.0-beta.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +397 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.js +397 -0
- package/package.json +42 -12
- package/src/BubbleMenu.ts +33 -8
- package/src/EditorContent.ts +16 -8
- package/src/FloatingMenu.ts +27 -8
- package/src/NodeViewContent.ts +15 -13
- package/src/NodeViewWrapper.ts +14 -7
- package/src/VueNodeViewRenderer.ts +74 -39
- package/src/VueRenderer.ts +7 -4
- package/src/index.ts +4 -4
- package/CHANGELOG.md +0 -180
- package/LICENSE.md +0 -21
- package/dist/packages/vue-2/src/BubbleMenu.d.ts +0 -5
- package/dist/packages/vue-2/src/Editor.d.ts +0 -5
- package/dist/packages/vue-2/src/EditorContent.d.ts +0 -5
- package/dist/packages/vue-2/src/FloatingMenu.d.ts +0 -5
- package/dist/packages/vue-2/src/NodeViewContent.d.ts +0 -4
- package/dist/packages/vue-2/src/NodeViewWrapper.d.ts +0 -4
- package/dist/packages/vue-2/src/VueNodeViewRenderer.d.ts +0 -43
- package/dist/packages/vue-2/src/VueRenderer.d.ts +0 -9
- package/dist/packages/vue-2/src/index.d.ts +0 -9
- package/dist/tiptap-vue-2.bundle.umd.min.js +0 -2
- package/dist/tiptap-vue-2.bundle.umd.min.js.map +0 -1
- package/dist/tiptap-vue-2.cjs.js +0 -358
- package/dist/tiptap-vue-2.cjs.js.map +0 -1
- package/dist/tiptap-vue-2.esm.js +0 -335
- package/dist/tiptap-vue-2.esm.js.map +0 -1
- package/dist/tiptap-vue-2.umd.js +0 -359
- package/dist/tiptap-vue-2.umd.js.map +0 -1
package/dist/tiptap-vue-2.cjs.js
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@tiptap/core');
|
|
6
|
-
var Vue = require('vue');
|
|
7
|
-
var extensionBubbleMenu = require('@tiptap/extension-bubble-menu');
|
|
8
|
-
var extensionFloatingMenu = require('@tiptap/extension-floating-menu');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
|
|
13
|
-
|
|
14
|
-
const BubbleMenu = Vue__default['default'].extend({
|
|
15
|
-
name: 'BubbleMenu',
|
|
16
|
-
props: {
|
|
17
|
-
editor: {
|
|
18
|
-
type: Object,
|
|
19
|
-
required: true,
|
|
20
|
-
},
|
|
21
|
-
tippyOptions: {
|
|
22
|
-
type: Object,
|
|
23
|
-
default: () => ({}),
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
watch: {
|
|
27
|
-
editor: {
|
|
28
|
-
immediate: true,
|
|
29
|
-
handler(editor) {
|
|
30
|
-
if (!editor) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
this.$nextTick(() => {
|
|
34
|
-
editor.registerPlugin(extensionBubbleMenu.BubbleMenuPlugin({
|
|
35
|
-
editor,
|
|
36
|
-
element: this.$el,
|
|
37
|
-
tippyOptions: this.tippyOptions,
|
|
38
|
-
}));
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
render(createElement) {
|
|
44
|
-
return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default);
|
|
45
|
-
},
|
|
46
|
-
beforeDestroy() {
|
|
47
|
-
this.editor.unregisterPlugin(extensionBubbleMenu.BubbleMenuPluginKey);
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
class Editor extends core.Editor {
|
|
52
|
-
constructor() {
|
|
53
|
-
super(...arguments);
|
|
54
|
-
this.contentComponent = null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const EditorContent = Vue__default['default'].extend({
|
|
59
|
-
name: 'EditorContent',
|
|
60
|
-
props: {
|
|
61
|
-
editor: {
|
|
62
|
-
default: null,
|
|
63
|
-
type: Object,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
watch: {
|
|
67
|
-
editor: {
|
|
68
|
-
immediate: true,
|
|
69
|
-
handler(editor) {
|
|
70
|
-
if (editor && editor.options.element) {
|
|
71
|
-
this.$nextTick(() => {
|
|
72
|
-
const element = this.$el;
|
|
73
|
-
if (!element || !editor.options.element.firstChild) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
element.appendChild(editor.options.element.firstChild);
|
|
77
|
-
editor.contentComponent = this;
|
|
78
|
-
editor.setOptions({
|
|
79
|
-
element,
|
|
80
|
-
});
|
|
81
|
-
editor.createNodeViews();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
render(createElement) {
|
|
88
|
-
return createElement('div');
|
|
89
|
-
},
|
|
90
|
-
beforeDestroy() {
|
|
91
|
-
const { editor } = this;
|
|
92
|
-
if (!editor.isDestroyed) {
|
|
93
|
-
editor.view.setProps({
|
|
94
|
-
nodeViews: {},
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
editor.contentComponent = null;
|
|
98
|
-
if (!editor.options.element.firstChild) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const newElement = document.createElement('div');
|
|
102
|
-
newElement.appendChild(editor.options.element.firstChild);
|
|
103
|
-
editor.setOptions({
|
|
104
|
-
element: newElement,
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const FloatingMenu = Vue__default['default'].extend({
|
|
110
|
-
name: 'FloatingMenu',
|
|
111
|
-
props: {
|
|
112
|
-
editor: {
|
|
113
|
-
type: Object,
|
|
114
|
-
required: true,
|
|
115
|
-
},
|
|
116
|
-
tippyOptions: {
|
|
117
|
-
type: Object,
|
|
118
|
-
default: () => ({}),
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
watch: {
|
|
122
|
-
editor: {
|
|
123
|
-
immediate: true,
|
|
124
|
-
handler(editor) {
|
|
125
|
-
if (!editor) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
this.$nextTick(() => {
|
|
129
|
-
editor.registerPlugin(extensionFloatingMenu.FloatingMenuPlugin({
|
|
130
|
-
editor,
|
|
131
|
-
element: this.$el,
|
|
132
|
-
tippyOptions: this.tippyOptions,
|
|
133
|
-
}));
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
render(createElement) {
|
|
139
|
-
return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default);
|
|
140
|
-
},
|
|
141
|
-
beforeDestroy() {
|
|
142
|
-
this.editor.unregisterPlugin(extensionFloatingMenu.FloatingMenuPluginKey);
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
class VueRenderer {
|
|
147
|
-
constructor(component, props) {
|
|
148
|
-
const Component = Vue__default['default'].extend(component);
|
|
149
|
-
this.ref = new Component(props).$mount();
|
|
150
|
-
}
|
|
151
|
-
get element() {
|
|
152
|
-
return this.ref.$el;
|
|
153
|
-
}
|
|
154
|
-
updateProps(props = {}) {
|
|
155
|
-
if (!this.ref.$props) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
// prevents `Avoid mutating a prop directly` error message
|
|
159
|
-
const originalSilent = Vue__default['default'].config.silent;
|
|
160
|
-
Vue__default['default'].config.silent = true;
|
|
161
|
-
Object
|
|
162
|
-
.entries(props)
|
|
163
|
-
.forEach(([key, value]) => {
|
|
164
|
-
this.ref.$props[key] = value;
|
|
165
|
-
});
|
|
166
|
-
Vue__default['default'].config.silent = originalSilent;
|
|
167
|
-
}
|
|
168
|
-
destroy() {
|
|
169
|
-
this.ref.$destroy();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const nodeViewProps = {
|
|
174
|
-
editor: {
|
|
175
|
-
type: Object,
|
|
176
|
-
required: true,
|
|
177
|
-
},
|
|
178
|
-
node: {
|
|
179
|
-
type: Object,
|
|
180
|
-
required: true,
|
|
181
|
-
},
|
|
182
|
-
decorations: {
|
|
183
|
-
type: Object,
|
|
184
|
-
required: true,
|
|
185
|
-
},
|
|
186
|
-
selected: {
|
|
187
|
-
type: Boolean,
|
|
188
|
-
required: true,
|
|
189
|
-
},
|
|
190
|
-
extension: {
|
|
191
|
-
type: Object,
|
|
192
|
-
required: true,
|
|
193
|
-
},
|
|
194
|
-
getPos: {
|
|
195
|
-
type: Function,
|
|
196
|
-
required: true,
|
|
197
|
-
},
|
|
198
|
-
updateAttributes: {
|
|
199
|
-
type: Function,
|
|
200
|
-
required: true,
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
class VueNodeView extends core.NodeView {
|
|
204
|
-
mount() {
|
|
205
|
-
const props = {
|
|
206
|
-
editor: this.editor,
|
|
207
|
-
node: this.node,
|
|
208
|
-
decorations: this.decorations,
|
|
209
|
-
selected: false,
|
|
210
|
-
extension: this.extension,
|
|
211
|
-
getPos: () => this.getPos(),
|
|
212
|
-
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
|
|
213
|
-
};
|
|
214
|
-
const onDragStart = this.onDragStart.bind(this);
|
|
215
|
-
this.decorationClasses = Vue__default['default'].observable({
|
|
216
|
-
value: this.getDecorationClasses(),
|
|
217
|
-
});
|
|
218
|
-
const Component = Vue__default['default']
|
|
219
|
-
.extend(this.component)
|
|
220
|
-
.extend({
|
|
221
|
-
props: Object.keys(props),
|
|
222
|
-
provide: () => {
|
|
223
|
-
return {
|
|
224
|
-
onDragStart,
|
|
225
|
-
decorationClasses: this.decorationClasses,
|
|
226
|
-
};
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
this.renderer = new VueRenderer(Component, {
|
|
230
|
-
parent: this.editor.contentComponent,
|
|
231
|
-
propsData: props,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
get dom() {
|
|
235
|
-
if (!this.renderer.element.hasAttribute('data-node-view-wrapper')) {
|
|
236
|
-
throw Error('Please use the NodeViewWrapper component for your node view.');
|
|
237
|
-
}
|
|
238
|
-
return this.renderer.element;
|
|
239
|
-
}
|
|
240
|
-
get contentDOM() {
|
|
241
|
-
if (this.node.isLeaf) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
const contentElement = this.dom.querySelector('[data-node-view-content]');
|
|
245
|
-
return contentElement || this.dom;
|
|
246
|
-
}
|
|
247
|
-
update(node, decorations) {
|
|
248
|
-
if (typeof this.options.update === 'function') {
|
|
249
|
-
return this.options.update(node, decorations);
|
|
250
|
-
}
|
|
251
|
-
if (node.type !== this.node.type) {
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
if (node === this.node && this.decorations === decorations) {
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
this.node = node;
|
|
258
|
-
this.decorations = decorations;
|
|
259
|
-
this.decorationClasses.value = this.getDecorationClasses();
|
|
260
|
-
this.renderer.updateProps({ node, decorations });
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
selectNode() {
|
|
264
|
-
this.renderer.updateProps({
|
|
265
|
-
selected: true,
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
deselectNode() {
|
|
269
|
-
this.renderer.updateProps({
|
|
270
|
-
selected: false,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
getDecorationClasses() {
|
|
274
|
-
return this.decorations
|
|
275
|
-
// @ts-ignore
|
|
276
|
-
.map(item => item.type.attrs.class)
|
|
277
|
-
.flat()
|
|
278
|
-
.join(' ');
|
|
279
|
-
}
|
|
280
|
-
destroy() {
|
|
281
|
-
this.renderer.destroy();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
function VueNodeViewRenderer(component, options) {
|
|
285
|
-
return (props) => {
|
|
286
|
-
// try to get the parent component
|
|
287
|
-
// this is important for vue devtools to show the component hierarchy correctly
|
|
288
|
-
// maybe it’s `undefined` because <editor-content> isn’t rendered yet
|
|
289
|
-
if (!props.editor.contentComponent) {
|
|
290
|
-
return {};
|
|
291
|
-
}
|
|
292
|
-
return new VueNodeView(component, props, options);
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const NodeViewWrapper = Vue__default['default'].extend({
|
|
297
|
-
props: {
|
|
298
|
-
as: {
|
|
299
|
-
type: String,
|
|
300
|
-
default: 'div',
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
inject: ['onDragStart', 'decorationClasses'],
|
|
304
|
-
render(createElement) {
|
|
305
|
-
return createElement(this.as, {
|
|
306
|
-
// @ts-ignore
|
|
307
|
-
class: this.decorationClasses.value,
|
|
308
|
-
style: {
|
|
309
|
-
whiteSpace: 'normal',
|
|
310
|
-
},
|
|
311
|
-
attrs: {
|
|
312
|
-
'data-node-view-wrapper': '',
|
|
313
|
-
},
|
|
314
|
-
on: {
|
|
315
|
-
// @ts-ignore
|
|
316
|
-
dragstart: this.onDragStart,
|
|
317
|
-
},
|
|
318
|
-
}, this.$slots.default);
|
|
319
|
-
},
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
const NodeViewContent = Vue__default['default'].extend({
|
|
323
|
-
props: {
|
|
324
|
-
as: {
|
|
325
|
-
type: String,
|
|
326
|
-
default: 'div',
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
render(createElement) {
|
|
330
|
-
return createElement(this.as, {
|
|
331
|
-
style: {
|
|
332
|
-
whiteSpace: 'pre-wrap',
|
|
333
|
-
},
|
|
334
|
-
attrs: {
|
|
335
|
-
'data-node-view-content': '',
|
|
336
|
-
},
|
|
337
|
-
});
|
|
338
|
-
},
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
exports.BubbleMenu = BubbleMenu;
|
|
342
|
-
exports.Editor = Editor;
|
|
343
|
-
exports.EditorContent = EditorContent;
|
|
344
|
-
exports.FloatingMenu = FloatingMenu;
|
|
345
|
-
exports.NodeViewContent = NodeViewContent;
|
|
346
|
-
exports.NodeViewWrapper = NodeViewWrapper;
|
|
347
|
-
exports.VueNodeViewRenderer = VueNodeViewRenderer;
|
|
348
|
-
exports.VueRenderer = VueRenderer;
|
|
349
|
-
exports.nodeViewProps = nodeViewProps;
|
|
350
|
-
Object.keys(core).forEach(function (k) {
|
|
351
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
352
|
-
enumerable: true,
|
|
353
|
-
get: function () {
|
|
354
|
-
return core[k];
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
//# sourceMappingURL=tiptap-vue-2.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-vue-2.cjs.js","sources":["../src/BubbleMenu.ts","../src/Editor.ts","../src/EditorContent.ts","../src/FloatingMenu.ts","../src/VueRenderer.ts","../src/VueNodeViewRenderer.ts","../src/NodeViewWrapper.ts","../src/NodeViewContent.ts"],"sourcesContent":["import Vue, { PropType } from 'vue'\nimport { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\nexport const BubbleMenu = Vue.extend({\n name: 'BubbleMenu',\n\n props: {\n editor: {\n type: Object as PropType<BubbleMenuPluginProps['editor']>,\n required: true,\n },\n\n tippyOptions: {\n type: Object as PropType<BubbleMenuPluginProps['tippyOptions']>,\n default: () => ({}),\n },\n },\n\n watch: {\n editor: {\n immediate: true,\n handler(editor: BubbleMenuPluginProps['editor']) {\n if (!editor) {\n return\n }\n\n this.$nextTick(() => {\n editor.registerPlugin(BubbleMenuPlugin({\n editor,\n element: this.$el as HTMLElement,\n tippyOptions: this.tippyOptions,\n }))\n })\n },\n },\n },\n\n render(createElement) {\n return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default)\n },\n\n beforeDestroy() {\n this.editor.unregisterPlugin(BubbleMenuPluginKey)\n },\n})\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport Vue from 'vue'\n\nexport class Editor extends CoreEditor {\n public contentComponent: Vue | null = null\n}\n","import Vue, { PropType } from 'vue'\nimport { Editor } from './Editor'\n\nexport const EditorContent = Vue.extend({\n name: 'EditorContent',\n\n props: {\n editor: {\n default: null,\n type: Object as PropType<Editor>,\n },\n },\n\n watch: {\n editor: {\n immediate: true,\n handler(editor: Editor) {\n if (editor && editor.options.element) {\n this.$nextTick(() => {\n const element = this.$el\n\n if (!element || !editor.options.element.firstChild) {\n return\n }\n\n element.appendChild(editor.options.element.firstChild)\n\n editor.contentComponent = this\n\n editor.setOptions({\n element,\n })\n\n editor.createNodeViews()\n })\n }\n },\n },\n },\n\n render(createElement) {\n return createElement('div')\n },\n\n beforeDestroy() {\n const { editor } = this\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.appendChild(editor.options.element.firstChild)\n\n editor.setOptions({\n element: newElement,\n })\n },\n})\n","import Vue, { PropType } from 'vue'\nimport { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\n\nexport const FloatingMenu = Vue.extend({\n name: 'FloatingMenu',\n\n props: {\n editor: {\n type: Object as PropType<FloatingMenuPluginProps['editor']>,\n required: true,\n },\n\n tippyOptions: {\n type: Object as PropType<FloatingMenuPluginProps['tippyOptions']>,\n default: () => ({}),\n },\n },\n\n watch: {\n editor: {\n immediate: true,\n handler(editor: FloatingMenuPluginProps['editor']) {\n if (!editor) {\n return\n }\n\n this.$nextTick(() => {\n editor.registerPlugin(FloatingMenuPlugin({\n editor,\n element: this.$el as HTMLElement,\n tippyOptions: this.tippyOptions,\n }))\n })\n },\n },\n },\n\n render(createElement) {\n return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default)\n },\n\n beforeDestroy() {\n this.editor.unregisterPlugin(FloatingMenuPluginKey)\n },\n})\n","import Vue from 'vue'\nimport { VueConstructor } from 'vue/types/umd'\n\nexport class VueRenderer {\n ref!: Vue\n\n constructor(component: Vue | VueConstructor, props: any) {\n const Component = Vue.extend(component)\n\n this.ref = new Component(props).$mount()\n }\n\n get element(): Element {\n return this.ref.$el\n }\n\n updateProps(props: Record<string, any> = {}): void {\n if (!this.ref.$props) {\n return\n }\n\n // prevents `Avoid mutating a prop directly` error message\n const originalSilent = Vue.config.silent\n Vue.config.silent = true\n\n Object\n .entries(props)\n .forEach(([key, value]) => {\n this.ref.$props[key] = value\n })\n\n Vue.config.silent = originalSilent\n }\n\n destroy(): void {\n this.ref.$destroy()\n }\n}\n","import {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport Vue from 'vue'\nimport { VueConstructor, PropType } from 'vue/types/umd'\nimport { Editor } from './Editor'\nimport { VueRenderer } from './VueRenderer'\n\nexport const nodeViewProps = {\n editor: {\n type: Object as PropType<NodeViewProps['editor']>,\n required: true,\n },\n node: {\n type: Object as PropType<NodeViewProps['node']>,\n required: true,\n },\n decorations: {\n type: Object as PropType<NodeViewProps['decorations']>,\n required: true,\n },\n selected: {\n type: Boolean as PropType<NodeViewProps['selected']>,\n required: true,\n },\n extension: {\n type: Object as PropType<NodeViewProps['extension']>,\n required: true,\n },\n getPos: {\n type: Function as PropType<NodeViewProps['getPos']>,\n required: true,\n },\n updateAttributes: {\n type: Function as PropType<NodeViewProps['updateAttributes']>,\n required: true,\n },\n}\n\ninterface VueNodeViewRendererOptions {\n stopEvent: ((event: Event) => boolean) | null,\n update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null,\n}\n\nclass VueNodeView extends NodeView<(Vue | VueConstructor), Editor> {\n\n renderer!: VueRenderer\n\n decorationClasses!: {\n value: string\n }\n\n mount() {\n const props: NodeViewProps = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations,\n selected: false,\n extension: this.extension,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n }\n\n const onDragStart = this.onDragStart.bind(this)\n\n this.decorationClasses = Vue.observable({\n value: this.getDecorationClasses(),\n })\n\n const Component = Vue\n .extend(this.component)\n .extend({\n props: Object.keys(props),\n provide: () => {\n return {\n onDragStart,\n decorationClasses: this.decorationClasses,\n }\n },\n })\n\n this.renderer = new VueRenderer(Component, {\n parent: this.editor.contentComponent,\n propsData: props,\n })\n }\n\n get dom() {\n if (!this.renderer.element.hasAttribute('data-node-view-wrapper')) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n const contentElement = this.dom.querySelector('[data-node-view-content]')\n\n return contentElement || this.dom\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n if (typeof this.options.update === 'function') {\n return this.options.update(node, decorations)\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n this.decorationClasses.value = this.getDecorationClasses()\n this.renderer.updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n getDecorationClasses() {\n return this.decorations\n // @ts-ignore\n .map(item => item.type.attrs.class)\n .flat()\n .join(' ')\n }\n\n destroy() {\n this.renderer.destroy()\n }\n\n}\n\nexport function VueNodeViewRenderer(component: Vue | VueConstructor, options?: Partial<VueNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new VueNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import Vue from 'vue'\n\nexport const NodeViewWrapper = Vue.extend({\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n inject: ['onDragStart', 'decorationClasses'],\n\n render(createElement) {\n return createElement(\n this.as, {\n // @ts-ignore\n class: this.decorationClasses.value,\n style: {\n whiteSpace: 'normal',\n },\n attrs: {\n 'data-node-view-wrapper': '',\n },\n on: {\n // @ts-ignore\n dragstart: this.onDragStart,\n },\n },\n this.$slots.default,\n )\n },\n})\n","import Vue from 'vue'\n\nexport const NodeViewContent = Vue.extend({\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n render(createElement) {\n return createElement(\n this.as, {\n style: {\n whiteSpace: 'pre-wrap',\n },\n attrs: {\n 'data-node-view-content': '',\n },\n },\n )\n },\n})\n"],"names":["Vue","BubbleMenuPlugin","BubbleMenuPluginKey","CoreEditor","FloatingMenuPlugin","FloatingMenuPluginKey","NodeView"],"mappings":";;;;;;;;;;;;;MAGa,UAAU,GAAGA,uBAAG,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,YAAY;IAElB,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,MAAmD;YACzD,QAAQ,EAAE,IAAI;SACf;QAED,YAAY,EAAE;YACZ,IAAI,EAAE,MAAyD;YAC/D,OAAO,EAAE,OAAO,EAAE,CAAC;SACpB;KACF;IAED,KAAK,EAAE;QACL,MAAM,EAAE;YACN,SAAS,EAAE,IAAI;YACf,OAAO,CAAC,MAAuC;gBAC7C,IAAI,CAAC,MAAM,EAAE;oBACX,OAAM;iBACP;gBAED,IAAI,CAAC,SAAS,CAAC;oBACb,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;wBACrC,MAAM;wBACN,OAAO,E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