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

Function charWidth

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

Source from the content-addressed store, hash-verified

2859
2860 // Compute the default character width.
2861 function charWidth(display) {
2862 if (display.cachedCharWidth != null) return display.cachedCharWidth;
2863 var anchor = elt("span", "xxxxxxxxxx");
2864 var pre = elt("pre", [anchor]);
2865 removeChildrenAndAdd(display.measure, pre);
2866 var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
2867 if (width > 2) display.cachedCharWidth = width;
2868 return width || 10;
2869 }
2870
2871 // OPERATIONS
2872

Callers 5

estimateHeightFunction · 0.70
measureCharInnerFunction · 0.70
estimateCoordsFunction · 0.70
posFromMouseFunction · 0.70
codemirror.jsFile · 0.70

Calls 2

eltFunction · 0.70
removeChildrenAndAddFunction · 0.70

Tested by

no test coverage detected