add doc page for bubble menu
This commit is contained in:
45
packages/vue-2/src/BubbleMenu.ts
Normal file
45
packages/vue-2/src/BubbleMenu.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import Vue, { PropType } from 'vue'
|
||||
import { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
|
||||
|
||||
export const BubbleMenu = Vue.extend({
|
||||
name: 'BubbleMenu',
|
||||
|
||||
props: {
|
||||
editor: {
|
||||
type: Object as PropType<BubbleMenuPluginProps['editor']>,
|
||||
required: true,
|
||||
},
|
||||
|
||||
keepInBounds: {
|
||||
type: Boolean as PropType<BubbleMenuPluginProps['keepInBounds']>,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
editor: {
|
||||
immediate: true,
|
||||
handler(editor: BubbleMenuPluginProps['editor']) {
|
||||
if (!editor) {
|
||||
return
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
editor.registerPlugin(BubbleMenuPlugin({
|
||||
editor,
|
||||
element: this.$el as HTMLElement,
|
||||
keepInBounds: this.keepInBounds,
|
||||
}))
|
||||
})
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
render(createElement) {
|
||||
return createElement('div', {}, this.$slots.default)
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.unregisterPlugin(BubbleMenuPluginKey)
|
||||
},
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from '@tiptap/core'
|
||||
export * from './BubbleMenu'
|
||||
export { Editor } from './Editor'
|
||||
export * from './EditorContent'
|
||||
export * from './VueRenderer'
|
||||
|
||||
Reference in New Issue
Block a user