tiptap/packages/extension-bubble-menu/src/bubble-menu.ts

30 lines
658 B
TypeScript
Raw Normal View History

2021-03-30 17:36:51 +08:00
import { Extension } from '@tiptap/core'
2021-03-30 20:07:18 +08:00
import { BubbleMenuPlugin, BubbleMenuPluginProps } from './bubble-menu-plugin'
2021-03-30 17:36:51 +08:00
export type BubbleMenuOptions = Omit<BubbleMenuPluginProps, 'editor' | 'element'> & {
element: HTMLElement | null,
}
2021-03-30 17:36:51 +08:00
export const BubbleMenu = Extension.create<BubbleMenuOptions>({
name: 'bubbleMenu',
defaultOptions: {
element: null,
2021-04-16 18:42:56 +08:00
tippyOptions: {},
2021-03-30 17:36:51 +08:00
},
addProseMirrorPlugins() {
if (!this.options.element) {
return []
}
2021-03-30 17:36:51 +08:00
return [
BubbleMenuPlugin({
editor: this.editor,
element: this.options.element,
2021-04-16 18:42:56 +08:00
tippyOptions: this.options.tippyOptions,
2021-03-30 17:36:51 +08:00
}),
]
},
})