(doc, change, update)
| 2326 | } |
| 2327 | |
| 2328 | function filterChange(doc, change, update) { |
| 2329 | var obj = { |
| 2330 | canceled: false, |
| 2331 | from: change.from, |
| 2332 | to: change.to, |
| 2333 | text: change.text, |
| 2334 | origin: change.origin, |
| 2335 | cancel: function() { this.canceled = true; } |
| 2336 | }; |
| 2337 | if (update) obj.update = function(from, to, text, origin) { |
| 2338 | if (from) this.from = clipPos(doc, from); |
| 2339 | if (to) this.to = clipPos(doc, to); |
| 2340 | if (text) this.text = text; |
| 2341 | if (origin !== undefined) this.origin = origin; |
| 2342 | }; |
| 2343 | signal(doc, "beforeChange", doc, obj); |
| 2344 | if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj); |
| 2345 | |
| 2346 | if (obj.canceled) return null; |
| 2347 | return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}; |
| 2348 | } |
| 2349 | |
| 2350 | // Replace the range from from to to by the strings in replacement. |
| 2351 | // change is a {from, to, text [, origin]} object |
no test coverage detected