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

Function walk

static/editor.md/lib/codemirror/lib/codemirror.js:1870–1899  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

1868 var text = "", closing = false;
1869 function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
1870 function walk(node) {
1871 if (node.nodeType == 1) {
1872 var cmText = node.getAttribute("cm-text");
1873 if (cmText != null) {
1874 if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
1875 text += cmText;
1876 return;
1877 }
1878 var markerID = node.getAttribute("cm-marker"), range;
1879 if (markerID) {
1880 var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
1881 if (found.length && (range = found[0].find()))
1882 text += getBetween(cm.doc, range.from, range.to).join("\n");
1883 return;
1884 }
1885 if (node.getAttribute("contenteditable") == "false") return;
1886 for (var i = 0; i < node.childNodes.length; i++)
1887 walk(node.childNodes[i]);
1888 if (/^(pre|div|p)$/i.test(node.nodeName))
1889 closing = true;
1890 } else if (node.nodeType == 3) {
1891 var val = node.nodeValue;
1892 if (!val) return;
1893 if (closing) {
1894 text += "\n";
1895 closing = false;
1896 }
1897 text += val;
1898 }
1899 }
1900 for (;;) {
1901 walk(from);
1902 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