tiptap/packages/extension-bubble-menu/src/bubble-menu.ts
2021-04-16 12:42:56 +02:00

30 lines
658 B
TypeScript

import { Extension } from '@tiptap/core'
import { BubbleMenuPlugin, BubbleMenuPluginProps } from './bubble-menu-plugin'
export type BubbleMenuOptions = Omit<BubbleMenuPluginProps, 'editor' | 'element'> & {
element: HTMLElement | null,
}
export const BubbleMenu = Extension.create<BubbleMenuOptions>({
name: 'bubbleMenu',
defaultOptions: {
element: null,
tippyOptions: {},
},
addProseMirrorPlugins() {
if (!this.options.element) {
return []
}
return [
BubbleMenuPlugin({
editor: this.editor,
element: this.options.element,
tippyOptions: this.options.tippyOptions,
}),
]
},
})