{"version":3,"file":"index.cjs","names":["x","y","flip","shift","offset","arrow","size","autoPlacement","hide","inline","posToDOMRect","NodeSelection","CellSelection","isTextSelection","Plugin","PluginKey","Extension"],"sources":["../src/bubble-menu-plugin.ts","../src/bubble-menu.ts","../src/index.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[0] | boolean\n flip?: Parameters[0] | boolean\n shift?: Parameters[0] | boolean\n arrow?: Parameters[0] | false\n size?: Parameters[0] | boolean\n autoPlacement?: Parameters[0] | boolean\n hide?: Parameters[0] | boolean\n inline?: Parameters[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 pluginKey: PluginKey | string\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 = {\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 = ({\n view,\n state,\n from,\n to,\n }) => {\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(\n flip(\n typeof this.floatingUIOptions.flip !== 'boolean'\n ? this.floatingUIOptions.flip\n : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.shift) {\n middlewares.push(\n shift(\n typeof this.floatingUIOptions.shift !== 'boolean'\n ? this.floatingUIOptions.shift\n : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.offset) {\n middlewares.push(\n offset(\n typeof this.floatingUIOptions.offset !== 'boolean'\n ? this.floatingUIOptions.offset\n : undefined,\n ),\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(\n size(\n typeof this.floatingUIOptions.size !== 'boolean'\n ? this.floatingUIOptions.size\n : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.autoPlacement) {\n middlewares.push(\n autoPlacement(\n typeof this.floatingUIOptions.autoPlacement !== 'boolean'\n ? this.floatingUIOptions.autoPlacement\n : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.hide) {\n middlewares.push(\n hide(\n typeof this.floatingUIOptions.hide !== 'boolean'\n ? this.floatingUIOptions.hide\n : undefined,\n ),\n )\n }\n\n if (this.floatingUIOptions.inline) {\n middlewares.push(\n inline(\n typeof this.floatingUIOptions.inline !== 'boolean'\n ? this.floatingUIOptions.inline\n : undefined,\n ),\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 if (!this.view?.dom?.parentNode) {\n return\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\n ? node\n : 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 pluginKey = 'bubbleMenu',\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.pluginKey = pluginKey\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 if (!this.isVisible) {\n return\n }\n\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, middlewareData }) => {\n if (!this.isVisible || this.editor.isDestroyed || !this.element.isConnected) {\n return\n }\n\n // Handle hide middleware - hide element if reference is hidden or element has escaped\n if (middlewareData.hide?.referenceHidden || middlewareData.hide?.escaped) {\n this.element.style.visibility = 'hidden'\n return\n }\n\n this.element.style.visibility = 'visible'\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 = (\n view: EditorView,\n selectionChanged: boolean,\n docChanged: boolean,\n oldState?: EditorState,\n ) => {\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.show()\n this.updatePosition()\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 /**\n * Handles the transaction event to update the position of the bubble menu.\n * This allows external code to trigger a position update via:\n * `editor.view.dispatch(editor.state.tr.setMeta(pluginKey, 'updatePosition'))`\n * The `pluginKey` defaults to `bubbleMenu`\n */\n transactionHandler = ({ transaction: tr }: { transaction: Transaction }) => {\n const meta = tr.getMeta(this.pluginKey)\n if (meta === 'updatePosition') {\n this.updatePosition()\n } else if (meta && typeof meta === 'object' && meta.type === 'updateOptions') {\n this.updateOptions(meta.options)\n } else if (meta === 'hide') {\n this.hide()\n } else if (meta === 'show') {\n this.updatePosition()\n this.show()\n }\n }\n\n updateOptions(\n newProps: Partial>,\n ) {\n if (newProps.updateDelay !== undefined) {\n this.updateDelay = newProps.updateDelay\n }\n\n if (newProps.resizeDelay !== undefined) {\n this.resizeDelay = newProps.resizeDelay\n }\n\n if (newProps.appendTo !== undefined) {\n this.appendTo = newProps.appendTo\n }\n\n if (newProps.getReferencedVirtualElement !== undefined) {\n this.getReferencedVirtualElement = newProps.getReferencedVirtualElement\n }\n\n if (newProps.shouldShow !== undefined) {\n if (newProps.shouldShow) {\n this.shouldShow = newProps.shouldShow\n }\n }\n\n if (newProps.options !== undefined) {\n // Handle scrollTarget change - need to remove old listener and add new one\n // Use nullish coalescing to default to window when scrollTarget is undefined/null\n const newScrollTarget = newProps.options.scrollTarget ?? window\n\n if (newScrollTarget !== this.scrollTarget) {\n this.scrollTarget.removeEventListener('scroll', this.resizeHandler)\n this.scrollTarget = newScrollTarget\n this.scrollTarget.addEventListener('scroll', this.resizeHandler)\n }\n\n this.floatingUIOptions = {\n ...this.floatingUIOptions,\n ...newProps.options,\n }\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:\n typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey,\n view: view => new BubbleMenuView({ view, ...options }),\n })\n}\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 & {\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({\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 { BubbleMenu } from './bubble-menu.js'\n\nexport * from './bubble-menu.js'\nexport * from './bubble-menu-plugin.js'\n\nexport default BubbleMenu\n"],"mappings":";;;;;;;;;AAoBA,SAAS,gBAAgB,OAAgB,OAAyB;CAChE,MAAM,MAAM,KAAK,IAAI,MAAM,KAAK,MAAM,GAAG;CACzC,MAAM,SAAS,KAAK,IAAI,MAAM,QAAQ,MAAM,MAAM;CAClD,MAAM,OAAO,KAAK,IAAI,MAAM,MAAM,MAAM,IAAI;CAE5C,MAAM,QADQ,KAAK,IAAI,MAAM,OAAO,MAAM,KACxB,IAAI;CACtB,MAAM,SAAS,SAAS;CAGxB,OAAO,IAAI,QAAQA,MAAGC,KAAG,OAAO,MAAM;AACxC;AAwHA,IAAa,iBAAb,MAAkD;CAwEhD,IAAI,cAAc;EAChB,MAAM,cAA4B,CAAC;EAEnC,IAAI,KAAK,kBAAkB,MACzB,YAAY,MAAA,GACVC,iBAAAA,KAAAA,CACE,OAAO,KAAK,kBAAkB,SAAS,YACnC,KAAK,kBAAkB,OACvB,KAAA,CACN,CACF;EAGF,IAAI,KAAK,kBAAkB,OACzB,YAAY,MAAA,GACVC,iBAAAA,MAAAA,CACE,OAAO,KAAK,kBAAkB,UAAU,YACpC,KAAK,kBAAkB,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