MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / walk

Function walk

lib/web/CodeMirror/src/input/ContentEditableInput.js:435–462  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

433 }
434 }
435 function walk(node) {
436 if (node.nodeType == 1) {
437 let cmText = node.getAttribute("cm-text")
438 if (cmText) {
439 addText(cmText)
440 return
441 }
442 let markerID = node.getAttribute("cm-marker"), range
443 if (markerID) {
444 let found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
445 if (found.length && (range = found[0].find(0)))
446 addText(getBetween(cm.doc, range.from, range.to).join(lineSep))
447 return
448 }
449 if (node.getAttribute("contenteditable") == "false") return
450 let isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName)
451 if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) return
452
453 if (isBlock) close()
454 for (let i = 0; i < node.childNodes.length; i++)
455 walk(node.childNodes[i])
456
457 if (/^(pre|p)$/i.test(node.nodeName)) extraLinebreak = true
458 if (isBlock) closing = true
459 } else if (node.nodeType == 3) {
460 addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "))
461 }
462 }
463 for (;;) {
464 walk(from)
465 if (from == to) break

Callers 1

domTextBetweenFunction · 0.70

Calls 9

PosFunction · 0.90
getBetweenFunction · 0.90
replaceMethod · 0.80
addTextFunction · 0.70
recognizeMarkerFunction · 0.70
closeFunction · 0.70
getAttributeMethod · 0.65
findMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected