MCPcopy Create free account
hub / github.com/editablejs/editable / findPath

Function findPath

packages/editor/src/plugin/editable.ts:289–315  ·  view source on GitHub ↗

* Find the path of Editor node.

(editor: Editor, node: Node)

Source from the content-addressed store, hash-verified

287 */
288
289 findPath(editor: Editor, node: Node): Path {
290 const path: Path = []
291 let child = node
292
293 while (true) {
294 const parent = NODE_TO_PARENT.get(child)
295
296 if (parent == null) {
297 if (Editor.isEditor(child)) {
298 return path
299 } else {
300 break
301 }
302 }
303
304 const i = NODE_TO_INDEX.get(child)
305
306 if (i == null) {
307 break
308 }
309
310 path.unshift(i)
311 child = parent
312 }
313
314 throw new Error(`Unable to find the path for Editor node: ${Scrubber.stringify(node)}`)
315 },
316
317 /**
318 * Find the DOM node that implements DocumentOrShadowRoot for the editor.

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…