@codemirror/view 6.16.0 → 6.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +659 -414
- package/dist/index.d.cts +100 -64
- package/dist/index.d.ts +100 -64
- package/dist/index.js +660 -413
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,47 @@ import * as _codemirror_state from '@codemirror/state';
|
|
|
2
2
|
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, EditorStateConfig, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
3
3
|
import { StyleModule, StyleSpec } from 'style-mod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
7
|
+
*/
|
|
8
|
+
declare enum Direction {
|
|
9
|
+
/**
|
|
10
|
+
Left-to-right.
|
|
11
|
+
*/
|
|
12
|
+
LTR = 0,
|
|
13
|
+
/**
|
|
14
|
+
Right-to-left.
|
|
15
|
+
*/
|
|
16
|
+
RTL = 1
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
Represents a contiguous range of text that has a single direction
|
|
20
|
+
(as in left-to-right or right-to-left).
|
|
21
|
+
*/
|
|
22
|
+
declare class BidiSpan {
|
|
23
|
+
/**
|
|
24
|
+
The start of the span (relative to the start of the line).
|
|
25
|
+
*/
|
|
26
|
+
readonly from: number;
|
|
27
|
+
/**
|
|
28
|
+
The end of the span.
|
|
29
|
+
*/
|
|
30
|
+
readonly to: number;
|
|
31
|
+
/**
|
|
32
|
+
The ["bidi
|
|
33
|
+
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
34
|
+
of the span (in this context, 0 means
|
|
35
|
+
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
36
|
+
number inside right-to-left text).
|
|
37
|
+
*/
|
|
38
|
+
readonly level: number;
|
|
39
|
+
/**
|
|
40
|
+
The direction of this span.
|
|
41
|
+
*/
|
|
42
|
+
get dir(): Direction;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type Attrs = {
|
|
6
46
|
[name: string]: string;
|
|
7
47
|
};
|
|
8
48
|
|
|
@@ -15,7 +55,7 @@ interface Rect {
|
|
|
15
55
|
readonly top: number;
|
|
16
56
|
readonly bottom: number;
|
|
17
57
|
}
|
|
18
|
-
|
|
58
|
+
type ScrollStrategy = "nearest" | "start" | "end" | "center";
|
|
19
59
|
|
|
20
60
|
interface MarkDecorationSpec {
|
|
21
61
|
/**
|
|
@@ -53,6 +93,12 @@ interface MarkDecorationSpec {
|
|
|
53
93
|
*/
|
|
54
94
|
tagName?: string;
|
|
55
95
|
/**
|
|
96
|
+
When using sets of decorations in
|
|
97
|
+
[`bidiIsolatedRanges`](https://codemirror.net/6/docs/ref/##view.EditorView^bidiIsolatedRanges),
|
|
98
|
+
this property provides the direction of the isolates.
|
|
99
|
+
*/
|
|
100
|
+
bidiIsolate?: Direction;
|
|
101
|
+
/**
|
|
56
102
|
Decoration specs allow extra properties, which can be retrieved
|
|
57
103
|
through the decoration's [`spec`](https://codemirror.net/6/docs/ref/#view.Decoration.spec)
|
|
58
104
|
property.
|
|
@@ -215,7 +261,7 @@ A decoration set represents a collection of decorated ranges,
|
|
|
215
261
|
organized for efficient access and mapping. See
|
|
216
262
|
[`RangeSet`](https://codemirror.net/6/docs/ref/#state.RangeSet) for its methods.
|
|
217
263
|
*/
|
|
218
|
-
|
|
264
|
+
type DecorationSet = RangeSet<Decoration>;
|
|
219
265
|
/**
|
|
220
266
|
The different types of blocks that can occur in an editor view.
|
|
221
267
|
*/
|
|
@@ -314,7 +360,7 @@ apply to the editor, and if it can, perform it as a side effect
|
|
|
314
360
|
(which usually means [dispatching](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) a
|
|
315
361
|
transaction) and return `true`.
|
|
316
362
|
*/
|
|
317
|
-
|
|
363
|
+
type Command = (target: EditorView) => boolean;
|
|
318
364
|
/**
|
|
319
365
|
Log or report an unhandled exception in client code. Should
|
|
320
366
|
probably only be used by extension code that allows client code to
|
|
@@ -416,7 +462,7 @@ interface MeasureRequest<T> {
|
|
|
416
462
|
*/
|
|
417
463
|
key?: any;
|
|
418
464
|
}
|
|
419
|
-
|
|
465
|
+
type AttrSource = Attrs | ((view: EditorView) => Attrs | null);
|
|
420
466
|
/**
|
|
421
467
|
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
422
468
|
class, which describe what happened, whenever the view is updated.
|
|
@@ -505,7 +551,7 @@ interface MouseSelectionStyle {
|
|
|
505
551
|
*/
|
|
506
552
|
update: (update: ViewUpdate) => boolean | void;
|
|
507
553
|
}
|
|
508
|
-
|
|
554
|
+
type MakeSelectionStyle = (view: EditorView, event: MouseEvent) => MouseSelectionStyle | null;
|
|
509
555
|
|
|
510
556
|
/**
|
|
511
557
|
Record used to represent information about a block-level element
|
|
@@ -554,46 +600,6 @@ declare class BlockInfo {
|
|
|
554
600
|
get widgetLineBreaks(): number;
|
|
555
601
|
}
|
|
556
602
|
|
|
557
|
-
/**
|
|
558
|
-
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
559
|
-
*/
|
|
560
|
-
declare enum Direction {
|
|
561
|
-
/**
|
|
562
|
-
Left-to-right.
|
|
563
|
-
*/
|
|
564
|
-
LTR = 0,
|
|
565
|
-
/**
|
|
566
|
-
Right-to-left.
|
|
567
|
-
*/
|
|
568
|
-
RTL = 1
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
Represents a contiguous range of text that has a single direction
|
|
572
|
-
(as in left-to-right or right-to-left).
|
|
573
|
-
*/
|
|
574
|
-
declare class BidiSpan {
|
|
575
|
-
/**
|
|
576
|
-
The start of the span (relative to the start of the line).
|
|
577
|
-
*/
|
|
578
|
-
readonly from: number;
|
|
579
|
-
/**
|
|
580
|
-
The end of the span.
|
|
581
|
-
*/
|
|
582
|
-
readonly to: number;
|
|
583
|
-
/**
|
|
584
|
-
The ["bidi
|
|
585
|
-
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
586
|
-
of the span (in this context, 0 means
|
|
587
|
-
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
588
|
-
number inside right-to-left text).
|
|
589
|
-
*/
|
|
590
|
-
readonly level: number;
|
|
591
|
-
/**
|
|
592
|
-
The direction of this span.
|
|
593
|
-
*/
|
|
594
|
-
get dir(): Direction;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
603
|
/**
|
|
598
604
|
The type of object given to the [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView)
|
|
599
605
|
constructor.
|
|
@@ -621,11 +627,16 @@ interface EditorViewConfig extends EditorStateConfig {
|
|
|
621
627
|
*/
|
|
622
628
|
root?: Document | ShadowRoot;
|
|
623
629
|
/**
|
|
624
|
-
Override the
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
630
|
+
Override the way transactions are
|
|
631
|
+
[dispatched](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) for this editor view.
|
|
632
|
+
Your implementation, if provided, should probably call the
|
|
633
|
+
view's [`update` method](https://codemirror.net/6/docs/ref/#view.EditorView.update).
|
|
634
|
+
*/
|
|
635
|
+
dispatchTransactions?: (trs: readonly Transaction[], view: EditorView) => void;
|
|
636
|
+
/**
|
|
637
|
+
**Deprecated** single-transaction version of
|
|
638
|
+
`dispatchTransactions`. Will force transactions to be dispatched
|
|
639
|
+
one at a time when used.
|
|
629
640
|
*/
|
|
630
641
|
dispatch?: (tr: Transaction, view: EditorView) => void;
|
|
631
642
|
}
|
|
@@ -681,7 +692,7 @@ declare class EditorView {
|
|
|
681
692
|
composition there.
|
|
682
693
|
*/
|
|
683
694
|
get compositionStarted(): boolean;
|
|
684
|
-
private
|
|
695
|
+
private dispatchTransactions;
|
|
685
696
|
private _root;
|
|
686
697
|
/**
|
|
687
698
|
The document or shadow root that the view lives in.
|
|
@@ -721,14 +732,19 @@ declare class EditorView {
|
|
|
721
732
|
constructor(config?: EditorViewConfig);
|
|
722
733
|
/**
|
|
723
734
|
All regular editor state updates should go through this. It
|
|
724
|
-
takes a transaction or transaction spec
|
|
725
|
-
show the new state produced by that
|
|
726
|
-
implementation can be overridden with an
|
|
727
|
-
[option](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.
|
|
728
|
-
function is bound to the view instance, so it does not have
|
|
729
|
-
be called as a method.
|
|
735
|
+
takes a transaction, array of transactions, or transaction spec
|
|
736
|
+
and updates the view to show the new state produced by that
|
|
737
|
+
transaction. Its implementation can be overridden with an
|
|
738
|
+
[option](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.dispatchTransactions).
|
|
739
|
+
This function is bound to the view instance, so it does not have
|
|
740
|
+
to be called as a method.
|
|
741
|
+
|
|
742
|
+
Note that when multiple `TransactionSpec` arguments are
|
|
743
|
+
provided, these define a single transaction (the specs will be
|
|
744
|
+
merged), not a sequence of transactions.
|
|
730
745
|
*/
|
|
731
746
|
dispatch(tr: Transaction): void;
|
|
747
|
+
dispatch(trs: readonly Transaction[]): void;
|
|
732
748
|
dispatch(...specs: TransactionSpec[]): void;
|
|
733
749
|
/**
|
|
734
750
|
Update the view for the given array of transactions. This will
|
|
@@ -1035,8 +1051,12 @@ declare class EditorView {
|
|
|
1035
1051
|
positions between which the change was found, and the new
|
|
1036
1052
|
content. When one returns true, no further input handlers are
|
|
1037
1053
|
called and the default behavior is prevented.
|
|
1054
|
+
|
|
1055
|
+
The `insert` argument can be used to get the default transaction
|
|
1056
|
+
that would be applied for this input. This can be useful when
|
|
1057
|
+
dispatching the custom behavior as a separate transaction.
|
|
1038
1058
|
*/
|
|
1039
|
-
static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string) => boolean, readonly ((view: EditorView, from: number, to: number, text: string) => boolean)[]>;
|
|
1059
|
+
static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string, insert: () => Transaction) => boolean, readonly ((view: EditorView, from: number, to: number, text: string, insert: () => Transaction) => boolean)[]>;
|
|
1040
1060
|
/**
|
|
1041
1061
|
This facet can be used to provide functions that create effects
|
|
1042
1062
|
to be dispatched when the editor's focus state changes.
|
|
@@ -1122,6 +1142,16 @@ declare class EditorView {
|
|
|
1122
1142
|
*/
|
|
1123
1143
|
static atomicRanges: Facet<(view: EditorView) => _codemirror_state.RangeSet<any>, readonly ((view: EditorView) => _codemirror_state.RangeSet<any>)[]>;
|
|
1124
1144
|
/**
|
|
1145
|
+
When range decorations add a `unicode-bidi: isolate` style, they
|
|
1146
|
+
should also include a
|
|
1147
|
+
[`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property
|
|
1148
|
+
in their decoration spec, and be exposed through this facet, so
|
|
1149
|
+
that the editor can compute the proper text order. (Other values
|
|
1150
|
+
for `unicode-bidi`, except of course `normal`, are not
|
|
1151
|
+
supported.)
|
|
1152
|
+
*/
|
|
1153
|
+
static bidiIsolatedRanges: Facet<DecorationSet | ((view: EditorView) => DecorationSet), readonly (DecorationSet | ((view: EditorView) => DecorationSet))[]>;
|
|
1154
|
+
/**
|
|
1125
1155
|
Facet that allows extensions to provide additional scroll
|
|
1126
1156
|
margins (space around the sides of the scrolling element that
|
|
1127
1157
|
should be considered invisible). This can be useful when the
|
|
@@ -1170,6 +1200,12 @@ declare class EditorView {
|
|
|
1170
1200
|
[selector: string]: StyleSpec;
|
|
1171
1201
|
}): Extension;
|
|
1172
1202
|
/**
|
|
1203
|
+
Provides a Content Security Policy nonce to use when creating
|
|
1204
|
+
the style sheets for the editor. Holds the empty string when no
|
|
1205
|
+
nonce has been provided.
|
|
1206
|
+
*/
|
|
1207
|
+
static cspNonce: Facet<string, string>;
|
|
1208
|
+
/**
|
|
1173
1209
|
Facet that provides additional DOM attributes for the editor's
|
|
1174
1210
|
editable DOM element.
|
|
1175
1211
|
*/
|
|
@@ -1213,7 +1249,7 @@ to hold the appropriate event object type. For unknown events, it
|
|
|
1213
1249
|
is inferred to `any`, and should be explicitly set if you want type
|
|
1214
1250
|
checking.
|
|
1215
1251
|
*/
|
|
1216
|
-
|
|
1252
|
+
type DOMEventHandlers<This> = {
|
|
1217
1253
|
[event in keyof DOMEventMap]?: (this: This, event: DOMEventMap[event], view: EditorView) => boolean | void;
|
|
1218
1254
|
};
|
|
1219
1255
|
|
|
@@ -1322,7 +1358,7 @@ handlers handled it.
|
|
|
1322
1358
|
*/
|
|
1323
1359
|
declare function runScopeHandlers(view: EditorView, event: KeyboardEvent, scope: string): boolean;
|
|
1324
1360
|
|
|
1325
|
-
|
|
1361
|
+
type SelectionConfig = {
|
|
1326
1362
|
/**
|
|
1327
1363
|
The length of a full cursor blink cycle, in milliseconds.
|
|
1328
1364
|
Defaults to 1200. Can be set to 0 to disable blinking.
|
|
@@ -1788,7 +1824,7 @@ invalidate the existing tooltip positions.
|
|
|
1788
1824
|
*/
|
|
1789
1825
|
declare function repositionTooltips(view: EditorView): void;
|
|
1790
1826
|
|
|
1791
|
-
|
|
1827
|
+
type PanelConfig = {
|
|
1792
1828
|
/**
|
|
1793
1829
|
By default, panels will be placed inside the editor's DOM
|
|
1794
1830
|
structure. You can use this option to override where panels with
|
|
@@ -1842,7 +1878,7 @@ declare function getPanel(view: EditorView, panel: PanelConstructor): Panel | nu
|
|
|
1842
1878
|
A function that initializes a panel. Used in
|
|
1843
1879
|
[`showPanel`](https://codemirror.net/6/docs/ref/#view.showPanel).
|
|
1844
1880
|
*/
|
|
1845
|
-
|
|
1881
|
+
type PanelConstructor = (view: EditorView) => Panel;
|
|
1846
1882
|
/**
|
|
1847
1883
|
Opening a panel is done by providing a constructor function for
|
|
1848
1884
|
the panel through this facet. (The panel is closed again when its
|
|
@@ -1883,7 +1919,7 @@ Markers given to this facet should _only_ define an
|
|
|
1883
1919
|
in all gutters for the line).
|
|
1884
1920
|
*/
|
|
1885
1921
|
declare const gutterLineClass: Facet<RangeSet<GutterMarker>, readonly RangeSet<GutterMarker>[]>;
|
|
1886
|
-
|
|
1922
|
+
type Handlers = {
|
|
1887
1923
|
[event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
|
|
1888
1924
|
};
|
|
1889
1925
|
interface GutterConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,47 @@ import * as _codemirror_state from '@codemirror/state';
|
|
|
2
2
|
import { RangeSet, RangeValue, Range, EditorState, Extension, Transaction, ChangeSet, EditorSelection, EditorStateConfig, TransactionSpec, SelectionRange, Line, StateEffect, Facet } from '@codemirror/state';
|
|
3
3
|
import { StyleModule, StyleSpec } from 'style-mod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
7
|
+
*/
|
|
8
|
+
declare enum Direction {
|
|
9
|
+
/**
|
|
10
|
+
Left-to-right.
|
|
11
|
+
*/
|
|
12
|
+
LTR = 0,
|
|
13
|
+
/**
|
|
14
|
+
Right-to-left.
|
|
15
|
+
*/
|
|
16
|
+
RTL = 1
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
Represents a contiguous range of text that has a single direction
|
|
20
|
+
(as in left-to-right or right-to-left).
|
|
21
|
+
*/
|
|
22
|
+
declare class BidiSpan {
|
|
23
|
+
/**
|
|
24
|
+
The start of the span (relative to the start of the line).
|
|
25
|
+
*/
|
|
26
|
+
readonly from: number;
|
|
27
|
+
/**
|
|
28
|
+
The end of the span.
|
|
29
|
+
*/
|
|
30
|
+
readonly to: number;
|
|
31
|
+
/**
|
|
32
|
+
The ["bidi
|
|
33
|
+
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
34
|
+
of the span (in this context, 0 means
|
|
35
|
+
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
36
|
+
number inside right-to-left text).
|
|
37
|
+
*/
|
|
38
|
+
readonly level: number;
|
|
39
|
+
/**
|
|
40
|
+
The direction of this span.
|
|
41
|
+
*/
|
|
42
|
+
get dir(): Direction;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type Attrs = {
|
|
6
46
|
[name: string]: string;
|
|
7
47
|
};
|
|
8
48
|
|
|
@@ -15,7 +55,7 @@ interface Rect {
|
|
|
15
55
|
readonly top: number;
|
|
16
56
|
readonly bottom: number;
|
|
17
57
|
}
|
|
18
|
-
|
|
58
|
+
type ScrollStrategy = "nearest" | "start" | "end" | "center";
|
|
19
59
|
|
|
20
60
|
interface MarkDecorationSpec {
|
|
21
61
|
/**
|
|
@@ -53,6 +93,12 @@ interface MarkDecorationSpec {
|
|
|
53
93
|
*/
|
|
54
94
|
tagName?: string;
|
|
55
95
|
/**
|
|
96
|
+
When using sets of decorations in
|
|
97
|
+
[`bidiIsolatedRanges`](https://codemirror.net/6/docs/ref/##view.EditorView^bidiIsolatedRanges),
|
|
98
|
+
this property provides the direction of the isolates.
|
|
99
|
+
*/
|
|
100
|
+
bidiIsolate?: Direction;
|
|
101
|
+
/**
|
|
56
102
|
Decoration specs allow extra properties, which can be retrieved
|
|
57
103
|
through the decoration's [`spec`](https://codemirror.net/6/docs/ref/#view.Decoration.spec)
|
|
58
104
|
property.
|
|
@@ -215,7 +261,7 @@ A decoration set represents a collection of decorated ranges,
|
|
|
215
261
|
organized for efficient access and mapping. See
|
|
216
262
|
[`RangeSet`](https://codemirror.net/6/docs/ref/#state.RangeSet) for its methods.
|
|
217
263
|
*/
|
|
218
|
-
|
|
264
|
+
type DecorationSet = RangeSet<Decoration>;
|
|
219
265
|
/**
|
|
220
266
|
The different types of blocks that can occur in an editor view.
|
|
221
267
|
*/
|
|
@@ -314,7 +360,7 @@ apply to the editor, and if it can, perform it as a side effect
|
|
|
314
360
|
(which usually means [dispatching](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) a
|
|
315
361
|
transaction) and return `true`.
|
|
316
362
|
*/
|
|
317
|
-
|
|
363
|
+
type Command = (target: EditorView) => boolean;
|
|
318
364
|
/**
|
|
319
365
|
Log or report an unhandled exception in client code. Should
|
|
320
366
|
probably only be used by extension code that allows client code to
|
|
@@ -416,7 +462,7 @@ interface MeasureRequest<T> {
|
|
|
416
462
|
*/
|
|
417
463
|
key?: any;
|
|
418
464
|
}
|
|
419
|
-
|
|
465
|
+
type AttrSource = Attrs | ((view: EditorView) => Attrs | null);
|
|
420
466
|
/**
|
|
421
467
|
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
422
468
|
class, which describe what happened, whenever the view is updated.
|
|
@@ -505,7 +551,7 @@ interface MouseSelectionStyle {
|
|
|
505
551
|
*/
|
|
506
552
|
update: (update: ViewUpdate) => boolean | void;
|
|
507
553
|
}
|
|
508
|
-
|
|
554
|
+
type MakeSelectionStyle = (view: EditorView, event: MouseEvent) => MouseSelectionStyle | null;
|
|
509
555
|
|
|
510
556
|
/**
|
|
511
557
|
Record used to represent information about a block-level element
|
|
@@ -554,46 +600,6 @@ declare class BlockInfo {
|
|
|
554
600
|
get widgetLineBreaks(): number;
|
|
555
601
|
}
|
|
556
602
|
|
|
557
|
-
/**
|
|
558
|
-
Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
|
|
559
|
-
*/
|
|
560
|
-
declare enum Direction {
|
|
561
|
-
/**
|
|
562
|
-
Left-to-right.
|
|
563
|
-
*/
|
|
564
|
-
LTR = 0,
|
|
565
|
-
/**
|
|
566
|
-
Right-to-left.
|
|
567
|
-
*/
|
|
568
|
-
RTL = 1
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
Represents a contiguous range of text that has a single direction
|
|
572
|
-
(as in left-to-right or right-to-left).
|
|
573
|
-
*/
|
|
574
|
-
declare class BidiSpan {
|
|
575
|
-
/**
|
|
576
|
-
The start of the span (relative to the start of the line).
|
|
577
|
-
*/
|
|
578
|
-
readonly from: number;
|
|
579
|
-
/**
|
|
580
|
-
The end of the span.
|
|
581
|
-
*/
|
|
582
|
-
readonly to: number;
|
|
583
|
-
/**
|
|
584
|
-
The ["bidi
|
|
585
|
-
level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
|
|
586
|
-
of the span (in this context, 0 means
|
|
587
|
-
left-to-right, 1 means right-to-left, 2 means left-to-right
|
|
588
|
-
number inside right-to-left text).
|
|
589
|
-
*/
|
|
590
|
-
readonly level: number;
|
|
591
|
-
/**
|
|
592
|
-
The direction of this span.
|
|
593
|
-
*/
|
|
594
|
-
get dir(): Direction;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
603
|
/**
|
|
598
604
|
The type of object given to the [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView)
|
|
599
605
|
constructor.
|
|
@@ -621,11 +627,16 @@ interface EditorViewConfig extends EditorStateConfig {
|
|
|
621
627
|
*/
|
|
622
628
|
root?: Document | ShadowRoot;
|
|
623
629
|
/**
|
|
624
|
-
Override the
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
630
|
+
Override the way transactions are
|
|
631
|
+
[dispatched](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) for this editor view.
|
|
632
|
+
Your implementation, if provided, should probably call the
|
|
633
|
+
view's [`update` method](https://codemirror.net/6/docs/ref/#view.EditorView.update).
|
|
634
|
+
*/
|
|
635
|
+
dispatchTransactions?: (trs: readonly Transaction[], view: EditorView) => void;
|
|
636
|
+
/**
|
|
637
|
+
**Deprecated** single-transaction version of
|
|
638
|
+
`dispatchTransactions`. Will force transactions to be dispatched
|
|
639
|
+
one at a time when used.
|
|
629
640
|
*/
|
|
630
641
|
dispatch?: (tr: Transaction, view: EditorView) => void;
|
|
631
642
|
}
|
|
@@ -681,7 +692,7 @@ declare class EditorView {
|
|
|
681
692
|
composition there.
|
|
682
693
|
*/
|
|
683
694
|
get compositionStarted(): boolean;
|
|
684
|
-
private
|
|
695
|
+
private dispatchTransactions;
|
|
685
696
|
private _root;
|
|
686
697
|
/**
|
|
687
698
|
The document or shadow root that the view lives in.
|
|
@@ -721,14 +732,19 @@ declare class EditorView {
|
|
|
721
732
|
constructor(config?: EditorViewConfig);
|
|
722
733
|
/**
|
|
723
734
|
All regular editor state updates should go through this. It
|
|
724
|
-
takes a transaction or transaction spec
|
|
725
|
-
show the new state produced by that
|
|
726
|
-
implementation can be overridden with an
|
|
727
|
-
[option](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.
|
|
728
|
-
function is bound to the view instance, so it does not have
|
|
729
|
-
be called as a method.
|
|
735
|
+
takes a transaction, array of transactions, or transaction spec
|
|
736
|
+
and updates the view to show the new state produced by that
|
|
737
|
+
transaction. Its implementation can be overridden with an
|
|
738
|
+
[option](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.dispatchTransactions).
|
|
739
|
+
This function is bound to the view instance, so it does not have
|
|
740
|
+
to be called as a method.
|
|
741
|
+
|
|
742
|
+
Note that when multiple `TransactionSpec` arguments are
|
|
743
|
+
provided, these define a single transaction (the specs will be
|
|
744
|
+
merged), not a sequence of transactions.
|
|
730
745
|
*/
|
|
731
746
|
dispatch(tr: Transaction): void;
|
|
747
|
+
dispatch(trs: readonly Transaction[]): void;
|
|
732
748
|
dispatch(...specs: TransactionSpec[]): void;
|
|
733
749
|
/**
|
|
734
750
|
Update the view for the given array of transactions. This will
|
|
@@ -1035,8 +1051,12 @@ declare class EditorView {
|
|
|
1035
1051
|
positions between which the change was found, and the new
|
|
1036
1052
|
content. When one returns true, no further input handlers are
|
|
1037
1053
|
called and the default behavior is prevented.
|
|
1054
|
+
|
|
1055
|
+
The `insert` argument can be used to get the default transaction
|
|
1056
|
+
that would be applied for this input. This can be useful when
|
|
1057
|
+
dispatching the custom behavior as a separate transaction.
|
|
1038
1058
|
*/
|
|
1039
|
-
static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string) => boolean, readonly ((view: EditorView, from: number, to: number, text: string) => boolean)[]>;
|
|
1059
|
+
static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string, insert: () => Transaction) => boolean, readonly ((view: EditorView, from: number, to: number, text: string, insert: () => Transaction) => boolean)[]>;
|
|
1040
1060
|
/**
|
|
1041
1061
|
This facet can be used to provide functions that create effects
|
|
1042
1062
|
to be dispatched when the editor's focus state changes.
|
|
@@ -1122,6 +1142,16 @@ declare class EditorView {
|
|
|
1122
1142
|
*/
|
|
1123
1143
|
static atomicRanges: Facet<(view: EditorView) => _codemirror_state.RangeSet<any>, readonly ((view: EditorView) => _codemirror_state.RangeSet<any>)[]>;
|
|
1124
1144
|
/**
|
|
1145
|
+
When range decorations add a `unicode-bidi: isolate` style, they
|
|
1146
|
+
should also include a
|
|
1147
|
+
[`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property
|
|
1148
|
+
in their decoration spec, and be exposed through this facet, so
|
|
1149
|
+
that the editor can compute the proper text order. (Other values
|
|
1150
|
+
for `unicode-bidi`, except of course `normal`, are not
|
|
1151
|
+
supported.)
|
|
1152
|
+
*/
|
|
1153
|
+
static bidiIsolatedRanges: Facet<DecorationSet | ((view: EditorView) => DecorationSet), readonly (DecorationSet | ((view: EditorView) => DecorationSet))[]>;
|
|
1154
|
+
/**
|
|
1125
1155
|
Facet that allows extensions to provide additional scroll
|
|
1126
1156
|
margins (space around the sides of the scrolling element that
|
|
1127
1157
|
should be considered invisible). This can be useful when the
|
|
@@ -1170,6 +1200,12 @@ declare class EditorView {
|
|
|
1170
1200
|
[selector: string]: StyleSpec;
|
|
1171
1201
|
}): Extension;
|
|
1172
1202
|
/**
|
|
1203
|
+
Provides a Content Security Policy nonce to use when creating
|
|
1204
|
+
the style sheets for the editor. Holds the empty string when no
|
|
1205
|
+
nonce has been provided.
|
|
1206
|
+
*/
|
|
1207
|
+
static cspNonce: Facet<string, string>;
|
|
1208
|
+
/**
|
|
1173
1209
|
Facet that provides additional DOM attributes for the editor's
|
|
1174
1210
|
editable DOM element.
|
|
1175
1211
|
*/
|
|
@@ -1213,7 +1249,7 @@ to hold the appropriate event object type. For unknown events, it
|
|
|
1213
1249
|
is inferred to `any`, and should be explicitly set if you want type
|
|
1214
1250
|
checking.
|
|
1215
1251
|
*/
|
|
1216
|
-
|
|
1252
|
+
type DOMEventHandlers<This> = {
|
|
1217
1253
|
[event in keyof DOMEventMap]?: (this: This, event: DOMEventMap[event], view: EditorView) => boolean | void;
|
|
1218
1254
|
};
|
|
1219
1255
|
|
|
@@ -1322,7 +1358,7 @@ handlers handled it.
|
|
|
1322
1358
|
*/
|
|
1323
1359
|
declare function runScopeHandlers(view: EditorView, event: KeyboardEvent, scope: string): boolean;
|
|
1324
1360
|
|
|
1325
|
-
|
|
1361
|
+
type SelectionConfig = {
|
|
1326
1362
|
/**
|
|
1327
1363
|
The length of a full cursor blink cycle, in milliseconds.
|
|
1328
1364
|
Defaults to 1200. Can be set to 0 to disable blinking.
|
|
@@ -1788,7 +1824,7 @@ invalidate the existing tooltip positions.
|
|
|
1788
1824
|
*/
|
|
1789
1825
|
declare function repositionTooltips(view: EditorView): void;
|
|
1790
1826
|
|
|
1791
|
-
|
|
1827
|
+
type PanelConfig = {
|
|
1792
1828
|
/**
|
|
1793
1829
|
By default, panels will be placed inside the editor's DOM
|
|
1794
1830
|
structure. You can use this option to override where panels with
|
|
@@ -1842,7 +1878,7 @@ declare function getPanel(view: EditorView, panel: PanelConstructor): Panel | nu
|
|
|
1842
1878
|
A function that initializes a panel. Used in
|
|
1843
1879
|
[`showPanel`](https://codemirror.net/6/docs/ref/#view.showPanel).
|
|
1844
1880
|
*/
|
|
1845
|
-
|
|
1881
|
+
type PanelConstructor = (view: EditorView) => Panel;
|
|
1846
1882
|
/**
|
|
1847
1883
|
Opening a panel is done by providing a constructor function for
|
|
1848
1884
|
the panel through this facet. (The panel is closed again when its
|
|
@@ -1883,7 +1919,7 @@ Markers given to this facet should _only_ define an
|
|
|
1883
1919
|
in all gutters for the line).
|
|
1884
1920
|
*/
|
|
1885
1921
|
declare const gutterLineClass: Facet<RangeSet<GutterMarker>, readonly RangeSet<GutterMarker>[]>;
|
|
1886
|
-
|
|
1922
|
+
type Handlers = {
|
|
1887
1923
|
[event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
|
|
1888
1924
|
};
|
|
1889
1925
|
interface GutterConfig {
|