fix: resolve TypeScript errors in frontend build

This commit is contained in:
Hiro
2026-03-30 23:16:07 +00:00
parent b733306773
commit 24925e1acb
2941 changed files with 418042 additions and 49 deletions

865
node_modules/@tiptap/vue-3/dist/menus/index.js generated vendored Normal file
View File

@@ -0,0 +1,865 @@
// ../extension-bubble-menu/src/bubble-menu-plugin.ts
import {
arrow,
autoPlacement,
computePosition,
flip,
hide,
inline,
offset,
shift,
size
} from "@floating-ui/dom";
import { isTextSelection, posToDOMRect } from "@tiptap/core";
import { NodeSelection, Plugin, PluginKey } from "@tiptap/pm/state";
import { CellSelection } from "@tiptap/pm/tables";
function combineDOMRects(rect1, rect2) {
const top = Math.min(rect1.top, rect2.top);
const bottom = Math.max(rect1.bottom, rect2.bottom);
const left = Math.min(rect1.left, rect2.left);
const right = Math.max(rect1.right, rect2.right);
const width = right - left;
const height = bottom - top;
const x = left;
const y = top;
return new DOMRect(x, y, width, height);
}
var BubbleMenuView = class {
constructor({
editor,
element,
view,
pluginKey = "bubbleMenu",
updateDelay = 250,
resizeDelay = 60,
shouldShow,
appendTo,
getReferencedVirtualElement,
options
}) {
this.preventHide = false;
this.isVisible = false;
this.scrollTarget = window;
this.floatingUIOptions = {
strategy: "absolute",
placement: "top",
offset: 8,
flip: {},
shift: {},
arrow: false,
size: false,
autoPlacement: false,
hide: false,
inline: false,
onShow: void 0,
onHide: void 0,
onUpdate: void 0,
onDestroy: void 0
};
this.shouldShow = ({ view, state, from, to }) => {
const { doc, selection } = state;
const { empty } = selection;
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
const isChildOfMenu = this.element.contains(document.activeElement);
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
return false;
}
return true;
};
this.mousedownHandler = () => {
this.preventHide = true;
};
this.dragstartHandler = () => {
this.hide();
};
/**
* Handles the window resize event to update the position of the bubble menu.
* It uses a debounce mechanism to prevent excessive updates.
* The delay is defined by the `resizeDelay` property.
*/
this.resizeHandler = () => {
if (this.resizeDebounceTimer) {
clearTimeout(this.resizeDebounceTimer);
}
this.resizeDebounceTimer = window.setTimeout(() => {
this.updatePosition();
}, this.resizeDelay);
};
this.focusHandler = () => {
setTimeout(() => this.update(this.editor.view));
};
this.blurHandler = ({ event }) => {
var _a;
if (this.editor.isDestroyed) {
this.destroy();
return;
}
if (this.preventHide) {
this.preventHide = false;
return;
}
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
return;
}
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
return;
}
this.hide();
};
this.handleDebouncedUpdate = (view, oldState) => {
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
if (!selectionChanged && !docChanged) {
return;
}
if (this.updateDebounceTimer) {
clearTimeout(this.updateDebounceTimer);
}
this.updateDebounceTimer = window.setTimeout(() => {
this.updateHandler(view, selectionChanged, docChanged, oldState);
}, this.updateDelay);
};
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
const { composing } = view;
const isSame = !selectionChanged && !docChanged;
if (composing || isSame) {
return;
}
const shouldShow = this.getShouldShow(oldState);
if (!shouldShow) {
this.hide();
return;
}
this.updatePosition();
this.show();
};
/**
* Handles the transaction event to update the position of the bubble menu.
* This allows external code to trigger a position update via:
* `editor.view.dispatch(editor.state.tr.setMeta(pluginKey, 'updatePosition'))`
* The `pluginKey` defaults to `bubbleMenu`
*/
this.transactionHandler = ({ transaction: tr }) => {
const meta = tr.getMeta(this.pluginKey);
if (meta === "updatePosition") {
this.updatePosition();
} else if (meta && typeof meta === "object" && meta.type === "updateOptions") {
this.updateOptions(meta.options);
}
};
var _a;
this.editor = editor;
this.element = element;
this.view = view;
this.pluginKey = pluginKey;
this.updateDelay = updateDelay;
this.resizeDelay = resizeDelay;
this.appendTo = appendTo;
this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
this.getReferencedVirtualElement = getReferencedVirtualElement;
this.floatingUIOptions = {
...this.floatingUIOptions,
...options
};
this.element.tabIndex = 0;
if (shouldShow) {
this.shouldShow = shouldShow;
}
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
this.editor.on("focus", this.focusHandler);
this.editor.on("blur", this.blurHandler);
this.editor.on("transaction", this.transactionHandler);
window.addEventListener("resize", this.resizeHandler);
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
this.update(view, view.state);
if (this.getShouldShow()) {
this.show();
this.updatePosition();
}
}
get middlewares() {
const middlewares = [];
if (this.floatingUIOptions.flip) {
middlewares.push(flip(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
}
if (this.floatingUIOptions.shift) {
middlewares.push(
shift(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
);
}
if (this.floatingUIOptions.offset) {
middlewares.push(
offset(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
);
}
if (this.floatingUIOptions.arrow) {
middlewares.push(arrow(this.floatingUIOptions.arrow));
}
if (this.floatingUIOptions.size) {
middlewares.push(size(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
}
if (this.floatingUIOptions.autoPlacement) {
middlewares.push(
autoPlacement(
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
)
);
}
if (this.floatingUIOptions.hide) {
middlewares.push(hide(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
}
if (this.floatingUIOptions.inline) {
middlewares.push(
inline(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
);
}
return middlewares;
}
get virtualElement() {
var _a, _b, _c;
const { selection } = this.editor.state;
const referencedVirtualElement = (_a = this.getReferencedVirtualElement) == null ? void 0 : _a.call(this);
if (referencedVirtualElement) {
return referencedVirtualElement;
}
if (!((_c = (_b = this.view) == null ? void 0 : _b.dom) == null ? void 0 : _c.parentNode)) {
return;
}
const domRect = posToDOMRect(this.view, selection.from, selection.to);
let virtualElement = {
getBoundingClientRect: () => domRect,
getClientRects: () => [domRect]
};
if (selection instanceof NodeSelection) {
let node = this.view.nodeDOM(selection.from);
const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector("[data-node-view-wrapper]");
if (nodeViewWrapper) {
node = nodeViewWrapper;
}
if (node) {
virtualElement = {
getBoundingClientRect: () => node.getBoundingClientRect(),
getClientRects: () => [node.getBoundingClientRect()]
};
}
}
if (selection instanceof CellSelection) {
const { $anchorCell, $headCell } = selection;
const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
const to = $headCell ? $headCell.pos : $anchorCell.pos;
const fromDOM = this.view.nodeDOM(from);
const toDOM = this.view.nodeDOM(to);
if (!fromDOM || !toDOM) {
return;
}
const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
fromDOM.getBoundingClientRect(),
toDOM.getBoundingClientRect()
);
virtualElement = {
getBoundingClientRect: () => clientRect,
getClientRects: () => [clientRect]
};
}
return virtualElement;
}
updatePosition() {
const virtualElement = this.virtualElement;
if (!virtualElement) {
return;
}
computePosition(virtualElement, this.element, {
placement: this.floatingUIOptions.placement,
strategy: this.floatingUIOptions.strategy,
middleware: this.middlewares
}).then(({ x, y, strategy, middlewareData }) => {
var _a, _b;
if (((_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden) || ((_b = middlewareData.hide) == null ? void 0 : _b.escaped)) {
this.element.style.visibility = "hidden";
return;
}
this.element.style.visibility = "visible";
this.element.style.width = "max-content";
this.element.style.position = strategy;
this.element.style.left = `${x}px`;
this.element.style.top = `${y}px`;
if (this.isVisible && this.floatingUIOptions.onUpdate) {
this.floatingUIOptions.onUpdate();
}
});
}
update(view, oldState) {
const { state } = view;
const hasValidSelection = state.selection.from !== state.selection.to;
if (this.updateDelay > 0 && hasValidSelection) {
this.handleDebouncedUpdate(view, oldState);
return;
}
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
this.updateHandler(view, selectionChanged, docChanged, oldState);
}
getShouldShow(oldState) {
var _a;
const { state } = this.view;
const { selection } = state;
const { ranges } = selection;
const from = Math.min(...ranges.map((range) => range.$from.pos));
const to = Math.max(...ranges.map((range) => range.$to.pos));
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
editor: this.editor,
element: this.element,
view: this.view,
state,
oldState,
from,
to
});
return shouldShow || false;
}
show() {
var _a;
if (this.isVisible) {
return;
}
this.element.style.visibility = "visible";
this.element.style.opacity = "1";
const appendToElement = typeof this.appendTo === "function" ? this.appendTo() : this.appendTo;
(_a = appendToElement != null ? appendToElement : this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
if (this.floatingUIOptions.onShow) {
this.floatingUIOptions.onShow();
}
this.isVisible = true;
}
hide() {
if (!this.isVisible) {
return;
}
this.element.style.visibility = "hidden";
this.element.style.opacity = "0";
this.element.remove();
if (this.floatingUIOptions.onHide) {
this.floatingUIOptions.onHide();
}
this.isVisible = false;
}
updateOptions(newProps) {
var _a;
if (newProps.updateDelay !== void 0) {
this.updateDelay = newProps.updateDelay;
}
if (newProps.resizeDelay !== void 0) {
this.resizeDelay = newProps.resizeDelay;
}
if (newProps.appendTo !== void 0) {
this.appendTo = newProps.appendTo;
}
if (newProps.getReferencedVirtualElement !== void 0) {
this.getReferencedVirtualElement = newProps.getReferencedVirtualElement;
}
if (newProps.shouldShow !== void 0) {
if (newProps.shouldShow) {
this.shouldShow = newProps.shouldShow;
}
}
if (newProps.options !== void 0) {
const newScrollTarget = (_a = newProps.options.scrollTarget) != null ? _a : window;
if (newScrollTarget !== this.scrollTarget) {
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
this.scrollTarget = newScrollTarget;
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
}
this.floatingUIOptions = {
...this.floatingUIOptions,
...newProps.options
};
}
}
destroy() {
this.hide();
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
window.removeEventListener("resize", this.resizeHandler);
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
this.editor.off("focus", this.focusHandler);
this.editor.off("blur", this.blurHandler);
this.editor.off("transaction", this.transactionHandler);
if (this.floatingUIOptions.onDestroy) {
this.floatingUIOptions.onDestroy();
}
}
};
var BubbleMenuPlugin = (options) => {
return new Plugin({
key: typeof options.pluginKey === "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
view: (view) => new BubbleMenuView({ view, ...options })
});
};
// src/menus/BubbleMenu.ts
import { PluginKey as PluginKey2 } from "@tiptap/pm/state";
import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref } from "vue";
var BubbleMenu = defineComponent({
name: "BubbleMenu",
inheritAttrs: false,
props: {
pluginKey: {
type: [String, Object],
default: void 0
},
editor: {
type: Object,
required: true
},
updateDelay: {
type: Number,
default: void 0
},
resizeDelay: {
type: Number,
default: void 0
},
options: {
type: Object,
default: () => ({})
},
appendTo: {
type: [Object, Function],
default: void 0
},
shouldShow: {
type: Function,
default: null
},
getReferencedVirtualElement: {
type: Function,
default: void 0
}
},
setup(props, { slots, attrs }) {
var _a;
const root = ref(null);
const resolvedPluginKey = (_a = props.pluginKey) != null ? _a : new PluginKey2("bubbleMenu");
onMounted(() => {
const { editor, options, resizeDelay, appendTo, shouldShow, getReferencedVirtualElement, updateDelay } = props;
const el = root.value;
if (!el) {
return;
}
el.style.visibility = "hidden";
el.style.position = "absolute";
el.remove();
nextTick(() => {
editor.registerPlugin(
BubbleMenuPlugin({
editor,
element: el,
options,
pluginKey: resolvedPluginKey,
resizeDelay,
appendTo,
shouldShow,
getReferencedVirtualElement,
updateDelay
})
);
});
});
onBeforeUnmount(() => {
const { editor } = props;
editor.unregisterPlugin(resolvedPluginKey);
});
return () => {
var _a2;
return h("div", { ref: root, ...attrs }, (_a2 = slots.default) == null ? void 0 : _a2.call(slots));
};
}
});
// ../extension-floating-menu/src/floating-menu-plugin.ts
import {
arrow as arrow2,
autoPlacement as autoPlacement2,
computePosition as computePosition2,
flip as flip2,
hide as hide2,
inline as inline2,
offset as offset2,
shift as shift2,
size as size2
} from "@floating-ui/dom";
import { getText, getTextSerializersFromSchema, posToDOMRect as posToDOMRect2 } from "@tiptap/core";
import { Plugin as Plugin2, PluginKey as PluginKey3 } from "@tiptap/pm/state";
var FloatingMenuView = class {
constructor({
editor,
element,
view,
pluginKey = "floatingMenu",
updateDelay = 250,
resizeDelay = 60,
options,
appendTo,
shouldShow
}) {
this.preventHide = false;
this.isVisible = false;
this.scrollTarget = window;
this.shouldShow = ({ view, state }) => {
const { selection } = state;
const { $anchor, empty } = selection;
const isRootDepth = $anchor.depth === 1;
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
return false;
}
return true;
};
this.floatingUIOptions = {
strategy: "absolute",
placement: "right",
offset: 8,
flip: {},
shift: {},
arrow: false,
size: false,
autoPlacement: false,
hide: false,
inline: false
};
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
const { composing } = view;
const isSame = !selectionChanged && !docChanged;
if (composing || isSame) {
return;
}
const shouldShow = this.getShouldShow(oldState);
if (!shouldShow) {
this.hide();
return;
}
this.updatePosition();
this.show();
};
this.mousedownHandler = () => {
this.preventHide = true;
};
this.focusHandler = () => {
setTimeout(() => this.update(this.editor.view));
};
this.blurHandler = ({ event }) => {
var _a;
if (this.preventHide) {
this.preventHide = false;
return;
}
if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
return;
}
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
return;
}
this.hide();
};
/**
* Handles the transaction event to update the position of the floating menu.
* This allows external code to trigger a position update via:
* `editor.view.dispatch(editor.state.tr.setMeta(pluginKey, 'updatePosition'))`
* The `pluginKey` defaults to `floatingMenu`
*/
this.transactionHandler = ({ transaction: tr }) => {
const meta = tr.getMeta(this.pluginKey);
if (meta === "updatePosition") {
this.updatePosition();
} else if (meta && typeof meta === "object" && meta.type === "updateOptions") {
this.updateOptions(meta.options);
}
};
/**
* Handles the window resize event to update the position of the floating menu.
* It uses a debounce mechanism to prevent excessive updates.
* The delay is defined by the `resizeDelay` property.
*/
this.resizeHandler = () => {
if (this.resizeDebounceTimer) {
clearTimeout(this.resizeDebounceTimer);
}
this.resizeDebounceTimer = window.setTimeout(() => {
this.updatePosition();
}, this.resizeDelay);
};
var _a;
this.editor = editor;
this.element = element;
this.view = view;
this.pluginKey = pluginKey;
this.updateDelay = updateDelay;
this.resizeDelay = resizeDelay;
this.appendTo = appendTo;
this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
this.floatingUIOptions = {
...this.floatingUIOptions,
...options
};
this.element.tabIndex = 0;
if (shouldShow) {
this.shouldShow = shouldShow;
}
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
this.editor.on("focus", this.focusHandler);
this.editor.on("blur", this.blurHandler);
this.editor.on("transaction", this.transactionHandler);
window.addEventListener("resize", this.resizeHandler);
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
this.update(view, view.state);
if (this.getShouldShow()) {
this.show();
this.updatePosition();
}
}
getTextContent(node) {
return getText(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) });
}
get middlewares() {
const middlewares = [];
if (this.floatingUIOptions.flip) {
middlewares.push(flip2(typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0));
}
if (this.floatingUIOptions.shift) {
middlewares.push(
shift2(typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0)
);
}
if (this.floatingUIOptions.offset) {
middlewares.push(
offset2(typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0)
);
}
if (this.floatingUIOptions.arrow) {
middlewares.push(arrow2(this.floatingUIOptions.arrow));
}
if (this.floatingUIOptions.size) {
middlewares.push(size2(typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0));
}
if (this.floatingUIOptions.autoPlacement) {
middlewares.push(
autoPlacement2(
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
)
);
}
if (this.floatingUIOptions.hide) {
middlewares.push(hide2(typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0));
}
if (this.floatingUIOptions.inline) {
middlewares.push(
inline2(typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0)
);
}
return middlewares;
}
getShouldShow(oldState) {
var _a;
const { state } = this.view;
const { selection } = state;
const { ranges } = selection;
const from = Math.min(...ranges.map((range) => range.$from.pos));
const to = Math.max(...ranges.map((range) => range.$to.pos));
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
editor: this.editor,
view: this.view,
state,
oldState,
from,
to
});
return shouldShow;
}
updateOptions(newProps) {
var _a;
if (newProps.updateDelay !== void 0) {
this.updateDelay = newProps.updateDelay;
}
if (newProps.resizeDelay !== void 0) {
this.resizeDelay = newProps.resizeDelay;
}
if (newProps.appendTo !== void 0) {
this.appendTo = newProps.appendTo;
}
if (newProps.shouldShow !== void 0) {
if (newProps.shouldShow) {
this.shouldShow = newProps.shouldShow;
}
}
if (newProps.options !== void 0) {
const newScrollTarget = (_a = newProps.options.scrollTarget) != null ? _a : window;
if (newScrollTarget !== this.scrollTarget) {
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
this.scrollTarget = newScrollTarget;
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
}
this.floatingUIOptions = {
...this.floatingUIOptions,
...newProps.options
};
}
}
updatePosition() {
const { selection } = this.editor.state;
const domRect = posToDOMRect2(this.view, selection.from, selection.to);
const virtualElement = {
getBoundingClientRect: () => domRect,
getClientRects: () => [domRect]
};
computePosition2(virtualElement, this.element, {
placement: this.floatingUIOptions.placement,
strategy: this.floatingUIOptions.strategy,
middleware: this.middlewares
}).then(({ x, y, strategy, middlewareData }) => {
var _a, _b;
if (((_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden) || ((_b = middlewareData.hide) == null ? void 0 : _b.escaped)) {
this.element.style.visibility = "hidden";
return;
}
this.element.style.visibility = "visible";
this.element.style.width = "max-content";
this.element.style.position = strategy;
this.element.style.left = `${x}px`;
this.element.style.top = `${y}px`;
if (this.isVisible && this.floatingUIOptions.onUpdate) {
this.floatingUIOptions.onUpdate();
}
});
}
update(view, oldState) {
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
this.updateHandler(view, selectionChanged, docChanged, oldState);
}
show() {
var _a;
if (this.isVisible) {
return;
}
this.element.style.visibility = "visible";
this.element.style.opacity = "1";
const appendToElement = typeof this.appendTo === "function" ? this.appendTo() : this.appendTo;
(_a = appendToElement != null ? appendToElement : this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
if (this.floatingUIOptions.onShow) {
this.floatingUIOptions.onShow();
}
this.isVisible = true;
}
hide() {
if (!this.isVisible) {
return;
}
this.element.style.visibility = "hidden";
this.element.style.opacity = "0";
this.element.remove();
if (this.floatingUIOptions.onHide) {
this.floatingUIOptions.onHide();
}
this.isVisible = false;
}
destroy() {
this.hide();
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
window.removeEventListener("resize", this.resizeHandler);
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
this.editor.off("focus", this.focusHandler);
this.editor.off("blur", this.blurHandler);
this.editor.off("transaction", this.transactionHandler);
if (this.floatingUIOptions.onDestroy) {
this.floatingUIOptions.onDestroy();
}
}
};
var FloatingMenuPlugin = (options) => {
return new Plugin2({
key: typeof options.pluginKey === "string" ? new PluginKey3(options.pluginKey) : options.pluginKey,
view: (view) => new FloatingMenuView({ view, ...options })
});
};
// src/menus/FloatingMenu.ts
import { PluginKey as PluginKey4 } from "@tiptap/pm/state";
import { defineComponent as defineComponent2, h as h2, onBeforeUnmount as onBeforeUnmount2, onMounted as onMounted2, ref as ref2 } from "vue";
var FloatingMenu = defineComponent2({
name: "FloatingMenu",
inheritAttrs: false,
props: {
pluginKey: {
// TODO: TypeScript breaks :(
// type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
type: null,
default: void 0
},
editor: {
type: Object,
required: true
},
updateDelay: {
type: Number,
default: void 0
},
resizeDelay: {
type: Number,
default: void 0
},
options: {
type: Object,
default: () => ({})
},
appendTo: {
type: [Object, Function],
default: void 0
},
shouldShow: {
type: Function,
default: null
}
},
setup(props, { slots, attrs }) {
var _a;
const root = ref2(null);
const resolvedPluginKey = (_a = props.pluginKey) != null ? _a : new PluginKey4("floatingMenu");
onMounted2(() => {
const { editor, updateDelay, resizeDelay, options, appendTo, shouldShow } = props;
const el = root.value;
if (!el) {
return;
}
el.style.visibility = "hidden";
el.style.position = "absolute";
el.remove();
editor.registerPlugin(
FloatingMenuPlugin({
pluginKey: resolvedPluginKey,
editor,
element: el,
updateDelay,
resizeDelay,
options,
appendTo,
shouldShow
})
);
});
onBeforeUnmount2(() => {
const { editor } = props;
editor.unregisterPlugin(resolvedPluginKey);
});
return () => {
var _a2;
return h2("div", { ref: root, ...attrs }, (_a2 = slots.default) == null ? void 0 : _a2.call(slots));
};
}
});
export {
BubbleMenu,
FloatingMenu
};
//# sourceMappingURL=index.js.map