@tiptap/vue-3 3.0.0-next.0 → 3.0.0-next.2

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 (190) hide show
  1. package/dist/index.cjs +589 -477
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +303 -0
  4. package/dist/index.d.ts +303 -0
  5. package/dist/index.js +591 -464
  6. package/dist/index.js.map +1 -1
  7. package/package.json +10 -12
  8. package/src/Editor.ts +17 -6
  9. package/src/EditorContent.ts +0 -19
  10. package/src/VueNodeViewRenderer.ts +90 -26
  11. package/src/useEditor.ts +6 -0
  12. package/dist/index.umd.js +0 -521
  13. package/dist/index.umd.js.map +0 -1
  14. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  15. package/dist/packages/core/src/Editor.d.ts +0 -159
  16. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  17. package/dist/packages/core/src/Extension.d.ts +0 -343
  18. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  19. package/dist/packages/core/src/InputRule.d.ts +0 -42
  20. package/dist/packages/core/src/Mark.d.ts +0 -451
  21. package/dist/packages/core/src/Node.d.ts +0 -611
  22. package/dist/packages/core/src/NodePos.d.ts +0 -44
  23. package/dist/packages/core/src/NodeView.d.ts +0 -31
  24. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  25. package/dist/packages/core/src/Tracker.d.ts +0 -11
  26. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  27. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  28. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  29. package/dist/packages/core/src/commands/command.d.ts +0 -18
  30. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  31. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  32. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  33. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  34. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  35. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  36. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  37. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  38. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  39. package/dist/packages/core/src/commands/first.d.ts +0 -14
  40. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  41. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  42. package/dist/packages/core/src/commands/index.d.ts +0 -55
  43. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  44. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  45. package/dist/packages/core/src/commands/join.d.ts +0 -41
  46. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  47. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  48. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  49. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  50. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  51. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  52. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  53. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  54. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  55. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  56. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  60. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  61. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  62. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  63. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  64. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  65. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  66. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  67. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  68. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  69. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  70. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  71. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  72. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  73. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  74. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  75. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  76. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  77. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  78. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  79. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  80. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  81. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  82. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  83. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  84. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  86. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  87. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  88. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  89. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  90. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  91. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  92. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  93. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  94. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  95. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  96. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  97. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  98. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  99. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  100. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  101. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  102. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  103. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  104. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  105. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  106. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  107. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  109. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  110. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  111. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  112. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  113. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  114. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  115. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  116. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  117. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  118. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  119. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  120. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  121. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  122. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  123. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  124. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  125. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  126. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  129. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  130. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  131. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  132. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  133. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -8
  134. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  137. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  138. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  139. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  140. package/dist/packages/core/src/index.d.ts +0 -24
  141. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  142. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  143. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  144. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  145. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  146. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  147. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  148. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  149. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  150. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  151. package/dist/packages/core/src/style.d.ts +0 -1
  152. package/dist/packages/core/src/types.d.ts +0 -253
  153. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  154. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  156. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  161. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  173. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  174. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  175. package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +0 -99
  176. package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +0 -15
  177. package/dist/packages/extension-bubble-menu/src/index.d.ts +0 -4
  178. package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +0 -81
  179. package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +0 -15
  180. package/dist/packages/extension-floating-menu/src/index.d.ts +0 -4
  181. package/dist/packages/vue-3/src/BubbleMenu.d.ts +0 -79
  182. package/dist/packages/vue-3/src/Editor.d.ts +0 -23
  183. package/dist/packages/vue-3/src/EditorContent.d.ts +0 -17
  184. package/dist/packages/vue-3/src/FloatingMenu.d.ts +0 -62
  185. package/dist/packages/vue-3/src/NodeViewContent.d.ts +0 -13
  186. package/dist/packages/vue-3/src/NodeViewWrapper.d.ts +0 -13
  187. package/dist/packages/vue-3/src/VueNodeViewRenderer.d.ts +0 -48
  188. package/dist/packages/vue-3/src/VueRenderer.d.ts +0 -36
  189. package/dist/packages/vue-3/src/index.d.ts +0 -10
  190. package/dist/packages/vue-3/src/useEditor.d.ts +0 -3
package/dist/index.js CHANGED
@@ -1,504 +1,631 @@
1
- import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu';
2
- import { defineComponent, ref, onMounted, onBeforeUnmount, h, Teleport, markRaw, customRef, getCurrentInstance, watchEffect, nextTick, unref, shallowRef, reactive, render, provide } from 'vue';
3
- import { Editor as Editor$1, NodeView } from '@tiptap/core';
4
- export * from '@tiptap/core';
5
- import { FloatingMenuPlugin } from '@tiptap/extension-floating-menu';
6
-
7
- const BubbleMenu = defineComponent({
8
- name: 'BubbleMenu',
9
- props: {
10
- pluginKey: {
11
- type: [String, Object],
12
- default: 'bubbleMenu',
13
- },
14
- editor: {
15
- type: Object,
16
- required: true,
17
- },
18
- updateDelay: {
19
- type: Number,
20
- default: undefined,
21
- },
22
- resizeDelay: {
23
- type: Number,
24
- default: undefined,
25
- },
26
- options: {
27
- type: Object,
28
- default: () => ({}),
29
- },
30
- shouldShow: {
31
- type: Function,
32
- default: null,
33
- },
1
+ // src/BubbleMenu.ts
2
+ import { BubbleMenuPlugin } from "@tiptap/extension-bubble-menu";
3
+ import {
4
+ defineComponent,
5
+ h,
6
+ onBeforeUnmount,
7
+ onMounted,
8
+ ref,
9
+ Teleport
10
+ } from "vue";
11
+ var BubbleMenu = defineComponent({
12
+ name: "BubbleMenu",
13
+ props: {
14
+ pluginKey: {
15
+ type: [String, Object],
16
+ default: "bubbleMenu"
34
17
  },
35
- setup(props, { slots }) {
36
- const root = ref(null);
37
- onMounted(() => {
38
- const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay, } = props;
39
- if (!root.value) {
40
- return;
41
- }
42
- root.value.style.visibility = 'hidden';
43
- root.value.style.position = 'absolute';
44
- // remove the element from the DOM
45
- root.value.remove();
46
- editor.registerPlugin(BubbleMenuPlugin({
47
- editor,
48
- element: root.value,
49
- options,
50
- pluginKey,
51
- resizeDelay,
52
- shouldShow,
53
- updateDelay,
54
- }));
55
- });
56
- onBeforeUnmount(() => {
57
- const { pluginKey, editor } = props;
58
- editor.unregisterPlugin(pluginKey);
59
- });
60
- return () => { var _a; return h(Teleport, { to: 'body' }, h('div', { ref: root }, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots))); };
18
+ editor: {
19
+ type: Object,
20
+ required: true
21
+ },
22
+ updateDelay: {
23
+ type: Number,
24
+ default: void 0
61
25
  },
26
+ resizeDelay: {
27
+ type: Number,
28
+ default: void 0
29
+ },
30
+ options: {
31
+ type: Object,
32
+ default: () => ({})
33
+ },
34
+ shouldShow: {
35
+ type: Function,
36
+ default: null
37
+ }
38
+ },
39
+ setup(props, { slots }) {
40
+ const root = ref(null);
41
+ onMounted(() => {
42
+ const {
43
+ editor,
44
+ options,
45
+ pluginKey,
46
+ resizeDelay,
47
+ shouldShow,
48
+ updateDelay
49
+ } = props;
50
+ if (!root.value) {
51
+ return;
52
+ }
53
+ root.value.style.visibility = "hidden";
54
+ root.value.style.position = "absolute";
55
+ root.value.remove();
56
+ editor.registerPlugin(BubbleMenuPlugin({
57
+ editor,
58
+ element: root.value,
59
+ options,
60
+ pluginKey,
61
+ resizeDelay,
62
+ shouldShow,
63
+ updateDelay
64
+ }));
65
+ });
66
+ onBeforeUnmount(() => {
67
+ const { pluginKey, editor } = props;
68
+ editor.unregisterPlugin(pluginKey);
69
+ });
70
+ return () => {
71
+ var _a;
72
+ return h(Teleport, { to: "body" }, h("div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots)));
73
+ };
74
+ }
62
75
  });
63
76
 
77
+ // src/Editor.ts
78
+ import { Editor as CoreEditor } from "@tiptap/core";
79
+ import {
80
+ customRef,
81
+ markRaw
82
+ } from "vue";
64
83
  function useDebouncedRef(value) {
65
- return customRef((track, trigger) => {
66
- return {
67
- get() {
68
- track();
69
- return value;
70
- },
71
- set(newValue) {
72
- // update state
73
- value = newValue;
74
- // update view as soon as possible
75
- requestAnimationFrame(() => {
76
- requestAnimationFrame(() => {
77
- trigger();
78
- });
79
- });
80
- },
81
- };
82
- });
83
- }
84
- class Editor extends Editor$1 {
85
- constructor(options = {}) {
86
- super(options);
87
- this.contentComponent = null;
88
- this.appContext = null;
89
- this.reactiveState = useDebouncedRef(this.view.state);
90
- this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage);
91
- this.on('beforeTransaction', ({ nextState }) => {
92
- this.reactiveState.value = nextState;
93
- this.reactiveExtensionStorage.value = this.extensionStorage;
84
+ return customRef((track, trigger) => {
85
+ return {
86
+ get() {
87
+ track();
88
+ return value;
89
+ },
90
+ set(newValue) {
91
+ value = newValue;
92
+ requestAnimationFrame(() => {
93
+ requestAnimationFrame(() => {
94
+ trigger();
95
+ });
94
96
  });
95
- return markRaw(this); // eslint-disable-line
96
- }
97
- get state() {
98
- return this.reactiveState ? this.reactiveState.value : this.view.state;
99
- }
100
- get storage() {
101
- return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
102
- }
103
- /**
104
- * Register a ProseMirror plugin.
105
- */
106
- registerPlugin(plugin, handlePlugins) {
107
- super.registerPlugin(plugin, handlePlugins);
108
- this.reactiveState.value = this.view.state;
97
+ }
98
+ };
99
+ });
100
+ }
101
+ var Editor = class extends CoreEditor {
102
+ constructor(options = {}) {
103
+ super(options);
104
+ this.contentComponent = null;
105
+ this.appContext = null;
106
+ this.reactiveState = useDebouncedRef(this.view.state);
107
+ this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage);
108
+ this.on("beforeTransaction", ({ nextState }) => {
109
+ this.reactiveState.value = nextState;
110
+ this.reactiveExtensionStorage.value = this.extensionStorage;
111
+ });
112
+ return markRaw(this);
113
+ }
114
+ get state() {
115
+ return this.reactiveState ? this.reactiveState.value : this.view.state;
116
+ }
117
+ get storage() {
118
+ return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
119
+ }
120
+ /**
121
+ * Register a ProseMirror plugin.
122
+ */
123
+ registerPlugin(plugin, handlePlugins) {
124
+ const nextState = super.registerPlugin(plugin, handlePlugins);
125
+ if (this.reactiveState) {
126
+ this.reactiveState.value = nextState;
109
127
  }
110
- /**
111
- * Unregister a ProseMirror plugin.
112
- */
113
- unregisterPlugin(nameOrPluginKey) {
114
- super.unregisterPlugin(nameOrPluginKey);
115
- this.reactiveState.value = this.view.state;
128
+ return nextState;
129
+ }
130
+ /**
131
+ * Unregister a ProseMirror plugin.
132
+ */
133
+ unregisterPlugin(nameOrPluginKey) {
134
+ const nextState = super.unregisterPlugin(nameOrPluginKey);
135
+ if (this.reactiveState && nextState) {
136
+ this.reactiveState.value = nextState;
116
137
  }
117
- }
138
+ return nextState;
139
+ }
140
+ };
118
141
 
119
- const EditorContent = defineComponent({
120
- name: 'EditorContent',
121
- props: {
122
- editor: {
123
- default: null,
124
- type: Object,
125
- },
126
- },
127
- setup(props) {
128
- const rootEl = ref();
129
- const instance = getCurrentInstance();
130
- watchEffect(() => {
131
- const editor = props.editor;
132
- if (editor && editor.options.element && rootEl.value) {
133
- nextTick(() => {
134
- if (!rootEl.value || !editor.options.element.firstChild) {
135
- return;
136
- }
137
- const element = unref(rootEl.value);
138
- rootEl.value.append(...editor.options.element.childNodes);
139
- // @ts-ignore
140
- editor.contentComponent = instance.ctx._;
141
- if (instance) {
142
- editor.appContext = {
143
- ...instance.appContext,
144
- // Vue internally uses prototype chain to forward/shadow injects across the entire component chain
145
- // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext
146
- // @ts-expect-error forward instance's 'provides' into appContext
147
- provides: instance.provides,
148
- };
149
- }
150
- editor.setOptions({
151
- element,
152
- });
153
- editor.createNodeViews();
154
- });
155
- }
156
- });
157
- onBeforeUnmount(() => {
158
- const editor = props.editor;
159
- if (!editor) {
160
- return;
161
- }
162
- // destroy nodeviews before vue removes dom element
163
- if (!editor.isDestroyed) {
164
- editor.view.setProps({
165
- nodeViews: {},
166
- });
167
- }
168
- editor.contentComponent = null;
169
- editor.appContext = null;
170
- if (!editor.options.element.firstChild) {
171
- return;
172
- }
173
- const newElement = document.createElement('div');
174
- newElement.append(...editor.options.element.childNodes);
175
- editor.setOptions({
176
- element: newElement,
177
- });
178
- });
179
- return { rootEl };
180
- },
181
- render() {
182
- return h('div', {
183
- ref: (el) => { this.rootEl = el; },
142
+ // src/EditorContent.ts
143
+ import {
144
+ defineComponent as defineComponent2,
145
+ getCurrentInstance,
146
+ h as h2,
147
+ nextTick,
148
+ onBeforeUnmount as onBeforeUnmount2,
149
+ ref as ref2,
150
+ unref,
151
+ watchEffect
152
+ } from "vue";
153
+ var EditorContent = defineComponent2({
154
+ name: "EditorContent",
155
+ props: {
156
+ editor: {
157
+ default: null,
158
+ type: Object
159
+ }
160
+ },
161
+ setup(props) {
162
+ const rootEl = ref2();
163
+ const instance = getCurrentInstance();
164
+ watchEffect(() => {
165
+ const editor = props.editor;
166
+ if (editor && editor.options.element && rootEl.value) {
167
+ nextTick(() => {
168
+ if (!rootEl.value || !editor.options.element.firstChild) {
169
+ return;
170
+ }
171
+ const element = unref(rootEl.value);
172
+ rootEl.value.append(...editor.options.element.childNodes);
173
+ editor.contentComponent = instance.ctx._;
174
+ if (instance) {
175
+ editor.appContext = {
176
+ ...instance.appContext,
177
+ // Vue internally uses prototype chain to forward/shadow injects across the entire component chain
178
+ // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext
179
+ // @ts-expect-error forward instance's 'provides' into appContext
180
+ provides: instance.provides
181
+ };
182
+ }
183
+ editor.setOptions({
184
+ element
185
+ });
186
+ editor.createNodeViews();
184
187
  });
185
- },
188
+ }
189
+ });
190
+ onBeforeUnmount2(() => {
191
+ const editor = props.editor;
192
+ if (!editor) {
193
+ return;
194
+ }
195
+ editor.contentComponent = null;
196
+ editor.appContext = null;
197
+ });
198
+ return { rootEl };
199
+ },
200
+ render() {
201
+ return h2(
202
+ "div",
203
+ {
204
+ ref: (el) => {
205
+ this.rootEl = el;
206
+ }
207
+ }
208
+ );
209
+ }
186
210
  });
187
211
 
188
- const FloatingMenu = defineComponent({
189
- name: 'FloatingMenu',
190
- props: {
191
- pluginKey: {
192
- // TODO: TypeScript breaks :(
193
- // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
194
- type: null,
195
- default: 'floatingMenu',
196
- },
197
- editor: {
198
- type: Object,
199
- required: true,
200
- },
201
- options: {
202
- type: Object,
203
- default: () => ({}),
204
- },
205
- shouldShow: {
206
- type: Function,
207
- default: null,
208
- },
212
+ // src/FloatingMenu.ts
213
+ import { FloatingMenuPlugin } from "@tiptap/extension-floating-menu";
214
+ import {
215
+ defineComponent as defineComponent3,
216
+ h as h3,
217
+ onBeforeUnmount as onBeforeUnmount3,
218
+ onMounted as onMounted2,
219
+ ref as ref3,
220
+ Teleport as Teleport2
221
+ } from "vue";
222
+ var FloatingMenu = defineComponent3({
223
+ name: "FloatingMenu",
224
+ props: {
225
+ pluginKey: {
226
+ // TODO: TypeScript breaks :(
227
+ // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
228
+ type: null,
229
+ default: "floatingMenu"
209
230
  },
210
- setup(props, { slots }) {
211
- const root = ref(null);
212
- onMounted(() => {
213
- const { pluginKey, editor, options, shouldShow, } = props;
214
- if (!root.value) {
215
- return;
216
- }
217
- root.value.style.visibility = 'hidden';
218
- root.value.style.position = 'absolute';
219
- // remove the element from the DOM
220
- root.value.remove();
221
- editor.registerPlugin(FloatingMenuPlugin({
222
- pluginKey,
223
- editor,
224
- element: root.value,
225
- options,
226
- shouldShow,
227
- }));
228
- });
229
- onBeforeUnmount(() => {
230
- const { pluginKey, editor } = props;
231
- editor.unregisterPlugin(pluginKey);
232
- });
233
- return () => { var _a; return h(Teleport, { to: 'body' }, h('div', { ref: root }, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots))); };
231
+ editor: {
232
+ type: Object,
233
+ required: true
234
+ },
235
+ options: {
236
+ type: Object,
237
+ default: () => ({})
234
238
  },
239
+ shouldShow: {
240
+ type: Function,
241
+ default: null
242
+ }
243
+ },
244
+ setup(props, { slots }) {
245
+ const root = ref3(null);
246
+ onMounted2(() => {
247
+ const {
248
+ pluginKey,
249
+ editor,
250
+ options,
251
+ shouldShow
252
+ } = props;
253
+ if (!root.value) {
254
+ return;
255
+ }
256
+ root.value.style.visibility = "hidden";
257
+ root.value.style.position = "absolute";
258
+ root.value.remove();
259
+ editor.registerPlugin(FloatingMenuPlugin({
260
+ pluginKey,
261
+ editor,
262
+ element: root.value,
263
+ options,
264
+ shouldShow
265
+ }));
266
+ });
267
+ onBeforeUnmount3(() => {
268
+ const { pluginKey, editor } = props;
269
+ editor.unregisterPlugin(pluginKey);
270
+ });
271
+ return () => {
272
+ var _a;
273
+ return h3(Teleport2, { to: "body" }, h3("div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots)));
274
+ };
275
+ }
235
276
  });
236
277
 
237
- const NodeViewContent = defineComponent({
238
- name: 'NodeViewContent',
239
- props: {
240
- as: {
241
- type: String,
242
- default: 'div',
243
- },
244
- },
245
- render() {
246
- return h(this.as, {
247
- style: {
248
- whiteSpace: 'pre-wrap',
249
- },
250
- 'data-node-view-content': '',
251
- });
252
- },
278
+ // src/NodeViewContent.ts
279
+ import { defineComponent as defineComponent4, h as h4 } from "vue";
280
+ var NodeViewContent = defineComponent4({
281
+ name: "NodeViewContent",
282
+ props: {
283
+ as: {
284
+ type: String,
285
+ default: "div"
286
+ }
287
+ },
288
+ render() {
289
+ return h4(this.as, {
290
+ style: {
291
+ whiteSpace: "pre-wrap"
292
+ },
293
+ "data-node-view-content": ""
294
+ });
295
+ }
253
296
  });
254
297
 
255
- const NodeViewWrapper = defineComponent({
256
- name: 'NodeViewWrapper',
257
- props: {
258
- as: {
259
- type: String,
260
- default: 'div',
298
+ // src/NodeViewWrapper.ts
299
+ import { defineComponent as defineComponent5, h as h5 } from "vue";
300
+ var NodeViewWrapper = defineComponent5({
301
+ name: "NodeViewWrapper",
302
+ props: {
303
+ as: {
304
+ type: String,
305
+ default: "div"
306
+ }
307
+ },
308
+ inject: ["onDragStart", "decorationClasses"],
309
+ render() {
310
+ var _a, _b;
311
+ return h5(
312
+ this.as,
313
+ {
314
+ // @ts-ignore
315
+ class: this.decorationClasses,
316
+ style: {
317
+ whiteSpace: "normal"
261
318
  },
262
- },
263
- inject: ['onDragStart', 'decorationClasses'],
264
- render() {
265
- var _a, _b;
266
- return h(this.as, {
267
- // @ts-ignore
268
- class: this.decorationClasses,
269
- style: {
270
- whiteSpace: 'normal',
271
- },
272
- 'data-node-view-wrapper': '',
273
- // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
274
- onDragstart: this.onDragStart,
275
- }, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a));
276
- },
319
+ "data-node-view-wrapper": "",
320
+ // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
321
+ onDragstart: this.onDragStart
322
+ },
323
+ (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
324
+ );
325
+ }
277
326
  });
278
327
 
279
- const useEditor = (options = {}) => {
280
- const editor = shallowRef();
281
- onMounted(() => {
282
- editor.value = new Editor(options);
283
- });
284
- onBeforeUnmount(() => {
285
- var _a;
286
- (_a = editor.value) === null || _a === void 0 ? void 0 : _a.destroy();
287
- });
288
- return editor;
328
+ // src/useEditor.ts
329
+ import { onBeforeUnmount as onBeforeUnmount4, onMounted as onMounted3, shallowRef } from "vue";
330
+ var useEditor = (options = {}) => {
331
+ const editor = shallowRef();
332
+ onMounted3(() => {
333
+ editor.value = new Editor(options);
334
+ });
335
+ onBeforeUnmount4(() => {
336
+ var _a, _b, _c;
337
+ const nodes = (_a = editor.value) == null ? void 0 : _a.options.element;
338
+ const newEl = nodes == null ? void 0 : nodes.cloneNode(true);
339
+ (_b = nodes == null ? void 0 : nodes.parentNode) == null ? void 0 : _b.replaceChild(newEl, nodes);
340
+ (_c = editor.value) == null ? void 0 : _c.destroy();
341
+ });
342
+ return editor;
289
343
  };
290
344
 
291
- /**
292
- * This class is used to render Vue components inside the editor.
293
- */
294
- class VueRenderer {
295
- constructor(component, { props = {}, editor }) {
296
- this.editor = editor;
297
- this.component = markRaw(component);
298
- this.el = document.createElement('div');
299
- this.props = reactive(props);
300
- this.renderedComponent = this.renderComponent();
301
- }
302
- get element() {
303
- return this.renderedComponent.el;
304
- }
305
- get ref() {
306
- var _a, _b, _c, _d;
307
- // Composition API
308
- if ((_b = (_a = this.renderedComponent.vNode) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.exposed) {
309
- return this.renderedComponent.vNode.component.exposed;
310
- }
311
- // Option API
312
- return (_d = (_c = this.renderedComponent.vNode) === null || _c === void 0 ? void 0 : _c.component) === null || _d === void 0 ? void 0 : _d.proxy;
313
- }
314
- renderComponent() {
315
- let vNode = h(this.component, this.props);
316
- if (this.editor.appContext) {
317
- vNode.appContext = this.editor.appContext;
318
- }
319
- if (typeof document !== 'undefined' && this.el) {
320
- render(vNode, this.el);
321
- }
322
- const destroy = () => {
323
- if (this.el) {
324
- render(null, this.el);
325
- }
326
- this.el = null;
327
- vNode = null;
328
- };
329
- return { vNode, destroy, el: this.el ? this.el.firstElementChild : null };
345
+ // src/VueNodeViewRenderer.ts
346
+ import {
347
+ NodeView
348
+ } from "@tiptap/core";
349
+ import {
350
+ defineComponent as defineComponent6,
351
+ provide,
352
+ ref as ref4
353
+ } from "vue";
354
+
355
+ // src/VueRenderer.ts
356
+ import {
357
+ h as h6,
358
+ markRaw as markRaw2,
359
+ reactive,
360
+ render
361
+ } from "vue";
362
+ var VueRenderer = class {
363
+ constructor(component, { props = {}, editor }) {
364
+ this.editor = editor;
365
+ this.component = markRaw2(component);
366
+ this.el = document.createElement("div");
367
+ this.props = reactive(props);
368
+ this.renderedComponent = this.renderComponent();
369
+ }
370
+ get element() {
371
+ return this.renderedComponent.el;
372
+ }
373
+ get ref() {
374
+ var _a, _b, _c, _d;
375
+ if ((_b = (_a = this.renderedComponent.vNode) == null ? void 0 : _a.component) == null ? void 0 : _b.exposed) {
376
+ return this.renderedComponent.vNode.component.exposed;
330
377
  }
331
- updateProps(props = {}) {
332
- Object.entries(props).forEach(([key, value]) => {
333
- this.props[key] = value;
334
- });
335
- this.renderComponent();
378
+ return (_d = (_c = this.renderedComponent.vNode) == null ? void 0 : _c.component) == null ? void 0 : _d.proxy;
379
+ }
380
+ renderComponent() {
381
+ let vNode = h6(this.component, this.props);
382
+ if (this.editor.appContext) {
383
+ vNode.appContext = this.editor.appContext;
336
384
  }
337
- destroy() {
338
- this.renderedComponent.destroy();
385
+ if (typeof document !== "undefined" && this.el) {
386
+ render(vNode, this.el);
339
387
  }
340
- }
388
+ const destroy = () => {
389
+ if (this.el) {
390
+ render(null, this.el);
391
+ }
392
+ this.el = null;
393
+ vNode = null;
394
+ };
395
+ return { vNode, destroy, el: this.el ? this.el.firstElementChild : null };
396
+ }
397
+ updateProps(props = {}) {
398
+ Object.entries(props).forEach(([key, value]) => {
399
+ this.props[key] = value;
400
+ });
401
+ this.renderComponent();
402
+ }
403
+ destroy() {
404
+ this.renderedComponent.destroy();
405
+ }
406
+ };
341
407
 
342
- const nodeViewProps = {
343
- editor: {
344
- type: Object,
345
- required: true,
346
- },
347
- node: {
348
- type: Object,
349
- required: true,
350
- },
351
- decorations: {
352
- type: Object,
353
- required: true,
354
- },
355
- selected: {
356
- type: Boolean,
357
- required: true,
358
- },
359
- extension: {
360
- type: Object,
361
- required: true,
362
- },
363
- getPos: {
364
- type: Function,
365
- required: true,
366
- },
367
- updateAttributes: {
368
- type: Function,
369
- required: true,
370
- },
371
- deleteNode: {
372
- type: Function,
373
- required: true,
374
- },
408
+ // src/VueNodeViewRenderer.ts
409
+ var nodeViewProps = {
410
+ editor: {
411
+ type: Object,
412
+ required: true
413
+ },
414
+ node: {
415
+ type: Object,
416
+ required: true
417
+ },
418
+ decorations: {
419
+ type: Object,
420
+ required: true
421
+ },
422
+ selected: {
423
+ type: Boolean,
424
+ required: true
425
+ },
426
+ extension: {
427
+ type: Object,
428
+ required: true
429
+ },
430
+ getPos: {
431
+ type: Function,
432
+ required: true
433
+ },
434
+ updateAttributes: {
435
+ type: Function,
436
+ required: true
437
+ },
438
+ deleteNode: {
439
+ type: Function,
440
+ required: true
441
+ }
375
442
  };
376
- class VueNodeView extends NodeView {
377
- mount() {
378
- const props = {
379
- editor: this.editor,
380
- node: this.node,
381
- decorations: this.decorations,
382
- selected: false,
383
- extension: this.extension,
384
- getPos: () => this.getPos(),
385
- updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
386
- deleteNode: () => this.deleteNode(),
387
- };
388
- const onDragStart = this.onDragStart.bind(this);
389
- this.decorationClasses = ref(this.getDecorationClasses());
390
- const extendedComponent = defineComponent({
391
- extends: { ...this.component },
392
- props: Object.keys(props),
393
- template: this.component.template,
394
- setup: reactiveProps => {
395
- var _a, _b;
396
- provide('onDragStart', onDragStart);
397
- provide('decorationClasses', this.decorationClasses);
398
- return (_b = (_a = this.component).setup) === null || _b === void 0 ? void 0 : _b.call(_a, reactiveProps, {
399
- expose: () => undefined,
400
- });
401
- },
402
- // add support for scoped styles
403
- // @ts-ignore
404
- // eslint-disable-next-line
405
- __scopeId: this.component.__scopeId,
406
- // add support for CSS Modules
407
- // @ts-ignore
408
- // eslint-disable-next-line
409
- __cssModules: this.component.__cssModules,
410
- // add support for vue devtools
411
- // @ts-ignore
412
- // eslint-disable-next-line
413
- __name: this.component.__name,
414
- // @ts-ignore
415
- // eslint-disable-next-line
416
- __file: this.component.__file,
417
- });
418
- this.renderer = new VueRenderer(extendedComponent, {
419
- editor: this.editor,
420
- props,
443
+ var VueNodeView = class extends NodeView {
444
+ mount() {
445
+ const props = {
446
+ editor: this.editor,
447
+ node: this.node,
448
+ decorations: this.decorations,
449
+ innerDecorations: this.innerDecorations,
450
+ view: this.view,
451
+ selected: false,
452
+ extension: this.extension,
453
+ HTMLAttributes: this.HTMLAttributes,
454
+ getPos: () => this.getPos(),
455
+ updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
456
+ deleteNode: () => this.deleteNode()
457
+ };
458
+ const onDragStart = this.onDragStart.bind(this);
459
+ this.decorationClasses = ref4(this.getDecorationClasses());
460
+ const extendedComponent = defineComponent6({
461
+ extends: { ...this.component },
462
+ props: Object.keys(props),
463
+ template: this.component.template,
464
+ setup: (reactiveProps) => {
465
+ var _a, _b;
466
+ provide("onDragStart", onDragStart);
467
+ provide("decorationClasses", this.decorationClasses);
468
+ return (_b = (_a = this.component).setup) == null ? void 0 : _b.call(_a, reactiveProps, {
469
+ expose: () => void 0
421
470
  });
471
+ },
472
+ // add support for scoped styles
473
+ // @ts-ignore
474
+ // eslint-disable-next-line
475
+ __scopeId: this.component.__scopeId,
476
+ // add support for CSS Modules
477
+ // @ts-ignore
478
+ // eslint-disable-next-line
479
+ __cssModules: this.component.__cssModules,
480
+ // add support for vue devtools
481
+ // @ts-ignore
482
+ // eslint-disable-next-line
483
+ __name: this.component.__name,
484
+ // @ts-ignore
485
+ // eslint-disable-next-line
486
+ __file: this.component.__file
487
+ });
488
+ this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
489
+ this.editor.on("selectionUpdate", this.handleSelectionUpdate);
490
+ this.renderer = new VueRenderer(extendedComponent, {
491
+ editor: this.editor,
492
+ props
493
+ });
494
+ }
495
+ /**
496
+ * Return the DOM element.
497
+ * This is the element that will be used to display the node view.
498
+ */
499
+ get dom() {
500
+ if (!this.renderer.element || !this.renderer.element.hasAttribute("data-node-view-wrapper")) {
501
+ throw Error("Please use the NodeViewWrapper component for your node view.");
422
502
  }
423
- get dom() {
424
- if (!this.renderer.element || !this.renderer.element.hasAttribute('data-node-view-wrapper')) {
425
- throw Error('Please use the NodeViewWrapper component for your node view.');
426
- }
427
- return this.renderer.element;
503
+ return this.renderer.element;
504
+ }
505
+ /**
506
+ * Return the content DOM element.
507
+ * This is the element that will be used to display the rich-text content of the node.
508
+ */
509
+ get contentDOM() {
510
+ if (this.node.isLeaf) {
511
+ return null;
428
512
  }
429
- get contentDOM() {
430
- if (this.node.isLeaf) {
431
- return null;
432
- }
433
- return this.dom.querySelector('[data-node-view-content]');
513
+ return this.dom.querySelector("[data-node-view-content]");
514
+ }
515
+ /**
516
+ * On editor selection update, check if the node is selected.
517
+ * If it is, call `selectNode`, otherwise call `deselectNode`.
518
+ */
519
+ handleSelectionUpdate() {
520
+ const { from, to } = this.editor.state.selection;
521
+ const pos = this.getPos();
522
+ if (typeof pos !== "number") {
523
+ return;
434
524
  }
435
- update(node, decorations) {
436
- const updateProps = (props) => {
437
- this.decorationClasses.value = this.getDecorationClasses();
438
- this.renderer.updateProps(props);
439
- };
440
- if (typeof this.options.update === 'function') {
441
- const oldNode = this.node;
442
- const oldDecorations = this.decorations;
443
- this.node = node;
444
- this.decorations = decorations;
445
- return this.options.update({
446
- oldNode,
447
- oldDecorations,
448
- newNode: node,
449
- newDecorations: decorations,
450
- updateProps: () => updateProps({ node, decorations }),
451
- });
452
- }
453
- if (node.type !== this.node.type) {
454
- return false;
455
- }
456
- if (node === this.node && this.decorations === decorations) {
457
- return true;
458
- }
459
- this.node = node;
460
- this.decorations = decorations;
461
- updateProps({ node, decorations });
462
- return true;
525
+ if (from <= pos && to >= pos + this.node.nodeSize) {
526
+ if (this.renderer.props.selected) {
527
+ return;
528
+ }
529
+ this.selectNode();
530
+ } else {
531
+ if (!this.renderer.props.selected) {
532
+ return;
533
+ }
534
+ this.deselectNode();
463
535
  }
464
- selectNode() {
465
- this.renderer.updateProps({
466
- selected: true,
467
- });
468
- if (this.renderer.element) {
469
- this.renderer.element.classList.add('ProseMirror-selectednode');
470
- }
536
+ }
537
+ /**
538
+ * On update, update the React component.
539
+ * To prevent unnecessary updates, the `update` option can be used.
540
+ */
541
+ update(node, decorations, innerDecorations) {
542
+ const rerenderComponent = (props) => {
543
+ this.decorationClasses.value = this.getDecorationClasses();
544
+ this.renderer.updateProps(props);
545
+ };
546
+ if (typeof this.options.update === "function") {
547
+ const oldNode = this.node;
548
+ const oldDecorations = this.decorations;
549
+ const oldInnerDecorations = this.innerDecorations;
550
+ this.node = node;
551
+ this.decorations = decorations;
552
+ this.innerDecorations = innerDecorations;
553
+ return this.options.update({
554
+ oldNode,
555
+ oldDecorations,
556
+ newNode: node,
557
+ newDecorations: decorations,
558
+ oldInnerDecorations,
559
+ innerDecorations,
560
+ updateProps: () => rerenderComponent({ node, decorations, innerDecorations })
561
+ });
471
562
  }
472
- deselectNode() {
473
- this.renderer.updateProps({
474
- selected: false,
475
- });
476
- if (this.renderer.element) {
477
- this.renderer.element.classList.remove('ProseMirror-selectednode');
478
- }
563
+ if (node.type !== this.node.type) {
564
+ return false;
479
565
  }
480
- getDecorationClasses() {
481
- return (this.decorations
482
- // @ts-ignore
483
- .map(item => item.type.attrs.class)
484
- .flat()
485
- .join(' '));
566
+ if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {
567
+ return true;
486
568
  }
487
- destroy() {
488
- this.renderer.destroy();
569
+ this.node = node;
570
+ this.decorations = decorations;
571
+ this.innerDecorations = innerDecorations;
572
+ rerenderComponent({ node, decorations, innerDecorations });
573
+ return true;
574
+ }
575
+ /**
576
+ * Select the node.
577
+ * Add the `selected` prop and the `ProseMirror-selectednode` class.
578
+ */
579
+ selectNode() {
580
+ this.renderer.updateProps({
581
+ selected: true
582
+ });
583
+ if (this.renderer.element) {
584
+ this.renderer.element.classList.add("ProseMirror-selectednode");
489
585
  }
490
- }
586
+ }
587
+ /**
588
+ * Deselect the node.
589
+ * Remove the `selected` prop and the `ProseMirror-selectednode` class.
590
+ */
591
+ deselectNode() {
592
+ this.renderer.updateProps({
593
+ selected: false
594
+ });
595
+ if (this.renderer.element) {
596
+ this.renderer.element.classList.remove("ProseMirror-selectednode");
597
+ }
598
+ }
599
+ getDecorationClasses() {
600
+ return this.decorations.map((item) => item.type.attrs.class).flat().join(" ");
601
+ }
602
+ destroy() {
603
+ this.renderer.destroy();
604
+ this.editor.off("selectionUpdate", this.handleSelectionUpdate);
605
+ }
606
+ };
491
607
  function VueNodeViewRenderer(component, options) {
492
- return (props) => {
493
- // try to get the parent component
494
- // this is important for vue devtools to show the component hierarchy correctly
495
- // maybe it’s `undefined` because <editor-content> isn’t rendered yet
496
- if (!props.editor.contentComponent) {
497
- return {};
498
- }
499
- return new VueNodeView(component, props, options);
500
- };
608
+ return (props) => {
609
+ if (!props.editor.contentComponent) {
610
+ return {};
611
+ }
612
+ const normalizedComponent = typeof component === "function" && "__vccOpts" in component ? component.__vccOpts : component;
613
+ return new VueNodeView(normalizedComponent, props, options);
614
+ };
501
615
  }
502
616
 
503
- export { BubbleMenu, Editor, EditorContent, FloatingMenu, NodeViewContent, NodeViewWrapper, VueNodeViewRenderer, VueRenderer, nodeViewProps, useEditor };
504
- //# sourceMappingURL=index.js.map
617
+ // src/index.ts
618
+ export * from "@tiptap/core";
619
+ export {
620
+ BubbleMenu,
621
+ Editor,
622
+ EditorContent,
623
+ FloatingMenu,
624
+ NodeViewContent,
625
+ NodeViewWrapper,
626
+ VueNodeViewRenderer,
627
+ VueRenderer,
628
+ nodeViewProps,
629
+ useEditor
630
+ };
631
+ //# sourceMappingURL=index.js.map