MCPcopy Create free account
hub / github.com/feiyu563/PrometheusAlert / filterChange

Function filterChange

static/plugins/codemirror/codemirror.js:5276–5299  ·  view source on GitHub ↗
(doc, change, update)

Source from the content-addressed store, hash-verified

5274
5275 // Allow "beforeChange" event handlers to influence a change
5276 function filterChange(doc, change, update) {
5277 var obj = {
5278 canceled: false,
5279 from: change.from,
5280 to: change.to,
5281 text: change.text,
5282 origin: change.origin,
5283 cancel: function () { return obj.canceled = true; }
5284 };
5285 if (update) { obj.update = function (from, to, text, origin) {
5286 if (from) { obj.from = clipPos(doc, from); }
5287 if (to) { obj.to = clipPos(doc, to); }
5288 if (text) { obj.text = text; }
5289 if (origin !== undefined) { obj.origin = origin; }
5290 }; }
5291 signal(doc, "beforeChange", doc, obj);
5292 if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); }
5293
5294 if (obj.canceled) {
5295 if (doc.cm) { doc.cm.curOp.updateInput = 2; }
5296 return null
5297 }
5298 return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
5299 }
5300
5301 // Apply a change to a document, and add it to the document's
5302 // history, and propagating it to all linked documents.

Callers 2

makeChangeFunction · 0.85
loopFunction · 0.85

Calls 2

clipPosFunction · 0.85
signalFunction · 0.85

Tested by

no test coverage detected