@tiptap/vue-3 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 +2 -2
- package/dist/index.cjs +523 -0
- package/dist/index.d.ts +271 -0
- package/dist/index.js +523 -0
- package/package.json +42 -13
- package/src/BubbleMenu.ts +41 -15
- package/src/Editor.ts +20 -10
- package/src/EditorContent.ts +15 -10
- package/src/FloatingMenu.ts +36 -11
- package/src/NodeViewContent.ts +6 -8
- package/src/NodeViewWrapper.ts +5 -4
- package/src/VueNodeViewRenderer.ts +78 -33
- package/src/VueRenderer.ts +10 -9
- package/src/index.ts +4 -4
- package/src/useEditor.ts +3 -2
- package/CHANGELOG.md +0 -179
- package/LICENSE.md +0 -21
- package/dist/packages/vue-3/src/BubbleMenu.d.ts +0 -18
- package/dist/packages/vue-3/src/Editor.d.ts +0 -22
- package/dist/packages/vue-3/src/EditorContent.d.ts +0 -14
- package/dist/packages/vue-3/src/FloatingMenu.d.ts +0 -11
- package/dist/packages/vue-3/src/NodeViewContent.d.ts +0 -10
- package/dist/packages/vue-3/src/NodeViewWrapper.d.ts +0 -10
- package/dist/packages/vue-3/src/VueNodeViewRenderer.d.ts +0 -42
- package/dist/packages/vue-3/src/VueRenderer.d.ts +0 -19
- package/dist/packages/vue-3/src/index.d.ts +0 -10
- package/dist/packages/vue-3/src/useEditor.d.ts +0 -3
- package/dist/tiptap-vue-3.bundle.umd.min.js +0 -2
- package/dist/tiptap-vue-3.bundle.umd.min.js.map +0 -1
- package/dist/tiptap-vue-3.cjs.js +0 -405
- package/dist/tiptap-vue-3.cjs.js.map +0 -1
- package/dist/tiptap-vue-3.esm.js +0 -385
- package/dist/tiptap-vue-3.esm.js.map +0 -1
- package/dist/tiptap-vue-3.umd.js +0 -406
- package/dist/tiptap-vue-3.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
## Introduction
|
|
8
8
|
tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Official Documentation
|
|
11
11
|
Documentation can be found on the [tiptap website](https://tiptap.dev).
|
|
12
12
|
|
|
13
13
|
## License
|
|
14
|
-
tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap
|
|
14
|
+
tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }// src/BubbleMenu.ts
|
|
2
|
+
var _extensionbubblemenu = require('@tiptap/extension-bubble-menu');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _vue = require('vue');
|
|
10
|
+
var BubbleMenu = _vue.defineComponent.call(void 0, {
|
|
11
|
+
name: "BubbleMenu",
|
|
12
|
+
props: {
|
|
13
|
+
pluginKey: {
|
|
14
|
+
type: null,
|
|
15
|
+
default: "bubbleMenu"
|
|
16
|
+
},
|
|
17
|
+
editor: {
|
|
18
|
+
type: Object,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
updateDelay: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: void 0
|
|
24
|
+
},
|
|
25
|
+
tippyOptions: {
|
|
26
|
+
type: Object,
|
|
27
|
+
default: () => ({})
|
|
28
|
+
},
|
|
29
|
+
shouldShow: {
|
|
30
|
+
type: Function,
|
|
31
|
+
default: null
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setup(props, { slots }) {
|
|
35
|
+
const root = _vue.ref.call(void 0, null);
|
|
36
|
+
_vue.onMounted.call(void 0, () => {
|
|
37
|
+
const {
|
|
38
|
+
updateDelay,
|
|
39
|
+
editor,
|
|
40
|
+
pluginKey,
|
|
41
|
+
shouldShow,
|
|
42
|
+
tippyOptions
|
|
43
|
+
} = props;
|
|
44
|
+
editor.registerPlugin(_extensionbubblemenu.BubbleMenuPlugin.call(void 0, {
|
|
45
|
+
updateDelay,
|
|
46
|
+
editor,
|
|
47
|
+
element: root.value,
|
|
48
|
+
pluginKey,
|
|
49
|
+
shouldShow,
|
|
50
|
+
tippyOptions
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
_vue.onBeforeUnmount.call(void 0, () => {
|
|
54
|
+
const { pluginKey, editor } = props;
|
|
55
|
+
editor.unregisterPlugin(pluginKey);
|
|
56
|
+
});
|
|
57
|
+
return () => {
|
|
58
|
+
var _a;
|
|
59
|
+
return _vue.h.call(void 0, "div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// src/Editor.ts
|
|
65
|
+
var _core = require('@tiptap/core'); _createStarExport(_core);
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
function useDebouncedRef(value) {
|
|
72
|
+
return _vue.customRef.call(void 0, (track, trigger) => {
|
|
73
|
+
return {
|
|
74
|
+
get() {
|
|
75
|
+
track();
|
|
76
|
+
return value;
|
|
77
|
+
},
|
|
78
|
+
set(newValue) {
|
|
79
|
+
value = newValue;
|
|
80
|
+
requestAnimationFrame(() => {
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
trigger();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
var Editor = class extends _core.Editor {
|
|
90
|
+
constructor(options = {}) {
|
|
91
|
+
super(options);
|
|
92
|
+
this.vueRenderers = _vue.reactive.call(void 0, /* @__PURE__ */ new Map());
|
|
93
|
+
this.contentComponent = null;
|
|
94
|
+
this.reactiveState = useDebouncedRef(this.view.state);
|
|
95
|
+
this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage);
|
|
96
|
+
this.on("transaction", () => {
|
|
97
|
+
this.reactiveState.value = this.view.state;
|
|
98
|
+
this.reactiveExtensionStorage.value = this.extensionStorage;
|
|
99
|
+
});
|
|
100
|
+
return _vue.markRaw.call(void 0, this);
|
|
101
|
+
}
|
|
102
|
+
get state() {
|
|
103
|
+
return this.reactiveState ? this.reactiveState.value : this.view.state;
|
|
104
|
+
}
|
|
105
|
+
get storage() {
|
|
106
|
+
return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
|
|
107
|
+
}
|
|
108
|
+
registerPlugin(plugin, handlePlugins) {
|
|
109
|
+
super.registerPlugin(plugin, handlePlugins);
|
|
110
|
+
this.reactiveState.value = this.view.state;
|
|
111
|
+
}
|
|
112
|
+
unregisterPlugin(nameOrPluginKey) {
|
|
113
|
+
super.unregisterPlugin(nameOrPluginKey);
|
|
114
|
+
this.reactiveState.value = this.view.state;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/EditorContent.ts
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
var EditorContent = _vue.defineComponent.call(void 0, {
|
|
131
|
+
name: "EditorContent",
|
|
132
|
+
props: {
|
|
133
|
+
editor: {
|
|
134
|
+
default: null,
|
|
135
|
+
type: Object
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
setup(props) {
|
|
139
|
+
const rootEl = _vue.ref.call(void 0, );
|
|
140
|
+
const instance = _vue.getCurrentInstance.call(void 0, );
|
|
141
|
+
_vue.watchEffect.call(void 0, () => {
|
|
142
|
+
const editor = props.editor;
|
|
143
|
+
if (editor && editor.options.element && rootEl.value) {
|
|
144
|
+
_vue.nextTick.call(void 0, () => {
|
|
145
|
+
if (!rootEl.value || !editor.options.element.firstChild) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const element = _vue.unref.call(void 0, rootEl.value);
|
|
149
|
+
rootEl.value.append(...editor.options.element.childNodes);
|
|
150
|
+
editor.contentComponent = instance.ctx._;
|
|
151
|
+
editor.setOptions({
|
|
152
|
+
element
|
|
153
|
+
});
|
|
154
|
+
editor.createNodeViews();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
_vue.onBeforeUnmount.call(void 0, () => {
|
|
159
|
+
const editor = props.editor;
|
|
160
|
+
if (!editor) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (!editor.isDestroyed) {
|
|
164
|
+
editor.view.setProps({
|
|
165
|
+
nodeViews: {}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
editor.contentComponent = null;
|
|
169
|
+
if (!editor.options.element.firstChild) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const newElement = document.createElement("div");
|
|
173
|
+
newElement.append(...editor.options.element.childNodes);
|
|
174
|
+
editor.setOptions({
|
|
175
|
+
element: newElement
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
return { rootEl };
|
|
179
|
+
},
|
|
180
|
+
render() {
|
|
181
|
+
const vueRenderers = [];
|
|
182
|
+
if (this.editor) {
|
|
183
|
+
this.editor.vueRenderers.forEach((vueRenderer) => {
|
|
184
|
+
const node = _vue.h.call(void 0,
|
|
185
|
+
_vue.Teleport,
|
|
186
|
+
{
|
|
187
|
+
to: vueRenderer.teleportElement,
|
|
188
|
+
key: vueRenderer.id
|
|
189
|
+
},
|
|
190
|
+
_vue.h.call(void 0,
|
|
191
|
+
vueRenderer.component,
|
|
192
|
+
{
|
|
193
|
+
ref: vueRenderer.id,
|
|
194
|
+
...vueRenderer.props
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
vueRenderers.push(node);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return _vue.h.call(void 0,
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
ref: (el) => {
|
|
205
|
+
this.rootEl = el;
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
...vueRenderers
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// src/FloatingMenu.ts
|
|
214
|
+
var _extensionfloatingmenu = require('@tiptap/extension-floating-menu');
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
var FloatingMenu = _vue.defineComponent.call(void 0, {
|
|
223
|
+
name: "FloatingMenu",
|
|
224
|
+
props: {
|
|
225
|
+
pluginKey: {
|
|
226
|
+
type: null,
|
|
227
|
+
default: "floatingMenu"
|
|
228
|
+
},
|
|
229
|
+
editor: {
|
|
230
|
+
type: Object,
|
|
231
|
+
required: true
|
|
232
|
+
},
|
|
233
|
+
tippyOptions: {
|
|
234
|
+
type: Object,
|
|
235
|
+
default: () => ({})
|
|
236
|
+
},
|
|
237
|
+
shouldShow: {
|
|
238
|
+
type: Function,
|
|
239
|
+
default: null
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
setup(props, { slots }) {
|
|
243
|
+
const root = _vue.ref.call(void 0, null);
|
|
244
|
+
_vue.onMounted.call(void 0, () => {
|
|
245
|
+
const {
|
|
246
|
+
pluginKey,
|
|
247
|
+
editor,
|
|
248
|
+
tippyOptions,
|
|
249
|
+
shouldShow
|
|
250
|
+
} = props;
|
|
251
|
+
editor.registerPlugin(_extensionfloatingmenu.FloatingMenuPlugin.call(void 0, {
|
|
252
|
+
pluginKey,
|
|
253
|
+
editor,
|
|
254
|
+
element: root.value,
|
|
255
|
+
tippyOptions,
|
|
256
|
+
shouldShow
|
|
257
|
+
}));
|
|
258
|
+
});
|
|
259
|
+
_vue.onBeforeUnmount.call(void 0, () => {
|
|
260
|
+
const { pluginKey, editor } = props;
|
|
261
|
+
editor.unregisterPlugin(pluginKey);
|
|
262
|
+
});
|
|
263
|
+
return () => {
|
|
264
|
+
var _a;
|
|
265
|
+
return _vue.h.call(void 0, "div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// src/NodeViewContent.ts
|
|
271
|
+
|
|
272
|
+
var NodeViewContent = _vue.defineComponent.call(void 0, {
|
|
273
|
+
props: {
|
|
274
|
+
as: {
|
|
275
|
+
type: String,
|
|
276
|
+
default: "div"
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
render() {
|
|
280
|
+
return _vue.h.call(void 0, this.as, {
|
|
281
|
+
style: {
|
|
282
|
+
whiteSpace: "pre-wrap"
|
|
283
|
+
},
|
|
284
|
+
"data-node-view-content": ""
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// src/NodeViewWrapper.ts
|
|
290
|
+
|
|
291
|
+
var NodeViewWrapper = _vue.defineComponent.call(void 0, {
|
|
292
|
+
props: {
|
|
293
|
+
as: {
|
|
294
|
+
type: String,
|
|
295
|
+
default: "div"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
inject: ["onDragStart", "decorationClasses"],
|
|
299
|
+
render() {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
return _vue.h.call(void 0,
|
|
302
|
+
this.as,
|
|
303
|
+
{
|
|
304
|
+
class: this.decorationClasses,
|
|
305
|
+
style: {
|
|
306
|
+
whiteSpace: "normal"
|
|
307
|
+
},
|
|
308
|
+
"data-node-view-wrapper": "",
|
|
309
|
+
onDragstart: this.onDragStart
|
|
310
|
+
},
|
|
311
|
+
(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// src/useEditor.ts
|
|
317
|
+
|
|
318
|
+
var useEditor = (options = {}) => {
|
|
319
|
+
const editor = _vue.shallowRef.call(void 0, );
|
|
320
|
+
_vue.onMounted.call(void 0, () => {
|
|
321
|
+
editor.value = new Editor(options);
|
|
322
|
+
});
|
|
323
|
+
_vue.onBeforeUnmount.call(void 0, () => {
|
|
324
|
+
var _a;
|
|
325
|
+
(_a = editor.value) == null ? void 0 : _a.destroy();
|
|
326
|
+
});
|
|
327
|
+
return editor;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/VueNodeViewRenderer.ts
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
// src/VueRenderer.ts
|
|
341
|
+
|
|
342
|
+
var VueRenderer = class {
|
|
343
|
+
constructor(component, { props = {}, editor }) {
|
|
344
|
+
this.id = Math.floor(Math.random() * 4294967295).toString();
|
|
345
|
+
this.editor = editor;
|
|
346
|
+
this.component = _vue.markRaw.call(void 0, component);
|
|
347
|
+
this.teleportElement = document.createElement("div");
|
|
348
|
+
this.element = this.teleportElement;
|
|
349
|
+
this.props = _vue.reactive.call(void 0, props);
|
|
350
|
+
this.editor.vueRenderers.set(this.id, this);
|
|
351
|
+
if (this.editor.contentComponent) {
|
|
352
|
+
this.editor.contentComponent.update();
|
|
353
|
+
if (this.teleportElement.children.length !== 1) {
|
|
354
|
+
throw Error("VueRenderer doesn\u2019t support multiple child elements.");
|
|
355
|
+
}
|
|
356
|
+
this.element = this.teleportElement.firstElementChild;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
get ref() {
|
|
360
|
+
var _a;
|
|
361
|
+
return (_a = this.editor.contentComponent) == null ? void 0 : _a.refs[this.id];
|
|
362
|
+
}
|
|
363
|
+
updateProps(props = {}) {
|
|
364
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
365
|
+
this.props[key] = value;
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
destroy() {
|
|
369
|
+
this.editor.vueRenderers.delete(this.id);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// src/VueNodeViewRenderer.ts
|
|
374
|
+
var nodeViewProps = {
|
|
375
|
+
editor: {
|
|
376
|
+
type: Object,
|
|
377
|
+
required: true
|
|
378
|
+
},
|
|
379
|
+
node: {
|
|
380
|
+
type: Object,
|
|
381
|
+
required: true
|
|
382
|
+
},
|
|
383
|
+
decorations: {
|
|
384
|
+
type: Object,
|
|
385
|
+
required: true
|
|
386
|
+
},
|
|
387
|
+
selected: {
|
|
388
|
+
type: Boolean,
|
|
389
|
+
required: true
|
|
390
|
+
},
|
|
391
|
+
extension: {
|
|
392
|
+
type: Object,
|
|
393
|
+
required: true
|
|
394
|
+
},
|
|
395
|
+
getPos: {
|
|
396
|
+
type: Function,
|
|
397
|
+
required: true
|
|
398
|
+
},
|
|
399
|
+
updateAttributes: {
|
|
400
|
+
type: Function,
|
|
401
|
+
required: true
|
|
402
|
+
},
|
|
403
|
+
deleteNode: {
|
|
404
|
+
type: Function,
|
|
405
|
+
required: true
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
var VueNodeView = class extends _core.NodeView {
|
|
409
|
+
mount() {
|
|
410
|
+
const props = {
|
|
411
|
+
editor: this.editor,
|
|
412
|
+
node: this.node,
|
|
413
|
+
decorations: this.decorations,
|
|
414
|
+
selected: false,
|
|
415
|
+
extension: this.extension,
|
|
416
|
+
getPos: () => this.getPos(),
|
|
417
|
+
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
|
|
418
|
+
deleteNode: () => this.deleteNode()
|
|
419
|
+
};
|
|
420
|
+
const onDragStart = this.onDragStart.bind(this);
|
|
421
|
+
this.decorationClasses = _vue.ref.call(void 0, this.getDecorationClasses());
|
|
422
|
+
const extendedComponent = _vue.defineComponent.call(void 0, {
|
|
423
|
+
extends: { ...this.component },
|
|
424
|
+
props: Object.keys(props),
|
|
425
|
+
template: this.component.template,
|
|
426
|
+
setup: (reactiveProps) => {
|
|
427
|
+
var _a, _b;
|
|
428
|
+
_vue.provide.call(void 0, "onDragStart", onDragStart);
|
|
429
|
+
_vue.provide.call(void 0, "decorationClasses", this.decorationClasses);
|
|
430
|
+
return (_b = (_a = this.component).setup) == null ? void 0 : _b.call(_a, reactiveProps, {
|
|
431
|
+
expose: () => void 0
|
|
432
|
+
});
|
|
433
|
+
},
|
|
434
|
+
__scopeId: this.component.__scopeId,
|
|
435
|
+
__cssModules: this.component.__cssModules
|
|
436
|
+
});
|
|
437
|
+
this.renderer = new VueRenderer(extendedComponent, {
|
|
438
|
+
editor: this.editor,
|
|
439
|
+
props
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
get dom() {
|
|
443
|
+
if (!this.renderer.element.hasAttribute("data-node-view-wrapper")) {
|
|
444
|
+
throw Error("Please use the NodeViewWrapper component for your node view.");
|
|
445
|
+
}
|
|
446
|
+
return this.renderer.element;
|
|
447
|
+
}
|
|
448
|
+
get contentDOM() {
|
|
449
|
+
if (this.node.isLeaf) {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
const contentElement = this.dom.querySelector("[data-node-view-content]");
|
|
453
|
+
return contentElement || this.dom;
|
|
454
|
+
}
|
|
455
|
+
update(node, decorations) {
|
|
456
|
+
const updateProps = (props) => {
|
|
457
|
+
this.decorationClasses.value = this.getDecorationClasses();
|
|
458
|
+
this.renderer.updateProps(props);
|
|
459
|
+
};
|
|
460
|
+
if (typeof this.options.update === "function") {
|
|
461
|
+
const oldNode = this.node;
|
|
462
|
+
const oldDecorations = this.decorations;
|
|
463
|
+
this.node = node;
|
|
464
|
+
this.decorations = decorations;
|
|
465
|
+
return this.options.update({
|
|
466
|
+
oldNode,
|
|
467
|
+
oldDecorations,
|
|
468
|
+
newNode: node,
|
|
469
|
+
newDecorations: decorations,
|
|
470
|
+
updateProps: () => updateProps({ node, decorations })
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
if (node.type !== this.node.type) {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
if (node === this.node && this.decorations === decorations) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
this.node = node;
|
|
480
|
+
this.decorations = decorations;
|
|
481
|
+
updateProps({ node, decorations });
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
selectNode() {
|
|
485
|
+
this.renderer.updateProps({
|
|
486
|
+
selected: true
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
deselectNode() {
|
|
490
|
+
this.renderer.updateProps({
|
|
491
|
+
selected: false
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
getDecorationClasses() {
|
|
495
|
+
return this.decorations.map((item) => item.type.attrs.class).flat().join(" ");
|
|
496
|
+
}
|
|
497
|
+
destroy() {
|
|
498
|
+
this.renderer.destroy();
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
function VueNodeViewRenderer(component, options) {
|
|
502
|
+
return (props) => {
|
|
503
|
+
if (!props.editor.contentComponent) {
|
|
504
|
+
return {};
|
|
505
|
+
}
|
|
506
|
+
return new VueNodeView(component, props, options);
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// src/index.ts
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
exports.BubbleMenu = BubbleMenu; exports.Editor = Editor; exports.EditorContent = EditorContent; exports.FloatingMenu = FloatingMenu; exports.NodeViewContent = NodeViewContent; exports.NodeViewWrapper = NodeViewWrapper; exports.VueNodeViewRenderer = VueNodeViewRenderer; exports.VueRenderer = VueRenderer; exports.nodeViewProps = nodeViewProps; exports.useEditor = useEditor;
|