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

Function makeChange

static/editor.md/lib/codemirror/lib/codemirror.js:4179–4199  ·  view source on GitHub ↗
(doc, change, ignoreReadOnly)

Source from the content-addressed store, hash-verified

4177 // Apply a change to a document, and add it to the document's
4178 // history, and propagating it to all linked documents.
4179 function makeChange(doc, change, ignoreReadOnly) {
4180 if (doc.cm) {
4181 if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
4182 if (doc.cm.state.suppressEdits) return;
4183 }
4184
4185 if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
4186 change = filterChange(doc, change, true);
4187 if (!change) return;
4188 }
4189
4190 // Possibly split or suppress the update based on the presence
4191 // of read-only spans in its range.
4192 var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
4193 if (split) {
4194 for (var i = split.length - 1; i >= 0; --i)
4195 makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
4196 } else {
4197 makeChangeInner(doc, change);
4198 }
4199 }
4200
4201 function makeChangeInner(doc, change) {
4202 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