MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / getClosestClickableNode

Function getClosestClickableNode

packages/core/src/document/node/node.ts:904–923  ·  view source on GitHub ↗
(currentNode: Node | undefined | null, event: MouseEvent)

Source from the content-addressed store, hash-verified

902 * get the closest clickable node
903 */
904export const getClosestClickableNode = (currentNode: Node | undefined | null, event: MouseEvent) => {
905 let node = currentNode
906 while (node) {
907 // check if the current node is clickable
908 let canClick = node.canClick(event)
909 const lockedNode = getClosestNode(node, n => {
910 // if the current node is locked, start searching from the parent node
911 return !n.locked
912 })
913 if (lockedNode && lockedNode.getId() !== node.getId()) {
914 canClick = false
915 }
916 if (canClick) {
917 break
918 }
919 // for unclickable nodes, continue searching up
920 node = node.parent
921 }
922 return node
923}
924
925/**
926 * ensure the node is a Node instance

Callers 1

setupDragAndClickMethod · 0.90

Calls 3

getClosestNodeFunction · 0.85
canClickMethod · 0.80
getIdMethod · 0.45

Tested by

no test coverage detected