@codemirror/view 0.19.21 → 0.19.25
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 +46 -0
- package/dist/index.cjs +276 -181
- package/dist/index.d.ts +69 -17
- package/dist/index.js +276 -181
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -424,13 +424,14 @@ interface MeasureRequest<T> {
|
|
|
424
424
|
Called in a DOM write phase to update the document. Should _not_
|
|
425
425
|
do anything that triggers DOM layout.
|
|
426
426
|
*/
|
|
427
|
-
write(measure: T, view: EditorView): void;
|
|
427
|
+
write?(measure: T, view: EditorView): void;
|
|
428
428
|
/**
|
|
429
429
|
When multiple requests with the same key are scheduled, only the
|
|
430
430
|
last one will actually be ran.
|
|
431
431
|
*/
|
|
432
432
|
key?: any;
|
|
433
433
|
}
|
|
434
|
+
declare type AttrSource = Attrs | ((view: EditorView) => Attrs | null);
|
|
434
435
|
/**
|
|
435
436
|
View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
|
|
436
437
|
class, which describe what happened, whenever the view is updated.
|
|
@@ -573,7 +574,8 @@ declare class BlockInfo {
|
|
|
573
574
|
*/
|
|
574
575
|
readonly length: number;
|
|
575
576
|
/**
|
|
576
|
-
The top position of the element
|
|
577
|
+
The top position of the element (relative to the top of the
|
|
578
|
+
document).
|
|
577
579
|
*/
|
|
578
580
|
readonly top: number;
|
|
579
581
|
/**
|
|
@@ -693,6 +695,7 @@ declare class EditorView {
|
|
|
693
695
|
readonly contentDOM: HTMLElement;
|
|
694
696
|
private announceDOM;
|
|
695
697
|
private plugins;
|
|
698
|
+
private pluginMap;
|
|
696
699
|
private editorAttrs;
|
|
697
700
|
private contentAttrs;
|
|
698
701
|
private styleModules;
|
|
@@ -767,6 +770,19 @@ declare class EditorView {
|
|
|
767
770
|
*/
|
|
768
771
|
plugin<T>(plugin: ViewPlugin<T>): T | null;
|
|
769
772
|
/**
|
|
773
|
+
The top position of the document, in screen coordinates. This
|
|
774
|
+
may be negative when the editor is scrolled down. Points
|
|
775
|
+
directly to the top of the first line, not above the padding.
|
|
776
|
+
*/
|
|
777
|
+
get documentTop(): number;
|
|
778
|
+
/**
|
|
779
|
+
Reports the padding above and below the document.
|
|
780
|
+
*/
|
|
781
|
+
get documentPadding(): {
|
|
782
|
+
top: number;
|
|
783
|
+
bottom: number;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
770
786
|
Find the line or block widget at the given vertical position.
|
|
771
787
|
|
|
772
788
|
By default, this position is interpreted as a screen position,
|
|
@@ -776,9 +792,17 @@ declare class EditorView {
|
|
|
776
792
|
position, or a precomputed document top
|
|
777
793
|
(`view.contentDOM.getBoundingClientRect().top`) to limit layout
|
|
778
794
|
queries.
|
|
795
|
+
|
|
796
|
+
*Deprecated: use `blockAtHeight` instead.*
|
|
779
797
|
*/
|
|
780
798
|
blockAtHeight(height: number, docTop?: number): BlockInfo;
|
|
781
799
|
/**
|
|
800
|
+
Find the text line or block widget at the given vertical
|
|
801
|
+
position (which is interpreted as relative to the [top of the
|
|
802
|
+
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
|
|
803
|
+
*/
|
|
804
|
+
elementAtHeight(height: number): BlockInfo;
|
|
805
|
+
/**
|
|
782
806
|
Find information for the visual line (see
|
|
783
807
|
[`visualLineAt`](https://codemirror.net/6/docs/ref/#view.EditorView.visualLineAt)) at the given
|
|
784
808
|
vertical position. The resulting block info might hold another
|
|
@@ -788,16 +812,33 @@ declare class EditorView {
|
|
|
788
812
|
Defaults to treating `height` as a screen position. See
|
|
789
813
|
[`blockAtHeight`](https://codemirror.net/6/docs/ref/#view.EditorView.blockAtHeight) for the
|
|
790
814
|
interpretation of the `docTop` parameter.
|
|
815
|
+
|
|
816
|
+
*Deprecated: use `lineBlockAtHeight` instead.*
|
|
791
817
|
*/
|
|
792
818
|
visualLineAtHeight(height: number, docTop?: number): BlockInfo;
|
|
793
819
|
/**
|
|
820
|
+
Find the line block (see
|
|
821
|
+
[`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
|
|
822
|
+
height.
|
|
823
|
+
*/
|
|
824
|
+
lineBlockAtHeight(height: number): BlockInfo;
|
|
825
|
+
/**
|
|
794
826
|
Iterate over the height information of the visual lines in the
|
|
795
827
|
viewport. The heights of lines are reported relative to the
|
|
796
828
|
given document top, which defaults to the screen position of the
|
|
797
829
|
document (forcing a layout).
|
|
830
|
+
|
|
831
|
+
*Deprecated: use `viewportLineBlocks` instead.*
|
|
798
832
|
*/
|
|
799
833
|
viewportLines(f: (line: BlockInfo) => void, docTop?: number): void;
|
|
800
834
|
/**
|
|
835
|
+
Get the extent and vertical position of all [line
|
|
836
|
+
blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
|
|
837
|
+
are relative to the [top of the
|
|
838
|
+
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
|
|
839
|
+
*/
|
|
840
|
+
get viewportLineBlocks(): BlockInfo[];
|
|
841
|
+
/**
|
|
801
842
|
Find the extent and height of the visual line (a range delimited
|
|
802
843
|
on both sides by either non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range)
|
|
803
844
|
line breaks, or the start/end of the document) at the given position.
|
|
@@ -806,9 +847,20 @@ declare class EditorView {
|
|
|
806
847
|
argument, which defaults to 0 for this method. You can pass
|
|
807
848
|
`view.contentDOM.getBoundingClientRect().top` here to get screen
|
|
808
849
|
coordinates.
|
|
850
|
+
|
|
851
|
+
*Deprecated: use `lineBlockAt` instead.*
|
|
809
852
|
*/
|
|
810
853
|
visualLineAt(pos: number, docTop?: number): BlockInfo;
|
|
811
854
|
/**
|
|
855
|
+
Find the line block around the given document position. A line
|
|
856
|
+
block is a range delimited on both sides by either a
|
|
857
|
+
non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range) line breaks, or the
|
|
858
|
+
start/end of the document. It will usually just hold a line of
|
|
859
|
+
text, but may be broken into multiple textblocks by block
|
|
860
|
+
widgets.
|
|
861
|
+
*/
|
|
862
|
+
lineBlockAt(pos: number): BlockInfo;
|
|
863
|
+
/**
|
|
812
864
|
The editor's total content height.
|
|
813
865
|
*/
|
|
814
866
|
get contentHeight(): number;
|
|
@@ -958,7 +1010,7 @@ declare class EditorView {
|
|
|
958
1010
|
mounted in its [document
|
|
959
1011
|
root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
|
|
960
1012
|
*/
|
|
961
|
-
static styleModule:
|
|
1013
|
+
static styleModule: Facet<StyleModule, readonly StyleModule[]>;
|
|
962
1014
|
/**
|
|
963
1015
|
Facet that can be used to add DOM event handlers. The value
|
|
964
1016
|
should be an object mapping event names to handler functions. The
|
|
@@ -979,7 +1031,7 @@ declare class EditorView {
|
|
|
979
1031
|
content. When one returns true, no further input handlers are
|
|
980
1032
|
called and the default behavior is prevented.
|
|
981
1033
|
*/
|
|
982
|
-
static inputHandler:
|
|
1034
|
+
static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string) => boolean, readonly ((view: EditorView, from: number, to: number, text: string) => boolean)[]>;
|
|
983
1035
|
/**
|
|
984
1036
|
Allows you to provide a function that should be called when the
|
|
985
1037
|
library catches an exception from an extension (mostly from view
|
|
@@ -987,12 +1039,12 @@ declare class EditorView {
|
|
|
987
1039
|
from user-code-provided callbacks). This is mostly useful for
|
|
988
1040
|
debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
|
|
989
1041
|
*/
|
|
990
|
-
static exceptionSink:
|
|
1042
|
+
static exceptionSink: Facet<(exception: any) => void, readonly ((exception: any) => void)[]>;
|
|
991
1043
|
/**
|
|
992
1044
|
A facet that can be used to register a function to be called
|
|
993
1045
|
every time the view updates.
|
|
994
1046
|
*/
|
|
995
|
-
static updateListener:
|
|
1047
|
+
static updateListener: Facet<(update: ViewUpdate) => void, readonly ((update: ViewUpdate) => void)[]>;
|
|
996
1048
|
/**
|
|
997
1049
|
Facet that controls whether the editor content DOM is editable.
|
|
998
1050
|
When its highest-precedence value is `false`, the element will
|
|
@@ -1001,33 +1053,33 @@ declare class EditorView {
|
|
|
1001
1053
|
even when those are bound to keys or buttons. See the
|
|
1002
1054
|
[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
|
|
1003
1055
|
*/
|
|
1004
|
-
static editable:
|
|
1056
|
+
static editable: Facet<boolean, boolean>;
|
|
1005
1057
|
/**
|
|
1006
1058
|
Allows you to influence the way mouse selection happens. The
|
|
1007
1059
|
functions in this facet will be called for a `mousedown` event
|
|
1008
1060
|
on the editor, and can return an object that overrides the way a
|
|
1009
1061
|
selection is computed from that mouse click or drag.
|
|
1010
1062
|
*/
|
|
1011
|
-
static mouseSelectionStyle:
|
|
1063
|
+
static mouseSelectionStyle: Facet<MakeSelectionStyle, readonly MakeSelectionStyle[]>;
|
|
1012
1064
|
/**
|
|
1013
1065
|
Facet used to configure whether a given selection drag event
|
|
1014
1066
|
should move or copy the selection. The given predicate will be
|
|
1015
1067
|
called with the `mousedown` event, and can return `true` when
|
|
1016
1068
|
the drag should move the content.
|
|
1017
1069
|
*/
|
|
1018
|
-
static dragMovesSelection:
|
|
1070
|
+
static dragMovesSelection: Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
|
|
1019
1071
|
/**
|
|
1020
1072
|
Facet used to configure whether a given selecting click adds
|
|
1021
1073
|
a new range to the existing selection or replaces it entirely.
|
|
1022
1074
|
*/
|
|
1023
|
-
static clickAddsSelectionRange:
|
|
1075
|
+
static clickAddsSelectionRange: Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
|
|
1024
1076
|
/**
|
|
1025
1077
|
A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
|
|
1026
1078
|
are shown in the view. See also [view
|
|
1027
1079
|
plugins](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), which have a separate
|
|
1028
1080
|
mechanism for providing decorations.
|
|
1029
1081
|
*/
|
|
1030
|
-
static decorations:
|
|
1082
|
+
static decorations: Facet<DecorationSet, readonly DecorationSet[]>;
|
|
1031
1083
|
/**
|
|
1032
1084
|
Create a theme extension. The first argument can be a
|
|
1033
1085
|
[`style-mod`](https://github.com/marijnh/style-mod#documentation)
|
|
@@ -1065,12 +1117,12 @@ declare class EditorView {
|
|
|
1065
1117
|
Facet that provides additional DOM attributes for the editor's
|
|
1066
1118
|
editable DOM element.
|
|
1067
1119
|
*/
|
|
1068
|
-
static contentAttributes:
|
|
1120
|
+
static contentAttributes: Facet<AttrSource, readonly AttrSource[]>;
|
|
1069
1121
|
/**
|
|
1070
1122
|
Facet that provides DOM attributes for the editor's outer
|
|
1071
1123
|
element.
|
|
1072
1124
|
*/
|
|
1073
|
-
static editorAttributes:
|
|
1125
|
+
static editorAttributes: Facet<AttrSource, readonly AttrSource[]>;
|
|
1074
1126
|
/**
|
|
1075
1127
|
An extension that enables line wrapping in the editor (by
|
|
1076
1128
|
setting CSS `white-space` to `pre-wrap` in the content).
|
|
@@ -1268,10 +1320,10 @@ Configuration options.
|
|
|
1268
1320
|
config?: SpecialCharConfig): Extension;
|
|
1269
1321
|
|
|
1270
1322
|
/**
|
|
1271
|
-
Returns
|
|
1272
|
-
equivalent to the height of the editor, minus one line
|
|
1273
|
-
that every line in the document can be scrolled to the
|
|
1274
|
-
editor.
|
|
1323
|
+
Returns an extension that makes sure the content has a bottom
|
|
1324
|
+
margin equivalent to the height of the editor, minus one line
|
|
1325
|
+
height, so that every line in the document can be scrolled to the
|
|
1326
|
+
top of the editor.
|
|
1275
1327
|
|
|
1276
1328
|
This is only meaningful when the editor is scrollable, and should
|
|
1277
1329
|
not be enabled in editors that take the size of their content.
|