PHP 8.2.30
Preview: BubbleMenu.tsx Size: 1.56 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/@tiptap/react/src/BubbleMenu.tsx

import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
import React, { useEffect, useState } from 'react'

import { useCurrentEditor } from './Context.js'

type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;

export type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element' | 'editor'> & {
  editor: BubbleMenuPluginProps['editor'] | null;
  className?: string;
  children: React.ReactNode;
  updateDelay?: number;
};

export const BubbleMenu = (props: BubbleMenuProps) => {
  const [element, setElement] = useState<HTMLDivElement | null>(null)
  const { editor: currentEditor } = useCurrentEditor()

  useEffect(() => {
    if (!element) {
      return
    }

    if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {
      return
    }

    const {
      pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,
    } = props

    const menuEditor = editor || currentEditor

    if (!menuEditor) {
      console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')
      return
    }

    const plugin = BubbleMenuPlugin({
      updateDelay,
      editor: menuEditor,
      element,
      pluginKey,
      shouldShow,
      tippyOptions,
    })

    menuEditor.registerPlugin(plugin)
    return () => { menuEditor.unregisterPlugin(pluginKey) }
  }, [props.editor, currentEditor, element])

  return (
    <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>
      {props.children}
    </div>
  )
}

Directory Contents

Dirs: 0 × Files: 14

Name Size Perms Modified Actions
1.56 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
1.42 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
510 B lrw-r--r-- 2026-02-28 11:47:14
Edit Download
5.75 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
1.56 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
443 B lrw-r--r-- 2026-02-28 11:47:14
Edit Download
546 B lrw-r--r-- 2026-02-28 11:47:14
Edit Download
579 B lrw-r--r-- 2026-02-28 11:47:14
Edit Download
10.57 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
6.18 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
210 B lrw-r--r-- 2026-02-28 11:47:14
Edit Download
12.35 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
5.54 KB lrw-r--r-- 2026-02-28 11:47:14
Edit Download
392 B lrw-r--r-- 2026-02-28 11:47:14
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).