@tiptap/vue-3 3.10.7 → 3.10.8
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/menus/index.cjs +35 -88
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +13 -13
- package/dist/menus/index.d.ts +13 -13
- package/dist/menus/index.js +29 -82
- package/dist/menus/index.js.map +1 -1
- package/package.json +7 -7
package/dist/menus/index.cjs
CHANGED
|
@@ -20,15 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/menus/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
BubbleMenu: () =>
|
|
24
|
-
FloatingMenu: () =>
|
|
23
|
+
BubbleMenu: () => BubbleMenu,
|
|
24
|
+
FloatingMenu: () => FloatingMenu
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
|
-
// ../extension-bubble-menu/
|
|
29
|
-
var import_core = require("@tiptap/core");
|
|
28
|
+
// ../extension-bubble-menu/src/bubble-menu-plugin.ts
|
|
30
29
|
var import_dom = require("@floating-ui/dom");
|
|
31
|
-
var
|
|
30
|
+
var import_core = require("@tiptap/core");
|
|
32
31
|
var import_state = require("@tiptap/pm/state");
|
|
33
32
|
var import_tables = require("@tiptap/pm/tables");
|
|
34
33
|
function combineDOMRects(rect1, rect2) {
|
|
@@ -73,12 +72,12 @@ var BubbleMenuView = class {
|
|
|
73
72
|
onUpdate: void 0,
|
|
74
73
|
onDestroy: void 0
|
|
75
74
|
};
|
|
76
|
-
this.shouldShow = ({ view
|
|
75
|
+
this.shouldShow = ({ view, state, from, to }) => {
|
|
77
76
|
const { doc, selection } = state;
|
|
78
77
|
const { empty } = selection;
|
|
79
|
-
const isEmptyTextBlock = !doc.textBetween(from, to).length && (0,
|
|
78
|
+
const isEmptyTextBlock = !doc.textBetween(from, to).length && (0, import_core.isTextSelection)(state.selection);
|
|
80
79
|
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
81
|
-
const hasEditorFocus =
|
|
80
|
+
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
82
81
|
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
83
82
|
return false;
|
|
84
83
|
}
|
|
@@ -90,6 +89,11 @@ var BubbleMenuView = class {
|
|
|
90
89
|
this.dragstartHandler = () => {
|
|
91
90
|
this.hide();
|
|
92
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Handles the window resize event to update the position of the bubble menu.
|
|
94
|
+
* It uses a debounce mechanism to prevent excessive updates.
|
|
95
|
+
* The delay is defined by the `resizeDelay` property.
|
|
96
|
+
*/
|
|
93
97
|
this.resizeHandler = () => {
|
|
94
98
|
if (this.resizeDebounceTimer) {
|
|
95
99
|
clearTimeout(this.resizeDebounceTimer);
|
|
@@ -102,7 +106,7 @@ var BubbleMenuView = class {
|
|
|
102
106
|
setTimeout(() => this.update(this.editor.view));
|
|
103
107
|
};
|
|
104
108
|
this.blurHandler = ({ event }) => {
|
|
105
|
-
var
|
|
109
|
+
var _a;
|
|
106
110
|
if (this.editor.isDestroyed) {
|
|
107
111
|
this.destroy();
|
|
108
112
|
return;
|
|
@@ -111,7 +115,7 @@ var BubbleMenuView = class {
|
|
|
111
115
|
this.preventHide = false;
|
|
112
116
|
return;
|
|
113
117
|
}
|
|
114
|
-
if ((event == null ? void 0 : event.relatedTarget) && ((
|
|
118
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
115
119
|
return;
|
|
116
120
|
}
|
|
117
121
|
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
@@ -119,9 +123,9 @@ var BubbleMenuView = class {
|
|
|
119
123
|
}
|
|
120
124
|
this.hide();
|
|
121
125
|
};
|
|
122
|
-
this.handleDebouncedUpdate = (
|
|
123
|
-
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(
|
|
124
|
-
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(
|
|
126
|
+
this.handleDebouncedUpdate = (view, oldState) => {
|
|
127
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
128
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
125
129
|
if (!selectionChanged && !docChanged) {
|
|
126
130
|
return;
|
|
127
131
|
}
|
|
@@ -129,17 +133,17 @@ var BubbleMenuView = class {
|
|
|
129
133
|
clearTimeout(this.updateDebounceTimer);
|
|
130
134
|
}
|
|
131
135
|
this.updateDebounceTimer = window.setTimeout(() => {
|
|
132
|
-
this.updateHandler(
|
|
136
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
133
137
|
}, this.updateDelay);
|
|
134
138
|
};
|
|
135
|
-
this.updateHandler = (
|
|
136
|
-
const { composing } =
|
|
139
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
140
|
+
const { composing } = view;
|
|
137
141
|
const isSame = !selectionChanged && !docChanged;
|
|
138
142
|
if (composing || isSame) {
|
|
139
143
|
return;
|
|
140
144
|
}
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
145
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
146
|
+
if (!shouldShow) {
|
|
143
147
|
this.hide();
|
|
144
148
|
return;
|
|
145
149
|
}
|
|
@@ -227,7 +231,7 @@ var BubbleMenuView = class {
|
|
|
227
231
|
if (referencedVirtualElement) {
|
|
228
232
|
return referencedVirtualElement;
|
|
229
233
|
}
|
|
230
|
-
const domRect = (0,
|
|
234
|
+
const domRect = (0, import_core.posToDOMRect)(this.view, selection.from, selection.to);
|
|
231
235
|
let virtualElement = {
|
|
232
236
|
getBoundingClientRect: () => domRect,
|
|
233
237
|
getClientRects: () => [domRect]
|
|
@@ -359,39 +363,10 @@ var BubbleMenuPlugin = (options) => {
|
|
|
359
363
|
view: (view) => new BubbleMenuView({ view, ...options })
|
|
360
364
|
});
|
|
361
365
|
};
|
|
362
|
-
var BubbleMenu = import_core.Extension.create({
|
|
363
|
-
name: "bubbleMenu",
|
|
364
|
-
addOptions() {
|
|
365
|
-
return {
|
|
366
|
-
element: null,
|
|
367
|
-
pluginKey: "bubbleMenu",
|
|
368
|
-
updateDelay: void 0,
|
|
369
|
-
appendTo: void 0,
|
|
370
|
-
shouldShow: null
|
|
371
|
-
};
|
|
372
|
-
},
|
|
373
|
-
addProseMirrorPlugins() {
|
|
374
|
-
if (!this.options.element) {
|
|
375
|
-
return [];
|
|
376
|
-
}
|
|
377
|
-
return [
|
|
378
|
-
BubbleMenuPlugin({
|
|
379
|
-
pluginKey: this.options.pluginKey,
|
|
380
|
-
editor: this.editor,
|
|
381
|
-
element: this.options.element,
|
|
382
|
-
updateDelay: this.options.updateDelay,
|
|
383
|
-
options: this.options.options,
|
|
384
|
-
appendTo: this.options.appendTo,
|
|
385
|
-
getReferencedVirtualElement: this.options.getReferencedVirtualElement,
|
|
386
|
-
shouldShow: this.options.shouldShow
|
|
387
|
-
})
|
|
388
|
-
];
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
366
|
|
|
392
367
|
// src/menus/BubbleMenu.ts
|
|
393
368
|
var import_vue = require("vue");
|
|
394
|
-
var
|
|
369
|
+
var BubbleMenu = (0, import_vue.defineComponent)({
|
|
395
370
|
name: "BubbleMenu",
|
|
396
371
|
inheritAttrs: false,
|
|
397
372
|
props: {
|
|
@@ -475,21 +450,20 @@ var BubbleMenu2 = (0, import_vue.defineComponent)({
|
|
|
475
450
|
}
|
|
476
451
|
});
|
|
477
452
|
|
|
478
|
-
// ../extension-floating-menu/
|
|
479
|
-
var import_core3 = require("@tiptap/core");
|
|
453
|
+
// ../extension-floating-menu/src/floating-menu-plugin.ts
|
|
480
454
|
var import_dom2 = require("@floating-ui/dom");
|
|
481
|
-
var
|
|
455
|
+
var import_core2 = require("@tiptap/core");
|
|
482
456
|
var import_state2 = require("@tiptap/pm/state");
|
|
483
457
|
var FloatingMenuView = class {
|
|
484
458
|
constructor({ editor, element, view, options, appendTo, shouldShow }) {
|
|
485
459
|
this.preventHide = false;
|
|
486
460
|
this.isVisible = false;
|
|
487
|
-
this.shouldShow = ({ view
|
|
461
|
+
this.shouldShow = ({ view, state }) => {
|
|
488
462
|
const { selection } = state;
|
|
489
463
|
const { $anchor, empty } = selection;
|
|
490
464
|
const isRootDepth = $anchor.depth === 1;
|
|
491
465
|
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
492
|
-
if (!
|
|
466
|
+
if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
493
467
|
return false;
|
|
494
468
|
}
|
|
495
469
|
return true;
|
|
@@ -506,14 +480,14 @@ var FloatingMenuView = class {
|
|
|
506
480
|
hide: false,
|
|
507
481
|
inline: false
|
|
508
482
|
};
|
|
509
|
-
this.updateHandler = (
|
|
510
|
-
const { composing } =
|
|
483
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
484
|
+
const { composing } = view;
|
|
511
485
|
const isSame = !selectionChanged && !docChanged;
|
|
512
486
|
if (composing || isSame) {
|
|
513
487
|
return;
|
|
514
488
|
}
|
|
515
|
-
const
|
|
516
|
-
if (!
|
|
489
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
490
|
+
if (!shouldShow) {
|
|
517
491
|
this.hide();
|
|
518
492
|
return;
|
|
519
493
|
}
|
|
@@ -562,7 +536,7 @@ var FloatingMenuView = class {
|
|
|
562
536
|
}
|
|
563
537
|
}
|
|
564
538
|
getTextContent(node) {
|
|
565
|
-
return (0,
|
|
539
|
+
return (0, import_core2.getText)(node, { textSerializers: (0, import_core2.getTextSerializersFromSchema)(this.editor.schema) });
|
|
566
540
|
}
|
|
567
541
|
get middlewares() {
|
|
568
542
|
const middlewares = [];
|
|
@@ -621,7 +595,7 @@ var FloatingMenuView = class {
|
|
|
621
595
|
}
|
|
622
596
|
updatePosition() {
|
|
623
597
|
const { selection } = this.editor.state;
|
|
624
|
-
const domRect = (0,
|
|
598
|
+
const domRect = (0, import_core2.posToDOMRect)(this.view, selection.from, selection.to);
|
|
625
599
|
const virtualElement = {
|
|
626
600
|
getBoundingClientRect: () => domRect,
|
|
627
601
|
getClientRects: () => [domRect]
|
|
@@ -687,37 +661,10 @@ var FloatingMenuPlugin = (options) => {
|
|
|
687
661
|
view: (view) => new FloatingMenuView({ view, ...options })
|
|
688
662
|
});
|
|
689
663
|
};
|
|
690
|
-
var FloatingMenu = import_core3.Extension.create({
|
|
691
|
-
name: "floatingMenu",
|
|
692
|
-
addOptions() {
|
|
693
|
-
return {
|
|
694
|
-
element: null,
|
|
695
|
-
options: {},
|
|
696
|
-
pluginKey: "floatingMenu",
|
|
697
|
-
appendTo: void 0,
|
|
698
|
-
shouldShow: null
|
|
699
|
-
};
|
|
700
|
-
},
|
|
701
|
-
addProseMirrorPlugins() {
|
|
702
|
-
if (!this.options.element) {
|
|
703
|
-
return [];
|
|
704
|
-
}
|
|
705
|
-
return [
|
|
706
|
-
FloatingMenuPlugin({
|
|
707
|
-
pluginKey: this.options.pluginKey,
|
|
708
|
-
editor: this.editor,
|
|
709
|
-
element: this.options.element,
|
|
710
|
-
options: this.options.options,
|
|
711
|
-
appendTo: this.options.appendTo,
|
|
712
|
-
shouldShow: this.options.shouldShow
|
|
713
|
-
})
|
|
714
|
-
];
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
664
|
|
|
718
665
|
// src/menus/FloatingMenu.ts
|
|
719
666
|
var import_vue2 = require("vue");
|
|
720
|
-
var
|
|
667
|
+
var FloatingMenu = (0, import_vue2.defineComponent)({
|
|
721
668
|
name: "FloatingMenu",
|
|
722
669
|
inheritAttrs: false,
|
|
723
670
|
props: {
|
package/dist/menus/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menus/index.ts","../../../extension-bubble-menu/src/bubble-menu.ts","../../../extension-bubble-menu/src/bubble-menu-plugin.ts","../../../extension-bubble-menu/src/index.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 { Extension } from '@tiptap/core'\n\nimport type { BubbleMenuPluginProps } from './bubble-menu-plugin.js'\nimport { BubbleMenuPlugin } from './bubble-menu-plugin.js'\n\nexport type BubbleMenuOptions = Omit<BubbleMenuPluginProps, '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 bubble menu.\n * @see https://tiptap.dev/api/extensions/bubble-menu\n */\nexport const BubbleMenu = Extension.create<BubbleMenuOptions>({\n name: 'bubbleMenu',\n\n addOptions() {\n return {\n element: null,\n pluginKey: 'bubbleMenu',\n updateDelay: undefined,\n appendTo: undefined,\n shouldShow: null,\n }\n },\n\n addProseMirrorPlugins() {\n if (!this.options.element) {\n return []\n }\n\n return [\n BubbleMenuPlugin({\n pluginKey: this.options.pluginKey,\n editor: this.editor,\n element: this.options.element,\n updateDelay: this.options.updateDelay,\n options: this.options.options,\n appendTo: this.options.appendTo,\n getReferencedVirtualElement: this.options.getReferencedVirtualElement,\n shouldShow: this.options.shouldShow,\n }),\n ]\n },\n})\n","import {\n type Middleware,\n type VirtualElement,\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, Transaction } from '@tiptap/pm/state'\nimport { NodeSelection, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { CellSelection } from '@tiptap/pm/tables'\nimport type { EditorView } from '@tiptap/pm/view'\n\nfunction combineDOMRects(rect1: DOMRect, rect2: DOMRect): DOMRect {\n const top = Math.min(rect1.top, rect2.top)\n const bottom = Math.max(rect1.bottom, rect2.bottom)\n const left = Math.min(rect1.left, rect2.left)\n const right = Math.max(rect1.right, rect2.right)\n const width = right - left\n const height = bottom - top\n const x = left\n const y = top\n return new DOMRect(x, y, width, height)\n}\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => HTMLElement)\n\n /**\n * A function that returns the virtual element for the menu.\n * This is useful when the menu needs to be positioned relative to a specific DOM element.\n * @type {() => VirtualElement | null}\n * @default Position based on the selection.\n */\n getReferencedVirtualElement?: () => VirtualElement | null\n\n /**\n * The options for the bubble menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\n\n /**\n * The scrollable element that should be listened to when updating the position of the bubble menu.\n * If not provided, the window will be used.\n * @type {HTMLElement | Window}\n */\n scrollTarget?: HTMLElement | Window\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 public appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public getReferencedVirtualElement: (() => VirtualElement | null) | undefined\n\n private updateDebounceTimer: number | undefined\n\n private resizeDebounceTimer: number | undefined\n\n private isVisible = false\n\n private scrollTarget: HTMLElement | Window = window\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 onShow: undefined,\n onHide: undefined,\n onUpdate: undefined,\n onDestroy: undefined,\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 private get virtualElement(): VirtualElement | undefined {\n const { selection } = this.editor.state\n\n const referencedVirtualElement = this.getReferencedVirtualElement?.()\n if (referencedVirtualElement) {\n return referencedVirtualElement\n }\n\n const domRect = posToDOMRect(this.view, selection.from, selection.to)\n let virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\n }\n\n if (selection instanceof NodeSelection) {\n let node = this.view.nodeDOM(selection.from) as HTMLElement\n\n const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')\n\n if (nodeViewWrapper) {\n node = nodeViewWrapper as HTMLElement\n }\n\n if (node) {\n virtualElement = {\n getBoundingClientRect: () => node.getBoundingClientRect(),\n getClientRects: () => [node.getBoundingClientRect()],\n }\n }\n }\n\n // this is a special case for cell selections\n if (selection instanceof CellSelection) {\n const { $anchorCell, $headCell } = selection\n\n const from = $anchorCell ? $anchorCell.pos : $headCell!.pos\n const to = $headCell ? $headCell.pos : $anchorCell!.pos\n\n const fromDOM = this.view.nodeDOM(from)\n const toDOM = this.view.nodeDOM(to)\n\n if (!fromDOM || !toDOM) {\n return\n }\n\n const clientRect =\n fromDOM === toDOM\n ? (fromDOM as HTMLElement).getBoundingClientRect()\n : combineDOMRects(\n (fromDOM as HTMLElement).getBoundingClientRect(),\n (toDOM as HTMLElement).getBoundingClientRect(),\n )\n\n virtualElement = {\n getBoundingClientRect: () => clientRect,\n getClientRects: () => [clientRect],\n }\n }\n\n return virtualElement\n }\n\n constructor({\n editor,\n element,\n view,\n updateDelay = 250,\n resizeDelay = 60,\n shouldShow,\n appendTo,\n getReferencedVirtualElement,\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 this.appendTo = appendTo\n this.scrollTarget = options?.scrollTarget ?? window\n this.getReferencedVirtualElement = getReferencedVirtualElement\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.editor.on('transaction', this.transactionHandler)\n window.addEventListener('resize', this.resizeHandler)\n this.scrollTarget.addEventListener('scroll', this.resizeHandler)\n\n this.update(view, view.state)\n\n if (this.getShouldShow()) {\n this.show()\n this.updatePosition()\n }\n }\n\n mousedownHandler = () => {\n this.preventHide = true\n }\n\n dragstartHandler = () => {\n this.hide()\n }\n\n /**\n * Handles the window resize event to update the position of the bubble menu.\n * It uses a debounce mechanism to prevent excessive updates.\n * The delay is defined by the `resizeDelay` property.\n */\n resizeHandler = () => {\n if (this.resizeDebounceTimer) {\n clearTimeout(this.resizeDebounceTimer)\n }\n\n this.resizeDebounceTimer = window.setTimeout(() => {\n this.updatePosition()\n }, this.resizeDelay)\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.editor.isDestroyed) {\n this.destroy()\n return\n }\n\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 virtualElement = this.virtualElement\n\n if (!virtualElement) {\n return\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 || false\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\n }\n\n transactionHandler = ({ transaction: tr }: { transaction: Transaction }) => {\n const meta = tr.getMeta('bubbleMenu')\n if (meta === 'updatePosition') {\n this.updatePosition()\n }\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 window.removeEventListener('resize', this.resizeHandler)\n this.scrollTarget.removeEventListener('scroll', this.resizeHandler)\n this.editor.off('focus', this.focusHandler)\n this.editor.off('blur', this.blurHandler)\n this.editor.off('transaction', this.transactionHandler)\n\n if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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 { BubbleMenu } from './bubble-menu.js'\n\nexport * from './bubble-menu.js'\nexport * from './bubble-menu-plugin.js'\n\nexport default BubbleMenu\n","import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu'\nimport type { PropType } from 'vue'\nimport { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<BubbleMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n\n getReferencedVirtualElement: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['getReferencedVirtualElement'], null>>,\n default: undefined,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n editor,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n nextTick(() => {\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: el,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n }),\n )\n })\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, 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 appendTo: undefined,\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 appendTo: this.options.appendTo,\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => 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 * The options for the floating menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\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 appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public preventHide = false\n\n private isVisible = 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, appendTo, shouldShow }: FloatingMenuViewProps) {\n this.editor = editor\n this.element = element\n this.view = view\n this.appendTo = appendTo\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.updatePosition()\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 domRect = posToDOMRect(this.view, selection.from, selection.to)\n\n const virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\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 if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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 } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<FloatingMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, appendTo, shouldShow } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: el,\n options,\n appendTo,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, slots.default?.())\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA,oBAAAC;AAAA;AAAA;;;ACAA,kBAA0B;ACA1B,iBAYO;AAEP,IAAAC,eAA8C;AAE9C,mBAAiD;AACjD,oBAA8B;AAG9B,SAAS,gBAAgB,OAAgB,OAAyB;AAChE,QAAM,MAAM,KAAK,IAAI,MAAM,KAAK,MAAM,GAAG;AACzC,QAAM,SAAS,KAAK,IAAI,MAAM,QAAQ,MAAM,MAAM;AAClD,QAAM,OAAO,KAAK,IAAI,MAAM,MAAM,MAAM,IAAI;AAC5C,QAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,MAAM,KAAK;AAC/C,QAAM,QAAQ,QAAQ;AACtB,QAAM,SAAS,SAAS;AACxB,QAAM,IAAI;AACV,QAAM,IAAI;AACV,SAAO,IAAI,QAAQ,GAAG,GAAG,OAAO,MAAM;AACxC;AAwHO,IAAM,iBAAN,MAA2C;EA+KhD,YAAY;IACV;IACA;IACA;IACA,cAAc;IACd,cAAc;IACd;IACA;IACA;IACA;EACF,GAAwB;AAlLxB,SAAO,cAAc;AAcrB,SAAQ,YAAY;AAEpB,SAAQ,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ACL,WAAW;AAAA;AAAA;AAAA,MAGT,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS,OAAO,CAAC;AAAA,IACnB;AAAA,IAEA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,MAAM,OAAO,EAAE,OAAO,MAAM,GAAG;AAC7B,UAAM,WAAO,iBAAwB,IAAI;AAEzC,+BAAU,MAAM;AACd,YAAM,EAAE,WAAW,QAAQ,SAAS,UAAU,WAAW,IAAI;AAE7D,YAAM,KAAK,KAAK;AAEhB,UAAI,CAAC,IAAI;AACP;AAAA,MACF;AAEA,SAAG,MAAM,aAAa;AACtB,SAAG,MAAM,WAAW;AAGpB,SAAG,OAAO;AAEV,aAAO;AAAA,QACL,mBAAmB;AAAA,UACjB;AAAA,UACA;AAAA,UACA,SAAS;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,qCAAgB,MAAM;AACpB,YAAM,EAAE,WAAW,OAAO,IAAI;AAE9B,aAAO,iBAAiB,SAAS;AAAA,IACnC,CAAC;AAID,WAAO,MAAG;AA7Ed;AA6EiB,gCAAE,OAAO,EAAE,KAAK,MAAM,GAAG,MAAM,IAAG,WAAM,YAAN,8BAAiB;AAAA;AAAA,EAClE;AACF,CAAC;","names":["BubbleMenu","FloatingMenu","import_core","view","_a","shouldShow","BubbleMenu","import_core","import_dom","import_state","view","shouldShow","import_vue","FloatingMenu"]}
|
|
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-plugin.ts","../../src/menus/FloatingMenu.ts"],"sourcesContent":["export * from './BubbleMenu.js'\nexport * from './FloatingMenu.js'\n","import {\n type Middleware,\n type VirtualElement,\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, Transaction } from '@tiptap/pm/state'\nimport { NodeSelection, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { CellSelection } from '@tiptap/pm/tables'\nimport type { EditorView } from '@tiptap/pm/view'\n\nfunction combineDOMRects(rect1: DOMRect, rect2: DOMRect): DOMRect {\n const top = Math.min(rect1.top, rect2.top)\n const bottom = Math.max(rect1.bottom, rect2.bottom)\n const left = Math.min(rect1.left, rect2.left)\n const right = Math.max(rect1.right, rect2.right)\n const width = right - left\n const height = bottom - top\n const x = left\n const y = top\n return new DOMRect(x, y, width, height)\n}\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => HTMLElement)\n\n /**\n * A function that returns the virtual element for the menu.\n * This is useful when the menu needs to be positioned relative to a specific DOM element.\n * @type {() => VirtualElement | null}\n * @default Position based on the selection.\n */\n getReferencedVirtualElement?: () => VirtualElement | null\n\n /**\n * The options for the bubble menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\n\n /**\n * The scrollable element that should be listened to when updating the position of the bubble menu.\n * If not provided, the window will be used.\n * @type {HTMLElement | Window}\n */\n scrollTarget?: HTMLElement | Window\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 public appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public getReferencedVirtualElement: (() => VirtualElement | null) | undefined\n\n private updateDebounceTimer: number | undefined\n\n private resizeDebounceTimer: number | undefined\n\n private isVisible = false\n\n private scrollTarget: HTMLElement | Window = window\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 onShow: undefined,\n onHide: undefined,\n onUpdate: undefined,\n onDestroy: undefined,\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 private get virtualElement(): VirtualElement | undefined {\n const { selection } = this.editor.state\n\n const referencedVirtualElement = this.getReferencedVirtualElement?.()\n if (referencedVirtualElement) {\n return referencedVirtualElement\n }\n\n const domRect = posToDOMRect(this.view, selection.from, selection.to)\n let virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\n }\n\n if (selection instanceof NodeSelection) {\n let node = this.view.nodeDOM(selection.from) as HTMLElement\n\n const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')\n\n if (nodeViewWrapper) {\n node = nodeViewWrapper as HTMLElement\n }\n\n if (node) {\n virtualElement = {\n getBoundingClientRect: () => node.getBoundingClientRect(),\n getClientRects: () => [node.getBoundingClientRect()],\n }\n }\n }\n\n // this is a special case for cell selections\n if (selection instanceof CellSelection) {\n const { $anchorCell, $headCell } = selection\n\n const from = $anchorCell ? $anchorCell.pos : $headCell!.pos\n const to = $headCell ? $headCell.pos : $anchorCell!.pos\n\n const fromDOM = this.view.nodeDOM(from)\n const toDOM = this.view.nodeDOM(to)\n\n if (!fromDOM || !toDOM) {\n return\n }\n\n const clientRect =\n fromDOM === toDOM\n ? (fromDOM as HTMLElement).getBoundingClientRect()\n : combineDOMRects(\n (fromDOM as HTMLElement).getBoundingClientRect(),\n (toDOM as HTMLElement).getBoundingClientRect(),\n )\n\n virtualElement = {\n getBoundingClientRect: () => clientRect,\n getClientRects: () => [clientRect],\n }\n }\n\n return virtualElement\n }\n\n constructor({\n editor,\n element,\n view,\n updateDelay = 250,\n resizeDelay = 60,\n shouldShow,\n appendTo,\n getReferencedVirtualElement,\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 this.appendTo = appendTo\n this.scrollTarget = options?.scrollTarget ?? window\n this.getReferencedVirtualElement = getReferencedVirtualElement\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.editor.on('transaction', this.transactionHandler)\n window.addEventListener('resize', this.resizeHandler)\n this.scrollTarget.addEventListener('scroll', this.resizeHandler)\n\n this.update(view, view.state)\n\n if (this.getShouldShow()) {\n this.show()\n this.updatePosition()\n }\n }\n\n mousedownHandler = () => {\n this.preventHide = true\n }\n\n dragstartHandler = () => {\n this.hide()\n }\n\n /**\n * Handles the window resize event to update the position of the bubble menu.\n * It uses a debounce mechanism to prevent excessive updates.\n * The delay is defined by the `resizeDelay` property.\n */\n resizeHandler = () => {\n if (this.resizeDebounceTimer) {\n clearTimeout(this.resizeDebounceTimer)\n }\n\n this.resizeDebounceTimer = window.setTimeout(() => {\n this.updatePosition()\n }, this.resizeDelay)\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.editor.isDestroyed) {\n this.destroy()\n return\n }\n\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 virtualElement = this.virtualElement\n\n if (!virtualElement) {\n return\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 || false\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\n }\n\n transactionHandler = ({ transaction: tr }: { transaction: Transaction }) => {\n const meta = tr.getMeta('bubbleMenu')\n if (meta === 'updatePosition') {\n this.updatePosition()\n }\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 window.removeEventListener('resize', this.resizeHandler)\n this.scrollTarget.removeEventListener('scroll', this.resizeHandler)\n this.editor.off('focus', this.focusHandler)\n this.editor.off('blur', this.blurHandler)\n this.editor.off('transaction', this.transactionHandler)\n\n if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<BubbleMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n\n getReferencedVirtualElement: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['getReferencedVirtualElement'], null>>,\n default: undefined,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n editor,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n nextTick(() => {\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: el,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n }),\n )\n })\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, slots.default?.())\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => 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 * The options for the floating menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\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 appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public preventHide = false\n\n private isVisible = 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, appendTo, shouldShow }: FloatingMenuViewProps) {\n this.editor = editor\n this.element = element\n this.view = view\n this.appendTo = appendTo\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.updatePosition()\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 domRect = posToDOMRect(this.view, selection.from, selection.to)\n\n const virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\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 if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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 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 } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<FloatingMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, appendTo, shouldShow } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: el,\n options,\n appendTo,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, slots.default?.())\n },\n})\n"],"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AAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,qCAAgB,MAAM;AACpB,YAAM,EAAE,WAAW,OAAO,IAAI;AAE9B,aAAO,iBAAiB,SAAS;AAAA,IACnC,CAAC;AAID,WAAO,MAAG;AA7Ed;AA6EiB,gCAAE,OAAO,EAAE,KAAK,MAAM,GAAG,MAAM,IAAG,WAAM,YAAN,8BAAiB;AAAA;AAAA,EAClE;AACF,CAAC;","names":["import_dom","import_core","import_state","import_vue"]}
|
package/dist/menus/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as prosemirror_state from 'prosemirror-state';
|
|
2
|
+
import * as prosemirror_view from 'prosemirror-view';
|
|
2
3
|
import * as _tiptap_core from '@tiptap/core';
|
|
3
4
|
import { Editor } from '@tiptap/core';
|
|
4
5
|
import * as _floating_ui_dom from '@floating-ui/dom';
|
|
5
6
|
import { VirtualElement, offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
6
|
-
import { PluginKey as PluginKey$1, EditorState as EditorState$1 } from 'prosemirror-state';
|
|
7
7
|
import * as vue from 'vue';
|
|
8
8
|
import { PropType } from 'vue';
|
|
9
9
|
import { PluginKey, EditorState } from '@tiptap/pm/state';
|
|
@@ -168,9 +168,6 @@ declare const BubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
168
168
|
default: undefined;
|
|
169
169
|
};
|
|
170
170
|
}>> & Readonly<{}>, {
|
|
171
|
-
pluginKey: string | PluginKey$1<any>;
|
|
172
|
-
updateDelay: number | undefined;
|
|
173
|
-
resizeDelay: number | undefined;
|
|
174
171
|
options: {
|
|
175
172
|
strategy?: "absolute" | "fixed";
|
|
176
173
|
placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
|
|
@@ -188,17 +185,20 @@ declare const BubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
188
185
|
onDestroy?: () => void;
|
|
189
186
|
scrollTarget?: HTMLElement | Window;
|
|
190
187
|
} | undefined;
|
|
188
|
+
updateDelay: number | undefined;
|
|
189
|
+
resizeDelay: number | undefined;
|
|
191
190
|
appendTo: HTMLElement | (() => HTMLElement) | undefined;
|
|
191
|
+
getReferencedVirtualElement: () => _floating_ui_dom.VirtualElement | null;
|
|
192
192
|
shouldShow: (props: {
|
|
193
193
|
editor: _tiptap_core.Editor;
|
|
194
194
|
element: HTMLElement;
|
|
195
|
-
view: EditorView
|
|
196
|
-
state: EditorState
|
|
197
|
-
oldState?: EditorState
|
|
195
|
+
view: prosemirror_view.EditorView;
|
|
196
|
+
state: prosemirror_state.EditorState;
|
|
197
|
+
oldState?: prosemirror_state.EditorState;
|
|
198
198
|
from: number;
|
|
199
199
|
to: number;
|
|
200
200
|
}) => boolean;
|
|
201
|
-
|
|
201
|
+
pluginKey: string | prosemirror_state.PluginKey<any>;
|
|
202
202
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
203
203
|
|
|
204
204
|
interface FloatingMenuPluginProps {
|
|
@@ -307,7 +307,6 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
307
307
|
default: null;
|
|
308
308
|
};
|
|
309
309
|
}>> & Readonly<{}>, {
|
|
310
|
-
pluginKey: any;
|
|
311
310
|
options: {
|
|
312
311
|
strategy?: "absolute" | "fixed";
|
|
313
312
|
placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
|
|
@@ -327,12 +326,13 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
327
326
|
appendTo: HTMLElement | (() => HTMLElement) | undefined;
|
|
328
327
|
shouldShow: (props: {
|
|
329
328
|
editor: _tiptap_core.Editor;
|
|
330
|
-
view: EditorView
|
|
331
|
-
state: EditorState
|
|
332
|
-
oldState?: EditorState
|
|
329
|
+
view: prosemirror_view.EditorView;
|
|
330
|
+
state: prosemirror_state.EditorState;
|
|
331
|
+
oldState?: prosemirror_state.EditorState;
|
|
333
332
|
from: number;
|
|
334
333
|
to: number;
|
|
335
334
|
}) => boolean;
|
|
335
|
+
pluginKey: any;
|
|
336
336
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
337
337
|
|
|
338
338
|
export { BubbleMenu, FloatingMenu };
|
package/dist/menus/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as prosemirror_state from 'prosemirror-state';
|
|
2
|
+
import * as prosemirror_view from 'prosemirror-view';
|
|
2
3
|
import * as _tiptap_core from '@tiptap/core';
|
|
3
4
|
import { Editor } from '@tiptap/core';
|
|
4
5
|
import * as _floating_ui_dom from '@floating-ui/dom';
|
|
5
6
|
import { VirtualElement, offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
6
|
-
import { PluginKey as PluginKey$1, EditorState as EditorState$1 } from 'prosemirror-state';
|
|
7
7
|
import * as vue from 'vue';
|
|
8
8
|
import { PropType } from 'vue';
|
|
9
9
|
import { PluginKey, EditorState } from '@tiptap/pm/state';
|
|
@@ -168,9 +168,6 @@ declare const BubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
168
168
|
default: undefined;
|
|
169
169
|
};
|
|
170
170
|
}>> & Readonly<{}>, {
|
|
171
|
-
pluginKey: string | PluginKey$1<any>;
|
|
172
|
-
updateDelay: number | undefined;
|
|
173
|
-
resizeDelay: number | undefined;
|
|
174
171
|
options: {
|
|
175
172
|
strategy?: "absolute" | "fixed";
|
|
176
173
|
placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
|
|
@@ -188,17 +185,20 @@ declare const BubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
188
185
|
onDestroy?: () => void;
|
|
189
186
|
scrollTarget?: HTMLElement | Window;
|
|
190
187
|
} | undefined;
|
|
188
|
+
updateDelay: number | undefined;
|
|
189
|
+
resizeDelay: number | undefined;
|
|
191
190
|
appendTo: HTMLElement | (() => HTMLElement) | undefined;
|
|
191
|
+
getReferencedVirtualElement: () => _floating_ui_dom.VirtualElement | null;
|
|
192
192
|
shouldShow: (props: {
|
|
193
193
|
editor: _tiptap_core.Editor;
|
|
194
194
|
element: HTMLElement;
|
|
195
|
-
view: EditorView
|
|
196
|
-
state: EditorState
|
|
197
|
-
oldState?: EditorState
|
|
195
|
+
view: prosemirror_view.EditorView;
|
|
196
|
+
state: prosemirror_state.EditorState;
|
|
197
|
+
oldState?: prosemirror_state.EditorState;
|
|
198
198
|
from: number;
|
|
199
199
|
to: number;
|
|
200
200
|
}) => boolean;
|
|
201
|
-
|
|
201
|
+
pluginKey: string | prosemirror_state.PluginKey<any>;
|
|
202
202
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
203
203
|
|
|
204
204
|
interface FloatingMenuPluginProps {
|
|
@@ -307,7 +307,6 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
307
307
|
default: null;
|
|
308
308
|
};
|
|
309
309
|
}>> & Readonly<{}>, {
|
|
310
|
-
pluginKey: any;
|
|
311
310
|
options: {
|
|
312
311
|
strategy?: "absolute" | "fixed";
|
|
313
312
|
placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
|
|
@@ -327,12 +326,13 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
327
326
|
appendTo: HTMLElement | (() => HTMLElement) | undefined;
|
|
328
327
|
shouldShow: (props: {
|
|
329
328
|
editor: _tiptap_core.Editor;
|
|
330
|
-
view: EditorView
|
|
331
|
-
state: EditorState
|
|
332
|
-
oldState?: EditorState
|
|
329
|
+
view: prosemirror_view.EditorView;
|
|
330
|
+
state: prosemirror_state.EditorState;
|
|
331
|
+
oldState?: prosemirror_state.EditorState;
|
|
333
332
|
from: number;
|
|
334
333
|
to: number;
|
|
335
334
|
}) => boolean;
|
|
335
|
+
pluginKey: any;
|
|
336
336
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
337
337
|
|
|
338
338
|
export { BubbleMenu, FloatingMenu };
|
package/dist/menus/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// ../extension-bubble-menu/
|
|
2
|
-
import { Extension } from "@tiptap/core";
|
|
1
|
+
// ../extension-bubble-menu/src/bubble-menu-plugin.ts
|
|
3
2
|
import {
|
|
4
3
|
arrow,
|
|
5
4
|
autoPlacement,
|
|
@@ -56,12 +55,12 @@ var BubbleMenuView = class {
|
|
|
56
55
|
onUpdate: void 0,
|
|
57
56
|
onDestroy: void 0
|
|
58
57
|
};
|
|
59
|
-
this.shouldShow = ({ view
|
|
58
|
+
this.shouldShow = ({ view, state, from, to }) => {
|
|
60
59
|
const { doc, selection } = state;
|
|
61
60
|
const { empty } = selection;
|
|
62
61
|
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
63
62
|
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
64
|
-
const hasEditorFocus =
|
|
63
|
+
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
65
64
|
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
66
65
|
return false;
|
|
67
66
|
}
|
|
@@ -73,6 +72,11 @@ var BubbleMenuView = class {
|
|
|
73
72
|
this.dragstartHandler = () => {
|
|
74
73
|
this.hide();
|
|
75
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Handles the window resize event to update the position of the bubble menu.
|
|
77
|
+
* It uses a debounce mechanism to prevent excessive updates.
|
|
78
|
+
* The delay is defined by the `resizeDelay` property.
|
|
79
|
+
*/
|
|
76
80
|
this.resizeHandler = () => {
|
|
77
81
|
if (this.resizeDebounceTimer) {
|
|
78
82
|
clearTimeout(this.resizeDebounceTimer);
|
|
@@ -85,7 +89,7 @@ var BubbleMenuView = class {
|
|
|
85
89
|
setTimeout(() => this.update(this.editor.view));
|
|
86
90
|
};
|
|
87
91
|
this.blurHandler = ({ event }) => {
|
|
88
|
-
var
|
|
92
|
+
var _a;
|
|
89
93
|
if (this.editor.isDestroyed) {
|
|
90
94
|
this.destroy();
|
|
91
95
|
return;
|
|
@@ -94,7 +98,7 @@ var BubbleMenuView = class {
|
|
|
94
98
|
this.preventHide = false;
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
|
-
if ((event == null ? void 0 : event.relatedTarget) && ((
|
|
101
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
100
104
|
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
@@ -102,9 +106,9 @@ var BubbleMenuView = class {
|
|
|
102
106
|
}
|
|
103
107
|
this.hide();
|
|
104
108
|
};
|
|
105
|
-
this.handleDebouncedUpdate = (
|
|
106
|
-
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(
|
|
107
|
-
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(
|
|
109
|
+
this.handleDebouncedUpdate = (view, oldState) => {
|
|
110
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
111
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
108
112
|
if (!selectionChanged && !docChanged) {
|
|
109
113
|
return;
|
|
110
114
|
}
|
|
@@ -112,17 +116,17 @@ var BubbleMenuView = class {
|
|
|
112
116
|
clearTimeout(this.updateDebounceTimer);
|
|
113
117
|
}
|
|
114
118
|
this.updateDebounceTimer = window.setTimeout(() => {
|
|
115
|
-
this.updateHandler(
|
|
119
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
116
120
|
}, this.updateDelay);
|
|
117
121
|
};
|
|
118
|
-
this.updateHandler = (
|
|
119
|
-
const { composing } =
|
|
122
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
123
|
+
const { composing } = view;
|
|
120
124
|
const isSame = !selectionChanged && !docChanged;
|
|
121
125
|
if (composing || isSame) {
|
|
122
126
|
return;
|
|
123
127
|
}
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
128
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
129
|
+
if (!shouldShow) {
|
|
126
130
|
this.hide();
|
|
127
131
|
return;
|
|
128
132
|
}
|
|
@@ -342,39 +346,10 @@ var BubbleMenuPlugin = (options) => {
|
|
|
342
346
|
view: (view) => new BubbleMenuView({ view, ...options })
|
|
343
347
|
});
|
|
344
348
|
};
|
|
345
|
-
var BubbleMenu = Extension.create({
|
|
346
|
-
name: "bubbleMenu",
|
|
347
|
-
addOptions() {
|
|
348
|
-
return {
|
|
349
|
-
element: null,
|
|
350
|
-
pluginKey: "bubbleMenu",
|
|
351
|
-
updateDelay: void 0,
|
|
352
|
-
appendTo: void 0,
|
|
353
|
-
shouldShow: null
|
|
354
|
-
};
|
|
355
|
-
},
|
|
356
|
-
addProseMirrorPlugins() {
|
|
357
|
-
if (!this.options.element) {
|
|
358
|
-
return [];
|
|
359
|
-
}
|
|
360
|
-
return [
|
|
361
|
-
BubbleMenuPlugin({
|
|
362
|
-
pluginKey: this.options.pluginKey,
|
|
363
|
-
editor: this.editor,
|
|
364
|
-
element: this.options.element,
|
|
365
|
-
updateDelay: this.options.updateDelay,
|
|
366
|
-
options: this.options.options,
|
|
367
|
-
appendTo: this.options.appendTo,
|
|
368
|
-
getReferencedVirtualElement: this.options.getReferencedVirtualElement,
|
|
369
|
-
shouldShow: this.options.shouldShow
|
|
370
|
-
})
|
|
371
|
-
];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
349
|
|
|
375
350
|
// src/menus/BubbleMenu.ts
|
|
376
351
|
import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref } from "vue";
|
|
377
|
-
var
|
|
352
|
+
var BubbleMenu = defineComponent({
|
|
378
353
|
name: "BubbleMenu",
|
|
379
354
|
inheritAttrs: false,
|
|
380
355
|
props: {
|
|
@@ -458,8 +433,7 @@ var BubbleMenu2 = defineComponent({
|
|
|
458
433
|
}
|
|
459
434
|
});
|
|
460
435
|
|
|
461
|
-
// ../extension-floating-menu/
|
|
462
|
-
import { Extension as Extension2 } from "@tiptap/core";
|
|
436
|
+
// ../extension-floating-menu/src/floating-menu-plugin.ts
|
|
463
437
|
import {
|
|
464
438
|
arrow as arrow2,
|
|
465
439
|
autoPlacement as autoPlacement2,
|
|
@@ -477,12 +451,12 @@ var FloatingMenuView = class {
|
|
|
477
451
|
constructor({ editor, element, view, options, appendTo, shouldShow }) {
|
|
478
452
|
this.preventHide = false;
|
|
479
453
|
this.isVisible = false;
|
|
480
|
-
this.shouldShow = ({ view
|
|
454
|
+
this.shouldShow = ({ view, state }) => {
|
|
481
455
|
const { selection } = state;
|
|
482
456
|
const { $anchor, empty } = selection;
|
|
483
457
|
const isRootDepth = $anchor.depth === 1;
|
|
484
458
|
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
485
|
-
if (!
|
|
459
|
+
if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
486
460
|
return false;
|
|
487
461
|
}
|
|
488
462
|
return true;
|
|
@@ -499,14 +473,14 @@ var FloatingMenuView = class {
|
|
|
499
473
|
hide: false,
|
|
500
474
|
inline: false
|
|
501
475
|
};
|
|
502
|
-
this.updateHandler = (
|
|
503
|
-
const { composing } =
|
|
476
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
477
|
+
const { composing } = view;
|
|
504
478
|
const isSame = !selectionChanged && !docChanged;
|
|
505
479
|
if (composing || isSame) {
|
|
506
480
|
return;
|
|
507
481
|
}
|
|
508
|
-
const
|
|
509
|
-
if (!
|
|
482
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
483
|
+
if (!shouldShow) {
|
|
510
484
|
this.hide();
|
|
511
485
|
return;
|
|
512
486
|
}
|
|
@@ -680,37 +654,10 @@ var FloatingMenuPlugin = (options) => {
|
|
|
680
654
|
view: (view) => new FloatingMenuView({ view, ...options })
|
|
681
655
|
});
|
|
682
656
|
};
|
|
683
|
-
var FloatingMenu = Extension2.create({
|
|
684
|
-
name: "floatingMenu",
|
|
685
|
-
addOptions() {
|
|
686
|
-
return {
|
|
687
|
-
element: null,
|
|
688
|
-
options: {},
|
|
689
|
-
pluginKey: "floatingMenu",
|
|
690
|
-
appendTo: void 0,
|
|
691
|
-
shouldShow: null
|
|
692
|
-
};
|
|
693
|
-
},
|
|
694
|
-
addProseMirrorPlugins() {
|
|
695
|
-
if (!this.options.element) {
|
|
696
|
-
return [];
|
|
697
|
-
}
|
|
698
|
-
return [
|
|
699
|
-
FloatingMenuPlugin({
|
|
700
|
-
pluginKey: this.options.pluginKey,
|
|
701
|
-
editor: this.editor,
|
|
702
|
-
element: this.options.element,
|
|
703
|
-
options: this.options.options,
|
|
704
|
-
appendTo: this.options.appendTo,
|
|
705
|
-
shouldShow: this.options.shouldShow
|
|
706
|
-
})
|
|
707
|
-
];
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
657
|
|
|
711
658
|
// src/menus/FloatingMenu.ts
|
|
712
659
|
import { defineComponent as defineComponent2, h as h2, onBeforeUnmount as onBeforeUnmount2, onMounted as onMounted2, ref as ref2 } from "vue";
|
|
713
|
-
var
|
|
660
|
+
var FloatingMenu = defineComponent2({
|
|
714
661
|
name: "FloatingMenu",
|
|
715
662
|
inheritAttrs: false,
|
|
716
663
|
props: {
|
|
@@ -770,7 +717,7 @@ var FloatingMenu2 = defineComponent2({
|
|
|
770
717
|
}
|
|
771
718
|
});
|
|
772
719
|
export {
|
|
773
|
-
|
|
774
|
-
|
|
720
|
+
BubbleMenu,
|
|
721
|
+
FloatingMenu
|
|
775
722
|
};
|
|
776
723
|
//# sourceMappingURL=index.js.map
|
package/dist/menus/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../extension-bubble-menu/src/bubble-menu.ts","../../../extension-bubble-menu/src/bubble-menu-plugin.ts","../../../extension-bubble-menu/src/index.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":["import { Extension } from '@tiptap/core'\n\nimport type { BubbleMenuPluginProps } from './bubble-menu-plugin.js'\nimport { BubbleMenuPlugin } from './bubble-menu-plugin.js'\n\nexport type BubbleMenuOptions = Omit<BubbleMenuPluginProps, '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 bubble menu.\n * @see https://tiptap.dev/api/extensions/bubble-menu\n */\nexport const BubbleMenu = Extension.create<BubbleMenuOptions>({\n name: 'bubbleMenu',\n\n addOptions() {\n return {\n element: null,\n pluginKey: 'bubbleMenu',\n updateDelay: undefined,\n appendTo: undefined,\n shouldShow: null,\n }\n },\n\n addProseMirrorPlugins() {\n if (!this.options.element) {\n return []\n }\n\n return [\n BubbleMenuPlugin({\n pluginKey: this.options.pluginKey,\n editor: this.editor,\n element: this.options.element,\n updateDelay: this.options.updateDelay,\n options: this.options.options,\n appendTo: this.options.appendTo,\n getReferencedVirtualElement: this.options.getReferencedVirtualElement,\n shouldShow: this.options.shouldShow,\n }),\n ]\n },\n})\n","import {\n type Middleware,\n type VirtualElement,\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, Transaction } from '@tiptap/pm/state'\nimport { NodeSelection, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { CellSelection } from '@tiptap/pm/tables'\nimport type { EditorView } from '@tiptap/pm/view'\n\nfunction combineDOMRects(rect1: DOMRect, rect2: DOMRect): DOMRect {\n const top = Math.min(rect1.top, rect2.top)\n const bottom = Math.max(rect1.bottom, rect2.bottom)\n const left = Math.min(rect1.left, rect2.left)\n const right = Math.max(rect1.right, rect2.right)\n const width = right - left\n const height = bottom - top\n const x = left\n const y = top\n return new DOMRect(x, y, width, height)\n}\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => HTMLElement)\n\n /**\n * A function that returns the virtual element for the menu.\n * This is useful when the menu needs to be positioned relative to a specific DOM element.\n * @type {() => VirtualElement | null}\n * @default Position based on the selection.\n */\n getReferencedVirtualElement?: () => VirtualElement | null\n\n /**\n * The options for the bubble menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\n\n /**\n * The scrollable element that should be listened to when updating the position of the bubble menu.\n * If not provided, the window will be used.\n * @type {HTMLElement | Window}\n */\n scrollTarget?: HTMLElement | Window\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 public appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public getReferencedVirtualElement: (() => VirtualElement | null) | undefined\n\n private updateDebounceTimer: number | undefined\n\n private resizeDebounceTimer: number | undefined\n\n private isVisible = false\n\n private scrollTarget: HTMLElement | Window = window\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 onShow: undefined,\n onHide: undefined,\n onUpdate: undefined,\n onDestroy: undefined,\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 private get virtualElement(): VirtualElement | undefined {\n const { selection } = this.editor.state\n\n const referencedVirtualElement = this.getReferencedVirtualElement?.()\n if (referencedVirtualElement) {\n return referencedVirtualElement\n }\n\n const domRect = posToDOMRect(this.view, selection.from, selection.to)\n let virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\n }\n\n if (selection instanceof NodeSelection) {\n let node = this.view.nodeDOM(selection.from) as HTMLElement\n\n const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')\n\n if (nodeViewWrapper) {\n node = nodeViewWrapper as HTMLElement\n }\n\n if (node) {\n virtualElement = {\n getBoundingClientRect: () => node.getBoundingClientRect(),\n getClientRects: () => [node.getBoundingClientRect()],\n }\n }\n }\n\n // this is a special case for cell selections\n if (selection instanceof CellSelection) {\n const { $anchorCell, $headCell } = selection\n\n const from = $anchorCell ? $anchorCell.pos : $headCell!.pos\n const to = $headCell ? $headCell.pos : $anchorCell!.pos\n\n const fromDOM = this.view.nodeDOM(from)\n const toDOM = this.view.nodeDOM(to)\n\n if (!fromDOM || !toDOM) {\n return\n }\n\n const clientRect =\n fromDOM === toDOM\n ? (fromDOM as HTMLElement).getBoundingClientRect()\n : combineDOMRects(\n (fromDOM as HTMLElement).getBoundingClientRect(),\n (toDOM as HTMLElement).getBoundingClientRect(),\n )\n\n virtualElement = {\n getBoundingClientRect: () => clientRect,\n getClientRects: () => [clientRect],\n }\n }\n\n return virtualElement\n }\n\n constructor({\n editor,\n element,\n view,\n updateDelay = 250,\n resizeDelay = 60,\n shouldShow,\n appendTo,\n getReferencedVirtualElement,\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 this.appendTo = appendTo\n this.scrollTarget = options?.scrollTarget ?? window\n this.getReferencedVirtualElement = getReferencedVirtualElement\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.editor.on('transaction', this.transactionHandler)\n window.addEventListener('resize', this.resizeHandler)\n this.scrollTarget.addEventListener('scroll', this.resizeHandler)\n\n this.update(view, view.state)\n\n if (this.getShouldShow()) {\n this.show()\n this.updatePosition()\n }\n }\n\n mousedownHandler = () => {\n this.preventHide = true\n }\n\n dragstartHandler = () => {\n this.hide()\n }\n\n /**\n * Handles the window resize event to update the position of the bubble menu.\n * It uses a debounce mechanism to prevent excessive updates.\n * The delay is defined by the `resizeDelay` property.\n */\n resizeHandler = () => {\n if (this.resizeDebounceTimer) {\n clearTimeout(this.resizeDebounceTimer)\n }\n\n this.resizeDebounceTimer = window.setTimeout(() => {\n this.updatePosition()\n }, this.resizeDelay)\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.editor.isDestroyed) {\n this.destroy()\n return\n }\n\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 virtualElement = this.virtualElement\n\n if (!virtualElement) {\n return\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 || false\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\n }\n\n transactionHandler = ({ transaction: tr }: { transaction: Transaction }) => {\n const meta = tr.getMeta('bubbleMenu')\n if (meta === 'updatePosition') {\n this.updatePosition()\n }\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 window.removeEventListener('resize', this.resizeHandler)\n this.scrollTarget.removeEventListener('scroll', this.resizeHandler)\n this.editor.off('focus', this.focusHandler)\n this.editor.off('blur', this.blurHandler)\n this.editor.off('transaction', this.transactionHandler)\n\n if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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 { BubbleMenu } from './bubble-menu.js'\n\nexport * from './bubble-menu.js'\nexport * from './bubble-menu-plugin.js'\n\nexport default BubbleMenu\n","import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu'\nimport type { PropType } from 'vue'\nimport { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<BubbleMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n\n getReferencedVirtualElement: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['getReferencedVirtualElement'], null>>,\n default: undefined,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n editor,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n nextTick(() => {\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: el,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n }),\n )\n })\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, 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 appendTo: undefined,\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 appendTo: this.options.appendTo,\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => 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 * The options for the floating menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\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 appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public preventHide = false\n\n private isVisible = 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, appendTo, shouldShow }: FloatingMenuViewProps) {\n this.editor = editor\n this.element = element\n this.view = view\n this.appendTo = appendTo\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.updatePosition()\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 domRect = posToDOMRect(this.view, selection.from, selection.to)\n\n const virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\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 if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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 } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<FloatingMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, appendTo, shouldShow } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: el,\n options,\n appendTo,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, slots.default?.())\n },\n})\n"],"mappings":";AAAA,SAAS,iBAAiB;ACA1B;EAGE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;OACK;AAEP,SAAS,iBAAiB,oBAAoB;AAE9C,SAAS,eAAe,QAAQ,iBAAiB;AACjD,SAAS,qBAAqB;AAG9B,SAAS,gBAAgB,OAAgB,OAAyB;AAChE,QAAM,MAAM,KAAK,IAAI,MAAM,KAAK,MAAM,GAAG;AACzC,QAAM,SAAS,KAAK,IAAI,MAAM,QAAQ,MAAM,MAAM;AAClD,QAAM,OAAO,KAAK,IAAI,MAAM,MAAM,MAAM,IAAI;AAC5C,QAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,MAAM,KAAK;AAC/C,QAAM,QAAQ,QAAQ;AACtB,QAAM,SAAS,SAAS;AACxB,QAAM,IAAI;AACV,QAAM,IAAI;AACV,SAAO,IAAI,QAAQ,GAAG,GAAG,OAAO,MAAM;AACxC;AAwHO,IAAM,iBAAN,MAA2C;EA+KhD,YAAY;IACV;IACA;IACA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AS;AAAA,IACnC,CAAC;AAID,WAAO,MAAG;AA7Ed;AA6EiB,aAAAD,GAAE,OAAO,EAAE,KAAK,MAAM,GAAG,MAAM,IAAG,WAAM,YAAN,8BAAiB;AAAA;AAAA,EAClE;AACF,CAAC;","names":["view","_a","shouldShow","BubbleMenu","Extension","arrow","autoPlacement","computePosition","flip","hide","inline","offset","shift","size","posToDOMRect","Plugin","PluginKey","view","shouldShow","defineComponent","h","onBeforeUnmount","onMounted","ref","FloatingMenu"]}
|
|
1
|
+
{"version":3,"sources":["../../../extension-bubble-menu/src/bubble-menu-plugin.ts","../../src/menus/BubbleMenu.ts","../../../extension-floating-menu/src/floating-menu-plugin.ts","../../src/menus/FloatingMenu.ts"],"sourcesContent":["import {\n type Middleware,\n type VirtualElement,\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, Transaction } from '@tiptap/pm/state'\nimport { NodeSelection, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { CellSelection } from '@tiptap/pm/tables'\nimport type { EditorView } from '@tiptap/pm/view'\n\nfunction combineDOMRects(rect1: DOMRect, rect2: DOMRect): DOMRect {\n const top = Math.min(rect1.top, rect2.top)\n const bottom = Math.max(rect1.bottom, rect2.bottom)\n const left = Math.min(rect1.left, rect2.left)\n const right = Math.max(rect1.right, rect2.right)\n const width = right - left\n const height = bottom - top\n const x = left\n const y = top\n return new DOMRect(x, y, width, height)\n}\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => HTMLElement)\n\n /**\n * A function that returns the virtual element for the menu.\n * This is useful when the menu needs to be positioned relative to a specific DOM element.\n * @type {() => VirtualElement | null}\n * @default Position based on the selection.\n */\n getReferencedVirtualElement?: () => VirtualElement | null\n\n /**\n * The options for the bubble menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\n\n /**\n * The scrollable element that should be listened to when updating the position of the bubble menu.\n * If not provided, the window will be used.\n * @type {HTMLElement | Window}\n */\n scrollTarget?: HTMLElement | Window\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 public appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public getReferencedVirtualElement: (() => VirtualElement | null) | undefined\n\n private updateDebounceTimer: number | undefined\n\n private resizeDebounceTimer: number | undefined\n\n private isVisible = false\n\n private scrollTarget: HTMLElement | Window = window\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 onShow: undefined,\n onHide: undefined,\n onUpdate: undefined,\n onDestroy: undefined,\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 private get virtualElement(): VirtualElement | undefined {\n const { selection } = this.editor.state\n\n const referencedVirtualElement = this.getReferencedVirtualElement?.()\n if (referencedVirtualElement) {\n return referencedVirtualElement\n }\n\n const domRect = posToDOMRect(this.view, selection.from, selection.to)\n let virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\n }\n\n if (selection instanceof NodeSelection) {\n let node = this.view.nodeDOM(selection.from) as HTMLElement\n\n const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')\n\n if (nodeViewWrapper) {\n node = nodeViewWrapper as HTMLElement\n }\n\n if (node) {\n virtualElement = {\n getBoundingClientRect: () => node.getBoundingClientRect(),\n getClientRects: () => [node.getBoundingClientRect()],\n }\n }\n }\n\n // this is a special case for cell selections\n if (selection instanceof CellSelection) {\n const { $anchorCell, $headCell } = selection\n\n const from = $anchorCell ? $anchorCell.pos : $headCell!.pos\n const to = $headCell ? $headCell.pos : $anchorCell!.pos\n\n const fromDOM = this.view.nodeDOM(from)\n const toDOM = this.view.nodeDOM(to)\n\n if (!fromDOM || !toDOM) {\n return\n }\n\n const clientRect =\n fromDOM === toDOM\n ? (fromDOM as HTMLElement).getBoundingClientRect()\n : combineDOMRects(\n (fromDOM as HTMLElement).getBoundingClientRect(),\n (toDOM as HTMLElement).getBoundingClientRect(),\n )\n\n virtualElement = {\n getBoundingClientRect: () => clientRect,\n getClientRects: () => [clientRect],\n }\n }\n\n return virtualElement\n }\n\n constructor({\n editor,\n element,\n view,\n updateDelay = 250,\n resizeDelay = 60,\n shouldShow,\n appendTo,\n getReferencedVirtualElement,\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 this.appendTo = appendTo\n this.scrollTarget = options?.scrollTarget ?? window\n this.getReferencedVirtualElement = getReferencedVirtualElement\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.editor.on('transaction', this.transactionHandler)\n window.addEventListener('resize', this.resizeHandler)\n this.scrollTarget.addEventListener('scroll', this.resizeHandler)\n\n this.update(view, view.state)\n\n if (this.getShouldShow()) {\n this.show()\n this.updatePosition()\n }\n }\n\n mousedownHandler = () => {\n this.preventHide = true\n }\n\n dragstartHandler = () => {\n this.hide()\n }\n\n /**\n * Handles the window resize event to update the position of the bubble menu.\n * It uses a debounce mechanism to prevent excessive updates.\n * The delay is defined by the `resizeDelay` property.\n */\n resizeHandler = () => {\n if (this.resizeDebounceTimer) {\n clearTimeout(this.resizeDebounceTimer)\n }\n\n this.resizeDebounceTimer = window.setTimeout(() => {\n this.updatePosition()\n }, this.resizeDelay)\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.editor.isDestroyed) {\n this.destroy()\n return\n }\n\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 virtualElement = this.virtualElement\n\n if (!virtualElement) {\n return\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 || false\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\n }\n\n transactionHandler = ({ transaction: tr }: { transaction: Transaction }) => {\n const meta = tr.getMeta('bubbleMenu')\n if (meta === 'updatePosition') {\n this.updatePosition()\n }\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 window.removeEventListener('resize', this.resizeHandler)\n this.scrollTarget.removeEventListener('scroll', this.resizeHandler)\n this.editor.off('focus', this.focusHandler)\n this.editor.off('blur', this.blurHandler)\n this.editor.off('transaction', this.transactionHandler)\n\n if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<BubbleMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n\n getReferencedVirtualElement: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['getReferencedVirtualElement'], null>>,\n default: undefined,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n editor,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n nextTick(() => {\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: el,\n options,\n pluginKey,\n resizeDelay,\n appendTo,\n shouldShow,\n getReferencedVirtualElement,\n updateDelay,\n }),\n )\n })\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, slots.default?.())\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 * The DOM element to append your menu to. Default is the editor's parent element.\n *\n * Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.\n *\n * @type {HTMLElement}\n * @default null\n */\n appendTo?: HTMLElement | (() => 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 * The options for the floating menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,\n * hide, and inline middlewares.\n * @default {}\n * @see https://floating-ui.com/docs/computePosition#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 onShow?: () => void\n onHide?: () => void\n onUpdate?: () => void\n onDestroy?: () => void\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 appendTo: HTMLElement | (() => HTMLElement) | undefined\n\n public preventHide = false\n\n private isVisible = 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, appendTo, shouldShow }: FloatingMenuViewProps) {\n this.editor = editor\n this.element = element\n this.view = view\n this.appendTo = appendTo\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...options,\n }\n\n this.element.tabIndex = 0\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 this.updatePosition()\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 domRect = posToDOMRect(this.view, selection.from, selection.to)\n\n const virtualElement = {\n getBoundingClientRect: () => domRect,\n getClientRects: () => [domRect],\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 if (this.isVisible && this.floatingUIOptions.onUpdate) {\n this.floatingUIOptions.onUpdate()\n }\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 if (this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'visible'\n this.element.style.opacity = '1'\n\n // attach to appendTo or editor's parent element\n const appendToElement = typeof this.appendTo === 'function' ? this.appendTo() : this.appendTo\n ;(appendToElement ?? this.view.dom.parentElement)?.appendChild(this.element)\n\n if (this.floatingUIOptions.onShow) {\n this.floatingUIOptions.onShow()\n }\n\n this.isVisible = true\n }\n\n hide() {\n if (!this.isVisible) {\n return\n }\n\n this.element.style.visibility = 'hidden'\n this.element.style.opacity = '0'\n // remove from the parent element\n this.element.remove()\n\n if (this.floatingUIOptions.onHide) {\n this.floatingUIOptions.onHide()\n }\n\n this.isVisible = false\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 if (this.floatingUIOptions.onDestroy) {\n this.floatingUIOptions.onDestroy()\n }\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 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 } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n inheritAttrs: false,\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 appendTo: {\n type: Object as PropType<FloatingMenuPluginProps['appendTo']>,\n default: undefined,\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots, attrs }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, appendTo, shouldShow } = props\n\n const el = root.value\n\n if (!el) {\n return\n }\n\n el.style.visibility = 'hidden'\n el.style.position = 'absolute'\n\n // Remove element from DOM; plugin will re-parent it when shown\n el.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: el,\n options,\n appendTo,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n // Vue owns this element; attrs are applied reactively by Vue\n // Plugin re-parents it when showing the menu\n return () => h('div', { ref: root, ...attrs }, slots.default?.())\n },\n})\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB,oBAAoB;AAE9C,SAAS,eAAe,QAAQ,iBAAiB;AACjD,SAAS,qBAAqB;AAG9B,SAAS,gBAAgB,OAAgB,OAAyB;AAChE,QAAM,MAAM,KAAK,IAAI,MAAM,KAAK,MAAM,GAAG;AACzC,QAAM,SAAS,KAAK,IAAI,MAAM,QAAQ,MAAM,MAAM;AAClD,QAAM,OAAO,KAAK,IAAI,MAAM,MAAM,MAAM,IAAI;AAC5C,QAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,MAAM,KAAK;AAC/C,QAAM,QAAQ,QAAQ;AACtB,QAAM,SAAS,SAAS;AACxB,QAAM,IAAI;AACV,QAAM,IAAI;AACV,SAAO,IAAI,QAAQ,GAAG,GAAG,OAAO,MAAM;AACxC;AAwHO,IAAM,iBAAN,MAA2C;AAAA,EA+KhD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAwB;AAlLxB,SAAO,cAAc;AAcrB,SAAQ,YAAY;AAEpB,SAAQ,eAAqC;AAE7C,SAAQ,oB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AAA,IACL,WAAW;AAAA;AAAA;AAAA,MAGT,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS,OAAO,CAAC;AAAA,IACnB;AAAA,IAEA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,MAAM,OAAO,EAAE,OAAO,MAAM,GAAG;AAC7B,UAAM,OAAOI,KAAwB,IAAI;AAEzC,IAAAD,WAAU,MAAM;AACd,YAAM,EAAE,WAAW,QAAQ,SAAS,UAAU,WAAW,IAAI;AAE7D,YAAM,KAAK,KAAK;AAEhB,UAAI,CAAC,IAAI;AACP;AAAA,MACF;AAEA,SAAG,MAAM,aAAa;AACtB,SAAG,MAAM,WAAW;AAGpB,SAAG,OAAO;AAEV,aAAO;AAAA,QACL,mBAAmB;AAAA,UACjB;AAAA,UACA;AAAA,UACA,SAAS;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,IAAAD,iBAAgB,MAAM;AACpB,YAAM,EAAE,WAAW,OAAO,IAAI;AAE9B,aAAO,iBAAiB,SAAS;AAAA,IACnC,CAAC;AAID,WAAO,MAAG;AA7Ed;AA6EiB,aAAAD,GAAE,OAAO,EAAE,KAAK,MAAM,GAAG,MAAM,IAAG,WAAM,YAAN,8BAAiB;AAAA;AAAA,EAClE;AACF,CAAC;","names":["arrow","autoPlacement","computePosition","flip","hide","inline","offset","shift","size","posToDOMRect","Plugin","PluginKey","defineComponent","h","onBeforeUnmount","onMounted","ref"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/vue-3",
|
|
3
3
|
"description": "Vue components for tiptap",
|
|
4
|
-
"version": "3.10.
|
|
4
|
+
"version": "3.10.8",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
],
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vue": "^3.5.13",
|
|
43
|
-
"@tiptap/core": "^3.10.
|
|
44
|
-
"@tiptap/pm": "^3.10.
|
|
43
|
+
"@tiptap/core": "^3.10.8",
|
|
44
|
+
"@tiptap/pm": "^3.10.8"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
|
-
"@tiptap/extension-bubble-menu": "^3.10.
|
|
48
|
-
"@tiptap/extension-floating-menu": "^3.10.
|
|
47
|
+
"@tiptap/extension-bubble-menu": "^3.10.8",
|
|
48
|
+
"@tiptap/extension-floating-menu": "^3.10.8"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"vue": "^3.0.0",
|
|
52
52
|
"@floating-ui/dom": "^1.0.0",
|
|
53
|
-
"@tiptap/core": "^3.10.
|
|
54
|
-
"@tiptap/pm": "^3.10.
|
|
53
|
+
"@tiptap/core": "^3.10.8",
|
|
54
|
+
"@tiptap/pm": "^3.10.8"
|
|
55
55
|
},
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|