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

Function fromCoordSystem

static/editor.md/lib/codemirror/lib/codemirror.js:2698–2713  ·  view source on GitHub ↗
(cm, coords, context)

Source from the content-addressed store, hash-verified

2696 // Coverts a box from "div" coords to another coordinate system.
2697 // Context may be "window", "page", "div", or "local"/null.
2698 function fromCoordSystem(cm, coords, context) {
2699 if (context == "div") return coords;
2700 var left = coords.left, top = coords.top;
2701 // First move into "page" coordinate system
2702 if (context == "page") {
2703 left -= pageScrollX();
2704 top -= pageScrollY();
2705 } else if (context == "local" || !context) {
2706 var localBox = cm.display.sizer.getBoundingClientRect();
2707 left += localBox.left;
2708 top += localBox.top;
2709 }
2710
2711 var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
2712 return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
2713 }
2714
2715 function charCoords(cm, pos, context, lineObj, bias) {
2716 if (!lineObj) lineObj = getLine(cm.doc, pos.line);

Callers 1

codemirror.jsFile · 0.70

Calls 2

pageScrollXFunction · 0.70
pageScrollYFunction · 0.70

Tested by

no test coverage detected