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
|
|
|
|
2021-03-31 22:51:48 +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: {
|
2021-03-31 22:51:48 +08:00
|
|
|
element: null,
|
2021-03-30 17:36:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
addProseMirrorPlugins() {
|
2021-03-31 22:51:48 +08:00
|
|
|
if (!this.options.element) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
2021-03-30 17:36:51 +08:00
|
|
|
return [
|
|
|
|
BubbleMenuPlugin({
|
|
|
|
editor: this.editor,
|
|
|
|
element: this.options.element,
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
},
|
|
|
|
})
|