@tiptap/vue-3 3.0.0-next.3 → 3.0.0-next.5

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/vue-3
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/vue-3.svg?label=version)](https://www.npmjs.com/package/@tiptap/vue-3)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/vue-3.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/vue-3.svg)](https://www.npmjs.com/package/@tiptap/vue-3)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## Introduction
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
+
10
+ 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
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs CHANGED
@@ -19,95 +19,28 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
 
21
21
  // src/index.ts
22
- var src_exports = {};
23
- __export(src_exports, {
24
- BubbleMenu: () => BubbleMenu,
22
+ var index_exports = {};
23
+ __export(index_exports, {
25
24
  Editor: () => Editor,
26
25
  EditorContent: () => EditorContent,
27
- FloatingMenu: () => FloatingMenu,
26
+ MarkViewContent: () => MarkViewContent,
28
27
  NodeViewContent: () => NodeViewContent,
29
28
  NodeViewWrapper: () => NodeViewWrapper,
29
+ VueMarkView: () => VueMarkView,
30
+ VueMarkViewRenderer: () => VueMarkViewRenderer,
30
31
  VueNodeViewRenderer: () => VueNodeViewRenderer,
31
32
  VueRenderer: () => VueRenderer,
33
+ markViewProps: () => markViewProps,
32
34
  nodeViewProps: () => nodeViewProps,
33
35
  useEditor: () => useEditor
34
36
  });
35
- module.exports = __toCommonJS(src_exports);
36
-
37
- // src/BubbleMenu.ts
38
- var import_extension_bubble_menu = require("@tiptap/extension-bubble-menu");
39
- var import_vue = require("vue");
40
- var BubbleMenu = (0, import_vue.defineComponent)({
41
- name: "BubbleMenu",
42
- props: {
43
- pluginKey: {
44
- type: [String, Object],
45
- default: "bubbleMenu"
46
- },
47
- editor: {
48
- type: Object,
49
- required: true
50
- },
51
- updateDelay: {
52
- type: Number,
53
- default: void 0
54
- },
55
- resizeDelay: {
56
- type: Number,
57
- default: void 0
58
- },
59
- options: {
60
- type: Object,
61
- default: () => ({})
62
- },
63
- shouldShow: {
64
- type: Function,
65
- default: null
66
- }
67
- },
68
- setup(props, { slots }) {
69
- const root = (0, import_vue.ref)(null);
70
- (0, import_vue.onMounted)(() => {
71
- const {
72
- editor,
73
- options,
74
- pluginKey,
75
- resizeDelay,
76
- shouldShow,
77
- updateDelay
78
- } = props;
79
- if (!root.value) {
80
- return;
81
- }
82
- root.value.style.visibility = "hidden";
83
- root.value.style.position = "absolute";
84
- root.value.remove();
85
- editor.registerPlugin((0, import_extension_bubble_menu.BubbleMenuPlugin)({
86
- editor,
87
- element: root.value,
88
- options,
89
- pluginKey,
90
- resizeDelay,
91
- shouldShow,
92
- updateDelay
93
- }));
94
- });
95
- (0, import_vue.onBeforeUnmount)(() => {
96
- const { pluginKey, editor } = props;
97
- editor.unregisterPlugin(pluginKey);
98
- });
99
- return () => {
100
- var _a;
101
- return (0, import_vue.h)(import_vue.Teleport, { to: "body" }, (0, import_vue.h)("div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots)));
102
- };
103
- }
104
- });
37
+ module.exports = __toCommonJS(index_exports);
105
38
 
106
39
  // src/Editor.ts
107
40
  var import_core = require("@tiptap/core");
108
- var import_vue2 = require("vue");
41
+ var import_vue = require("vue");
109
42
  function useDebouncedRef(value) {
110
- return (0, import_vue2.customRef)((track, trigger) => {
43
+ return (0, import_vue.customRef)((track, trigger) => {
111
44
  return {
112
45
  get() {
113
46
  track();
@@ -135,7 +68,7 @@ var Editor = class extends import_core.Editor {
135
68
  this.reactiveState.value = nextState;
136
69
  this.reactiveExtensionStorage.value = this.extensionStorage;
137
70
  });
138
- return (0, import_vue2.markRaw)(this);
71
+ return (0, import_vue.markRaw)(this);
139
72
  }
140
73
  get state() {
141
74
  return this.reactiveState ? this.reactiveState.value : this.view.state;
@@ -166,8 +99,8 @@ var Editor = class extends import_core.Editor {
166
99
  };
167
100
 
168
101
  // src/EditorContent.ts
169
- var import_vue3 = require("vue");
170
- var EditorContent = (0, import_vue3.defineComponent)({
102
+ var import_vue2 = require("vue");
103
+ var EditorContent = (0, import_vue2.defineComponent)({
171
104
  name: "EditorContent",
172
105
  props: {
173
106
  editor: {
@@ -176,16 +109,17 @@ var EditorContent = (0, import_vue3.defineComponent)({
176
109
  }
177
110
  },
178
111
  setup(props) {
179
- const rootEl = (0, import_vue3.ref)();
180
- const instance = (0, import_vue3.getCurrentInstance)();
181
- (0, import_vue3.watchEffect)(() => {
112
+ const rootEl = (0, import_vue2.ref)();
113
+ const instance = (0, import_vue2.getCurrentInstance)();
114
+ (0, import_vue2.watchEffect)(() => {
182
115
  const editor = props.editor;
183
116
  if (editor && editor.options.element && rootEl.value) {
184
- (0, import_vue3.nextTick)(() => {
185
- if (!rootEl.value || !editor.options.element.firstChild) {
117
+ (0, import_vue2.nextTick)(() => {
118
+ var _a;
119
+ if (!rootEl.value || !((_a = editor.options.element) == null ? void 0 : _a.firstChild)) {
186
120
  return;
187
121
  }
188
- const element = (0, import_vue3.unref)(rootEl.value);
122
+ const element = (0, import_vue2.unref)(rootEl.value);
189
123
  rootEl.value.append(...editor.options.element.childNodes);
190
124
  editor.contentComponent = instance.ctx._;
191
125
  if (instance) {
@@ -204,7 +138,7 @@ var EditorContent = (0, import_vue3.defineComponent)({
204
138
  });
205
139
  }
206
140
  });
207
- (0, import_vue3.onBeforeUnmount)(() => {
141
+ (0, import_vue2.onBeforeUnmount)(() => {
208
142
  const editor = props.editor;
209
143
  if (!editor) {
210
144
  return;
@@ -215,79 +149,17 @@ var EditorContent = (0, import_vue3.defineComponent)({
215
149
  return { rootEl };
216
150
  },
217
151
  render() {
218
- return (0, import_vue3.h)(
219
- "div",
220
- {
221
- ref: (el) => {
222
- this.rootEl = el;
223
- }
224
- }
225
- );
226
- }
227
- });
228
-
229
- // src/FloatingMenu.ts
230
- var import_extension_floating_menu = require("@tiptap/extension-floating-menu");
231
- var import_vue4 = require("vue");
232
- var FloatingMenu = (0, import_vue4.defineComponent)({
233
- name: "FloatingMenu",
234
- props: {
235
- pluginKey: {
236
- // TODO: TypeScript breaks :(
237
- // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
238
- type: null,
239
- default: "floatingMenu"
240
- },
241
- editor: {
242
- type: Object,
243
- required: true
244
- },
245
- options: {
246
- type: Object,
247
- default: () => ({})
248
- },
249
- shouldShow: {
250
- type: Function,
251
- default: null
252
- }
253
- },
254
- setup(props, { slots }) {
255
- const root = (0, import_vue4.ref)(null);
256
- (0, import_vue4.onMounted)(() => {
257
- const {
258
- pluginKey,
259
- editor,
260
- options,
261
- shouldShow
262
- } = props;
263
- if (!root.value) {
264
- return;
152
+ return (0, import_vue2.h)("div", {
153
+ ref: (el) => {
154
+ this.rootEl = el;
265
155
  }
266
- root.value.style.visibility = "hidden";
267
- root.value.style.position = "absolute";
268
- root.value.remove();
269
- editor.registerPlugin((0, import_extension_floating_menu.FloatingMenuPlugin)({
270
- pluginKey,
271
- editor,
272
- element: root.value,
273
- options,
274
- shouldShow
275
- }));
276
156
  });
277
- (0, import_vue4.onBeforeUnmount)(() => {
278
- const { pluginKey, editor } = props;
279
- editor.unregisterPlugin(pluginKey);
280
- });
281
- return () => {
282
- var _a;
283
- return (0, import_vue4.h)(import_vue4.Teleport, { to: "body" }, (0, import_vue4.h)("div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots)));
284
- };
285
157
  }
286
158
  });
287
159
 
288
160
  // src/NodeViewContent.ts
289
- var import_vue5 = require("vue");
290
- var NodeViewContent = (0, import_vue5.defineComponent)({
161
+ var import_vue3 = require("vue");
162
+ var NodeViewContent = (0, import_vue3.defineComponent)({
291
163
  name: "NodeViewContent",
292
164
  props: {
293
165
  as: {
@@ -296,7 +168,7 @@ var NodeViewContent = (0, import_vue5.defineComponent)({
296
168
  }
297
169
  },
298
170
  render() {
299
- return (0, import_vue5.h)(this.as, {
171
+ return (0, import_vue3.h)(this.as, {
300
172
  style: {
301
173
  whiteSpace: "pre-wrap"
302
174
  },
@@ -306,8 +178,8 @@ var NodeViewContent = (0, import_vue5.defineComponent)({
306
178
  });
307
179
 
308
180
  // src/NodeViewWrapper.ts
309
- var import_vue6 = require("vue");
310
- var NodeViewWrapper = (0, import_vue6.defineComponent)({
181
+ var import_vue4 = require("vue");
182
+ var NodeViewWrapper = (0, import_vue4.defineComponent)({
311
183
  name: "NodeViewWrapper",
312
184
  props: {
313
185
  as: {
@@ -318,7 +190,7 @@ var NodeViewWrapper = (0, import_vue6.defineComponent)({
318
190
  inject: ["onDragStart", "decorationClasses"],
319
191
  render() {
320
192
  var _a, _b;
321
- return (0, import_vue6.h)(
193
+ return (0, import_vue4.h)(
322
194
  this.as,
323
195
  {
324
196
  // @ts-ignore
@@ -336,13 +208,13 @@ var NodeViewWrapper = (0, import_vue6.defineComponent)({
336
208
  });
337
209
 
338
210
  // src/useEditor.ts
339
- var import_vue7 = require("vue");
211
+ var import_vue5 = require("vue");
340
212
  var useEditor = (options = {}) => {
341
- const editor = (0, import_vue7.shallowRef)();
342
- (0, import_vue7.onMounted)(() => {
213
+ const editor = (0, import_vue5.shallowRef)();
214
+ (0, import_vue5.onMounted)(() => {
343
215
  editor.value = new Editor(options);
344
216
  });
345
- (0, import_vue7.onBeforeUnmount)(() => {
217
+ (0, import_vue5.onBeforeUnmount)(() => {
346
218
  var _a, _b, _c;
347
219
  const nodes = (_a = editor.value) == null ? void 0 : _a.options.element;
348
220
  const newEl = nodes == null ? void 0 : nodes.cloneNode(true);
@@ -352,18 +224,18 @@ var useEditor = (options = {}) => {
352
224
  return editor;
353
225
  };
354
226
 
355
- // src/VueNodeViewRenderer.ts
227
+ // src/VueMarkViewRenderer.ts
356
228
  var import_core2 = require("@tiptap/core");
357
- var import_vue9 = require("vue");
229
+ var import_vue7 = require("vue");
358
230
 
359
231
  // src/VueRenderer.ts
360
- var import_vue8 = require("vue");
232
+ var import_vue6 = require("vue");
361
233
  var VueRenderer = class {
362
234
  constructor(component, { props = {}, editor }) {
363
235
  this.editor = editor;
364
- this.component = (0, import_vue8.markRaw)(component);
236
+ this.component = (0, import_vue6.markRaw)(component);
365
237
  this.el = document.createElement("div");
366
- this.props = (0, import_vue8.reactive)(props);
238
+ this.props = (0, import_vue6.reactive)(props);
367
239
  this.renderedComponent = this.renderComponent();
368
240
  }
369
241
  get element() {
@@ -377,16 +249,16 @@ var VueRenderer = class {
377
249
  return (_d = (_c = this.renderedComponent.vNode) == null ? void 0 : _c.component) == null ? void 0 : _d.proxy;
378
250
  }
379
251
  renderComponent() {
380
- let vNode = (0, import_vue8.h)(this.component, this.props);
252
+ let vNode = (0, import_vue6.h)(this.component, this.props);
381
253
  if (this.editor.appContext) {
382
254
  vNode.appContext = this.editor.appContext;
383
255
  }
384
256
  if (typeof document !== "undefined" && this.el) {
385
- (0, import_vue8.render)(vNode, this.el);
257
+ (0, import_vue6.render)(vNode, this.el);
386
258
  }
387
259
  const destroy = () => {
388
260
  if (this.el) {
389
- (0, import_vue8.render)(null, this.el);
261
+ (0, import_vue6.render)(null, this.el);
390
262
  }
391
263
  this.el = null;
392
264
  vNode = null;
@@ -404,7 +276,92 @@ var VueRenderer = class {
404
276
  }
405
277
  };
406
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"
308
+ }
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
330
+ });
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 {};
357
+ }
358
+ return new VueMarkView(component, props, options);
359
+ };
360
+ }
361
+
407
362
  // src/VueNodeViewRenderer.ts
363
+ var import_core3 = require("@tiptap/core");
364
+ var import_vue8 = require("vue");
408
365
  var nodeViewProps = {
409
366
  editor: {
410
367
  type: Object,
@@ -437,9 +394,21 @@ var nodeViewProps = {
437
394
  deleteNode: {
438
395
  type: Function,
439
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
440
409
  }
441
410
  };
442
- var VueNodeView = class extends import_core2.NodeView {
411
+ var VueNodeView = class extends import_core3.NodeView {
443
412
  mount() {
444
413
  const props = {
445
414
  editor: this.editor,
@@ -455,15 +424,15 @@ var VueNodeView = class extends import_core2.NodeView {
455
424
  deleteNode: () => this.deleteNode()
456
425
  };
457
426
  const onDragStart = this.onDragStart.bind(this);
458
- this.decorationClasses = (0, import_vue9.ref)(this.getDecorationClasses());
459
- const extendedComponent = (0, import_vue9.defineComponent)({
427
+ this.decorationClasses = (0, import_vue8.ref)(this.getDecorationClasses());
428
+ const extendedComponent = (0, import_vue8.defineComponent)({
460
429
  extends: { ...this.component },
461
430
  props: Object.keys(props),
462
431
  template: this.component.template,
463
432
  setup: (reactiveProps) => {
464
433
  var _a, _b;
465
- (0, import_vue9.provide)("onDragStart", onDragStart);
466
- (0, import_vue9.provide)("decorationClasses", this.decorationClasses);
434
+ (0, import_vue8.provide)("onDragStart", onDragStart);
435
+ (0, import_vue8.provide)("decorationClasses", this.decorationClasses);
467
436
  return (_b = (_a = this.component).setup) == null ? void 0 : _b.call(_a, reactiveProps, {
468
437
  expose: () => void 0
469
438
  });
@@ -614,17 +583,19 @@ function VueNodeViewRenderer(component, options) {
614
583
  }
615
584
 
616
585
  // src/index.ts
617
- __reExport(src_exports, require("@tiptap/core"), module.exports);
586
+ __reExport(index_exports, require("@tiptap/core"), module.exports);
618
587
  // Annotate the CommonJS export names for ESM import in node:
619
588
  0 && (module.exports = {
620
- BubbleMenu,
621
589
  Editor,
622
590
  EditorContent,
623
- FloatingMenu,
591
+ MarkViewContent,
624
592
  NodeViewContent,
625
593
  NodeViewWrapper,
594
+ VueMarkView,
595
+ VueMarkViewRenderer,
626
596
  VueNodeViewRenderer,
627
597
  VueRenderer,
598
+ markViewProps,
628
599
  nodeViewProps,
629
600
  useEditor,
630
601
  ...require("@tiptap/core")