add doc page for bubble menu

This commit is contained in:
Philipp Kühn
2021-03-30 14:07:18 +02:00
parent 35ca89311f
commit daa8e72477
10 changed files with 122 additions and 47 deletions

View File

@@ -26,6 +26,7 @@
"vue": "^2.6.12"
},
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.0.0-beta.1",
"prosemirror-view": "^1.18.2"
}
}

View 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)
},
})

View File

@@ -1,4 +1,5 @@
export * from '@tiptap/core'
export * from './BubbleMenu'
export { Editor } from './Editor'
export * from './EditorContent'
export * from './VueRenderer'