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

Function makeChangeSingleDoc

static/editor.md/lib/codemirror/lib/codemirror.js:4301–4330  ·  view source on GitHub ↗
(doc, change, selAfter, spans)

Source from the content-addressed store, hash-verified

4299 // More lower-level change function, handling only a single document
4300 // (not linked ones).
4301 function makeChangeSingleDoc(doc, change, selAfter, spans) {
4302 if (doc.cm && !doc.cm.curOp)
4303 return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
4304
4305 if (change.to.line < doc.first) {
4306 shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
4307 return;
4308 }
4309 if (change.from.line > doc.lastLine()) return;
4310
4311 // Clip the change to the size of this doc
4312 if (change.from.line < doc.first) {
4313 var shift = change.text.length - 1 - (doc.first - change.from.line);
4314 shiftDoc(doc, shift);
4315 change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
4316 text: [lst(change.text)], origin: change.origin};
4317 }
4318 var last = doc.lastLine();
4319 if (change.to.line > last) {
4320 change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
4321 text: [change.text[0]], origin: change.origin};
4322 }
4323
4324 change.removed = getBetween(doc, change.from, change.to);
4325
4326 if (!selAfter) selAfter = computeSelAfterChange(doc, change);
4327 if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
4328 else updateDoc(doc, change, spans);
4329 setSelectionNoUndo(doc, selAfter, sel_dontScroll);
4330 }
4331
4332 // Handle the interaction of a change to a document with the editor
4333 // that this document is part of.

Callers 2

makeChangeInnerFunction · 0.70
makeChangeFromHistoryFunction · 0.70

Calls 9

operationFunction · 0.70
shiftDocFunction · 0.70
lstFunction · 0.70
getLineFunction · 0.70
getBetweenFunction · 0.70
computeSelAfterChangeFunction · 0.70
updateDocFunction · 0.70
setSelectionNoUndoFunction · 0.70

Tested by

no test coverage detected