@tiptap/vue-3 2.11.7 → 3.0.0-beta.1

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.
Files changed (48) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +562 -528
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +219 -0
  6. package/dist/index.d.ts +218 -10
  7. package/dist/index.js +526 -516
  8. package/dist/index.js.map +1 -1
  9. package/dist/menus/index.cjs +613 -0
  10. package/dist/menus/index.cjs.map +1 -0
  11. package/dist/menus/index.d.cts +257 -0
  12. package/dist/menus/index.d.ts +257 -0
  13. package/dist/menus/index.js +605 -0
  14. package/dist/menus/index.js.map +1 -0
  15. package/package.json +27 -16
  16. package/src/Editor.ts +6 -11
  17. package/src/EditorContent.ts +10 -20
  18. package/src/VueMarkViewRenderer.ts +114 -0
  19. package/src/VueNodeViewRenderer.ts +19 -30
  20. package/src/VueRenderer.ts +10 -11
  21. package/src/index.ts +1 -2
  22. package/src/menus/BubbleMenu.ts +78 -0
  23. package/src/menus/FloatingMenu.ts +68 -0
  24. package/src/menus/index.ts +2 -0
  25. package/src/useEditor.ts +1 -1
  26. package/dist/BubbleMenu.d.ts +0 -61
  27. package/dist/BubbleMenu.d.ts.map +0 -1
  28. package/dist/Editor.d.ts +0 -24
  29. package/dist/Editor.d.ts.map +0 -1
  30. package/dist/EditorContent.d.ts +0 -18
  31. package/dist/EditorContent.d.ts.map +0 -1
  32. package/dist/FloatingMenu.d.ts +0 -49
  33. package/dist/FloatingMenu.d.ts.map +0 -1
  34. package/dist/NodeViewContent.d.ts +0 -14
  35. package/dist/NodeViewContent.d.ts.map +0 -1
  36. package/dist/NodeViewWrapper.d.ts +0 -14
  37. package/dist/NodeViewWrapper.d.ts.map +0 -1
  38. package/dist/VueNodeViewRenderer.d.ts +0 -63
  39. package/dist/VueNodeViewRenderer.d.ts.map +0 -1
  40. package/dist/VueRenderer.d.ts +0 -37
  41. package/dist/VueRenderer.d.ts.map +0 -1
  42. package/dist/index.d.ts.map +0 -1
  43. package/dist/index.umd.js +0 -570
  44. package/dist/index.umd.js.map +0 -1
  45. package/dist/useEditor.d.ts +0 -4
  46. package/dist/useEditor.d.ts.map +0 -1
  47. package/src/BubbleMenu.ts +0 -71
  48. package/src/FloatingMenu.ts +0 -66
package/dist/index.cjs CHANGED
@@ -1,569 +1,603 @@
1
- 'use strict';
2
-
3
- var extensionBubbleMenu = require('@tiptap/extension-bubble-menu');
4
- var vue = require('vue');
5
- var core = require('@tiptap/core');
6
- var extensionFloatingMenu = require('@tiptap/extension-floating-menu');
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
7
20
 
8
- const BubbleMenu = vue.defineComponent({
9
- name: 'BubbleMenu',
10
- props: {
11
- pluginKey: {
12
- type: [String, Object],
13
- default: 'bubbleMenu',
14
- },
15
- editor: {
16
- type: Object,
17
- required: true,
18
- },
19
- updateDelay: {
20
- type: Number,
21
- default: undefined,
22
- },
23
- tippyOptions: {
24
- type: Object,
25
- default: () => ({}),
26
- },
27
- shouldShow: {
28
- type: Function,
29
- default: null,
30
- },
31
- },
32
- setup(props, { slots }) {
33
- const root = vue.ref(null);
34
- vue.onMounted(() => {
35
- const { updateDelay, editor, pluginKey, shouldShow, tippyOptions, } = props;
36
- editor.registerPlugin(extensionBubbleMenu.BubbleMenuPlugin({
37
- updateDelay,
38
- editor,
39
- element: root.value,
40
- pluginKey,
41
- shouldShow,
42
- tippyOptions,
43
- }));
44
- });
45
- vue.onBeforeUnmount(() => {
46
- const { pluginKey, editor } = props;
47
- editor.unregisterPlugin(pluginKey);
48
- });
49
- return () => { var _a; return vue.h('div', { ref: root }, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)); };
50
- },
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Editor: () => Editor,
25
+ EditorContent: () => EditorContent,
26
+ MarkViewContent: () => MarkViewContent,
27
+ NodeViewContent: () => NodeViewContent,
28
+ NodeViewWrapper: () => NodeViewWrapper,
29
+ VueMarkView: () => VueMarkView,
30
+ VueMarkViewRenderer: () => VueMarkViewRenderer,
31
+ VueNodeViewRenderer: () => VueNodeViewRenderer,
32
+ VueRenderer: () => VueRenderer,
33
+ markViewProps: () => markViewProps,
34
+ nodeViewProps: () => nodeViewProps,
35
+ useEditor: () => useEditor
51
36
  });
37
+ module.exports = __toCommonJS(index_exports);
52
38
 
53
- /* eslint-disable react-hooks/rules-of-hooks */
39
+ // src/Editor.ts
40
+ var import_core = require("@tiptap/core");
41
+ var import_vue = require("vue");
54
42
  function useDebouncedRef(value) {
55
- return vue.customRef((track, trigger) => {
56
- return {
57
- get() {
58
- track();
59
- return value;
60
- },
61
- set(newValue) {
62
- // update state
63
- value = newValue;
64
- // update view as soon as possible
65
- requestAnimationFrame(() => {
66
- requestAnimationFrame(() => {
67
- trigger();
68
- });
69
- });
70
- },
71
- };
72
- });
73
- }
74
- class Editor extends core.Editor {
75
- constructor(options = {}) {
76
- super(options);
77
- this.contentComponent = null;
78
- this.appContext = null;
79
- this.reactiveState = useDebouncedRef(this.view.state);
80
- this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage);
81
- this.on('beforeTransaction', ({ nextState }) => {
82
- this.reactiveState.value = nextState;
83
- this.reactiveExtensionStorage.value = this.extensionStorage;
43
+ return (0, import_vue.customRef)((track, trigger) => {
44
+ return {
45
+ get() {
46
+ track();
47
+ return value;
48
+ },
49
+ set(newValue) {
50
+ value = newValue;
51
+ requestAnimationFrame(() => {
52
+ requestAnimationFrame(() => {
53
+ trigger();
54
+ });
84
55
  });
85
- return vue.markRaw(this); // eslint-disable-line
86
- }
87
- get state() {
88
- return this.reactiveState ? this.reactiveState.value : this.view.state;
89
- }
90
- get storage() {
91
- return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
92
- }
93
- /**
94
- * Register a ProseMirror plugin.
95
- */
96
- registerPlugin(plugin, handlePlugins) {
97
- const nextState = super.registerPlugin(plugin, handlePlugins);
98
- if (this.reactiveState) {
99
- this.reactiveState.value = nextState;
100
- }
101
- return nextState;
56
+ }
57
+ };
58
+ });
59
+ }
60
+ var Editor = class extends import_core.Editor {
61
+ constructor(options = {}) {
62
+ super(options);
63
+ this.contentComponent = null;
64
+ this.appContext = null;
65
+ this.reactiveState = useDebouncedRef(this.view.state);
66
+ this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage);
67
+ this.on("beforeTransaction", ({ nextState }) => {
68
+ this.reactiveState.value = nextState;
69
+ this.reactiveExtensionStorage.value = this.extensionStorage;
70
+ });
71
+ return (0, import_vue.markRaw)(this);
72
+ }
73
+ get state() {
74
+ return this.reactiveState ? this.reactiveState.value : this.view.state;
75
+ }
76
+ get storage() {
77
+ return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
78
+ }
79
+ /**
80
+ * Register a ProseMirror plugin.
81
+ */
82
+ registerPlugin(plugin, handlePlugins) {
83
+ const nextState = super.registerPlugin(plugin, handlePlugins);
84
+ if (this.reactiveState) {
85
+ this.reactiveState.value = nextState;
102
86
  }
103
- /**
104
- * Unregister a ProseMirror plugin.
105
- */
106
- unregisterPlugin(nameOrPluginKey) {
107
- const nextState = super.unregisterPlugin(nameOrPluginKey);
108
- if (this.reactiveState && nextState) {
109
- this.reactiveState.value = nextState;
110
- }
111
- return nextState;
87
+ return nextState;
88
+ }
89
+ /**
90
+ * Unregister a ProseMirror plugin.
91
+ */
92
+ unregisterPlugin(nameOrPluginKey) {
93
+ const nextState = super.unregisterPlugin(nameOrPluginKey);
94
+ if (this.reactiveState && nextState) {
95
+ this.reactiveState.value = nextState;
112
96
  }
113
- }
114
-
115
- const EditorContent = vue.defineComponent({
116
- name: 'EditorContent',
117
- props: {
118
- editor: {
119
- default: null,
120
- type: Object,
121
- },
122
- },
123
- setup(props) {
124
- const rootEl = vue.ref();
125
- const instance = vue.getCurrentInstance();
126
- vue.watchEffect(() => {
127
- const editor = props.editor;
128
- if (editor && editor.options.element && rootEl.value) {
129
- vue.nextTick(() => {
130
- if (!rootEl.value || !editor.options.element.firstChild) {
131
- return;
132
- }
133
- const element = vue.unref(rootEl.value);
134
- rootEl.value.append(...editor.options.element.childNodes);
135
- // @ts-ignore
136
- editor.contentComponent = instance.ctx._;
137
- if (instance) {
138
- editor.appContext = {
139
- ...instance.appContext,
140
- // Vue internally uses prototype chain to forward/shadow injects across the entire component chain
141
- // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext
142
- // @ts-expect-error forward instance's 'provides' into appContext
143
- provides: instance.provides,
144
- };
145
- }
146
- editor.setOptions({
147
- element,
148
- });
149
- editor.createNodeViews();
150
- });
151
- }
152
- });
153
- vue.onBeforeUnmount(() => {
154
- const editor = props.editor;
155
- if (!editor) {
156
- return;
157
- }
158
- editor.contentComponent = null;
159
- editor.appContext = null;
160
- });
161
- return { rootEl };
162
- },
163
- render() {
164
- return vue.h('div', {
165
- ref: (el) => { this.rootEl = el; },
166
- });
167
- },
168
- });
97
+ return nextState;
98
+ }
99
+ };
169
100
 
170
- const FloatingMenu = vue.defineComponent({
171
- name: 'FloatingMenu',
172
- props: {
173
- pluginKey: {
174
- // TODO: TypeScript breaks :(
175
- // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
176
- type: null,
177
- default: 'floatingMenu',
178
- },
179
- editor: {
180
- type: Object,
181
- required: true,
182
- },
183
- tippyOptions: {
184
- type: Object,
185
- default: () => ({}),
186
- },
187
- shouldShow: {
188
- type: Function,
189
- default: null,
190
- },
191
- },
192
- setup(props, { slots }) {
193
- const root = vue.ref(null);
194
- vue.onMounted(() => {
195
- const { pluginKey, editor, tippyOptions, shouldShow, } = props;
196
- editor.registerPlugin(extensionFloatingMenu.FloatingMenuPlugin({
197
- pluginKey,
198
- editor,
199
- element: root.value,
200
- tippyOptions,
201
- shouldShow,
202
- }));
203
- });
204
- vue.onBeforeUnmount(() => {
205
- const { pluginKey, editor } = props;
206
- editor.unregisterPlugin(pluginKey);
101
+ // src/EditorContent.ts
102
+ var import_vue2 = require("vue");
103
+ var EditorContent = (0, import_vue2.defineComponent)({
104
+ name: "EditorContent",
105
+ props: {
106
+ editor: {
107
+ default: null,
108
+ type: Object
109
+ }
110
+ },
111
+ setup(props) {
112
+ const rootEl = (0, import_vue2.ref)();
113
+ const instance = (0, import_vue2.getCurrentInstance)();
114
+ (0, import_vue2.watchEffect)(() => {
115
+ const editor = props.editor;
116
+ if (editor && editor.options.element && rootEl.value) {
117
+ (0, import_vue2.nextTick)(() => {
118
+ var _a;
119
+ if (!rootEl.value || !((_a = editor.options.element) == null ? void 0 : _a.firstChild)) {
120
+ return;
121
+ }
122
+ const element = (0, import_vue2.unref)(rootEl.value);
123
+ rootEl.value.append(...editor.options.element.childNodes);
124
+ editor.contentComponent = instance.ctx._;
125
+ if (instance) {
126
+ editor.appContext = {
127
+ ...instance.appContext,
128
+ // Vue internally uses prototype chain to forward/shadow injects across the entire component chain
129
+ // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext
130
+ // @ts-expect-error forward instance's 'provides' into appContext
131
+ provides: instance.provides
132
+ };
133
+ }
134
+ editor.setOptions({
135
+ element
136
+ });
137
+ editor.createNodeViews();
207
138
  });
208
- return () => { var _a; return vue.h('div', { ref: root }, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)); };
209
- },
139
+ }
140
+ });
141
+ (0, import_vue2.onBeforeUnmount)(() => {
142
+ const editor = props.editor;
143
+ if (!editor) {
144
+ return;
145
+ }
146
+ editor.contentComponent = null;
147
+ editor.appContext = null;
148
+ });
149
+ return { rootEl };
150
+ },
151
+ render() {
152
+ return (0, import_vue2.h)("div", {
153
+ ref: (el) => {
154
+ this.rootEl = el;
155
+ }
156
+ });
157
+ }
210
158
  });
211
159
 
212
- const NodeViewContent = vue.defineComponent({
213
- name: 'NodeViewContent',
214
- props: {
215
- as: {
216
- type: String,
217
- default: 'div',
218
- },
219
- },
220
- render() {
221
- return vue.h(this.as, {
222
- style: {
223
- whiteSpace: 'pre-wrap',
224
- },
225
- 'data-node-view-content': '',
226
- });
227
- },
160
+ // src/NodeViewContent.ts
161
+ var import_vue3 = require("vue");
162
+ var NodeViewContent = (0, import_vue3.defineComponent)({
163
+ name: "NodeViewContent",
164
+ props: {
165
+ as: {
166
+ type: String,
167
+ default: "div"
168
+ }
169
+ },
170
+ render() {
171
+ return (0, import_vue3.h)(this.as, {
172
+ style: {
173
+ whiteSpace: "pre-wrap"
174
+ },
175
+ "data-node-view-content": ""
176
+ });
177
+ }
228
178
  });
229
179
 
230
- const NodeViewWrapper = vue.defineComponent({
231
- name: 'NodeViewWrapper',
232
- props: {
233
- as: {
234
- type: String,
235
- default: 'div',
180
+ // src/NodeViewWrapper.ts
181
+ var import_vue4 = require("vue");
182
+ var NodeViewWrapper = (0, import_vue4.defineComponent)({
183
+ name: "NodeViewWrapper",
184
+ props: {
185
+ as: {
186
+ type: String,
187
+ default: "div"
188
+ }
189
+ },
190
+ inject: ["onDragStart", "decorationClasses"],
191
+ render() {
192
+ var _a, _b;
193
+ return (0, import_vue4.h)(
194
+ this.as,
195
+ {
196
+ // @ts-ignore
197
+ class: this.decorationClasses,
198
+ style: {
199
+ whiteSpace: "normal"
236
200
  },
237
- },
238
- inject: ['onDragStart', 'decorationClasses'],
239
- render() {
240
- var _a, _b;
241
- return vue.h(this.as, {
242
- // @ts-ignore
243
- class: this.decorationClasses,
244
- style: {
245
- whiteSpace: 'normal',
246
- },
247
- 'data-node-view-wrapper': '',
248
- // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
249
- onDragstart: this.onDragStart,
250
- }, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a));
251
- },
201
+ "data-node-view-wrapper": "",
202
+ // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
203
+ onDragstart: this.onDragStart
204
+ },
205
+ (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
206
+ );
207
+ }
252
208
  });
253
209
 
254
- const useEditor = (options = {}) => {
255
- const editor = vue.shallowRef();
256
- vue.onMounted(() => {
257
- editor.value = new Editor(options);
258
- });
259
- vue.onBeforeUnmount(() => {
260
- var _a, _b, _c;
261
- // Cloning root node (and its children) to avoid content being lost by destroy
262
- const nodes = (_a = editor.value) === null || _a === void 0 ? void 0 : _a.options.element;
263
- const newEl = nodes === null || nodes === void 0 ? void 0 : nodes.cloneNode(true);
264
- (_b = nodes === null || nodes === void 0 ? void 0 : nodes.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(newEl, nodes);
265
- (_c = editor.value) === null || _c === void 0 ? void 0 : _c.destroy();
266
- });
267
- return editor;
210
+ // src/useEditor.ts
211
+ var import_vue5 = require("vue");
212
+ var useEditor = (options = {}) => {
213
+ const editor = (0, import_vue5.shallowRef)();
214
+ (0, import_vue5.onMounted)(() => {
215
+ editor.value = new Editor(options);
216
+ });
217
+ (0, import_vue5.onBeforeUnmount)(() => {
218
+ var _a, _b, _c;
219
+ const nodes = (_a = editor.value) == null ? void 0 : _a.options.element;
220
+ const newEl = nodes == null ? void 0 : nodes.cloneNode(true);
221
+ (_b = nodes == null ? void 0 : nodes.parentNode) == null ? void 0 : _b.replaceChild(newEl, nodes);
222
+ (_c = editor.value) == null ? void 0 : _c.destroy();
223
+ });
224
+ return editor;
268
225
  };
269
226
 
270
- /**
271
- * This class is used to render Vue components inside the editor.
272
- */
273
- class VueRenderer {
274
- constructor(component, { props = {}, editor }) {
275
- this.editor = editor;
276
- this.component = vue.markRaw(component);
277
- this.el = document.createElement('div');
278
- this.props = vue.reactive(props);
279
- this.renderedComponent = this.renderComponent();
227
+ // src/VueMarkViewRenderer.ts
228
+ var import_core2 = require("@tiptap/core");
229
+ var import_vue7 = require("vue");
230
+
231
+ // src/VueRenderer.ts
232
+ var import_vue6 = require("vue");
233
+ var VueRenderer = class {
234
+ constructor(component, { props = {}, editor }) {
235
+ this.editor = editor;
236
+ this.component = (0, import_vue6.markRaw)(component);
237
+ this.el = document.createElement("div");
238
+ this.props = (0, import_vue6.reactive)(props);
239
+ this.renderedComponent = this.renderComponent();
240
+ }
241
+ get element() {
242
+ return this.renderedComponent.el;
243
+ }
244
+ get ref() {
245
+ var _a, _b, _c, _d;
246
+ if ((_b = (_a = this.renderedComponent.vNode) == null ? void 0 : _a.component) == null ? void 0 : _b.exposed) {
247
+ return this.renderedComponent.vNode.component.exposed;
280
248
  }
281
- get element() {
282
- return this.renderedComponent.el;
249
+ return (_d = (_c = this.renderedComponent.vNode) == null ? void 0 : _c.component) == null ? void 0 : _d.proxy;
250
+ }
251
+ renderComponent() {
252
+ let vNode = (0, import_vue6.h)(this.component, this.props);
253
+ if (this.editor.appContext) {
254
+ vNode.appContext = this.editor.appContext;
283
255
  }
284
- get ref() {
285
- var _a, _b, _c, _d;
286
- // Composition API
287
- if ((_b = (_a = this.renderedComponent.vNode) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.exposed) {
288
- return this.renderedComponent.vNode.component.exposed;
289
- }
290
- // Option API
291
- return (_d = (_c = this.renderedComponent.vNode) === null || _c === void 0 ? void 0 : _c.component) === null || _d === void 0 ? void 0 : _d.proxy;
256
+ if (typeof document !== "undefined" && this.el) {
257
+ (0, import_vue6.render)(vNode, this.el);
292
258
  }
293
- renderComponent() {
294
- let vNode = vue.h(this.component, this.props);
295
- if (this.editor.appContext) {
296
- vNode.appContext = this.editor.appContext;
297
- }
298
- if (typeof document !== 'undefined' && this.el) {
299
- vue.render(vNode, this.el);
300
- }
301
- const destroy = () => {
302
- if (this.el) {
303
- vue.render(null, this.el);
304
- }
305
- this.el = null;
306
- vNode = null;
307
- };
308
- return { vNode, destroy, el: this.el ? this.el.firstElementChild : null };
259
+ const destroy = () => {
260
+ if (this.el) {
261
+ (0, import_vue6.render)(null, this.el);
262
+ }
263
+ this.el = null;
264
+ vNode = null;
265
+ };
266
+ return { vNode, destroy, el: this.el ? this.el.firstElementChild : null };
267
+ }
268
+ updateProps(props = {}) {
269
+ Object.entries(props).forEach(([key, value]) => {
270
+ this.props[key] = value;
271
+ });
272
+ this.renderComponent();
273
+ }
274
+ destroy() {
275
+ this.renderedComponent.destroy();
276
+ }
277
+ };
278
+
279
+ // src/VueMarkViewRenderer.ts
280
+ var markViewProps = {
281
+ editor: {
282
+ type: Object,
283
+ required: true
284
+ },
285
+ mark: {
286
+ type: Object,
287
+ required: true
288
+ },
289
+ extension: {
290
+ type: Object,
291
+ required: true
292
+ },
293
+ inline: {
294
+ type: Boolean,
295
+ required: true
296
+ },
297
+ view: {
298
+ type: Object,
299
+ required: true
300
+ }
301
+ };
302
+ var MarkViewContent = (0, import_vue7.defineComponent)({
303
+ name: "MarkViewContent",
304
+ props: {
305
+ as: {
306
+ type: String,
307
+ default: "span"
309
308
  }
310
- updateProps(props = {}) {
311
- Object.entries(props).forEach(([key, value]) => {
312
- this.props[key] = value;
309
+ },
310
+ render() {
311
+ return (0, import_vue7.h)(this.as, {
312
+ style: {
313
+ whiteSpace: "inherit"
314
+ },
315
+ "data-mark-view-content": ""
316
+ });
317
+ }
318
+ });
319
+ var VueMarkView = class extends import_core2.MarkView {
320
+ constructor(component, props, options) {
321
+ super(component, props, options);
322
+ const extendedComponent = (0, import_vue7.defineComponent)({
323
+ extends: { ...component },
324
+ props: Object.keys(props),
325
+ template: this.component.template,
326
+ setup: (reactiveProps) => {
327
+ var _a;
328
+ return (_a = component.setup) == null ? void 0 : _a.call(component, reactiveProps, {
329
+ expose: () => void 0
313
330
  });
314
- this.renderComponent();
315
- }
316
- destroy() {
317
- this.renderedComponent.destroy();
331
+ },
332
+ // Add support for scoped styles
333
+ __scopeId: component.__scopeId,
334
+ __cssModules: component.__cssModules,
335
+ __name: component.__name,
336
+ __file: component.__file
337
+ });
338
+ this.renderer = new VueRenderer(extendedComponent, {
339
+ editor: this.editor,
340
+ props
341
+ });
342
+ }
343
+ get dom() {
344
+ return this.renderer.element;
345
+ }
346
+ get contentDOM() {
347
+ return this.dom.querySelector("[data-mark-view-content]");
348
+ }
349
+ destroy() {
350
+ this.renderer.destroy();
351
+ }
352
+ };
353
+ function VueMarkViewRenderer(component, options = {}) {
354
+ return (props) => {
355
+ if (!props.editor.contentComponent) {
356
+ return {};
318
357
  }
358
+ return new VueMarkView(component, props, options);
359
+ };
319
360
  }
320
361
 
321
- /* eslint-disable no-underscore-dangle */
322
- const nodeViewProps = {
323
- editor: {
324
- type: Object,
325
- required: true,
326
- },
327
- node: {
328
- type: Object,
329
- required: true,
330
- },
331
- decorations: {
332
- type: Object,
333
- required: true,
334
- },
335
- selected: {
336
- type: Boolean,
337
- required: true,
338
- },
339
- extension: {
340
- type: Object,
341
- required: true,
342
- },
343
- getPos: {
344
- type: Function,
345
- required: true,
346
- },
347
- updateAttributes: {
348
- type: Function,
349
- required: true,
350
- },
351
- deleteNode: {
352
- type: Function,
353
- required: true,
354
- },
355
- view: {
356
- type: Object,
357
- required: true,
358
- },
359
- innerDecorations: {
360
- type: Object,
361
- required: true,
362
- },
363
- HTMLAttributes: {
364
- type: Object,
365
- required: true,
366
- },
362
+ // src/VueNodeViewRenderer.ts
363
+ var import_core3 = require("@tiptap/core");
364
+ var import_vue8 = require("vue");
365
+ var nodeViewProps = {
366
+ editor: {
367
+ type: Object,
368
+ required: true
369
+ },
370
+ node: {
371
+ type: Object,
372
+ required: true
373
+ },
374
+ decorations: {
375
+ type: Object,
376
+ required: true
377
+ },
378
+ selected: {
379
+ type: Boolean,
380
+ required: true
381
+ },
382
+ extension: {
383
+ type: Object,
384
+ required: true
385
+ },
386
+ getPos: {
387
+ type: Function,
388
+ required: true
389
+ },
390
+ updateAttributes: {
391
+ type: Function,
392
+ required: true
393
+ },
394
+ deleteNode: {
395
+ type: Function,
396
+ required: true
397
+ },
398
+ view: {
399
+ type: Object,
400
+ required: true
401
+ },
402
+ innerDecorations: {
403
+ type: Object,
404
+ required: true
405
+ },
406
+ HTMLAttributes: {
407
+ type: Object,
408
+ required: true
409
+ }
367
410
  };
368
- class VueNodeView extends core.NodeView {
369
- mount() {
370
- const props = {
371
- editor: this.editor,
372
- node: this.node,
373
- decorations: this.decorations,
374
- innerDecorations: this.innerDecorations,
375
- view: this.view,
376
- selected: false,
377
- extension: this.extension,
378
- HTMLAttributes: this.HTMLAttributes,
379
- getPos: () => this.getPos(),
380
- updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
381
- deleteNode: () => this.deleteNode(),
382
- };
383
- const onDragStart = this.onDragStart.bind(this);
384
- this.decorationClasses = vue.ref(this.getDecorationClasses());
385
- const extendedComponent = vue.defineComponent({
386
- extends: { ...this.component },
387
- props: Object.keys(props),
388
- template: this.component.template,
389
- setup: reactiveProps => {
390
- var _a, _b;
391
- vue.provide('onDragStart', onDragStart);
392
- vue.provide('decorationClasses', this.decorationClasses);
393
- return (_b = (_a = this.component).setup) === null || _b === void 0 ? void 0 : _b.call(_a, reactiveProps, {
394
- expose: () => undefined,
395
- });
396
- },
397
- // add support for scoped styles
398
- // @ts-ignore
399
- // eslint-disable-next-line
400
- __scopeId: this.component.__scopeId,
401
- // add support for CSS Modules
402
- // @ts-ignore
403
- // eslint-disable-next-line
404
- __cssModules: this.component.__cssModules,
405
- // add support for vue devtools
406
- // @ts-ignore
407
- // eslint-disable-next-line
408
- __name: this.component.__name,
409
- // @ts-ignore
410
- // eslint-disable-next-line
411
- __file: this.component.__file,
412
- });
413
- this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
414
- this.editor.on('selectionUpdate', this.handleSelectionUpdate);
415
- this.renderer = new VueRenderer(extendedComponent, {
416
- editor: this.editor,
417
- props,
411
+ var VueNodeView = class extends import_core3.NodeView {
412
+ mount() {
413
+ const props = {
414
+ editor: this.editor,
415
+ node: this.node,
416
+ decorations: this.decorations,
417
+ innerDecorations: this.innerDecorations,
418
+ view: this.view,
419
+ selected: false,
420
+ extension: this.extension,
421
+ HTMLAttributes: this.HTMLAttributes,
422
+ getPos: () => this.getPos(),
423
+ updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
424
+ deleteNode: () => this.deleteNode()
425
+ };
426
+ const onDragStart = this.onDragStart.bind(this);
427
+ this.decorationClasses = (0, import_vue8.ref)(this.getDecorationClasses());
428
+ const extendedComponent = (0, import_vue8.defineComponent)({
429
+ extends: { ...this.component },
430
+ props: Object.keys(props),
431
+ template: this.component.template,
432
+ setup: (reactiveProps) => {
433
+ var _a, _b;
434
+ (0, import_vue8.provide)("onDragStart", onDragStart);
435
+ (0, import_vue8.provide)("decorationClasses", this.decorationClasses);
436
+ return (_b = (_a = this.component).setup) == null ? void 0 : _b.call(_a, reactiveProps, {
437
+ expose: () => void 0
418
438
  });
439
+ },
440
+ // add support for scoped styles
441
+ // @ts-ignore
442
+ // eslint-disable-next-line
443
+ __scopeId: this.component.__scopeId,
444
+ // add support for CSS Modules
445
+ // @ts-ignore
446
+ // eslint-disable-next-line
447
+ __cssModules: this.component.__cssModules,
448
+ // add support for vue devtools
449
+ // @ts-ignore
450
+ // eslint-disable-next-line
451
+ __name: this.component.__name,
452
+ // @ts-ignore
453
+ // eslint-disable-next-line
454
+ __file: this.component.__file
455
+ });
456
+ this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
457
+ this.editor.on("selectionUpdate", this.handleSelectionUpdate);
458
+ this.renderer = new VueRenderer(extendedComponent, {
459
+ editor: this.editor,
460
+ props
461
+ });
462
+ }
463
+ /**
464
+ * Return the DOM element.
465
+ * This is the element that will be used to display the node view.
466
+ */
467
+ get dom() {
468
+ if (!this.renderer.element || !this.renderer.element.hasAttribute("data-node-view-wrapper")) {
469
+ throw Error("Please use the NodeViewWrapper component for your node view.");
419
470
  }
420
- /**
421
- * Return the DOM element.
422
- * This is the element that will be used to display the node view.
423
- */
424
- get dom() {
425
- if (!this.renderer.element || !this.renderer.element.hasAttribute('data-node-view-wrapper')) {
426
- throw Error('Please use the NodeViewWrapper component for your node view.');
427
- }
428
- return this.renderer.element;
471
+ return this.renderer.element;
472
+ }
473
+ /**
474
+ * Return the content DOM element.
475
+ * This is the element that will be used to display the rich-text content of the node.
476
+ */
477
+ get contentDOM() {
478
+ if (this.node.isLeaf) {
479
+ return null;
429
480
  }
430
- /**
431
- * Return the content DOM element.
432
- * This is the element that will be used to display the rich-text content of the node.
433
- */
434
- get contentDOM() {
435
- if (this.node.isLeaf) {
436
- return null;
437
- }
438
- return this.dom.querySelector('[data-node-view-content]');
481
+ return this.dom.querySelector("[data-node-view-content]");
482
+ }
483
+ /**
484
+ * On editor selection update, check if the node is selected.
485
+ * If it is, call `selectNode`, otherwise call `deselectNode`.
486
+ */
487
+ handleSelectionUpdate() {
488
+ const { from, to } = this.editor.state.selection;
489
+ const pos = this.getPos();
490
+ if (typeof pos !== "number") {
491
+ return;
439
492
  }
440
- /**
441
- * On editor selection update, check if the node is selected.
442
- * If it is, call `selectNode`, otherwise call `deselectNode`.
443
- */
444
- handleSelectionUpdate() {
445
- const { from, to } = this.editor.state.selection;
446
- const pos = this.getPos();
447
- if (typeof pos !== 'number') {
448
- return;
449
- }
450
- if (from <= pos && to >= pos + this.node.nodeSize) {
451
- if (this.renderer.props.selected) {
452
- return;
453
- }
454
- this.selectNode();
455
- }
456
- else {
457
- if (!this.renderer.props.selected) {
458
- return;
459
- }
460
- this.deselectNode();
461
- }
493
+ if (from <= pos && to >= pos + this.node.nodeSize) {
494
+ if (this.renderer.props.selected) {
495
+ return;
496
+ }
497
+ this.selectNode();
498
+ } else {
499
+ if (!this.renderer.props.selected) {
500
+ return;
501
+ }
502
+ this.deselectNode();
462
503
  }
463
- /**
464
- * On update, update the React component.
465
- * To prevent unnecessary updates, the `update` option can be used.
466
- */
467
- update(node, decorations, innerDecorations) {
468
- const rerenderComponent = (props) => {
469
- this.decorationClasses.value = this.getDecorationClasses();
470
- this.renderer.updateProps(props);
471
- };
472
- if (typeof this.options.update === 'function') {
473
- const oldNode = this.node;
474
- const oldDecorations = this.decorations;
475
- const oldInnerDecorations = this.innerDecorations;
476
- this.node = node;
477
- this.decorations = decorations;
478
- this.innerDecorations = innerDecorations;
479
- return this.options.update({
480
- oldNode,
481
- oldDecorations,
482
- newNode: node,
483
- newDecorations: decorations,
484
- oldInnerDecorations,
485
- innerDecorations,
486
- updateProps: () => rerenderComponent({ node, decorations, innerDecorations }),
487
- });
488
- }
489
- if (node.type !== this.node.type) {
490
- return false;
491
- }
492
- if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {
493
- return true;
494
- }
495
- this.node = node;
496
- this.decorations = decorations;
497
- this.innerDecorations = innerDecorations;
498
- rerenderComponent({ node, decorations, innerDecorations });
499
- return true;
504
+ }
505
+ /**
506
+ * On update, update the React component.
507
+ * To prevent unnecessary updates, the `update` option can be used.
508
+ */
509
+ update(node, decorations, innerDecorations) {
510
+ const rerenderComponent = (props) => {
511
+ this.decorationClasses.value = this.getDecorationClasses();
512
+ this.renderer.updateProps(props);
513
+ };
514
+ if (typeof this.options.update === "function") {
515
+ const oldNode = this.node;
516
+ const oldDecorations = this.decorations;
517
+ const oldInnerDecorations = this.innerDecorations;
518
+ this.node = node;
519
+ this.decorations = decorations;
520
+ this.innerDecorations = innerDecorations;
521
+ return this.options.update({
522
+ oldNode,
523
+ oldDecorations,
524
+ newNode: node,
525
+ newDecorations: decorations,
526
+ oldInnerDecorations,
527
+ innerDecorations,
528
+ updateProps: () => rerenderComponent({ node, decorations, innerDecorations })
529
+ });
500
530
  }
501
- /**
502
- * Select the node.
503
- * Add the `selected` prop and the `ProseMirror-selectednode` class.
504
- */
505
- selectNode() {
506
- this.renderer.updateProps({
507
- selected: true,
508
- });
509
- if (this.renderer.element) {
510
- this.renderer.element.classList.add('ProseMirror-selectednode');
511
- }
531
+ if (node.type !== this.node.type) {
532
+ return false;
512
533
  }
513
- /**
514
- * Deselect the node.
515
- * Remove the `selected` prop and the `ProseMirror-selectednode` class.
516
- */
517
- deselectNode() {
518
- this.renderer.updateProps({
519
- selected: false,
520
- });
521
- if (this.renderer.element) {
522
- this.renderer.element.classList.remove('ProseMirror-selectednode');
523
- }
534
+ if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {
535
+ return true;
524
536
  }
525
- getDecorationClasses() {
526
- return (this.decorations
527
- // @ts-ignore
528
- .map(item => item.type.attrs.class)
529
- .flat()
530
- .join(' '));
537
+ this.node = node;
538
+ this.decorations = decorations;
539
+ this.innerDecorations = innerDecorations;
540
+ rerenderComponent({ node, decorations, innerDecorations });
541
+ return true;
542
+ }
543
+ /**
544
+ * Select the node.
545
+ * Add the `selected` prop and the `ProseMirror-selectednode` class.
546
+ */
547
+ selectNode() {
548
+ this.renderer.updateProps({
549
+ selected: true
550
+ });
551
+ if (this.renderer.element) {
552
+ this.renderer.element.classList.add("ProseMirror-selectednode");
531
553
  }
532
- destroy() {
533
- this.renderer.destroy();
534
- this.editor.off('selectionUpdate', this.handleSelectionUpdate);
554
+ }
555
+ /**
556
+ * Deselect the node.
557
+ * Remove the `selected` prop and the `ProseMirror-selectednode` class.
558
+ */
559
+ deselectNode() {
560
+ this.renderer.updateProps({
561
+ selected: false
562
+ });
563
+ if (this.renderer.element) {
564
+ this.renderer.element.classList.remove("ProseMirror-selectednode");
535
565
  }
536
- }
566
+ }
567
+ getDecorationClasses() {
568
+ return this.decorations.map((item) => item.type.attrs.class).flat().join(" ");
569
+ }
570
+ destroy() {
571
+ this.renderer.destroy();
572
+ this.editor.off("selectionUpdate", this.handleSelectionUpdate);
573
+ }
574
+ };
537
575
  function VueNodeViewRenderer(component, options) {
538
- return props => {
539
- // try to get the parent component
540
- // this is important for vue devtools to show the component hierarchy correctly
541
- // maybe it’s `undefined` because <editor-content> isn’t rendered yet
542
- if (!props.editor.contentComponent) {
543
- return {};
544
- }
545
- // check for class-component and normalize if neccessary
546
- const normalizedComponent = typeof component === 'function' && '__vccOpts' in component
547
- ? component.__vccOpts
548
- : component;
549
- return new VueNodeView(normalizedComponent, props, options);
550
- };
576
+ return (props) => {
577
+ if (!props.editor.contentComponent) {
578
+ return {};
579
+ }
580
+ const normalizedComponent = typeof component === "function" && "__vccOpts" in component ? component.__vccOpts : component;
581
+ return new VueNodeView(normalizedComponent, props, options);
582
+ };
551
583
  }
552
584
 
553
- exports.BubbleMenu = BubbleMenu;
554
- exports.Editor = Editor;
555
- exports.EditorContent = EditorContent;
556
- exports.FloatingMenu = FloatingMenu;
557
- exports.NodeViewContent = NodeViewContent;
558
- exports.NodeViewWrapper = NodeViewWrapper;
559
- exports.VueNodeViewRenderer = VueNodeViewRenderer;
560
- exports.VueRenderer = VueRenderer;
561
- exports.nodeViewProps = nodeViewProps;
562
- exports.useEditor = useEditor;
563
- Object.keys(core).forEach(function (k) {
564
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
565
- enumerable: true,
566
- get: function () { return core[k]; }
567
- });
585
+ // src/index.ts
586
+ __reExport(index_exports, require("@tiptap/core"), module.exports);
587
+ // Annotate the CommonJS export names for ESM import in node:
588
+ 0 && (module.exports = {
589
+ Editor,
590
+ EditorContent,
591
+ MarkViewContent,
592
+ NodeViewContent,
593
+ NodeViewWrapper,
594
+ VueMarkView,
595
+ VueMarkViewRenderer,
596
+ VueNodeViewRenderer,
597
+ VueRenderer,
598
+ markViewProps,
599
+ nodeViewProps,
600
+ useEditor,
601
+ ...require("@tiptap/core")
568
602
  });
569
- //# sourceMappingURL=index.cjs.map
603
+ //# sourceMappingURL=index.cjs.map