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