sometimes i need to find the cursor is in my custom plugin or not, the method is like blow:
findParentNode(path, check) {
for (let i = path.length - 1; i >= 0; i--) {
if (check(path[i])) {
return {
node: path[i],
pos: path[i - 1]
}
}
}
return null
}
const target = findParentNode($from.path, item => item.type && item.type.name === "pluginName")
...
...Decoration.node(target.pos, target.pos + target.node.nodeSize, attrubutes)
...
i do know path is not on type $from and typescript throw typing error , while $from.path is really helpful, what is the proper way to use $from.path or how can i findParentNode without $from.path