@codemirror/view 0.19.18 → 0.19.22

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
@@ -424,7 +424,7 @@ 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.
@@ -573,7 +573,8 @@ declare class BlockInfo {
573
573
  */
574
574
  readonly length: number;
575
575
  /**
576
- The top position of the element.
576
+ The top position of the element (relative to the top of the
577
+ document).
577
578
  */
578
579
  readonly top: number;
579
580
  /**
@@ -767,6 +768,11 @@ declare class EditorView {
767
768
  */
768
769
  plugin<T>(plugin: ViewPlugin<T>): T | null;
769
770
  /**
771
+ The top position of the document, in screen coordinates. This
772
+ may be negative when the editor is scrolled down.
773
+ */
774
+ get documentTop(): number;
775
+ /**
770
776
  Find the line or block widget at the given vertical position.
771
777
 
772
778
  By default, this position is interpreted as a screen position,
@@ -776,9 +782,17 @@ declare class EditorView {
776
782
  position, or a precomputed document top
777
783
  (`view.contentDOM.getBoundingClientRect().top`) to limit layout
778
784
  queries.
785
+
786
+ *Deprecated: use `blockAtHeight` instead.*
779
787
  */
780
788
  blockAtHeight(height: number, docTop?: number): BlockInfo;
781
789
  /**
790
+ Find the text line or block widget at the given vertical
791
+ position (which is interpreted as relative to the [top of the
792
+ document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
793
+ */
794
+ elementAtHeight(height: number): BlockInfo;
795
+ /**
782
796
  Find information for the visual line (see
783
797
  [`visualLineAt`](https://codemirror.net/6/docs/ref/#view.EditorView.visualLineAt)) at the given
784
798
  vertical position. The resulting block info might hold another
@@ -788,16 +802,33 @@ declare class EditorView {
788
802
  Defaults to treating `height` as a screen position. See
789
803
  [`blockAtHeight`](https://codemirror.net/6/docs/ref/#view.EditorView.blockAtHeight) for the
790
804
  interpretation of the `docTop` parameter.
805
+
806
+ *Deprecated: use `lineBlockAtHeight` instead.*
791
807
  */
792
808
  visualLineAtHeight(height: number, docTop?: number): BlockInfo;
793
809
  /**
810
+ Find the line block (see
811
+ [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
812
+ height.
813
+ */
814
+ lineBlockAtHeight(height: number): BlockInfo;
815
+ /**
794
816
  Iterate over the height information of the visual lines in the
795
817
  viewport. The heights of lines are reported relative to the
796
818
  given document top, which defaults to the screen position of the
797
819
  document (forcing a layout).
820
+
821
+ *Deprecated: use `viewportLineBlocks` instead.*
798
822
  */
799
823
  viewportLines(f: (line: BlockInfo) => void, docTop?: number): void;
800
824
  /**
825
+ Get the extent and vertical position of all [line
826
+ blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
827
+ are relative to the [top of the
828
+ document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
829
+ */
830
+ get viewportLineBlocks(): BlockInfo[];
831
+ /**
801
832
  Find the extent and height of the visual line (a range delimited
802
833
  on both sides by either non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range)
803
834
  line breaks, or the start/end of the document) at the given position.
@@ -806,9 +837,20 @@ declare class EditorView {
806
837
  argument, which defaults to 0 for this method. You can pass
807
838
  `view.contentDOM.getBoundingClientRect().top` here to get screen
808
839
  coordinates.
840
+
841
+ *Deprecated: use `lineBlockAt` instead.*
809
842
  */
810
843
  visualLineAt(pos: number, docTop?: number): BlockInfo;
811
844
  /**
845
+ Find the line block around the given document position. A line
846
+ block is a range delimited on both sides by either a
847
+ non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range) line breaks, or the
848
+ start/end of the document. It will usually just hold a line of
849
+ text, but may be broken into multiple textblocks by block
850
+ widgets.
851
+ */
852
+ lineBlockAt(pos: number): BlockInfo;
853
+ /**
812
854
  The editor's total content height.
813
855
  */
814
856
  get contentHeight(): number;