(doc, change, ignoreReadOnly)
| 48 | // Apply a change to a document, and add it to the document's |
| 49 | // history, and propagating it to all linked documents. |
| 50 | export 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 | |
| 72 | function makeChangeInner(doc, change) { |
| 73 | if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return |
no test coverage detected