Files
tiptap/packages/extension-bubble-menu/src/bubble-menu.ts
Dominik 8c6751f0c6 add precommit hook for linting and automatic eslint fixes + update eslint packages (#2862)
* chore: add precommit hook for eslint fixes, fix linting issues
* chore: add eslint import sort plugin
2022-06-08 14:10:25 +02:00

37 lines
822 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',
addOptions() {
return {
element: null,
tippyOptions: {},
pluginKey: 'bubbleMenu',
shouldShow: null,
}
},
addProseMirrorPlugins() {
if (!this.options.element) {
return []
}
return [
BubbleMenuPlugin({
pluginKey: this.options.pluginKey,
editor: this.editor,
element: this.options.element,
tippyOptions: this.options.tippyOptions,
shouldShow: this.options.shouldShow,
}),
]
},
})