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

Function textHeight

static/editor.md/lib/codemirror/lib/codemirror.js:2841–2858  ·  view source on GitHub ↗
(display)

Source from the content-addressed store, hash-verified

2839 var measureText;
2840 // Compute the default text height.
2841 function textHeight(display) {
2842 if (display.cachedTextHeight != null) return display.cachedTextHeight;
2843 if (measureText == null) {
2844 measureText = elt("pre");
2845 // Measure a bunch of lines, for browsers that compute
2846 // fractional heights.
2847 for (var i = 0; i < 49; ++i) {
2848 measureText.appendChild(document.createTextNode("x"));
2849 measureText.appendChild(elt("br"));
2850 }
2851 measureText.appendChild(document.createTextNode("x"));
2852 }
2853 removeChildrenAndAdd(display.measure, measureText);
2854 var height = measureText.offsetHeight / 50;
2855 if (height > 3) display.cachedTextHeight = height;
2856 removeChildren(display.measure);
2857 return height || 1;
2858 }
2859
2860 // Compute the default character width.
2861 function charWidth(display) {

Callers 5

estimateHeightFunction · 0.70
updateHeightsInViewportFunction · 0.70
calculateScrollPosFunction · 0.70
findPosVFunction · 0.70
codemirror.jsFile · 0.70

Calls 3

eltFunction · 0.70
removeChildrenAndAddFunction · 0.70
removeChildrenFunction · 0.70

Tested by

no test coverage detected