@codemirror/view 6.13.0 → 6.13.2

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,17 @@
1
+ ## 6.13.2 (2023-06-13)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue in scroll position stabilization for changes above the visible, where Chrome already does this natively and we ended up compensating twice.
6
+
7
+ ## 6.13.1 (2023-06-12)
8
+
9
+ ### Bug fixes
10
+
11
+ Fix a bug where the cursor would in some circumstances be drawn on the wrong side of an inline widget.
12
+
13
+ Fix an issue where `scrollPastEnd` could cause the scroll position of editors that weren't in view to be changed unnecessarily.
14
+
1
15
  ## 6.13.0 (2023-06-05)
2
16
 
3
17
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -897,7 +897,7 @@ class WidgetView extends ContentView {
897
897
  if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
898
898
  break;
899
899
  }
900
- return this.length ? rect : flattenRect(rect, !fromBack);
900
+ return flattenRect(rect, !fromBack);
901
901
  }
902
902
  get isEditable() { return false; }
903
903
  get isWidget() { return true; }
@@ -6837,15 +6837,16 @@ class EditorView {
6837
6837
  if (flush)
6838
6838
  this.observer.forceFlush();
6839
6839
  let updated = null;
6840
- let sDOM = this.scrollDOM, { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
6840
+ let sDOM = this.scrollDOM, { scrollTop } = sDOM;
6841
+ let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
6841
6842
  this.viewState.scrollAnchorHeight = -1;
6842
- if (scrollAnchorHeight < 0 || sDOM.scrollTop != this.viewState.scrollTop) {
6843
- if (sDOM.scrollTop > sDOM.scrollHeight - sDOM.clientHeight - 4) {
6843
+ if (scrollAnchorHeight < 0 || scrollTop != this.viewState.scrollTop) {
6844
+ if (scrollTop > sDOM.scrollHeight - sDOM.clientHeight - 4) {
6844
6845
  scrollAnchorPos = -1;
6845
6846
  scrollAnchorHeight = this.viewState.heightMap.height;
6846
6847
  }
6847
6848
  else {
6848
- let block = this.viewState.lineBlockAtHeight(sDOM.scrollTop);
6849
+ let block = this.viewState.lineBlockAtHeight(scrollTop);
6849
6850
  scrollAnchorPos = block.from;
6850
6851
  scrollAnchorHeight = block.top;
6851
6852
  }
@@ -6911,7 +6912,7 @@ class EditorView {
6911
6912
  this.viewState.lineBlockAt(scrollAnchorPos).top;
6912
6913
  let diff = newAnchorHeight - scrollAnchorHeight;
6913
6914
  if (diff > 1 || diff < -1) {
6914
- sDOM.scrollTop += diff;
6915
+ sDOM.scrollTop = scrollTop + diff;
6915
6916
  scrolled = true;
6916
6917
  }
6917
6918
  }
@@ -8407,7 +8408,7 @@ const plugin = ViewPlugin.fromClass(class {
8407
8408
  update(update) {
8408
8409
  let { view } = update;
8409
8410
  let height = view.viewState.editorHeight - view.defaultLineHeight - view.documentPadding.top - 0.5;
8410
- if (height != this.height) {
8411
+ if (height >= 0 && height != this.height) {
8411
8412
  this.height = height;
8412
8413
  this.attrs = { style: `padding-bottom: ${height}px` };
8413
8414
  }
package/dist/index.js CHANGED
@@ -893,7 +893,7 @@ class WidgetView extends ContentView {
893
893
  if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
894
894
  break;
895
895
  }
896
- return this.length ? rect : flattenRect(rect, !fromBack);
896
+ return flattenRect(rect, !fromBack);
897
897
  }
898
898
  get isEditable() { return false; }
899
899
  get isWidget() { return true; }
@@ -6830,15 +6830,16 @@ class EditorView {
6830
6830
  if (flush)
6831
6831
  this.observer.forceFlush();
6832
6832
  let updated = null;
6833
- let sDOM = this.scrollDOM, { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
6833
+ let sDOM = this.scrollDOM, { scrollTop } = sDOM;
6834
+ let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
6834
6835
  this.viewState.scrollAnchorHeight = -1;
6835
- if (scrollAnchorHeight < 0 || sDOM.scrollTop != this.viewState.scrollTop) {
6836
- if (sDOM.scrollTop > sDOM.scrollHeight - sDOM.clientHeight - 4) {
6836
+ if (scrollAnchorHeight < 0 || scrollTop != this.viewState.scrollTop) {
6837
+ if (scrollTop > sDOM.scrollHeight - sDOM.clientHeight - 4) {
6837
6838
  scrollAnchorPos = -1;
6838
6839
  scrollAnchorHeight = this.viewState.heightMap.height;
6839
6840
  }
6840
6841
  else {
6841
- let block = this.viewState.lineBlockAtHeight(sDOM.scrollTop);
6842
+ let block = this.viewState.lineBlockAtHeight(scrollTop);
6842
6843
  scrollAnchorPos = block.from;
6843
6844
  scrollAnchorHeight = block.top;
6844
6845
  }
@@ -6904,7 +6905,7 @@ class EditorView {
6904
6905
  this.viewState.lineBlockAt(scrollAnchorPos).top;
6905
6906
  let diff = newAnchorHeight - scrollAnchorHeight;
6906
6907
  if (diff > 1 || diff < -1) {
6907
- sDOM.scrollTop += diff;
6908
+ sDOM.scrollTop = scrollTop + diff;
6908
6909
  scrolled = true;
6909
6910
  }
6910
6911
  }
@@ -8400,7 +8401,7 @@ const plugin = /*@__PURE__*/ViewPlugin.fromClass(class {
8400
8401
  update(update) {
8401
8402
  let { view } = update;
8402
8403
  let height = view.viewState.editorHeight - view.defaultLineHeight - view.documentPadding.top - 0.5;
8403
- if (height != this.height) {
8404
+ if (height >= 0 && height != this.height) {
8404
8405
  this.height = height;
8405
8406
  this.attrs = { style: `padding-bottom: ${height}px` };
8406
8407
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "6.13.0",
3
+ "version": "6.13.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",