Skip to content

Commit 5e2aa82

Browse files
committed
Move CodeMirror type definitions
1 parent cc5c241 commit 5e2aa82

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

src/lib/CodeMirror.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,6 @@ import 'codemirror/addon/mode/overlay'
44
import 'codemirror/mode/markdown/markdown'
55
import debounce from 'lodash/debounce'
66

7-
window.CodeMirror = CodeMirror
8-
9-
declare module 'codemirror' {
10-
function autoLoadMode(instance: CodeMirror.Editor, mode: string): void
11-
12-
interface ModeInfo {
13-
name: string
14-
mime?: string
15-
mimes?: string[]
16-
mode: string
17-
ext: string[]
18-
alias?: string[]
19-
}
20-
const modeInfo: ModeInfo[]
21-
22-
interface Editor {
23-
options: CodeMirror.EditorConfiguration
24-
}
25-
26-
function findModeByMIME(mime: string): ModeInfo | undefined
27-
function findModeByName(name: string): ModeInfo | undefined
28-
29-
function runMode(
30-
text: string,
31-
modespec: any,
32-
callback: HTMLElement | ((text: string, style: string | null) => void),
33-
options?: { tabSize?: number; state?: any }
34-
): void
35-
}
36-
377
const dispatchModeLoad = debounce(() => {
388
window.dispatchEvent(new CustomEvent('codemirror-mode-load'))
399
}, 300)

typings/codemirror.d.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1-
declare module 'codemirror/mode/*' {
1+
import CodeMirror from 'codemirror'
22

3+
declare module 'codemirror/mode/*'
4+
5+
declare module 'codemirror' {
6+
function autoLoadMode(instance: CodeMirror.Editor, mode: string): void
7+
8+
interface ModeInfo {
9+
name: string
10+
mime?: string
11+
mimes?: string[]
12+
mode: string
13+
ext: string[]
14+
alias?: string[]
15+
}
16+
const modeInfo: ModeInfo[]
17+
18+
interface Editor {
19+
options: CodeMirror.EditorConfiguration
20+
}
21+
22+
function findModeByMIME(mime: string): ModeInfo | undefined
23+
function findModeByName(name: string): ModeInfo | undefined
24+
25+
function runMode(
26+
text: string,
27+
modespec: any,
28+
callback: HTMLElement | ((text: string, style: string | null) => void),
29+
options?: { tabSize?: number; state?: any }
30+
): void
331
}

0 commit comments

Comments
 (0)