Skip to content

Commit

Permalink
Move CodeMirror type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rokt33r committed Sep 24, 2019
1 parent cc5c241 commit 5e2aa82
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
30 changes: 0 additions & 30 deletions src/lib/CodeMirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 29 additions & 1 deletion typings/codemirror.d.ts
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 5e2aa82

Please sign in to comment.