{"version":3,"sources":["../src/index.ts","../src/bubble-menu.ts","../src/bubble-menu-plugin.ts"],"sourcesContent":["import { BubbleMenu } from './bubble-menu.js'\n\nexport * from './bubble-menu.js'\nexport * from './bubble-menu-plugin.js'\n\nexport default BubbleMenu\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 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<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    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 ? 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    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 = (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.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(newProps: Partial<Omit<BubbleMenuPluginProps, 'editor' | 'element' | 'pluginKey'>>) {\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: typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey,\n    view: view => new BubbleMenuView({ view, ...options }),\n  })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AA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