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

30 lines
676 B
TypeScript
Raw Normal View History

2021-04-01 21:19:31 +08:00
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>({
2021-06-08 07:53:05 +08:00
name: 'floatingMenu',
2021-04-01 21:19:31 +08:00
defaultOptions: {
element: null,
2021-04-16 18:42:56 +08:00
tippyOptions: {},
2021-04-01 21:19:31 +08:00
},
addProseMirrorPlugins() {
if (!this.options.element) {
return []
}
return [
FloatingMenuPlugin({
editor: this.editor,
element: this.options.element,
2021-04-16 18:42:56 +08:00
tippyOptions: this.options.tippyOptions,
2021-04-01 21:19:31 +08:00
}),
]
},
})