mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
codemirror: EditorChangeCancellable.update is undefined for changes
coming from undo/redo.
This commit is contained in:
5
types/codemirror/index.d.ts
vendored
5
types/codemirror/index.d.ts
vendored
@@ -716,8 +716,9 @@ declare namespace CodeMirror {
|
||||
}
|
||||
|
||||
interface EditorChangeCancellable extends CodeMirror.EditorChange {
|
||||
/** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */
|
||||
update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void;
|
||||
/** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact.
|
||||
If the change came from undo/redo, `update` is undefined and the change cannot be modified. */
|
||||
update?(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void;
|
||||
|
||||
cancel(): void;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,15 @@ myCodeMirror.on(
|
||||
(instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => { }
|
||||
);
|
||||
|
||||
myCodeMirror.on(
|
||||
"beforeChange",
|
||||
(instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => {
|
||||
// $ExpectError
|
||||
change.update();
|
||||
if (change.update != null) change.update();
|
||||
}
|
||||
);
|
||||
|
||||
CodeMirror.registerHelper("lint", "javascript", {});
|
||||
|
||||
myCodeMirror.isReadOnly();
|
||||
|
||||
Reference in New Issue
Block a user