@tiptap/vue-2 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 (186) hide show
  1. package/dist/index.cjs +446 -354
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +99 -0
  4. package/dist/index.d.ts +99 -0
  5. package/dist/index.js +404 -338
  6. package/dist/index.js.map +1 -1
  7. package/package.json +11 -13
  8. package/src/VueNodeViewRenderer.ts +85 -21
  9. package/dist/index.umd.js +0 -389
  10. package/dist/index.umd.js.map +0 -1
  11. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  12. package/dist/packages/core/src/Editor.d.ts +0 -159
  13. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  14. package/dist/packages/core/src/Extension.d.ts +0 -343
  15. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  16. package/dist/packages/core/src/InputRule.d.ts +0 -42
  17. package/dist/packages/core/src/Mark.d.ts +0 -451
  18. package/dist/packages/core/src/Node.d.ts +0 -611
  19. package/dist/packages/core/src/NodePos.d.ts +0 -44
  20. package/dist/packages/core/src/NodeView.d.ts +0 -31
  21. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  22. package/dist/packages/core/src/Tracker.d.ts +0 -11
  23. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  24. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  25. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  26. package/dist/packages/core/src/commands/command.d.ts +0 -18
  27. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  28. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  29. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  30. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  31. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  32. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  33. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  34. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  35. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  36. package/dist/packages/core/src/commands/first.d.ts +0 -14
  37. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  38. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  39. package/dist/packages/core/src/commands/index.d.ts +0 -55
  40. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  41. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  42. package/dist/packages/core/src/commands/join.d.ts +0 -41
  43. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  44. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  45. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  46. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  47. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  48. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  49. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  50. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  51. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  52. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  53. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  54. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  55. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  60. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  61. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  62. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  63. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  64. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  65. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  66. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  67. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  68. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  69. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  70. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  71. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  72. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  73. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  74. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  75. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  76. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  77. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  78. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  79. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  80. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  81. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  82. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  83. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  84. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  86. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  87. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  88. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  89. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  90. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  91. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  92. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  93. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  94. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  95. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  96. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  97. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  98. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  99. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  100. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  101. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  102. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  103. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  104. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  105. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  106. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  107. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  109. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  110. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  111. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  113. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  114. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  115. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  116. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  117. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  118. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  119. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  120. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  121. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  122. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  123. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  124. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  125. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  129. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  130. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -8
  131. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  132. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  135. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  137. package/dist/packages/core/src/index.d.ts +0 -24
  138. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  139. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  140. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  141. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  142. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  143. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  144. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  145. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  146. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  147. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  148. package/dist/packages/core/src/style.d.ts +0 -1
  149. package/dist/packages/core/src/types.d.ts +0 -253
  150. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  151. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  152. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  153. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  158. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  171. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  172. package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +0 -99
  173. package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +0 -15
  174. package/dist/packages/extension-bubble-menu/src/index.d.ts +0 -4
  175. package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +0 -81
  176. package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +0 -15
  177. package/dist/packages/extension-floating-menu/src/index.d.ts +0 -4
  178. package/dist/packages/vue-2/src/BubbleMenu.d.ts +0 -11
  179. package/dist/packages/vue-2/src/Editor.d.ts +0 -5
  180. package/dist/packages/vue-2/src/EditorContent.d.ts +0 -6
  181. package/dist/packages/vue-2/src/FloatingMenu.d.ts +0 -9
  182. package/dist/packages/vue-2/src/NodeViewContent.d.ts +0 -5
  183. package/dist/packages/vue-2/src/NodeViewWrapper.d.ts +0 -9
  184. package/dist/packages/vue-2/src/VueNodeViewRenderer.d.ts +0 -37
  185. package/dist/packages/vue-2/src/VueRenderer.d.ts +0 -12
  186. package/dist/packages/vue-2/src/index.d.ts +0 -9
package/dist/index.js CHANGED
@@ -1,374 +1,440 @@
1
- import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu';
2
- import { Editor as Editor$1, NodeView } from '@tiptap/core';
3
- export * from '@tiptap/core';
4
- import { FloatingMenuPlugin } from '@tiptap/extension-floating-menu';
5
- import Vue from 'vue';
6
- import { objectProp, booleanProp, functionProp } from 'vue-ts-types';
7
-
8
- const BubbleMenu = {
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
- },
22
- options: {
23
- type: Object,
24
- default: {},
25
- },
26
- resizeDelay: {
27
- type: Number,
28
- },
29
- shouldShow: {
30
- type: Function,
31
- default: null,
32
- },
1
+ // src/BubbleMenu.ts
2
+ import { BubbleMenuPlugin } from "@tiptap/extension-bubble-menu";
3
+ var BubbleMenu = {
4
+ name: "BubbleMenu",
5
+ props: {
6
+ pluginKey: {
7
+ type: [String, Object],
8
+ default: "bubbleMenu"
33
9
  },
34
- watch: {
35
- editor: {
36
- immediate: true,
37
- handler(editor) {
38
- if (!editor) {
39
- return;
40
- }
41
- this.$el.style.visibility = 'hidden';
42
- this.$el.style.position = 'absolute';
43
- this.$el.remove();
44
- this.$nextTick(() => {
45
- editor.registerPlugin(BubbleMenuPlugin({
46
- updateDelay: this.updateDelay,
47
- resizeDelay: this.resizeDelay,
48
- options: this.options,
49
- editor,
50
- element: this.$el,
51
- pluginKey: this.pluginKey,
52
- shouldShow: this.shouldShow,
53
- }));
54
- });
55
- },
56
- },
10
+ editor: {
11
+ type: Object,
12
+ required: true
57
13
  },
58
- render(createElement) {
59
- return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default);
14
+ updateDelay: {
15
+ type: Number
60
16
  },
61
- beforeDestroy() {
62
- this.editor.unregisterPlugin(this.pluginKey);
17
+ options: {
18
+ type: Object,
19
+ default: {}
63
20
  },
21
+ resizeDelay: {
22
+ type: Number
23
+ },
24
+ shouldShow: {
25
+ type: Function,
26
+ default: null
27
+ }
28
+ },
29
+ watch: {
30
+ editor: {
31
+ immediate: true,
32
+ handler(editor) {
33
+ if (!editor) {
34
+ return;
35
+ }
36
+ this.$el.style.visibility = "hidden";
37
+ this.$el.style.position = "absolute";
38
+ this.$el.remove();
39
+ this.$nextTick(() => {
40
+ editor.registerPlugin(BubbleMenuPlugin({
41
+ updateDelay: this.updateDelay,
42
+ resizeDelay: this.resizeDelay,
43
+ options: this.options,
44
+ editor,
45
+ element: this.$el,
46
+ pluginKey: this.pluginKey,
47
+ shouldShow: this.shouldShow
48
+ }));
49
+ });
50
+ }
51
+ }
52
+ },
53
+ render(createElement) {
54
+ return createElement("div", { style: { visibility: "hidden" } }, this.$slots.default);
55
+ },
56
+ beforeDestroy() {
57
+ this.editor.unregisterPlugin(this.pluginKey);
58
+ }
59
+ };
60
+
61
+ // src/Editor.ts
62
+ import { Editor as CoreEditor } from "@tiptap/core";
63
+ var Editor = class extends CoreEditor {
64
+ constructor() {
65
+ super(...arguments);
66
+ this.contentComponent = null;
67
+ }
64
68
  };
65
69
 
66
- class Editor extends Editor$1 {
67
- constructor() {
68
- super(...arguments);
69
- this.contentComponent = null;
70
+ // src/EditorContent.ts
71
+ var EditorContent = {
72
+ name: "EditorContent",
73
+ props: {
74
+ editor: {
75
+ default: null,
76
+ type: Object
70
77
  }
71
- }
78
+ },
79
+ watch: {
80
+ editor: {
81
+ immediate: true,
82
+ handler(editor) {
83
+ if (editor && editor.options.element) {
84
+ this.$nextTick(() => {
85
+ const element = this.$el;
86
+ if (!element || !editor.options.element.firstChild) {
87
+ return;
88
+ }
89
+ element.append(...editor.options.element.childNodes);
90
+ editor.contentComponent = this;
91
+ editor.setOptions({
92
+ element
93
+ });
94
+ editor.createNodeViews();
95
+ });
96
+ }
97
+ }
98
+ }
99
+ },
100
+ render(createElement) {
101
+ return createElement("div");
102
+ },
103
+ beforeDestroy() {
104
+ const { editor } = this;
105
+ if (!editor) {
106
+ return;
107
+ }
108
+ if (!editor.isDestroyed) {
109
+ editor.view.setProps({
110
+ nodeViews: {}
111
+ });
112
+ }
113
+ editor.contentComponent = null;
114
+ if (!editor.options.element.firstChild) {
115
+ return;
116
+ }
117
+ const newElement = document.createElement("div");
118
+ newElement.append(...editor.options.element.childNodes);
119
+ editor.setOptions({
120
+ element: newElement
121
+ });
122
+ }
123
+ };
72
124
 
73
- const EditorContent = {
74
- name: 'EditorContent',
75
- props: {
76
- editor: {
77
- default: null,
78
- type: Object,
79
- },
125
+ // src/FloatingMenu.ts
126
+ import { FloatingMenuPlugin } from "@tiptap/extension-floating-menu";
127
+ var FloatingMenu = {
128
+ name: "FloatingMenu",
129
+ props: {
130
+ pluginKey: {
131
+ type: [String, Object],
132
+ default: "floatingMenu"
80
133
  },
81
- watch: {
82
- editor: {
83
- immediate: true,
84
- handler(editor) {
85
- if (editor && editor.options.element) {
86
- this.$nextTick(() => {
87
- const element = this.$el;
88
- if (!element || !editor.options.element.firstChild) {
89
- return;
90
- }
91
- element.append(...editor.options.element.childNodes);
92
- editor.contentComponent = this;
93
- editor.setOptions({
94
- element,
95
- });
96
- editor.createNodeViews();
97
- });
98
- }
99
- },
100
- },
134
+ editor: {
135
+ type: Object,
136
+ required: true
101
137
  },
102
- render(createElement) {
103
- return createElement('div');
138
+ options: {
139
+ type: Object,
140
+ default: () => ({})
104
141
  },
105
- beforeDestroy() {
106
- const { editor } = this;
142
+ shouldShow: {
143
+ type: Function,
144
+ default: null
145
+ }
146
+ },
147
+ watch: {
148
+ editor: {
149
+ immediate: true,
150
+ handler(editor) {
107
151
  if (!editor) {
108
- return;
109
- }
110
- if (!editor.isDestroyed) {
111
- editor.view.setProps({
112
- nodeViews: {},
113
- });
114
- }
115
- editor.contentComponent = null;
116
- if (!editor.options.element.firstChild) {
117
- return;
152
+ return;
118
153
  }
119
- const newElement = document.createElement('div');
120
- newElement.append(...editor.options.element.childNodes);
121
- editor.setOptions({
122
- element: newElement,
154
+ this.$el.style.visibility = "hidden";
155
+ this.$el.style.position = "absolute";
156
+ this.$el.remove();
157
+ this.$nextTick(() => {
158
+ editor.registerPlugin(FloatingMenuPlugin({
159
+ pluginKey: this.pluginKey,
160
+ editor,
161
+ element: this.$el,
162
+ options: this.options,
163
+ shouldShow: this.shouldShow
164
+ }));
123
165
  });
124
- },
166
+ }
167
+ }
168
+ },
169
+ render(createElement) {
170
+ return createElement("div", { style: { visibility: "hidden" } }, this.$slots.default);
171
+ },
172
+ beforeDestroy() {
173
+ this.editor.unregisterPlugin(this.pluginKey);
174
+ }
125
175
  };
126
176
 
127
- const FloatingMenu = {
128
- name: 'FloatingMenu',
129
- props: {
130
- pluginKey: {
131
- type: [String, Object],
132
- default: 'floatingMenu',
133
- },
134
- editor: {
135
- type: Object,
136
- required: true,
137
- },
138
- options: {
139
- type: Object,
140
- default: () => ({}),
141
- },
142
- shouldShow: {
143
- type: Function,
144
- default: null,
145
- },
146
- },
147
- watch: {
148
- editor: {
149
- immediate: true,
150
- handler(editor) {
151
- if (!editor) {
152
- return;
153
- }
154
- this.$el.style.visibility = 'hidden';
155
- this.$el.style.position = 'absolute';
156
- this.$el.remove();
157
- this.$nextTick(() => {
158
- editor.registerPlugin(FloatingMenuPlugin({
159
- pluginKey: this.pluginKey,
160
- editor,
161
- element: this.$el,
162
- options: this.options,
163
- shouldShow: this.shouldShow,
164
- }));
165
- });
166
- },
167
- },
168
- },
169
- render(createElement) {
170
- return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default);
171
- },
172
- beforeDestroy() {
173
- this.editor.unregisterPlugin(this.pluginKey);
174
- },
177
+ // src/NodeViewContent.ts
178
+ var NodeViewContent = {
179
+ props: {
180
+ as: {
181
+ type: String,
182
+ default: "div"
183
+ }
184
+ },
185
+ render(createElement) {
186
+ return createElement(this.as, {
187
+ style: {
188
+ whiteSpace: "pre-wrap"
189
+ },
190
+ attrs: {
191
+ "data-node-view-content": ""
192
+ }
193
+ });
194
+ }
175
195
  };
176
196
 
177
- const NodeViewContent = {
178
- props: {
179
- as: {
180
- type: String,
181
- default: 'div',
197
+ // src/NodeViewWrapper.ts
198
+ var NodeViewWrapper = {
199
+ props: {
200
+ as: {
201
+ type: String,
202
+ default: "div"
203
+ }
204
+ },
205
+ inject: ["onDragStart", "decorationClasses"],
206
+ render(createElement) {
207
+ return createElement(
208
+ this.as,
209
+ {
210
+ class: this.decorationClasses.value,
211
+ style: {
212
+ whiteSpace: "normal"
182
213
  },
183
- },
184
- render(createElement) {
185
- return createElement(this.as, {
186
- style: {
187
- whiteSpace: 'pre-wrap',
188
- },
189
- attrs: {
190
- 'data-node-view-content': '',
191
- },
192
- });
193
- },
194
- };
195
-
196
- const NodeViewWrapper = {
197
- props: {
198
- as: {
199
- type: String,
200
- default: 'div',
214
+ attrs: {
215
+ "data-node-view-wrapper": ""
201
216
  },
202
- },
203
- inject: ['onDragStart', 'decorationClasses'],
204
- render(createElement) {
205
- return createElement(this.as, {
206
- class: this.decorationClasses.value,
207
- style: {
208
- whiteSpace: 'normal',
209
- },
210
- attrs: {
211
- 'data-node-view-wrapper': '',
212
- },
213
- on: {
214
- dragstart: this.onDragStart,
215
- },
216
- }, this.$slots.default);
217
- },
217
+ on: {
218
+ dragstart: this.onDragStart
219
+ }
220
+ },
221
+ this.$slots.default
222
+ );
223
+ }
218
224
  };
219
225
 
220
- /**
221
- * The VueRenderer class is responsible for rendering a Vue component as a ProseMirror node view.
222
- */
223
- class VueRenderer {
224
- constructor(component, props) {
225
- const Component = (typeof component === 'function') ? component : Vue.extend(component);
226
- this.ref = new Component(props).$mount();
227
- }
228
- get element() {
229
- return this.ref.$el;
230
- }
231
- updateProps(props = {}) {
232
- var _a, _b, _c;
233
- if (!this.ref.$props) {
234
- return;
235
- }
236
- // prevents `Avoid mutating a prop directly` error message
237
- // Fix: `VueNodeViewRenderer` change vue Constructor `config.silent` not working
238
- const currentVueConstructor = (_c = (_b = (_a = this.ref.$props.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) === null || _b === void 0 ? void 0 : _b.$options._base) !== null && _c !== void 0 ? _c : Vue; // eslint-disable-line
239
- const originalSilent = currentVueConstructor.config.silent;
240
- currentVueConstructor.config.silent = true;
241
- Object
242
- .entries(props)
243
- .forEach(([key, value]) => {
244
- this.ref.$props[key] = value;
245
- });
246
- currentVueConstructor.config.silent = originalSilent;
247
- }
248
- destroy() {
249
- this.ref.$destroy();
226
+ // src/VueNodeViewRenderer.ts
227
+ import {
228
+ NodeView
229
+ } from "@tiptap/core";
230
+ import Vue2 from "vue";
231
+ import { booleanProp, functionProp, objectProp } from "vue-ts-types";
232
+
233
+ // src/VueRenderer.ts
234
+ import Vue from "vue";
235
+ var VueRenderer = class {
236
+ constructor(component, props) {
237
+ const Component = typeof component === "function" ? component : Vue.extend(component);
238
+ this.ref = new Component(props).$mount();
239
+ }
240
+ get element() {
241
+ return this.ref.$el;
242
+ }
243
+ updateProps(props = {}) {
244
+ var _a, _b, _c;
245
+ if (!this.ref.$props) {
246
+ return;
250
247
  }
251
- }
248
+ const currentVueConstructor = (_c = (_b = (_a = this.ref.$props.editor) == null ? void 0 : _a.contentComponent) == null ? void 0 : _b.$options._base) != null ? _c : Vue;
249
+ const originalSilent = currentVueConstructor.config.silent;
250
+ currentVueConstructor.config.silent = true;
251
+ Object.entries(props).forEach(([key, value]) => {
252
+ this.ref.$props[key] = value;
253
+ });
254
+ currentVueConstructor.config.silent = originalSilent;
255
+ }
256
+ destroy() {
257
+ this.ref.$destroy();
258
+ }
259
+ };
252
260
 
253
- const nodeViewProps = {
254
- editor: objectProp().required,
255
- node: objectProp().required,
256
- decorations: objectProp().required,
257
- selected: booleanProp().required,
258
- extension: objectProp().required,
259
- getPos: functionProp().required,
260
- updateAttributes: functionProp().required,
261
- deleteNode: functionProp().required,
261
+ // src/VueNodeViewRenderer.ts
262
+ var nodeViewProps = {
263
+ editor: objectProp().required,
264
+ node: objectProp().required,
265
+ decorations: objectProp().required,
266
+ selected: booleanProp().required,
267
+ extension: objectProp().required,
268
+ getPos: functionProp().required,
269
+ updateAttributes: functionProp().required,
270
+ deleteNode: functionProp().required
262
271
  };
263
- class VueNodeView extends NodeView {
264
- mount() {
265
- var _a, _b;
266
- const props = {
267
- editor: this.editor,
268
- node: this.node,
269
- decorations: this.decorations,
270
- selected: false,
271
- extension: this.extension,
272
- getPos: () => this.getPos(),
273
- updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
274
- deleteNode: () => this.deleteNode(),
272
+ var VueNodeView = class extends NodeView {
273
+ mount() {
274
+ var _a, _b;
275
+ const props = {
276
+ editor: this.editor,
277
+ node: this.node,
278
+ decorations: this.decorations,
279
+ innerDecorations: this.innerDecorations,
280
+ view: this.view,
281
+ selected: false,
282
+ extension: this.extension,
283
+ HTMLAttributes: this.HTMLAttributes,
284
+ getPos: () => this.getPos(),
285
+ updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
286
+ deleteNode: () => this.deleteNode()
287
+ };
288
+ const onDragStart = this.onDragStart.bind(this);
289
+ this.decorationClasses = Vue2.observable({
290
+ value: this.getDecorationClasses()
291
+ });
292
+ const vue = (_b = (_a = this.editor.contentComponent) == null ? void 0 : _a.$options._base) != null ? _b : Vue2;
293
+ const Component = vue.extend(this.component).extend({
294
+ props: Object.keys(props),
295
+ provide: () => {
296
+ return {
297
+ onDragStart,
298
+ decorationClasses: this.decorationClasses
275
299
  };
276
- const onDragStart = this.onDragStart.bind(this);
277
- this.decorationClasses = Vue.observable({
278
- value: this.getDecorationClasses(),
279
- });
280
- // @ts-ignore
281
- const vue = (_b = (_a = this.editor.contentComponent) === null || _a === void 0 ? void 0 : _a.$options._base) !== null && _b !== void 0 ? _b : Vue; // eslint-disable-line
282
- const Component = vue.extend(this.component).extend({
283
- props: Object.keys(props),
284
- provide: () => {
285
- return {
286
- onDragStart,
287
- decorationClasses: this.decorationClasses,
288
- };
289
- },
290
- });
291
- this.renderer = new VueRenderer(Component, {
292
- parent: this.editor.contentComponent,
293
- propsData: props,
294
- });
295
- }
296
- get dom() {
297
- if (!this.renderer.element.hasAttribute('data-node-view-wrapper')) {
298
- throw Error('Please use the NodeViewWrapper component for your node view.');
299
- }
300
- return this.renderer.element;
300
+ }
301
+ });
302
+ this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
303
+ this.editor.on("selectionUpdate", this.handleSelectionUpdate);
304
+ this.renderer = new VueRenderer(Component, {
305
+ parent: this.editor.contentComponent,
306
+ propsData: props
307
+ });
308
+ }
309
+ /**
310
+ * Return the DOM element.
311
+ * This is the element that will be used to display the node view.
312
+ */
313
+ get dom() {
314
+ if (!this.renderer.element.hasAttribute("data-node-view-wrapper")) {
315
+ throw Error("Please use the NodeViewWrapper component for your node view.");
301
316
  }
302
- get contentDOM() {
303
- if (this.node.isLeaf) {
304
- return null;
305
- }
306
- const contentElement = this.dom.querySelector('[data-node-view-content]');
307
- return (contentElement || this.dom);
317
+ return this.renderer.element;
318
+ }
319
+ /**
320
+ * Return the content DOM element.
321
+ * This is the element that will be used to display the rich-text content of the node.
322
+ */
323
+ get contentDOM() {
324
+ if (this.node.isLeaf) {
325
+ return null;
308
326
  }
309
- update(node, decorations) {
310
- const updateProps = (props) => {
311
- this.decorationClasses.value = this.getDecorationClasses();
312
- this.renderer.updateProps(props);
313
- };
314
- if (typeof this.options.update === 'function') {
315
- const oldNode = this.node;
316
- const oldDecorations = this.decorations;
317
- this.node = node;
318
- this.decorations = decorations;
319
- return this.options.update({
320
- oldNode,
321
- oldDecorations,
322
- newNode: node,
323
- newDecorations: decorations,
324
- updateProps: () => updateProps({ node, decorations }),
325
- });
326
- }
327
- if (node.type !== this.node.type) {
328
- return false;
329
- }
330
- if (node === this.node && this.decorations === decorations) {
331
- return true;
332
- }
333
- this.node = node;
334
- this.decorations = decorations;
335
- updateProps({ node, decorations });
336
- return true;
327
+ const contentElement = this.dom.querySelector("[data-node-view-content]");
328
+ return contentElement || this.dom;
329
+ }
330
+ /**
331
+ * On editor selection update, check if the node is selected.
332
+ * If it is, call `selectNode`, otherwise call `deselectNode`.
333
+ */
334
+ handleSelectionUpdate() {
335
+ const { from, to } = this.editor.state.selection;
336
+ const pos = this.getPos();
337
+ if (typeof pos !== "number") {
338
+ return;
337
339
  }
338
- selectNode() {
339
- this.renderer.updateProps({
340
- selected: true,
341
- });
342
- this.renderer.element.classList.add('ProseMirror-selectednode');
340
+ if (from <= pos && to >= pos + this.node.nodeSize) {
341
+ if (this.renderer.ref.$props.selected) {
342
+ return;
343
+ }
344
+ this.selectNode();
345
+ } else {
346
+ if (!this.renderer.ref.$props.selected) {
347
+ return;
348
+ }
349
+ this.deselectNode();
343
350
  }
344
- deselectNode() {
345
- this.renderer.updateProps({
346
- selected: false,
347
- });
348
- this.renderer.element.classList.remove('ProseMirror-selectednode');
351
+ }
352
+ /**
353
+ * On update, update the React component.
354
+ * To prevent unnecessary updates, the `update` option can be used.
355
+ */
356
+ update(node, decorations, innerDecorations) {
357
+ const rerenderComponent = (props) => {
358
+ this.decorationClasses.value = this.getDecorationClasses();
359
+ this.renderer.updateProps(props);
360
+ };
361
+ if (typeof this.options.update === "function") {
362
+ const oldNode = this.node;
363
+ const oldDecorations = this.decorations;
364
+ const oldInnerDecorations = this.innerDecorations;
365
+ this.node = node;
366
+ this.decorations = decorations;
367
+ this.innerDecorations = innerDecorations;
368
+ return this.options.update({
369
+ oldNode,
370
+ oldDecorations,
371
+ newNode: node,
372
+ newDecorations: decorations,
373
+ oldInnerDecorations,
374
+ innerDecorations,
375
+ updateProps: () => rerenderComponent({ node, decorations, innerDecorations })
376
+ });
349
377
  }
350
- getDecorationClasses() {
351
- return (this.decorations
352
- // @ts-ignore
353
- .map(item => item.type.attrs.class)
354
- .flat()
355
- .join(' '));
378
+ if (node.type !== this.node.type) {
379
+ return false;
356
380
  }
357
- destroy() {
358
- this.renderer.destroy();
381
+ if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {
382
+ return true;
359
383
  }
360
- }
384
+ this.node = node;
385
+ this.decorations = decorations;
386
+ this.innerDecorations = innerDecorations;
387
+ rerenderComponent({ node, decorations, innerDecorations });
388
+ return true;
389
+ }
390
+ /**
391
+ * Select the node.
392
+ * Add the `selected` prop and the `ProseMirror-selectednode` class.
393
+ */
394
+ selectNode() {
395
+ this.renderer.updateProps({
396
+ selected: true
397
+ });
398
+ this.renderer.element.classList.add("ProseMirror-selectednode");
399
+ }
400
+ /**
401
+ * Deselect the node.
402
+ * Remove the `selected` prop and the `ProseMirror-selectednode` class.
403
+ */
404
+ deselectNode() {
405
+ this.renderer.updateProps({
406
+ selected: false
407
+ });
408
+ this.renderer.element.classList.remove("ProseMirror-selectednode");
409
+ }
410
+ getDecorationClasses() {
411
+ return this.decorations.map((item) => item.type.attrs.class).flat().join(" ");
412
+ }
413
+ destroy() {
414
+ this.renderer.destroy();
415
+ this.editor.off("selectionUpdate", this.handleSelectionUpdate);
416
+ }
417
+ };
361
418
  function VueNodeViewRenderer(component, options) {
362
- return (props) => {
363
- // try to get the parent component
364
- // this is important for vue devtools to show the component hierarchy correctly
365
- // maybe it’s `undefined` because <editor-content> isn’t rendered yet
366
- if (!props.editor.contentComponent) {
367
- return {};
368
- }
369
- return new VueNodeView(component, props, options);
370
- };
419
+ return (props) => {
420
+ if (!props.editor.contentComponent) {
421
+ return {};
422
+ }
423
+ return new VueNodeView(component, props, options);
424
+ };
371
425
  }
372
426
 
373
- export { BubbleMenu, Editor, EditorContent, FloatingMenu, NodeViewContent, NodeViewWrapper, VueNodeViewRenderer, VueRenderer, nodeViewProps };
374
- //# sourceMappingURL=index.js.map
427
+ // src/index.ts
428
+ export * from "@tiptap/core";
429
+ export {
430
+ BubbleMenu,
431
+ Editor,
432
+ EditorContent,
433
+ FloatingMenu,
434
+ NodeViewContent,
435
+ NodeViewWrapper,
436
+ VueNodeViewRenderer,
437
+ VueRenderer,
438
+ nodeViewProps
439
+ };
440
+ //# sourceMappingURL=index.js.map