UNPKG

2.53 kBTypeScriptView Raw
1import '../../';
2
3declare module '../../' {
4 interface Editor {
5 /** Tries to uncomment the current selection, and if that fails, line-comments it. */
6 toggleComment(options?: CommentOptions): void;
7 /** Set the lines in the given range to be line comments. Will fall back to `blockComment` when no line comment style is defined for the mode. */
8 lineComment(from: Position, to: Position, options?: CommentOptions): void;
9 /** Wrap the code in the given range in a block comment. Will fall back to `lineComment` when no block comment style is defined for the mode. */
10 blockComment(from: Position, to: Position, options?: CommentOptions): void;
11 /** Try to uncomment the given range. Returns `true` if a comment range was found and removed, `false` otherwise. */
12 uncomment(from: Position, to: Position, options?: CommentOptions): boolean;
13 }
14
15 interface CommentOptions {
16 /** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
17 blockCommentStart?: string | undefined;
18 /** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
19 blockCommentEnd?: string | undefined;
20 /** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
21 blockCommentLead?: string | undefined;
22 /** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
23 lineComment?: string | undefined;
24 /** A string that will be inserted after opening and leading markers, and before closing comment markers. Defaults to a single space. */
25 padding?: string | null | undefined;
26 /** Whether, when adding line comments, to also comment lines that contain only whitespace. */
27 commentBlankLines?: boolean | undefined;
28 /** When adding line comments and this is turned on, it will align the comment block to the current indentation of the first line of the block. */
29 indent?: boolean | undefined;
30 /** When block commenting, this controls whether the whole lines are indented, or only the precise range that is given. Defaults to `true`. */
31 fullLines?: boolean | undefined;
32 }
33
34 interface CommandActions {
35 toggleComment(cm: Editor): void;
36 }
37}