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

Function ensureLineHeights

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

Source from the content-addressed store, hash-verified

2535 // line. When lineWrapping is on, there might be more than one
2536 // height.
2537 function ensureLineHeights(cm, lineView, rect) {
2538 var wrapping = cm.options.lineWrapping;
2539 var curWidth = wrapping && displayWidth(cm);
2540 if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
2541 var heights = lineView.measure.heights = [];
2542 if (wrapping) {
2543 lineView.measure.width = curWidth;
2544 var rects = lineView.text.firstChild.getClientRects();
2545 for (var i = 0; i < rects.length - 1; i++) {
2546 var cur = rects[i], next = rects[i + 1];
2547 if (Math.abs(cur.bottom - next.bottom) > 2)
2548 heights.push((cur.bottom + next.top) / 2 - rect.top);
2549 }
2550 }
2551 heights.push(rect.bottom - rect.top);
2552 }
2553 }
2554
2555 // Find a line map (mapping character offsets to text nodes) and a
2556 // measurement cache for the given line number. (A line view might

Callers 1

measureCharPreparedFunction · 0.70

Calls 1

displayWidthFunction · 0.70

Tested by

no test coverage detected