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

Function intoCoordSystem

static/editor.md/lib/codemirror/lib/codemirror.js:2676–2694  ·  view source on GitHub ↗
(cm, lineObj, rect, context)

Source from the content-addressed store, hash-verified

2674 // "line", "div" (display.lineDiv), "local"/null (editor), "window",
2675 // or "page".
2676 function intoCoordSystem(cm, lineObj, rect, context) {
2677 if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
2678 var size = widgetHeight(lineObj.widgets[i]);
2679 rect.top += size; rect.bottom += size;
2680 }
2681 if (context == "line") return rect;
2682 if (!context) context = "local";
2683 var yOff = heightAtLine(lineObj);
2684 if (context == "local") yOff += paddingTop(cm.display);
2685 else yOff -= cm.display.viewOffset;
2686 if (context == "page" || context == "window") {
2687 var lOff = cm.display.lineSpace.getBoundingClientRect();
2688 yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
2689 var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
2690 rect.left += xOff; rect.right += xOff;
2691 }
2692 rect.top += yOff; rect.bottom += yOff;
2693 return rect;
2694 }
2695
2696 // Coverts a box from "div" coords to another coordinate system.
2697 // Context may be "window", "page", "div", or "local"/null.

Callers 3

charCoordsFunction · 0.70
getFunction · 0.70
codemirror.jsFile · 0.70

Calls 5

widgetHeightFunction · 0.70
heightAtLineFunction · 0.70
paddingTopFunction · 0.70
pageScrollYFunction · 0.70
pageScrollXFunction · 0.70

Tested by

no test coverage detected