add floating menu to vue 3 and react

This commit is contained in:
Philipp Kühn
2021-04-01 15:55:19 +02:00
parent 3f1fa81392
commit 3eac1ce319
8 changed files with 94 additions and 13 deletions

View File

@@ -26,6 +26,7 @@
},
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.0.0-beta.3",
"@tiptap/extension-floating-menu": "^2.0.0-beta.0",
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.2",
"vue": "^3.0.0"

View File

@@ -0,0 +1,41 @@
import {
h,
ref,
PropType,
onMounted,
onBeforeUnmount,
defineComponent,
} from 'vue'
import {
FloatingMenuPlugin,
FloatingMenuPluginKey,
FloatingMenuPluginProps,
} from '@tiptap/extension-floating-menu'
export const FloatingMenu = defineComponent({
name: 'FloatingMenu',
props: {
editor: {
type: Object as PropType<FloatingMenuPluginProps['editor']>,
required: true,
},
},
setup({ editor }, { slots }) {
const root = ref<HTMLElement | null>(null)
onMounted(() => {
editor.registerPlugin(FloatingMenuPlugin({
editor,
element: root.value as HTMLElement,
}))
})
onBeforeUnmount(() => {
editor.unregisterPlugin(FloatingMenuPluginKey)
})
return () => h('div', { ref: root }, slots.default?.())
},
})

View File

@@ -2,6 +2,7 @@ export * from '@tiptap/core'
export * from './BubbleMenu'
export { Editor } from './Editor'
export * from './EditorContent'
export * from './FloatingMenu'
export * from './useEditor'
export * from './VueRenderer'
export * from './VueNodeViewRenderer'