@codemirror/view 0.19.22 → 0.19.23

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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.19.23 (2021-11-30)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where after some kinds of changes, `EditorView.viewportLineBlocks` held an out-of-date set of blocks.
6
+
7
+ ### New features
8
+
9
+ Export `EditorView.documentPadding`, with information about the vertical padding of the document.
10
+
1
11
  ## 0.19.22 (2021-11-30)
2
12
 
3
13
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1912,7 +1912,7 @@ class ViewUpdate {
1912
1912
  Whether the document changed in this update.
1913
1913
  */
1914
1914
  get docChanged() {
1915
- return this.transactions.some(tr => tr.docChanged);
1915
+ return !this.changes.empty;
1916
1916
  }
1917
1917
  /**
1918
1918
  Whether the selection was explicitly set in this update.
@@ -4575,10 +4575,11 @@ class ViewState {
4575
4575
  if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
4576
4576
  !this.viewportIsAppropriate(viewport))
4577
4577
  viewport = this.getViewport(0, scrollTarget);
4578
- if (!update.changes.empty || (update.flags & 2 /* Height */) ||
4579
- viewport.from != this.viewport.from || viewport.to != this.viewport.to)
4580
- this.updateViewportLines();
4578
+ let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
4579
+ viewport.from != this.viewport.from || viewport.to != this.viewport.to;
4581
4580
  this.viewport = viewport;
4581
+ if (updateLines)
4582
+ this.updateViewportLines();
4582
4583
  this.updateForViewport();
4583
4584
  if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
4584
4585
  this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
@@ -6069,12 +6070,19 @@ class EditorView {
6069
6070
  }
6070
6071
  /**
6071
6072
  The top position of the document, in screen coordinates. This
6072
- may be negative when the editor is scrolled down.
6073
+ may be negative when the editor is scrolled down. Points
6074
+ directly to the top of the first line, not above the padding.
6073
6075
  */
6074
6076
  get documentTop() {
6075
6077
  return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
6076
6078
  }
6077
6079
  /**
6080
+ Reports the padding above and below the document.
6081
+ */
6082
+ get documentPadding() {
6083
+ return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
6084
+ }
6085
+ /**
6078
6086
  Find the line or block widget at the given vertical position.
6079
6087
 
6080
6088
  By default, this position is interpreted as a screen position,
package/dist/index.d.ts CHANGED
@@ -769,10 +769,18 @@ declare class EditorView {
769
769
  plugin<T>(plugin: ViewPlugin<T>): T | null;
770
770
  /**
771
771
  The top position of the document, in screen coordinates. This
772
- may be negative when the editor is scrolled down.
772
+ may be negative when the editor is scrolled down. Points
773
+ directly to the top of the first line, not above the padding.
773
774
  */
774
775
  get documentTop(): number;
775
776
  /**
777
+ Reports the padding above and below the document.
778
+ */
779
+ get documentPadding(): {
780
+ top: number;
781
+ bottom: number;
782
+ };
783
+ /**
776
784
  Find the line or block widget at the given vertical position.
777
785
 
778
786
  By default, this position is interpreted as a screen position,
package/dist/index.js CHANGED
@@ -1908,7 +1908,7 @@ class ViewUpdate {
1908
1908
  Whether the document changed in this update.
1909
1909
  */
1910
1910
  get docChanged() {
1911
- return this.transactions.some(tr => tr.docChanged);
1911
+ return !this.changes.empty;
1912
1912
  }
1913
1913
  /**
1914
1914
  Whether the selection was explicitly set in this update.
@@ -4569,10 +4569,11 @@ class ViewState {
4569
4569
  if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
4570
4570
  !this.viewportIsAppropriate(viewport))
4571
4571
  viewport = this.getViewport(0, scrollTarget);
4572
- if (!update.changes.empty || (update.flags & 2 /* Height */) ||
4573
- viewport.from != this.viewport.from || viewport.to != this.viewport.to)
4574
- this.updateViewportLines();
4572
+ let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
4573
+ viewport.from != this.viewport.from || viewport.to != this.viewport.to;
4575
4574
  this.viewport = viewport;
4575
+ if (updateLines)
4576
+ this.updateViewportLines();
4576
4577
  this.updateForViewport();
4577
4578
  if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
4578
4579
  this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
@@ -6063,12 +6064,19 @@ class EditorView {
6063
6064
  }
6064
6065
  /**
6065
6066
  The top position of the document, in screen coordinates. This
6066
- may be negative when the editor is scrolled down.
6067
+ may be negative when the editor is scrolled down. Points
6068
+ directly to the top of the first line, not above the padding.
6067
6069
  */
6068
6070
  get documentTop() {
6069
6071
  return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
6070
6072
  }
6071
6073
  /**
6074
+ Reports the padding above and below the document.
6075
+ */
6076
+ get documentPadding() {
6077
+ return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
6078
+ }
6079
+ /**
6072
6080
  Find the line or block widget at the given vertical position.
6073
6081
 
6074
6082
  By default, this position is interpreted as a screen position,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "0.19.22",
3
+ "version": "0.19.23",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",