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

Function Display

static/editor.md/lib/codemirror/lib/codemirror.js:130–226  ·  view source on GitHub ↗
(place, doc, input)

Source from the content-addressed store, hash-verified

128 // display-related state.
129
130 function Display(place, doc, input) {
131 var d = this;
132 this.input = input;
133
134 // Covers bottom-right square when both scrollbars are present.
135 d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
136 d.scrollbarFiller.setAttribute("cm-not-content", "true");
137 // Covers bottom of gutter when coverGutterNextToScrollbar is on
138 // and h scrollbar is present.
139 d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
140 d.gutterFiller.setAttribute("cm-not-content", "true");
141 // Will contain the actual code, positioned to cover the viewport.
142 d.lineDiv = elt("div", null, "CodeMirror-code");
143 // Elements are added to these to represent selection and cursors.
144 d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
145 d.cursorDiv = elt("div", null, "CodeMirror-cursors");
146 // A visibility: hidden element used to find the size of things.
147 d.measure = elt("div", null, "CodeMirror-measure");
148 // When lines outside of the viewport are measured, they are drawn in this.
149 d.lineMeasure = elt("div", null, "CodeMirror-measure");
150 // Wraps everything that needs to exist inside the vertically-padded coordinate system
151 d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
152 null, "position: relative; outline: none");
153 // Moved around its parent to cover visible view.
154 d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
155 // Set to the height of the document, allowing scrolling.
156 d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
157 d.sizerWidth = null;
158 // Behavior of elts with overflow: auto and padding is
159 // inconsistent across browsers. This is used to ensure the
160 // scrollable area is big enough.
161 d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
162 // Will contain the gutters, if any.
163 d.gutters = elt("div", null, "CodeMirror-gutters");
164 d.lineGutter = null;
165 // Actual scrollable element.
166 d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
167 d.scroller.setAttribute("tabIndex", "-1");
168 // The element in which the editor lives.
169 d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
170
171 // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
172 if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
173 if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
174
175 if (place) {
176 if (place.appendChild) place.appendChild(d.wrapper);
177 else place(d.wrapper);
178 }
179
180 // Current rendered range (may be bigger than the view window).
181 d.viewFrom = d.viewTo = doc.first;
182 d.reportedViewFrom = d.reportedViewTo = doc.first;
183 // Information about the rendered lines.
184 d.view = [];
185 d.renderedView = null;
186 // Holds info about a single rendered line when it was rendered
187 // for measurement, while not in view.

Callers

nothing calls this directly

Calls 2

eltFunction · 0.70
setAttributeMethod · 0.45

Tested by

no test coverage detected