MCPcopy Create free account
hub / github.com/TruthHun/BookStack / walk

Function walk

static/mergely/lib/codemirror.js:1966–1995  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

1964 var text = "", closing = false, lineSep = cm.doc.lineSeparator();
1965 function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
1966 function walk(node) {
1967 if (node.nodeType == 1) {
1968 var cmText = node.getAttribute("cm-text");
1969 if (cmText != null) {
1970 if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
1971 text += cmText;
1972 return;
1973 }
1974 var markerID = node.getAttribute("cm-marker"), range;
1975 if (markerID) {
1976 var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
1977 if (found.length && (range = found[0].find()))
1978 text += getBetween(cm.doc, range.from, range.to).join(lineSep);
1979 return;
1980 }
1981 if (node.getAttribute("contenteditable") == "false") return;
1982 for (var i = 0; i < node.childNodes.length; i++)
1983 walk(node.childNodes[i]);
1984 if (/^(pre|div|p)$/i.test(node.nodeName))
1985 closing = true;
1986 } else if (node.nodeType == 3) {
1987 var val = node.nodeValue;
1988 if (!val) return;
1989 if (closing) {
1990 text += lineSep;
1991 closing = false;
1992 }
1993 text += val;
1994 }
1995 }
1996 for (;;) {
1997 walk(from);
1998 if (from == to) break;

Callers 1

domTextBetweenFunction · 0.70

Calls 3

getAttributeMethod · 0.80
recognizeMarkerFunction · 0.70
getBetweenFunction · 0.70

Tested by

no test coverage detected