@tiptap/vue-3 2.11.6 → 3.0.0-beta.0
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 +562 -528
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +219 -0
- package/dist/index.d.ts +218 -10
- package/dist/index.js +526 -516
- package/dist/index.js.map +1 -1
- package/dist/menus/index.cjs +587 -0
- package/dist/menus/index.cjs.map +1 -0
- package/dist/menus/index.d.cts +257 -0
- package/dist/menus/index.d.ts +257 -0
- package/dist/menus/index.js +579 -0
- package/dist/menus/index.js.map +1 -0
- package/package.json +27 -16
- package/src/Editor.ts +6 -11
- package/src/EditorContent.ts +10 -20
- package/src/VueMarkViewRenderer.ts +114 -0
- package/src/VueNodeViewRenderer.ts +19 -30
- package/src/VueRenderer.ts +10 -11
- package/src/index.ts +1 -2
- package/src/menus/BubbleMenu.ts +78 -0
- package/src/menus/FloatingMenu.ts +68 -0
- package/src/menus/index.ts +2 -0
- package/src/useEditor.ts +1 -1
- package/dist/BubbleMenu.d.ts +0 -61
- package/dist/BubbleMenu.d.ts.map +0 -1
- package/dist/Editor.d.ts +0 -24
- package/dist/Editor.d.ts.map +0 -1
- package/dist/EditorContent.d.ts +0 -18
- package/dist/EditorContent.d.ts.map +0 -1
- package/dist/FloatingMenu.d.ts +0 -49
- package/dist/FloatingMenu.d.ts.map +0 -1
- package/dist/NodeViewContent.d.ts +0 -14
- package/dist/NodeViewContent.d.ts.map +0 -1
- package/dist/NodeViewWrapper.d.ts +0 -14
- package/dist/NodeViewWrapper.d.ts.map +0 -1
- package/dist/VueNodeViewRenderer.d.ts +0 -63
- package/dist/VueNodeViewRenderer.d.ts.map +0 -1
- package/dist/VueRenderer.d.ts +0 -37
- package/dist/VueRenderer.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -570
- package/dist/index.umd.js.map +0 -1
- package/dist/useEditor.d.ts +0 -4
- package/dist/useEditor.d.ts.map +0 -1
- package/src/BubbleMenu.ts +0 -71
- package/src/FloatingMenu.ts +0 -66
|
@@ -0,0 +1,587 @@
|
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/menus/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
BubbleMenu: () => BubbleMenu,
|
|
24
|
+
FloatingMenu: () => FloatingMenu2
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// ../extension-bubble-menu/src/bubble-menu-plugin.ts
|
|
29
|
+
var import_dom = require("@floating-ui/dom");
|
|
30
|
+
var import_core = require("@tiptap/core");
|
|
31
|
+
var import_state = require("@tiptap/pm/state");
|
|
32
|
+
var BubbleMenuView = class {
|
|
33
|
+
constructor({
|
|
34
|
+
editor,
|
|
35
|
+
element,
|
|
36
|
+
view,
|
|
37
|
+
updateDelay = 250,
|
|
38
|
+
resizeDelay = 60,
|
|
39
|
+
shouldShow,
|
|
40
|
+
options
|
|
41
|
+
}) {
|
|
42
|
+
this.preventHide = false;
|
|
43
|
+
this.floatingUIOptions = {
|
|
44
|
+
strategy: "absolute",
|
|
45
|
+
placement: "top",
|
|
46
|
+
offset: 8,
|
|
47
|
+
flip: {},
|
|
48
|
+
shift: {},
|
|
49
|
+
arrow: false,
|
|
50
|
+
size: false,
|
|
51
|
+
autoPlacement: false,
|
|
52
|
+
hide: false,
|
|
53
|
+
inline: false
|
|
54
|
+
};
|
|
55
|
+
this.shouldShow = ({ view, state, from, to }) => {
|
|
56
|
+
const { doc, selection } = state;
|
|
57
|
+
const { empty } = selection;
|
|
58
|
+
const isEmptyTextBlock = !doc.textBetween(from, to).length && (0, import_core.isTextSelection)(state.selection);
|
|
59
|
+
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
60
|
+
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
61
|
+
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
this.mousedownHandler = () => {
|
|
67
|
+
this.preventHide = true;
|
|
68
|
+
};
|
|
69
|
+
this.dragstartHandler = () => {
|
|
70
|
+
this.hide();
|
|
71
|
+
};
|
|
72
|
+
this.focusHandler = () => {
|
|
73
|
+
setTimeout(() => this.update(this.editor.view));
|
|
74
|
+
};
|
|
75
|
+
this.blurHandler = ({ event }) => {
|
|
76
|
+
var _a;
|
|
77
|
+
if (this.preventHide) {
|
|
78
|
+
this.preventHide = false;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.hide();
|
|
88
|
+
};
|
|
89
|
+
this.handleDebouncedUpdate = (view, oldState) => {
|
|
90
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
91
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
92
|
+
if (!selectionChanged && !docChanged) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (this.updateDebounceTimer) {
|
|
96
|
+
clearTimeout(this.updateDebounceTimer);
|
|
97
|
+
}
|
|
98
|
+
this.updateDebounceTimer = window.setTimeout(() => {
|
|
99
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
100
|
+
}, this.updateDelay);
|
|
101
|
+
};
|
|
102
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
103
|
+
const { composing } = view;
|
|
104
|
+
const isSame = !selectionChanged && !docChanged;
|
|
105
|
+
if (composing || isSame) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
109
|
+
if (!shouldShow) {
|
|
110
|
+
this.hide();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.updatePosition();
|
|
114
|
+
this.show();
|
|
115
|
+
};
|
|
116
|
+
this.editor = editor;
|
|
117
|
+
this.element = element;
|
|
118
|
+
this.view = view;
|
|
119
|
+
this.updateDelay = updateDelay;
|
|
120
|
+
this.resizeDelay = resizeDelay;
|
|
121
|
+
this.floatingUIOptions = {
|
|
122
|
+
...this.floatingUIOptions,
|
|
123
|
+
...options
|
|
124
|
+
};
|
|
125
|
+
if (shouldShow) {
|
|
126
|
+
this.shouldShow = shouldShow;
|
|
127
|
+
}
|
|
128
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
129
|
+
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
|
|
130
|
+
this.editor.on("focus", this.focusHandler);
|
|
131
|
+
this.editor.on("blur", this.blurHandler);
|
|
132
|
+
window.addEventListener("resize", () => {
|
|
133
|
+
if (this.resizeDebounceTimer) {
|
|
134
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
135
|
+
}
|
|
136
|
+
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
137
|
+
this.updatePosition();
|
|
138
|
+
}, this.resizeDelay);
|
|
139
|
+
});
|
|
140
|
+
this.update(view, view.state);
|
|
141
|
+
if (this.getShouldShow()) {
|
|
142
|
+
this.show();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
get middlewares() {
|
|
146
|
+
const middlewares = [];
|
|
147
|
+
if (this.floatingUIOptions.flip) {
|
|
148
|
+
middlewares.push((0, import_dom.flip)(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
|
|
149
|
+
}
|
|
150
|
+
if (this.floatingUIOptions.shift) {
|
|
151
|
+
middlewares.push(
|
|
152
|
+
(0, import_dom.shift)(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (this.floatingUIOptions.offset) {
|
|
156
|
+
middlewares.push(
|
|
157
|
+
(0, import_dom.offset)(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
if (this.floatingUIOptions.arrow) {
|
|
161
|
+
middlewares.push((0, import_dom.arrow)(this.floatingUIOptions.arrow));
|
|
162
|
+
}
|
|
163
|
+
if (this.floatingUIOptions.size) {
|
|
164
|
+
middlewares.push((0, import_dom.size)(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
|
|
165
|
+
}
|
|
166
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
167
|
+
middlewares.push(
|
|
168
|
+
(0, import_dom.autoPlacement)(
|
|
169
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
if (this.floatingUIOptions.hide) {
|
|
174
|
+
middlewares.push((0, import_dom.hide)(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
|
|
175
|
+
}
|
|
176
|
+
if (this.floatingUIOptions.inline) {
|
|
177
|
+
middlewares.push(
|
|
178
|
+
(0, import_dom.inline)(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return middlewares;
|
|
182
|
+
}
|
|
183
|
+
updatePosition() {
|
|
184
|
+
const { selection } = this.editor.state;
|
|
185
|
+
const virtualElement = {
|
|
186
|
+
getBoundingClientRect: () => (0, import_core.posToDOMRect)(this.view, selection.from, selection.to)
|
|
187
|
+
};
|
|
188
|
+
(0, import_dom.computePosition)(virtualElement, this.element, {
|
|
189
|
+
placement: this.floatingUIOptions.placement,
|
|
190
|
+
strategy: this.floatingUIOptions.strategy,
|
|
191
|
+
middleware: this.middlewares
|
|
192
|
+
}).then(({ x, y, strategy }) => {
|
|
193
|
+
this.element.style.width = "max-content";
|
|
194
|
+
this.element.style.position = strategy;
|
|
195
|
+
this.element.style.left = `${x}px`;
|
|
196
|
+
this.element.style.top = `${y}px`;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
update(view, oldState) {
|
|
200
|
+
const { state } = view;
|
|
201
|
+
const hasValidSelection = state.selection.from !== state.selection.to;
|
|
202
|
+
if (this.updateDelay > 0 && hasValidSelection) {
|
|
203
|
+
this.handleDebouncedUpdate(view, oldState);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
207
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
208
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
209
|
+
}
|
|
210
|
+
getShouldShow(oldState) {
|
|
211
|
+
var _a;
|
|
212
|
+
const { state } = this.view;
|
|
213
|
+
const { selection } = state;
|
|
214
|
+
const { ranges } = selection;
|
|
215
|
+
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
216
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
217
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
218
|
+
editor: this.editor,
|
|
219
|
+
element: this.element,
|
|
220
|
+
view: this.view,
|
|
221
|
+
state,
|
|
222
|
+
oldState,
|
|
223
|
+
from,
|
|
224
|
+
to
|
|
225
|
+
});
|
|
226
|
+
return shouldShow;
|
|
227
|
+
}
|
|
228
|
+
show() {
|
|
229
|
+
var _a;
|
|
230
|
+
this.element.style.visibility = "visible";
|
|
231
|
+
this.element.style.opacity = "1";
|
|
232
|
+
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
233
|
+
}
|
|
234
|
+
hide() {
|
|
235
|
+
this.element.style.visibility = "hidden";
|
|
236
|
+
this.element.style.opacity = "0";
|
|
237
|
+
this.element.remove();
|
|
238
|
+
}
|
|
239
|
+
destroy() {
|
|
240
|
+
this.hide();
|
|
241
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
242
|
+
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
|
|
243
|
+
this.editor.off("focus", this.focusHandler);
|
|
244
|
+
this.editor.off("blur", this.blurHandler);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var BubbleMenuPlugin = (options) => {
|
|
248
|
+
return new import_state.Plugin({
|
|
249
|
+
key: typeof options.pluginKey === "string" ? new import_state.PluginKey(options.pluginKey) : options.pluginKey,
|
|
250
|
+
view: (view) => new BubbleMenuView({ view, ...options })
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// src/menus/BubbleMenu.ts
|
|
255
|
+
var import_vue = require("vue");
|
|
256
|
+
var BubbleMenu = (0, import_vue.defineComponent)({
|
|
257
|
+
name: "BubbleMenu",
|
|
258
|
+
props: {
|
|
259
|
+
pluginKey: {
|
|
260
|
+
type: [String, Object],
|
|
261
|
+
default: "bubbleMenu"
|
|
262
|
+
},
|
|
263
|
+
editor: {
|
|
264
|
+
type: Object,
|
|
265
|
+
required: true
|
|
266
|
+
},
|
|
267
|
+
updateDelay: {
|
|
268
|
+
type: Number,
|
|
269
|
+
default: void 0
|
|
270
|
+
},
|
|
271
|
+
resizeDelay: {
|
|
272
|
+
type: Number,
|
|
273
|
+
default: void 0
|
|
274
|
+
},
|
|
275
|
+
options: {
|
|
276
|
+
type: Object,
|
|
277
|
+
default: () => ({})
|
|
278
|
+
},
|
|
279
|
+
shouldShow: {
|
|
280
|
+
type: Function,
|
|
281
|
+
default: null
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
setup(props, { slots }) {
|
|
285
|
+
const root = (0, import_vue.ref)(null);
|
|
286
|
+
(0, import_vue.onMounted)(() => {
|
|
287
|
+
const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props;
|
|
288
|
+
if (!root.value) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
root.value.style.visibility = "hidden";
|
|
292
|
+
root.value.style.position = "absolute";
|
|
293
|
+
root.value.remove();
|
|
294
|
+
editor.registerPlugin(
|
|
295
|
+
BubbleMenuPlugin({
|
|
296
|
+
editor,
|
|
297
|
+
element: root.value,
|
|
298
|
+
options,
|
|
299
|
+
pluginKey,
|
|
300
|
+
resizeDelay,
|
|
301
|
+
shouldShow,
|
|
302
|
+
updateDelay
|
|
303
|
+
})
|
|
304
|
+
);
|
|
305
|
+
});
|
|
306
|
+
(0, import_vue.onBeforeUnmount)(() => {
|
|
307
|
+
const { pluginKey, editor } = props;
|
|
308
|
+
editor.unregisterPlugin(pluginKey);
|
|
309
|
+
});
|
|
310
|
+
return () => {
|
|
311
|
+
var _a;
|
|
312
|
+
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)));
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// ../extension-floating-menu/dist/index.js
|
|
318
|
+
var import_core2 = require("@tiptap/core");
|
|
319
|
+
var import_dom2 = require("@floating-ui/dom");
|
|
320
|
+
var import_core3 = require("@tiptap/core");
|
|
321
|
+
var import_state2 = require("@tiptap/pm/state");
|
|
322
|
+
var FloatingMenuView = class {
|
|
323
|
+
constructor({ editor, element, view, options, shouldShow }) {
|
|
324
|
+
this.preventHide = false;
|
|
325
|
+
this.shouldShow = ({ view: view2, state }) => {
|
|
326
|
+
const { selection } = state;
|
|
327
|
+
const { $anchor, empty } = selection;
|
|
328
|
+
const isRootDepth = $anchor.depth === 1;
|
|
329
|
+
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
330
|
+
if (!view2.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
return true;
|
|
334
|
+
};
|
|
335
|
+
this.floatingUIOptions = {
|
|
336
|
+
strategy: "absolute",
|
|
337
|
+
placement: "right",
|
|
338
|
+
offset: 8,
|
|
339
|
+
flip: {},
|
|
340
|
+
shift: {},
|
|
341
|
+
arrow: false,
|
|
342
|
+
size: false,
|
|
343
|
+
autoPlacement: false,
|
|
344
|
+
hide: false,
|
|
345
|
+
inline: false
|
|
346
|
+
};
|
|
347
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
348
|
+
const { composing } = view2;
|
|
349
|
+
const isSame = !selectionChanged && !docChanged;
|
|
350
|
+
if (composing || isSame) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
354
|
+
if (!shouldShow2) {
|
|
355
|
+
this.hide();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
this.updatePosition();
|
|
359
|
+
this.show();
|
|
360
|
+
};
|
|
361
|
+
this.mousedownHandler = () => {
|
|
362
|
+
this.preventHide = true;
|
|
363
|
+
};
|
|
364
|
+
this.focusHandler = () => {
|
|
365
|
+
setTimeout(() => this.update(this.editor.view));
|
|
366
|
+
};
|
|
367
|
+
this.blurHandler = ({ event }) => {
|
|
368
|
+
var _a;
|
|
369
|
+
if (this.preventHide) {
|
|
370
|
+
this.preventHide = false;
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
this.hide();
|
|
380
|
+
};
|
|
381
|
+
this.editor = editor;
|
|
382
|
+
this.element = element;
|
|
383
|
+
this.view = view;
|
|
384
|
+
this.floatingUIOptions = {
|
|
385
|
+
...this.floatingUIOptions,
|
|
386
|
+
...options
|
|
387
|
+
};
|
|
388
|
+
if (shouldShow) {
|
|
389
|
+
this.shouldShow = shouldShow;
|
|
390
|
+
}
|
|
391
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
392
|
+
this.editor.on("focus", this.focusHandler);
|
|
393
|
+
this.editor.on("blur", this.blurHandler);
|
|
394
|
+
this.update(view, view.state);
|
|
395
|
+
if (this.getShouldShow()) {
|
|
396
|
+
this.show();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
getTextContent(node) {
|
|
400
|
+
return (0, import_core3.getText)(node, { textSerializers: (0, import_core3.getTextSerializersFromSchema)(this.editor.schema) });
|
|
401
|
+
}
|
|
402
|
+
get middlewares() {
|
|
403
|
+
const middlewares = [];
|
|
404
|
+
if (this.floatingUIOptions.flip) {
|
|
405
|
+
middlewares.push((0, import_dom2.flip)(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
|
|
406
|
+
}
|
|
407
|
+
if (this.floatingUIOptions.shift) {
|
|
408
|
+
middlewares.push(
|
|
409
|
+
(0, import_dom2.shift)(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
if (this.floatingUIOptions.offset) {
|
|
413
|
+
middlewares.push(
|
|
414
|
+
(0, import_dom2.offset)(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
if (this.floatingUIOptions.arrow) {
|
|
418
|
+
middlewares.push((0, import_dom2.arrow)(this.floatingUIOptions.arrow));
|
|
419
|
+
}
|
|
420
|
+
if (this.floatingUIOptions.size) {
|
|
421
|
+
middlewares.push((0, import_dom2.size)(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
|
|
422
|
+
}
|
|
423
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
424
|
+
middlewares.push(
|
|
425
|
+
(0, import_dom2.autoPlacement)(
|
|
426
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
427
|
+
)
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
if (this.floatingUIOptions.hide) {
|
|
431
|
+
middlewares.push((0, import_dom2.hide)(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
|
|
432
|
+
}
|
|
433
|
+
if (this.floatingUIOptions.inline) {
|
|
434
|
+
middlewares.push(
|
|
435
|
+
(0, import_dom2.inline)(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
return middlewares;
|
|
439
|
+
}
|
|
440
|
+
getShouldShow(oldState) {
|
|
441
|
+
var _a;
|
|
442
|
+
const { state } = this.view;
|
|
443
|
+
const { selection } = state;
|
|
444
|
+
const { ranges } = selection;
|
|
445
|
+
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
446
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
447
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
448
|
+
editor: this.editor,
|
|
449
|
+
view: this.view,
|
|
450
|
+
state,
|
|
451
|
+
oldState,
|
|
452
|
+
from,
|
|
453
|
+
to
|
|
454
|
+
});
|
|
455
|
+
return shouldShow;
|
|
456
|
+
}
|
|
457
|
+
updatePosition() {
|
|
458
|
+
const { selection } = this.editor.state;
|
|
459
|
+
const virtualElement = {
|
|
460
|
+
getBoundingClientRect: () => (0, import_core3.posToDOMRect)(this.view, selection.from, selection.to)
|
|
461
|
+
};
|
|
462
|
+
(0, import_dom2.computePosition)(virtualElement, this.element, {
|
|
463
|
+
placement: this.floatingUIOptions.placement,
|
|
464
|
+
strategy: this.floatingUIOptions.strategy,
|
|
465
|
+
middleware: this.middlewares
|
|
466
|
+
}).then(({ x, y, strategy }) => {
|
|
467
|
+
this.element.style.width = "max-content";
|
|
468
|
+
this.element.style.position = strategy;
|
|
469
|
+
this.element.style.left = `${x}px`;
|
|
470
|
+
this.element.style.top = `${y}px`;
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
update(view, oldState) {
|
|
474
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
475
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
476
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
477
|
+
}
|
|
478
|
+
show() {
|
|
479
|
+
var _a;
|
|
480
|
+
this.element.style.visibility = "visible";
|
|
481
|
+
this.element.style.opacity = "1";
|
|
482
|
+
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
483
|
+
}
|
|
484
|
+
hide() {
|
|
485
|
+
this.element.style.visibility = "hidden";
|
|
486
|
+
this.element.style.opacity = "0";
|
|
487
|
+
this.element.remove();
|
|
488
|
+
}
|
|
489
|
+
destroy() {
|
|
490
|
+
this.hide();
|
|
491
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
492
|
+
this.editor.off("focus", this.focusHandler);
|
|
493
|
+
this.editor.off("blur", this.blurHandler);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
var FloatingMenuPlugin = (options) => {
|
|
497
|
+
return new import_state2.Plugin({
|
|
498
|
+
key: typeof options.pluginKey === "string" ? new import_state2.PluginKey(options.pluginKey) : options.pluginKey,
|
|
499
|
+
view: (view) => new FloatingMenuView({ view, ...options })
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
var FloatingMenu = import_core2.Extension.create({
|
|
503
|
+
name: "floatingMenu",
|
|
504
|
+
addOptions() {
|
|
505
|
+
return {
|
|
506
|
+
element: null,
|
|
507
|
+
options: {},
|
|
508
|
+
pluginKey: "floatingMenu",
|
|
509
|
+
shouldShow: null
|
|
510
|
+
};
|
|
511
|
+
},
|
|
512
|
+
addProseMirrorPlugins() {
|
|
513
|
+
if (!this.options.element) {
|
|
514
|
+
return [];
|
|
515
|
+
}
|
|
516
|
+
return [
|
|
517
|
+
FloatingMenuPlugin({
|
|
518
|
+
pluginKey: this.options.pluginKey,
|
|
519
|
+
editor: this.editor,
|
|
520
|
+
element: this.options.element,
|
|
521
|
+
options: this.options.options,
|
|
522
|
+
shouldShow: this.options.shouldShow
|
|
523
|
+
})
|
|
524
|
+
];
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// src/menus/FloatingMenu.ts
|
|
529
|
+
var import_vue2 = require("vue");
|
|
530
|
+
var FloatingMenu2 = (0, import_vue2.defineComponent)({
|
|
531
|
+
name: "FloatingMenu",
|
|
532
|
+
props: {
|
|
533
|
+
pluginKey: {
|
|
534
|
+
// TODO: TypeScript breaks :(
|
|
535
|
+
// type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
|
|
536
|
+
type: null,
|
|
537
|
+
default: "floatingMenu"
|
|
538
|
+
},
|
|
539
|
+
editor: {
|
|
540
|
+
type: Object,
|
|
541
|
+
required: true
|
|
542
|
+
},
|
|
543
|
+
options: {
|
|
544
|
+
type: Object,
|
|
545
|
+
default: () => ({})
|
|
546
|
+
},
|
|
547
|
+
shouldShow: {
|
|
548
|
+
type: Function,
|
|
549
|
+
default: null
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
setup(props, { slots }) {
|
|
553
|
+
const root = (0, import_vue2.ref)(null);
|
|
554
|
+
(0, import_vue2.onMounted)(() => {
|
|
555
|
+
const { pluginKey, editor, options, shouldShow } = props;
|
|
556
|
+
if (!root.value) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
root.value.style.visibility = "hidden";
|
|
560
|
+
root.value.style.position = "absolute";
|
|
561
|
+
root.value.remove();
|
|
562
|
+
editor.registerPlugin(
|
|
563
|
+
FloatingMenuPlugin({
|
|
564
|
+
pluginKey,
|
|
565
|
+
editor,
|
|
566
|
+
element: root.value,
|
|
567
|
+
options,
|
|
568
|
+
shouldShow
|
|
569
|
+
})
|
|
570
|
+
);
|
|
571
|
+
});
|
|
572
|
+
(0, import_vue2.onBeforeUnmount)(() => {
|
|
573
|
+
const { pluginKey, editor } = props;
|
|
574
|
+
editor.unregisterPlugin(pluginKey);
|
|
575
|
+
});
|
|
576
|
+
return () => {
|
|
577
|
+
var _a;
|
|
578
|
+
return (0, import_vue2.h)(import_vue2.Teleport, { to: "body" }, (0, import_vue2.h)("div", { ref: root }, (_a = slots.default) == null ? void 0 : _a.call(slots)));
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
583
|
+
0 && (module.exports = {
|
|
584
|
+
BubbleMenu,
|
|
585
|
+
FloatingMenu
|
|
586
|
+
});
|
|
587
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/menus/index.ts","../../../extension-bubble-menu/src/bubble-menu-plugin.ts","../../src/menus/BubbleMenu.ts","../../../extension-floating-menu/src/floating-menu.ts","../../../extension-floating-menu/src/floating-menu-plugin.ts","../../../extension-floating-menu/src/index.ts","../../src/menus/FloatingMenu.ts"],"sourcesContent":["export * from './BubbleMenu.js'\nexport * from './FloatingMenu.js'\n","import {\n type Middleware,\n arrow,\n autoPlacement,\n computePosition,\n flip,\n hide,\n inline,\n offset,\n shift,\n size,\n} from '@floating-ui/dom'\nimport type { Editor } from '@tiptap/core'\nimport { isTextSelection, posToDOMRect } from '@tiptap/core'\nimport type { EditorState, PluginView } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport type { EditorView } from '@tiptap/pm/view'\n\nexport interface BubbleMenuPluginProps {\n /**\n * The plugin key.\n * @type {PluginKey | string}\n * @default 'bubbleMenu'\n */\n pluginKey: PluginKey | string\n\n /**\n * The editor instance.\n */\n editor: Editor\n\n /**\n * The DOM element that contains your menu.\n * @type {HTMLElement}\n * @default null\n */\n element: HTMLElement\n\n /**\n * The delay in milliseconds before the menu should be updated.\n * This can be useful to prevent performance issues.\n * @type {number}\n * @default 250\n */\n updateDelay?: number\n\n /**\n * The delay in milliseconds before the menu position should be updated on window resize.\n * This can be useful to prevent performance issues.\n * @type {number}\n * @default 60\n */\n resizeDelay?: number\n\n /**\n * A function that determines whether the menu should be shown or not.\n * If this function returns `false`, the menu will be hidden, otherwise it will be shown.\n */\n shouldShow:\n | ((props: {\n editor: Editor\n element: HTMLElement\n view: EditorView\n state: EditorState\n oldState?: EditorState\n from: number\n to: number\n }) => boolean)\n | null\n\n /**\n * FloatingUI options.\n */\n options?: {\n strategy?: 'absolute' | 'fixed'\n placement?:\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top-start'\n | 'top-end'\n | 'right-start'\n | 'right-end'\n | 'bottom-start'\n | 'bottom-end'\n | 'left-start'\n | 'left-end'\n offset?: Parameters<typeof offset>[0] | boolean\n flip?: Parameters<typeof flip>[0] | boolean\n shift?: Parameters<typeof shift>[0] | boolean\n arrow?: Parameters<typeof arrow>[0] | false\n size?: Parameters<typeof size>[0] | boolean\n autoPlacement?: Parameters<typeof autoPlacement>[0] | boolean\n hide?: Parameters<typeof hide>[0] | boolean\n inline?: Parameters<typeof inline>[0] | boolean\n }\n}\n\nexport type BubbleMenuViewProps = BubbleMenuPluginProps & {\n view: EditorView\n}\n\nexport class BubbleMenuView implements PluginView {\n public editor: Editor\n\n public element: HTMLElement\n\n public view: EditorView\n\n public preventHide = false\n\n public updateDelay: number\n\n public resizeDelay: number\n\n private updateDebounceTimer: number | undefined\n\n private resizeDebounceTimer: number | undefined\n\n private floatingUIOptions: NonNullable<BubbleMenuPluginProps['options']> = {\n strategy: 'absolute',\n placement: 'top',\n offset: 8,\n flip: {},\n shift: {},\n arrow: false,\n size: false,\n autoPlacement: false,\n hide: false,\n inline: false,\n }\n\n public shouldShow: Exclude<BubbleMenuPluginProps['shouldShow'], null> = ({ view, state, from, to }) => {\n const { doc, selection } = state\n const { empty } = selection\n\n // Sometime check for `empty` is not enough.\n // Doubleclick an empty paragraph returns a node size of 2.\n // So we check also for an empty text size.\n const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection)\n\n // When clicking on a element inside the bubble menu the editor \"blur\" event\n // is called and the bubble menu item is focussed. In this case we should\n // consider the menu as part of the editor and keep showing the menu\n const isChildOfMenu = this.element.contains(document.activeElement)\n\n const hasEditorFocus = view.hasFocus() || isChildOfMenu\n\n if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {\n return false\n }\n\n return true\n }\n\n get middlewares() {\n const middlewares: Middleware[] = []\n\n if (this.floatingUIOptions.flip) {\n middlewares.push(flip(typeof this.floatingUIOptions.flip !== 'boolean' ? this.floatingUIOptions.flip : undefined))\n }\n\n if (this.floatingUIOptions.shift) {\n middlewares.push(\n shift(typeof this.floatingUIOptions.shift !== 'boolean' ? this.floatingUIOptions.shift : undefined),\n )\n }\n\n if (this.floatingUIOptions.offset) {\n middlewares.push(\n offset(typeof this.floatingUIOptions.offset !== 'boolean' ? this.floatingUIOptions.offset : undefined),\n )\n }\n\n if (this.floatingUIOptions.arrow) {\n middlewares.push(arrow(this.floatingUIOptions.arrow))\n }\n\n if (this.floatingUIOptions.size) {\n middlewares.push(size(typeof this.floatingUIOptions.size !== 'boolean' ? this.floatingUIOptions.size : undefined))\n }\n\n if (this.floatingUIOptions.autoPlacement) {\n middlewares.push(\n autoPlacement(\n typeof this.floatingUIOptions.autoPlacement !== 'boolean' ? this.floatingUIOptions.autoPlacement : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.hide) {\n middlewares.push(hide(typeof this.floatingUIOptions.hide !== 'boolean' ? this.floatingUIOptions.hide : undefined))\n }\n\n if (this.floatingUIOptions.inline) {\n middlewares.push(\n inline(typeof this.floatingUIOptions.inline !== 'boolean' ? this.floatingUIOptions.inline : undefined),\n )\n }\n\n return middlewares\n }\n\n constructor({\n editor,\n element,\n view,\n updateDelay = 250,\n resizeDelay = 60,\n shouldShow,\n options,\n }: BubbleMenuViewProps) {\n this.editor = editor\n this.element = element\n this.view = view\n this.updateDelay = updateDelay\n this.resizeDelay = resizeDelay\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n if (shouldShow) {\n this.shouldShow = shouldShow\n }\n\n this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })\n this.view.dom.addEventListener('dragstart', this.dragstartHandler)\n this.editor.on('focus', this.focusHandler)\n this.editor.on('blur', this.blurHandler)\n window.addEventListener('resize', () => {\n if (this.resizeDebounceTimer) {\n clearTimeout(this.resizeDebounceTimer)\n }\n\n this.resizeDebounceTimer = window.setTimeout(() => {\n this.updatePosition()\n }, this.resizeDelay)\n })\n\n this.update(view, view.state)\n\n if (this.getShouldShow()) {\n this.show()\n }\n }\n\n mousedownHandler = () => {\n this.preventHide = true\n }\n\n dragstartHandler = () => {\n this.hide()\n }\n\n focusHandler = () => {\n // we use `setTimeout` to make sure `selection` is already updated\n setTimeout(() => this.update(this.editor.view))\n }\n\n blurHandler = ({ event }: { event: FocusEvent }) => {\n if (this.preventHide) {\n this.preventHide = false\n\n return\n }\n\n if (event?.relatedTarget && this.element.parentNode?.contains(event.relatedTarget as Node)) {\n return\n }\n\n if (event?.relatedTarget === this.editor.view.dom) {\n return\n }\n\n this.hide()\n }\n\n updatePosition() {\n const { selection } = this.editor.state\n\n const virtualElement = {\n getBoundingClientRect: () => posToDOMRect(this.view, selection.from, selection.to),\n }\n\n computePosition(virtualElement, this.element, {\n placement: this.floatingUIOptions.placement,\n strategy: this.floatingUIOptions.strategy,\n middleware: this.middlewares,\n }).then(({ x, y, strategy }) => {\n this.element.style.width = 'max-content'\n this.element.style.position = strategy\n this.element.style.left = `${x}px`\n this.element.style.top = `${y}px`\n })\n }\n\n update(view: EditorView, oldState?: EditorState) {\n const { state } = view\n const hasValidSelection = state.selection.from !== state.selection.to\n\n if (this.updateDelay > 0 && hasValidSelection) {\n this.handleDebouncedUpdate(view, oldState)\n return\n }\n\n const selectionChanged = !oldState?.selection.eq(view.state.selection)\n const docChanged = !oldState?.doc.eq(view.state.doc)\n\n this.updateHandler(view, selectionChanged, docChanged, oldState)\n }\n\n handleDebouncedUpdate = (view: EditorView, oldState?: EditorState) => {\n const selectionChanged = !oldState?.selection.eq(view.state.selection)\n const docChanged = !oldState?.doc.eq(view.state.doc)\n\n if (!selectionChanged && !docChanged) {\n return\n }\n\n if (this.updateDebounceTimer) {\n clearTimeout(this.updateDebounceTimer)\n }\n\n this.updateDebounceTimer = window.setTimeout(() => {\n this.updateHandler(view, selectionChanged, docChanged, oldState)\n }, this.updateDelay)\n }\n\n getShouldShow(oldState?: EditorState) {\n const { state } = this.view\n const { selection } = state\n\n // support for CellSelections\n const { ranges } = selection\n const from = Math.min(...ranges.map(range => range.$from.pos))\n const to = Math.max(...ranges.map(range => range.$to.pos))\n\n const shouldShow = this.shouldShow?.({\n editor: this.editor,\n element: this.element,\n view: this.view,\n state,\n oldState,\n from,\n to,\n })\n\n return shouldShow\n }\n\n updateHandler = (view: EditorView, selectionChanged: boolean, docChanged: boolean, oldState?: EditorState) => {\n const { composing } = view\n\n const isSame = !selectionChanged && !docChanged\n\n if (composing || isSame) {\n return\n }\n\n const shouldShow = this.getShouldShow(oldState)\n\n if (!shouldShow) {\n this.hide()\n\n return\n }\n\n this.updatePosition()\n this.show()\n }\n\n show() {\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n // attach to editor's parent element\n this.view.dom.parentElement?.appendChild(this.element)\n }\n\n hide() {\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n }\n\n destroy() {\n this.hide()\n this.element.removeEventListener('mousedown', this.mousedownHandler, { capture: true })\n this.view.dom.removeEventListener('dragstart', this.dragstartHandler)\n this.editor.off('focus', this.focusHandler)\n this.editor.off('blur', this.blurHandler)\n }\n}\n\nexport const BubbleMenuPlugin = (options: BubbleMenuPluginProps) => {\n return new Plugin({\n key: typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey,\n view: view => new BubbleMenuView({ view, ...options }),\n })\n}\n","import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu'\nimport type { PropType } from 'vue'\nimport { defineComponent, h, onBeforeUnmount, onMounted, ref, Teleport } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n props: {\n pluginKey: {\n type: [String, Object] as PropType<BubbleMenuPluginProps['pluginKey']>,\n default: 'bubbleMenu',\n },\n\n editor: {\n type: Object as PropType<BubbleMenuPluginProps['editor']>,\n required: true,\n },\n\n updateDelay: {\n type: Number as PropType<BubbleMenuPluginProps['updateDelay']>,\n default: undefined,\n },\n\n resizeDelay: {\n type: Number as PropType<BubbleMenuPluginProps['resizeDelay']>,\n default: undefined,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: root.value as HTMLElement,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","import { Extension } from '@tiptap/core'\n\nimport type { FloatingMenuPluginProps } from './floating-menu-plugin.js'\nimport { FloatingMenuPlugin } from './floating-menu-plugin.js'\n\nexport type FloatingMenuOptions = Omit<FloatingMenuPluginProps, 'editor' | 'element'> & {\n /**\n * The DOM element that contains your menu.\n * @type {HTMLElement}\n * @default null\n */\n element: HTMLElement | null\n}\n\n/**\n * This extension allows you to create a floating menu.\n * @see https://tiptap.dev/api/extensions/floating-menu\n */\nexport const FloatingMenu = Extension.create<FloatingMenuOptions>({\n name: 'floatingMenu',\n\n addOptions() {\n return {\n element: null,\n options: {},\n pluginKey: 'floatingMenu',\n shouldShow: null,\n }\n },\n\n addProseMirrorPlugins() {\n if (!this.options.element) {\n return []\n }\n\n return [\n FloatingMenuPlugin({\n pluginKey: this.options.pluginKey,\n editor: this.editor,\n element: this.options.element,\n options: this.options.options,\n shouldShow: this.options.shouldShow,\n }),\n ]\n },\n})\n","import {\n type Middleware,\n arrow,\n autoPlacement,\n computePosition,\n flip,\n hide,\n inline,\n offset,\n shift,\n size,\n} from '@floating-ui/dom'\nimport type { Editor } from '@tiptap/core'\nimport { getText, getTextSerializersFromSchema, posToDOMRect } from '@tiptap/core'\nimport type { Node as ProsemirrorNode } from '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport type { EditorView } from '@tiptap/pm/view'\n\nexport interface FloatingMenuPluginProps {\n /**\n * The plugin key for the floating menu.\n * @default 'floatingMenu'\n */\n pluginKey: PluginKey | string\n\n /**\n * The editor instance.\n * @default null\n */\n editor: Editor\n\n /**\n * The DOM element that contains your menu.\n * @default null\n */\n element: HTMLElement\n\n /**\n * A function that determines whether the menu should be shown or not.\n * If this function returns `false`, the menu will be hidden, otherwise it will be shown.\n */\n shouldShow:\n | ((props: {\n editor: Editor\n view: EditorView\n state: EditorState\n oldState?: EditorState\n from: number\n to: number\n }) => boolean)\n | null\n\n /**\n * FloatingUI options.\n */\n options?: {\n strategy?: 'absolute' | 'fixed'\n placement?:\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top-start'\n | 'top-end'\n | 'right-start'\n | 'right-end'\n | 'bottom-start'\n | 'bottom-end'\n | 'left-start'\n | 'left-end'\n offset?: Parameters<typeof offset>[0] | boolean\n flip?: Parameters<typeof flip>[0] | boolean\n shift?: Parameters<typeof shift>[0] | boolean\n arrow?: Parameters<typeof arrow>[0] | false\n size?: Parameters<typeof size>[0] | boolean\n autoPlacement?: Parameters<typeof autoPlacement>[0] | boolean\n hide?: Parameters<typeof hide>[0] | boolean\n inline?: Parameters<typeof inline>[0] | boolean\n }\n}\n\nexport type FloatingMenuViewProps = FloatingMenuPluginProps & {\n /**\n * The editor view.\n */\n view: EditorView\n}\n\nexport class FloatingMenuView {\n public editor: Editor\n\n public element: HTMLElement\n\n public view: EditorView\n\n public preventHide = false\n\n private getTextContent(node: ProsemirrorNode) {\n return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) })\n }\n\n public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ view, state }) => {\n const { selection } = state\n const { $anchor, empty } = selection\n const isRootDepth = $anchor.depth === 1\n\n const isEmptyTextBlock =\n $anchor.parent.isTextblock &&\n !$anchor.parent.type.spec.code &&\n !$anchor.parent.textContent &&\n $anchor.parent.childCount === 0 &&\n !this.getTextContent($anchor.parent)\n\n if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {\n return false\n }\n\n return true\n }\n\n private floatingUIOptions: NonNullable<FloatingMenuPluginProps['options']> = {\n strategy: 'absolute',\n placement: 'right',\n offset: 8,\n flip: {},\n shift: {},\n arrow: false,\n size: false,\n autoPlacement: false,\n hide: false,\n inline: false,\n }\n\n get middlewares() {\n const middlewares: Middleware[] = []\n\n if (this.floatingUIOptions.flip) {\n middlewares.push(flip(typeof this.floatingUIOptions.flip !== 'boolean' ? this.floatingUIOptions.flip : undefined))\n }\n\n if (this.floatingUIOptions.shift) {\n middlewares.push(\n shift(typeof this.floatingUIOptions.shift !== 'boolean' ? this.floatingUIOptions.shift : undefined),\n )\n }\n\n if (this.floatingUIOptions.offset) {\n middlewares.push(\n offset(typeof this.floatingUIOptions.offset !== 'boolean' ? this.floatingUIOptions.offset : undefined),\n )\n }\n\n if (this.floatingUIOptions.arrow) {\n middlewares.push(arrow(this.floatingUIOptions.arrow))\n }\n\n if (this.floatingUIOptions.size) {\n middlewares.push(size(typeof this.floatingUIOptions.size !== 'boolean' ? this.floatingUIOptions.size : undefined))\n }\n\n if (this.floatingUIOptions.autoPlacement) {\n middlewares.push(\n autoPlacement(\n typeof this.floatingUIOptions.autoPlacement !== 'boolean' ? this.floatingUIOptions.autoPlacement : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.hide) {\n middlewares.push(hide(typeof this.floatingUIOptions.hide !== 'boolean' ? this.floatingUIOptions.hide : undefined))\n }\n\n if (this.floatingUIOptions.inline) {\n middlewares.push(\n inline(typeof this.floatingUIOptions.inline !== 'boolean' ? this.floatingUIOptions.inline : undefined),\n )\n }\n\n return middlewares\n }\n\n constructor({ editor, element, view, options, shouldShow }: FloatingMenuViewProps) {\n this.editor = editor\n this.element = element\n this.view = view\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n if (shouldShow) {\n this.shouldShow = shouldShow\n }\n\n this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true })\n this.editor.on('focus', this.focusHandler)\n this.editor.on('blur', this.blurHandler)\n\n this.update(view, view.state)\n\n if (this.getShouldShow()) {\n this.show()\n }\n }\n\n getShouldShow(oldState?: EditorState) {\n const { state } = this.view\n const { selection } = state\n\n const { ranges } = selection\n const from = Math.min(...ranges.map(range => range.$from.pos))\n const to = Math.max(...ranges.map(range => range.$to.pos))\n\n const shouldShow = this.shouldShow?.({\n editor: this.editor,\n view: this.view,\n state,\n oldState,\n from,\n to,\n })\n\n return shouldShow\n }\n\n updateHandler = (view: EditorView, selectionChanged: boolean, docChanged: boolean, oldState?: EditorState) => {\n const { composing } = view\n\n const isSame = !selectionChanged && !docChanged\n\n if (composing || isSame) {\n return\n }\n\n const shouldShow = this.getShouldShow(oldState)\n\n if (!shouldShow) {\n this.hide()\n\n return\n }\n\n this.updatePosition()\n this.show()\n }\n\n mousedownHandler = () => {\n this.preventHide = true\n }\n\n focusHandler = () => {\n // we use `setTimeout` to make sure `selection` is already updated\n setTimeout(() => this.update(this.editor.view))\n }\n\n blurHandler = ({ event }: { event: FocusEvent }) => {\n if (this.preventHide) {\n this.preventHide = false\n\n return\n }\n\n if (event?.relatedTarget && this.element.parentNode?.contains(event.relatedTarget as Node)) {\n return\n }\n\n if (event?.relatedTarget === this.editor.view.dom) {\n return\n }\n\n this.hide()\n }\n\n updatePosition() {\n const { selection } = this.editor.state\n\n const virtualElement = {\n getBoundingClientRect: () => posToDOMRect(this.view, selection.from, selection.to),\n }\n\n computePosition(virtualElement, this.element, {\n placement: this.floatingUIOptions.placement,\n strategy: this.floatingUIOptions.strategy,\n middleware: this.middlewares,\n }).then(({ x, y, strategy }) => {\n this.element.style.width = 'max-content'\n this.element.style.position = strategy\n this.element.style.left = `${x}px`\n this.element.style.top = `${y}px`\n })\n }\n\n update(view: EditorView, oldState?: EditorState) {\n const selectionChanged = !oldState?.selection.eq(view.state.selection)\n const docChanged = !oldState?.doc.eq(view.state.doc)\n\n this.updateHandler(view, selectionChanged, docChanged, oldState)\n }\n\n show() {\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n // attach to editor's parent element\n this.view.dom.parentElement?.appendChild(this.element)\n }\n\n hide() {\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n }\n\n destroy() {\n this.hide()\n this.element.removeEventListener('mousedown', this.mousedownHandler, { capture: true })\n this.editor.off('focus', this.focusHandler)\n this.editor.off('blur', this.blurHandler)\n }\n}\n\nexport const FloatingMenuPlugin = (options: FloatingMenuPluginProps) => {\n return new Plugin({\n key: typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey,\n view: view => new FloatingMenuView({ view, ...options }),\n })\n}\n","import { FloatingMenu } from './floating-menu.js'\n\nexport * from './floating-menu.js'\nexport * from './floating-menu-plugin.js'\n\nexport default FloatingMenu\n","import type { FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport { FloatingMenuPlugin } from '@tiptap/extension-floating-menu'\nimport type { PropType } from 'vue'\nimport { defineComponent, h, onBeforeUnmount, onMounted, ref, Teleport } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n props: {\n pluginKey: {\n // TODO: TypeScript breaks :(\n // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],\n type: null,\n default: 'floatingMenu',\n },\n\n editor: {\n type: Object as PropType<FloatingMenuPluginProps['editor']>,\n required: true,\n },\n\n options: {\n type: Object as PropType<FloatingMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, shouldShow } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: root.value as HTMLElement,\n options,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,sBAAAA;AAAA;AAAA;;;ACAA,iBAWO;AAEP,kBAA8C;AAE9C,mBAAkC;AAwF3B,IAAM,iBAAN,MAA2C;AAAA,EAqGhD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,GAAwB;AAtGxB,SAAO,cAAc;AAUrB,SAAQ,oBAAmE;AAAA,MACzE,UAAU;AAAA,MACV,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,MAAM,CAAC;AAAA,MACP,OAAO,CAAC;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,MACN,eAAe;AAAA,MACf,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAEA,SAAO,aAAiE,CAAC,EAAE,MAAM,OAAO,MAAM,GAAG,MAAM;AACrG,YA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