refactor: don’t use destructuring for props

This commit is contained in:
Philipp Kühn
2021-04-23 20:50:01 +02:00
parent 9110258a4c
commit 888cce2e4c
2 changed files with 10 additions and 2 deletions

View File

@@ -27,10 +27,12 @@ export const BubbleMenu = defineComponent({
}, },
}, },
setup({ editor, tippyOptions }, { slots }) { setup(props, { slots }) {
const root = ref<HTMLElement | null>(null) const root = ref<HTMLElement | null>(null)
onMounted(() => { onMounted(() => {
const { editor, tippyOptions } = props
editor.registerPlugin(BubbleMenuPlugin({ editor.registerPlugin(BubbleMenuPlugin({
editor, editor,
element: root.value as HTMLElement, element: root.value as HTMLElement,
@@ -39,6 +41,8 @@ export const BubbleMenu = defineComponent({
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
const { editor } = props
editor.unregisterPlugin(BubbleMenuPluginKey) editor.unregisterPlugin(BubbleMenuPluginKey)
}) })

View File

@@ -27,10 +27,12 @@ export const FloatingMenu = defineComponent({
}, },
}, },
setup({ editor, tippyOptions }, { slots }) { setup(props, { slots }) {
const root = ref<HTMLElement | null>(null) const root = ref<HTMLElement | null>(null)
onMounted(() => { onMounted(() => {
const { editor, tippyOptions } = props
editor.registerPlugin(FloatingMenuPlugin({ editor.registerPlugin(FloatingMenuPlugin({
editor, editor,
element: root.value as HTMLElement, element: root.value as HTMLElement,
@@ -39,6 +41,8 @@ export const FloatingMenu = defineComponent({
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
const { editor } = props
editor.unregisterPlugin(FloatingMenuPluginKey) editor.unregisterPlugin(FloatingMenuPluginKey)
}) })