MCPcopy Index your code
hub / github.com/TruthHun/BookStack / buildLineContent

Function buildLineContent

static/mergely/lib/codemirror.js:6915–6967  ·  view source on GitHub ↗
(cm, lineView)

Source from the content-addressed store, hash-verified

6913 // The returned object contains the DOM node, this map, and
6914 // information about line-wide styles that were set by the mode.
6915 function buildLineContent(cm, lineView) {
6916 // The padding-right forces the element to have a 'border', which
6917 // is needed on Webkit to be able to get line-level bounding
6918 // rectangles for it (in measureChar).
6919 var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
6920 var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
6921 col: 0, pos: 0, cm: cm,
6922 splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
6923 lineView.measure = {};
6924
6925 // Iterate over the logical lines that make up this visual line.
6926 for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
6927 var line = i ? lineView.rest[i - 1] : lineView.line, order;
6928 builder.pos = 0;
6929 builder.addToken = buildToken;
6930 // Optionally wire in some hacks into the token-rendering
6931 // algorithm, to deal with browser quirks.
6932 if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
6933 builder.addToken = buildTokenBadBidi(builder.addToken, order);
6934 builder.map = [];
6935 var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
6936 insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
6937 if (line.styleClasses) {
6938 if (line.styleClasses.bgClass)
6939 builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
6940 if (line.styleClasses.textClass)
6941 builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
6942 }
6943
6944 // Ensure at least a single node is present, for measuring.
6945 if (builder.map.length == 0)
6946 builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
6947
6948 // Store the map and a cache object for the current logical line
6949 if (i == 0) {
6950 lineView.measure.map = builder.map;
6951 lineView.measure.cache = {};
6952 } else {
6953 (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
6954 (lineView.measure.caches || (lineView.measure.caches = [])).push({});
6955 }
6956 }
6957
6958 // See issue #2901
6959 if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className))
6960 builder.content.className = "cm-tab-wrap-hack";
6961
6962 signal(cm, "renderLine", cm, lineView.line, builder.pre);
6963 if (builder.pre.className)
6964 builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
6965
6966 return builder;
6967 }
6968
6969 function defaultSpecialCharPlaceholder(ch) {
6970 var token = elt("span", "\u2022", "cm-invalidchar");

Callers 2

getLineContentFunction · 0.70

Calls 9

eltFunction · 0.70
hasBadBidiRectsFunction · 0.70
getOrderFunction · 0.70
buildTokenBadBidiFunction · 0.70
lineNoFunction · 0.70
insertLineContentFunction · 0.70
getLineStylesFunction · 0.70
joinClassesFunction · 0.70
zeroWidthElementFunction · 0.70

Tested by

no test coverage detected