tiptap/packages/extension-floating-menu/src/floating-menu.ts
2021-06-08 09:53:05 +10:00

30 lines
676 B
TypeScript

import { Extension } from '@tiptap/core'
import { FloatingMenuPlugin, FloatingMenuPluginProps } from './floating-menu-plugin'
export type FloatingMenuOptions = Omit<FloatingMenuPluginProps, 'editor' | 'element'> & {
element: HTMLElement | null,
}
export const FloatingMenu = Extension.create<FloatingMenuOptions>({
name: 'floatingMenu',
defaultOptions: {
element: null,
tippyOptions: {},
},
addProseMirrorPlugins() {
if (!this.options.element) {
return []
}
return [
FloatingMenuPlugin({
editor: this.editor,
element: this.options.element,
tippyOptions: this.options.tippyOptions,
}),
]
},
})