MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / makeChange

Function makeChange

lib/web/CodeMirror/src/model/changes.js:50–70  ·  view source on GitHub ↗
(doc, change, ignoreReadOnly)

Source from the content-addressed store, hash-verified

48// Apply a change to a document, and add it to the document's
49// history, and propagating it to all linked documents.
50export function makeChange(doc, change, ignoreReadOnly) {
51 if (doc.cm) {
52 if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly)
53 if (doc.cm.state.suppressEdits) return
54 }
55
56 if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
57 change = filterChange(doc, change, true)
58 if (!change) return
59 }
60
61 // Possibly split or suppress the update based on the presence
62 // of read-only spans in its range.
63 let split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
64 if (split) {
65 for (let i = split.length - 1; i >= 0; --i)
66 makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin})
67 } else {
68 makeChangeInner(doc, change)
69 }
70}
71
72function makeChangeInner(doc, change) {
73 if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return

Callers 4

Doc.jsFile · 0.90
applyTextInputFunction · 0.90
replaceRangeFunction · 0.70

Calls 5

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

Tested by

no test coverage detected