MCPcopy Create free account
hub / github.com/sql-js/sql.js / filterChange

Function filterChange

GUI/codemirror/lib/codemirror.js:3272–3292  ·  view source on GitHub ↗
(doc, change, update)

Source from the content-addressed store, hash-verified

3270
3271 // Allow "beforeChange" event handlers to influence a change
3272 function filterChange(doc, change, update) {
3273 var obj = {
3274 canceled: false,
3275 from: change.from,
3276 to: change.to,
3277 text: change.text,
3278 origin: change.origin,
3279 cancel: function() { this.canceled = true; }
3280 };
3281 if (update) obj.update = function(from, to, text, origin) {
3282 if (from) this.from = clipPos(doc, from);
3283 if (to) this.to = clipPos(doc, to);
3284 if (text) this.text = text;
3285 if (origin !== undefined) this.origin = origin;
3286 };
3287 signal(doc, "beforeChange", doc, obj);
3288 if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
3289
3290 if (obj.canceled) return null;
3291 return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
3292 }
3293
3294 // Apply a change to a document, and add it to the document's
3295 // history, and propagating it to all linked documents.

Callers 2

makeChangeFunction · 0.85
makeChangeFromHistoryFunction · 0.85

Calls 1

clipPosFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…