From 84e67a17f6e9e29024a39144de3bdbf6b42e4ca9 Mon Sep 17 00:00:00 2001 From: Josh Abernathy Date: Mon, 14 Aug 2017 14:14:05 -0400 Subject: [PATCH] Add CodeMirror DOM events (#18824) * Support the 'copy' event * Make it generic over DOM events --- types/codemirror/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 65696db739..960f293656 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -102,6 +102,8 @@ declare namespace CodeMirror { To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. */ function signal(target: any, name: string, ...args: any[]): void; + type DOMEvent = 'mousedown' | 'dblclick' | 'touchstart' | 'contextmenu' | 'keydown' | 'keypress' | 'keyup' | 'cut' | 'copy' | 'paste' | 'dragstart' | 'dragenter' | 'dragover' | 'dragleave' | 'drop'; + interface Editor { /** Tells you whether the editor currently has focus. */ @@ -405,6 +407,10 @@ declare namespace CodeMirror { on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void; off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void; + /** Fires when one of the DOM events fires. */ + on(eventName: DOMEvent, handler: (instance: CodeMirror.Editor, event: Event) => void ): void; + off(eventName: DOMEvent, handler: (instance: CodeMirror.Editor, event: Event) => void ): void; + /** Expose the state object, so that the Editor.state.completionActive property is reachable*/ state: any; }