Add definitions for CodeMirror's runmode addon

This commit is contained in:
Joseph Vaughan 2015-12-14 13:54:03 +00:00
parent 8ea42cd8bb
commit 8b7eef80b3
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,6 @@
/// <reference path="codemirror.d.ts" />
/// <reference path="codemirror-runmode.d.ts" />
var query = "SELECT * FROM Table";
CodeMirror.runMode(query, "text/x-sql", document.body);

22
codemirror/codemirror-runmode.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
// Type definitions for CodeMirror
// Project: https://github.com/marijnh/CodeMirror
// Definitions by: Joseph Vaughan <https://github.com/Joev->
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// See docs https://codemirror.net/doc/manual.html#addon_runmode
declare module CodeMirror {
/**
* Can be used to run a CodeMirror mode over text without actually opening an editor instance.
*
* @param text The document to run through the highlighter.
* @param mode The mode to use (must be loaded as normal).
* @param output If this is a function, it will be called for each token with
* two arguments, the token's text and the token's style class
* (may be null for unstyled tokens). If it is a DOM node, the
* tokens will be converted to span elements as in an editor,
* and inserted into the node (through innerHTML).
*/
function runMode(text : string, mode : any, output : any): void;
}