mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
import type { Component } from 'vue' |
|
import { VueRenderer } from '@tiptap/vue-3' |
|
import tippy from 'tippy.js' |
|
|
|
export default (comp: Component) => ({ |
|
render: () => { |
|
let component: VueRenderer |
|
let popup: any |
|
|
|
return { |
|
onStart: (props: Record<string, any>) => { |
|
component = new VueRenderer(comp, { |
|
props, |
|
editor: props.editor, |
|
}) |
|
|
|
if (!props.clientRect) { |
|
return |
|
} |
|
|
|
popup = tippy('body', { |
|
getReferenceClientRect: props.clientRect, |
|
appendTo: () => document.body, |
|
content: component.element, |
|
showOnCreate: true, |
|
interactive: true, |
|
trigger: 'manual', |
|
placement: 'bottom-start', |
|
}) |
|
}, |
|
|
|
onUpdate(props: Record<string, any>) { |
|
component.updateProps(props) |
|
|
|
if (!props.clientRect) { |
|
return |
|
} |
|
|
|
popup[0].setProps({ |
|
getReferenceClientRect: props.clientRect, |
|
}) |
|
}, |
|
|
|
onKeyDown(props: Record<string, any>) { |
|
if (props.event.key === 'Escape') { |
|
popup[0].hide() |
|
|
|
return true |
|
} |
|
|
|
return component.ref?.onKeyDown(props) |
|
}, |
|
|
|
onExit() { |
|
popup[0].destroy() |
|
component.destroy() |
|
}, |
|
} |
|
}, |
|
})
|
|
|