|
8 | 8 | // ysulyma <https://github.com/ysulyma>
|
9 | 9 | // azoson <https://github.com/azoson>
|
10 | 10 | // kylesferrazza <https://github.com/kylesferrazza>
|
| 11 | +// fityocsaba96 <https://github.com/fityocsaba96> |
11 | 12 | // koddsson <https://github.com/koddsson>
|
12 | 13 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
13 | 14 | // TypeScript Version: 3.2
|
@@ -112,16 +113,8 @@ declare namespace CodeMirror {
|
112 | 113 | function off(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void;
|
113 | 114 |
|
114 | 115 | /** Equivalent to the event by the same name as fired on editor instances. */
|
115 |
| - function on( |
116 |
| - doc: Doc, |
117 |
| - eventName: 'beforeSelectionChange', |
118 |
| - handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position }) => void, |
119 |
| - ): void; |
120 |
| - function off( |
121 |
| - doc: Doc, |
122 |
| - eventName: 'beforeSelectionChange', |
123 |
| - handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position }) => void, |
124 |
| - ): void; |
| 116 | + function on(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void ): void; |
| 117 | + function off(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void ): void; |
125 | 118 |
|
126 | 119 | /** Will be fired when the line object is deleted. A line object is associated with the start of the line.
|
127 | 120 | Mostly useful when you need to find out when your gutter markers on a given line are removed. */
|
@@ -467,6 +460,9 @@ declare namespace CodeMirror {
|
467 | 460 | /** Tells you whether the editor's content can be edited by the user. */
|
468 | 461 | isReadOnly(): boolean;
|
469 | 462 |
|
| 463 | + /** Returns the preferred line separator string for this document, as per the option by the same name. When that option is null, the string "\n" is returned. */ |
| 464 | + lineSeparator(): string; |
| 465 | + |
470 | 466 | /** Switches between overwrite and normal insert mode (when not given an argument),
|
471 | 467 | or sets the overwrite mode to a specific state (when given an argument). */
|
472 | 468 | toggleOverwrite(value?: boolean): void;
|
@@ -550,20 +546,8 @@ declare namespace CodeMirror {
|
550 | 546 |
|
551 | 547 | /** This event is fired before the selection is moved. Its handler may modify the resulting selection head and anchor.
|
552 | 548 | Handlers for this event have the same restriction as "beforeChange" handlers they should not do anything to directly update the state of the editor. */
|
553 |
| - on( |
554 |
| - eventName: 'beforeSelectionChange', |
555 |
| - handler: ( |
556 |
| - instance: CodeMirror.Editor, |
557 |
| - selection: { head: CodeMirror.Position; anchor: CodeMirror.Position }, |
558 |
| - ) => void, |
559 |
| - ): void; |
560 |
| - off( |
561 |
| - eventName: 'beforeSelectionChange', |
562 |
| - handler: ( |
563 |
| - instance: CodeMirror.Editor, |
564 |
| - selection: { head: CodeMirror.Position; anchor: CodeMirror.Position }, |
565 |
| - ) => void, |
566 |
| - ): void; |
| 549 | + on(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void ): void; |
| 550 | + off(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, obj: EditorSelectionChange) => void ): void; |
567 | 551 |
|
568 | 552 | /** Fires whenever the view port of the editor changes (due to scrolling, editing, or any other factor).
|
569 | 553 | The from and to arguments give the new start and end of the viewport. */
|
@@ -706,7 +690,7 @@ declare namespace CodeMirror {
|
706 | 690 |
|
707 | 691 | /** Replace the part of the document between from and to with the given string.
|
708 | 692 | from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. */
|
709 |
| - replaceRange(replacement: string, from: CodeMirror.Position, to?: CodeMirror.Position, origin?: string): void; |
| 693 | + replaceRange(replacement: string | string[], from: CodeMirror.Position, to?: CodeMirror.Position, origin?: string): void; |
710 | 694 |
|
711 | 695 | /** Get the content of line n. */
|
712 | 696 | getLine(n: number): string;
|
@@ -774,7 +758,7 @@ declare namespace CodeMirror {
|
774 | 758 |
|
775 | 759 | /** Retrieves a list of all current selections. These will always be sorted, and never overlap (overlapping selections are merged).
|
776 | 760 | Each object in the array contains anchor and head properties referring to {line, ch} objects. */
|
777 |
| - listSelections(): { anchor: CodeMirror.Position; head: CodeMirror.Position }[]; |
| 761 | + listSelections(): Range[]; |
778 | 762 |
|
779 | 763 | /** Return true if any text is selected. */
|
780 | 764 | somethingSelected(): boolean;
|
@@ -976,11 +960,11 @@ declare namespace CodeMirror {
|
976 | 960 | above?: boolean;
|
977 | 961 | /** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */
|
978 | 962 | showIfHidden?: boolean;
|
979 |
| - /** Determines whether the editor will capture mouse and drag events occurring in this widget. |
| 963 | + /** Determines whether the editor will capture mouse and drag events occurring in this widget. |
980 | 964 | Default is false—the events will be left alone for the default browser handler, or specific handlers on the widget, to capture. */
|
981 | 965 | handleMouseEvents?: boolean;
|
982 |
| - /** By default, the widget is added below other widgets for the line. |
983 |
| - This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget). |
| 966 | + /** By default, the widget is added below other widgets for the line. |
| 967 | + This option can be used to place it at a different position (zero for the top, N to put it after the Nth other widget). |
984 | 968 | Note that this only has effect once, when the widget is created. */
|
985 | 969 | insertAt?: number;
|
986 | 970 | /** Add an extra CSS class name to the wrapper element created for the widget. */
|
@@ -1018,11 +1002,18 @@ declare namespace CodeMirror {
|
1018 | 1002 | (line: number, ch?: number, sticky?: string): Position;
|
1019 | 1003 | }
|
1020 | 1004 |
|
| 1005 | + interface EditorSelectionChange { |
| 1006 | + ranges: Range[]; |
| 1007 | + update(ranges: Range[]): void; |
| 1008 | + origin?: string; |
| 1009 | + } |
| 1010 | + |
1021 | 1011 | interface Range {
|
1022 | 1012 | anchor: CodeMirror.Position;
|
1023 | 1013 | head: CodeMirror.Position;
|
1024 | 1014 | from(): CodeMirror.Position;
|
1025 | 1015 | to(): CodeMirror.Position;
|
| 1016 | + empty(): boolean; |
1026 | 1017 | }
|
1027 | 1018 |
|
1028 | 1019 | interface Position {
|
@@ -1125,12 +1116,21 @@ declare namespace CodeMirror {
|
1125 | 1116 | /** boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed. */
|
1126 | 1117 | readOnly?: any;
|
1127 | 1118 |
|
| 1119 | + /** This label is read by the screenreaders when CodeMirror text area is focused. This is helpful for accessibility. */ |
| 1120 | + screenReaderLabel?: string; |
| 1121 | + |
1128 | 1122 | /**Whether the cursor should be drawn when a selection is active. Defaults to false. */
|
1129 | 1123 | showCursorWhenSelecting?: boolean;
|
1130 | 1124 |
|
1131 | 1125 | /** When enabled, which is the default, doing copy or cut when there is no selection will copy or cut the whole lines that have cursors on them. */
|
1132 | 1126 | lineWiseCopyCut?: boolean;
|
1133 | 1127 |
|
| 1128 | + /** When pasting something from an external source (not from the editor itself), if the number of lines matches the number of selection, CodeMirror will by default insert one line per selection. You can set this to false to disable that behavior. */ |
| 1129 | + pasteLinesPerSelection?: boolean; |
| 1130 | + |
| 1131 | + /** Determines whether multiple selections are joined as soon as they touch (the default) or only when they overlap (true). */ |
| 1132 | + selectionsMayTouch?: boolean; |
| 1133 | + |
1134 | 1134 | /** The maximum number of undo levels that the editor stores. Defaults to 40. */
|
1135 | 1135 | undoDepth?: number;
|
1136 | 1136 |
|
|
0 commit comments