mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add getLineTokens method
This commit is contained in:
parent
62cadd0386
commit
54cf4c673b
33
types/codemirror/index.d.ts
vendored
33
types/codemirror/index.d.ts
vendored
@ -1,6 +1,7 @@
|
||||
// Type definitions for CodeMirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: mihailik <https://github.com/mihailik>
|
||||
// nrbernard <https://github.com/nrbernard>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = CodeMirror;
|
||||
@ -104,6 +105,19 @@ declare namespace CodeMirror {
|
||||
|
||||
type DOMEvent = 'mousedown' | 'dblclick' | 'touchstart' | 'contextmenu' | 'keydown' | 'keypress' | 'keyup' | 'cut' | 'copy' | 'paste' | 'dragstart' | 'dragenter' | 'dragover' | 'dragleave' | 'drop';
|
||||
|
||||
interface Token {
|
||||
/** The character(on the given line) at which the token starts. */
|
||||
start: number;
|
||||
/** The character at which the token ends. */
|
||||
end: number;
|
||||
/** The token's string. */
|
||||
string: string;
|
||||
/** The token type the mode assigned to the token, such as "keyword" or "comment" (may also be null). */
|
||||
type: string | null;
|
||||
/** The mode's state at the end of this token. */
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
|
||||
/** Tells you whether the editor currently has focus. */
|
||||
@ -289,20 +303,11 @@ declare namespace CodeMirror {
|
||||
you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */
|
||||
refresh(): void;
|
||||
|
||||
|
||||
/** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */
|
||||
getTokenAt(pos: CodeMirror.Position): {
|
||||
/** The character(on the given line) at which the token starts. */
|
||||
start: number;
|
||||
/** The character at which the token ends. */
|
||||
end: number;
|
||||
/** The token's string. */
|
||||
string: string;
|
||||
/** The token type the mode assigned to the token, such as "keyword" or "comment" (may also be null). */
|
||||
type: string | null;
|
||||
/** The mode's state at the end of this token. */
|
||||
state: any;
|
||||
};
|
||||
getTokenAt(pos: CodeMirror.Position): Token;
|
||||
|
||||
/** This is similar to getTokenAt, but collects all tokens for a given line into an array. */
|
||||
getLineTokens(line: number, precise?: boolean): Token[];
|
||||
|
||||
/** Returns the mode's parser state, if any, at the end of the given line number.
|
||||
If no line number is given, the state at the end of the document is returned.
|
||||
@ -410,7 +415,7 @@ declare namespace CodeMirror {
|
||||
/** 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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user