GitHub

@@ -40,6 +40,7 @@ export interface EditorDragHandleSlots {

40404141

export interface EditorDragHandleEmits {

4242

nodeChange: [{ node: JSONContent, pos: number }]

43+

hover: [{ node: JSONContent, pos: number }]

4344

}

4445

</script>

4546

@@ -65,8 +66,8 @@ const props = withDefaults(defineProps<EditorDragHandleProps>(), {

6566

defineSlots<EditorDragHandleSlots>()

6667

const emit = defineEmits<EditorDragHandleEmits>()

676868-

const dragHandleProps = useForwardProps(reactivePick(props, 'pluginKey', 'onElementDragEnd', 'onElementDragStart', 'getReferencedVirtualElement'))

69-

const buttonProps = useForwardProps(reactiveOmit(props, 'icon', 'options', 'editor', 'pluginKey', 'onElementDragEnd', 'onElementDragStart', 'getReferencedVirtualElement', 'class', 'ui'))

69+

const dragHandleProps = useForwardProps(reactivePick(props, 'pluginKey', 'nested', 'nestedOptions', 'onElementDragEnd', 'onElementDragStart', 'getReferencedVirtualElement'))

70+

const buttonProps = useForwardProps(reactiveOmit(props, 'icon', 'options', 'editor', 'pluginKey', 'nested', 'nestedOptions', 'onElementDragEnd', 'onElementDragStart', 'getReferencedVirtualElement', 'class', 'ui'))

70717172

const appConfig = useAppConfig() as EditorDragHandle['AppConfig']

7273

@@ -114,13 +115,19 @@ const currentNodePos = ref<number | null>()

114115115116

function onNodeChange({ pos }: { pos: number }) {

116117

currentNodePos.value = pos

118+

if (pos == null || pos < 0) return

119+120+

const node = props.editor.state.doc.nodeAt(pos)

121+

if (node) {

122+

emit('hover', { node: node.toJSON(), pos })

123+

}

117124

}

118125119126

function onClick() {

120127

if (!props.editor) return

121128122129

const pos = currentNodePos.value

123-

if (pos == null) return

130+

if (pos == null || pos < 0) return

124131125132

const node = props.editor.state.doc.nodeAt(pos)

126133

if (node) {

Read the original on github.com ↗