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