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

Function makeChange

static/mergely/lib/codemirror.js:4358–4378  ·  view source on GitHub ↗
(doc, change, ignoreReadOnly)

Source from the content-addressed store, hash-verified

4356 // Apply a change to a document, and add it to the document's
4357 // history, and propagating it to all linked documents.
4358 function makeChange(doc, change, ignoreReadOnly) {
4359 if (doc.cm) {
4360 if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
4361 if (doc.cm.state.suppressEdits) return;
4362 }
4363
4364 if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
4365 change = filterChange(doc, change, true);
4366 if (!change) return;
4367 }
4368
4369 // Possibly split or suppress the update based on the presence
4370 // of read-only spans in its range.
4371 var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
4372 if (split) {
4373 for (var i = split.length - 1; i >= 0; --i)
4374 makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
4375 } else {
4376 makeChangeInner(doc, change);
4377 }
4378 }
4379
4380 function makeChangeInner(doc, change) {
4381 if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;

Callers 4

applyTextInputFunction · 0.70
loadFileFunction · 0.70
replaceRangeFunction · 0.70
codemirror.jsFile · 0.70

Calls 5

operationFunction · 0.70
hasHandlerFunction · 0.70
filterChangeFunction · 0.70
removeReadOnlyRangesFunction · 0.70
makeChangeInnerFunction · 0.70

Tested by

no test coverage detected