Move CodeMirror type definitions

This commit is contained in:
Junyoung Choi 2019-09-24 10:25:53 +09:00
parent cc5c24194e
commit 5e2aa82f99
No known key found for this signature in database
GPG Key ID: C1B25CE98BF97FBF
2 changed files with 29 additions and 31 deletions

View File

@ -4,36 +4,6 @@ import 'codemirror/addon/mode/overlay'
import 'codemirror/mode/markdown/markdown'
import debounce from 'lodash/debounce'
window.CodeMirror = CodeMirror
declare module 'codemirror' {
function autoLoadMode(instance: CodeMirror.Editor, mode: string): void
interface ModeInfo {
name: string
mime?: string
mimes?: string[]
mode: string
ext: string[]
alias?: string[]
}
const modeInfo: ModeInfo[]
interface Editor {
options: CodeMirror.EditorConfiguration
}
function findModeByMIME(mime: string): ModeInfo | undefined
function findModeByName(name: string): ModeInfo | undefined
function runMode(
text: string,
modespec: any,
callback: HTMLElement | ((text: string, style: string | null) => void),
options?: { tabSize?: number; state?: any }
): void
}
const dispatchModeLoad = debounce(() => {
window.dispatchEvent(new CustomEvent('codemirror-mode-load'))
}, 300)

View File

@ -1,3 +1,31 @@
declare module 'codemirror/mode/*' {
import CodeMirror from 'codemirror'
declare module 'codemirror/mode/*'
declare module 'codemirror' {
function autoLoadMode(instance: CodeMirror.Editor, mode: string): void
interface ModeInfo {
name: string
mime?: string
mimes?: string[]
mode: string
ext: string[]
alias?: string[]
}
const modeInfo: ModeInfo[]
interface Editor {
options: CodeMirror.EditorConfiguration
}
function findModeByMIME(mime: string): ModeInfo | undefined
function findModeByName(name: string): ModeInfo | undefined
function runMode(
text: string,
modespec: any,
callback: HTMLElement | ((text: string, style: string | null) => void),
options?: { tabSize?: number; state?: any }
): void
}