@codemirror/view 0.19.22 → 0.19.26

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/dist/index.d.ts CHANGED
@@ -171,6 +171,11 @@ declare abstract class WidgetType {
171
171
  events.
172
172
  */
173
173
  ignoreEvent(_event: Event): boolean;
174
+ /**
175
+ This is called when the an instance of the widget is removed
176
+ from the editor view.
177
+ */
178
+ destroy(_dom: HTMLElement): void;
174
179
  }
175
180
  /**
176
181
  A decoration set represents a collection of decorated ranges,
@@ -431,6 +436,7 @@ interface MeasureRequest<T> {
431
436
  */
432
437
  key?: any;
433
438
  }
439
+ declare type AttrSource = Attrs | ((view: EditorView) => Attrs | null);
434
440
  /**
435
441
  View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
436
442
  class, which describe what happened, whenever the view is updated.
@@ -694,6 +700,7 @@ declare class EditorView {
694
700
  readonly contentDOM: HTMLElement;
695
701
  private announceDOM;
696
702
  private plugins;
703
+ private pluginMap;
697
704
  private editorAttrs;
698
705
  private contentAttrs;
699
706
  private styleModules;
@@ -769,10 +776,18 @@ declare class EditorView {
769
776
  plugin<T>(plugin: ViewPlugin<T>): T | null;
770
777
  /**
771
778
  The top position of the document, in screen coordinates. This
772
- may be negative when the editor is scrolled down.
779
+ may be negative when the editor is scrolled down. Points
780
+ directly to the top of the first line, not above the padding.
773
781
  */
774
782
  get documentTop(): number;
775
783
  /**
784
+ Reports the padding above and below the document.
785
+ */
786
+ get documentPadding(): {
787
+ top: number;
788
+ bottom: number;
789
+ };
790
+ /**
776
791
  Find the line or block widget at the given vertical position.
777
792
 
778
793
  By default, this position is interpreted as a screen position,
@@ -1000,7 +1015,7 @@ declare class EditorView {
1000
1015
  mounted in its [document
1001
1016
  root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
1002
1017
  */
1003
- static styleModule: _codemirror_state.Facet<StyleModule, readonly StyleModule[]>;
1018
+ static styleModule: Facet<StyleModule, readonly StyleModule[]>;
1004
1019
  /**
1005
1020
  Facet that can be used to add DOM event handlers. The value
1006
1021
  should be an object mapping event names to handler functions. The
@@ -1021,7 +1036,7 @@ declare class EditorView {
1021
1036
  content. When one returns true, no further input handlers are
1022
1037
  called and the default behavior is prevented.
1023
1038
  */
1024
- static inputHandler: _codemirror_state.Facet<(view: EditorView, from: number, to: number, text: string) => boolean, readonly ((view: EditorView, from: number, to: number, text: string) => boolean)[]>;
1039
+ static inputHandler: Facet<(view: EditorView, from: number, to: number, text: string) => boolean, readonly ((view: EditorView, from: number, to: number, text: string) => boolean)[]>;
1025
1040
  /**
1026
1041
  Allows you to provide a function that should be called when the
1027
1042
  library catches an exception from an extension (mostly from view
@@ -1029,12 +1044,12 @@ declare class EditorView {
1029
1044
  from user-code-provided callbacks). This is mostly useful for
1030
1045
  debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
1031
1046
  */
1032
- static exceptionSink: _codemirror_state.Facet<(exception: any) => void, readonly ((exception: any) => void)[]>;
1047
+ static exceptionSink: Facet<(exception: any) => void, readonly ((exception: any) => void)[]>;
1033
1048
  /**
1034
1049
  A facet that can be used to register a function to be called
1035
1050
  every time the view updates.
1036
1051
  */
1037
- static updateListener: _codemirror_state.Facet<(update: ViewUpdate) => void, readonly ((update: ViewUpdate) => void)[]>;
1052
+ static updateListener: Facet<(update: ViewUpdate) => void, readonly ((update: ViewUpdate) => void)[]>;
1038
1053
  /**
1039
1054
  Facet that controls whether the editor content DOM is editable.
1040
1055
  When its highest-precedence value is `false`, the element will
@@ -1043,33 +1058,33 @@ declare class EditorView {
1043
1058
  even when those are bound to keys or buttons. See the
1044
1059
  [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
1045
1060
  */
1046
- static editable: _codemirror_state.Facet<boolean, boolean>;
1061
+ static editable: Facet<boolean, boolean>;
1047
1062
  /**
1048
1063
  Allows you to influence the way mouse selection happens. The
1049
1064
  functions in this facet will be called for a `mousedown` event
1050
1065
  on the editor, and can return an object that overrides the way a
1051
1066
  selection is computed from that mouse click or drag.
1052
1067
  */
1053
- static mouseSelectionStyle: _codemirror_state.Facet<MakeSelectionStyle, readonly MakeSelectionStyle[]>;
1068
+ static mouseSelectionStyle: Facet<MakeSelectionStyle, readonly MakeSelectionStyle[]>;
1054
1069
  /**
1055
1070
  Facet used to configure whether a given selection drag event
1056
1071
  should move or copy the selection. The given predicate will be
1057
1072
  called with the `mousedown` event, and can return `true` when
1058
1073
  the drag should move the content.
1059
1074
  */
1060
- static dragMovesSelection: _codemirror_state.Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
1075
+ static dragMovesSelection: Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
1061
1076
  /**
1062
1077
  Facet used to configure whether a given selecting click adds
1063
1078
  a new range to the existing selection or replaces it entirely.
1064
1079
  */
1065
- static clickAddsSelectionRange: _codemirror_state.Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
1080
+ static clickAddsSelectionRange: Facet<(event: MouseEvent) => boolean, readonly ((event: MouseEvent) => boolean)[]>;
1066
1081
  /**
1067
1082
  A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
1068
1083
  are shown in the view. See also [view
1069
1084
  plugins](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), which have a separate
1070
1085
  mechanism for providing decorations.
1071
1086
  */
1072
- static decorations: _codemirror_state.Facet<DecorationSet, readonly DecorationSet[]>;
1087
+ static decorations: Facet<DecorationSet, readonly DecorationSet[]>;
1073
1088
  /**
1074
1089
  Create a theme extension. The first argument can be a
1075
1090
  [`style-mod`](https://github.com/marijnh/style-mod#documentation)
@@ -1107,12 +1122,12 @@ declare class EditorView {
1107
1122
  Facet that provides additional DOM attributes for the editor's
1108
1123
  editable DOM element.
1109
1124
  */
1110
- static contentAttributes: _codemirror_state.Facet<Attrs, Attrs>;
1125
+ static contentAttributes: Facet<AttrSource, readonly AttrSource[]>;
1111
1126
  /**
1112
1127
  Facet that provides DOM attributes for the editor's outer
1113
1128
  element.
1114
1129
  */
1115
- static editorAttributes: _codemirror_state.Facet<Attrs, Attrs>;
1130
+ static editorAttributes: Facet<AttrSource, readonly AttrSource[]>;
1116
1131
  /**
1117
1132
  An extension that enables line wrapping in the editor (by
1118
1133
  setting CSS `white-space` to `pre-wrap` in the content).
@@ -1310,10 +1325,10 @@ Configuration options.
1310
1325
  config?: SpecialCharConfig): Extension;
1311
1326
 
1312
1327
  /**
1313
- Returns a plugin that makes sure the content has a bottom margin
1314
- equivalent to the height of the editor, minus one line height, so
1315
- that every line in the document can be scrolled to the top of the
1316
- editor.
1328
+ Returns an extension that makes sure the content has a bottom
1329
+ margin equivalent to the height of the editor, minus one line
1330
+ height, so that every line in the document can be scrolled to the
1331
+ top of the editor.
1317
1332
 
1318
1333
  This is only meaningful when the editor is scrollable, and should
1319
1334
  not be enabled in editors that take the size of their content.