@codemirror/view 0.19.19 → 0.19.20
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 +6 -0
- package/dist/index.cjs +23 -6
- package/dist/index.js +23 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1943,6 +1943,9 @@ class DocView extends ContentView {
|
|
|
1943
1943
|
// we don't mess it up when reading it back it
|
|
1944
1944
|
this.impreciseAnchor = null;
|
|
1945
1945
|
this.impreciseHead = null;
|
|
1946
|
+
// Used by the resize observer to ignore resizes that we caused
|
|
1947
|
+
// ourselves
|
|
1948
|
+
this.lastUpdate = 0;
|
|
1946
1949
|
this.setDOM(view.contentDOM);
|
|
1947
1950
|
this.children = [new LineView];
|
|
1948
1951
|
this.children[0].setParent(this);
|
|
@@ -1956,6 +1959,7 @@ class DocView extends ContentView {
|
|
|
1956
1959
|
// position, if we know the editor is going to scroll that position
|
|
1957
1960
|
// into view.
|
|
1958
1961
|
update(update) {
|
|
1962
|
+
this.lastUpdate = Date.now();
|
|
1959
1963
|
let changedRanges = update.changedRanges;
|
|
1960
1964
|
if (this.minWidth > 0 && changedRanges.length) {
|
|
1961
1965
|
if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
|
|
@@ -4482,6 +4486,7 @@ class ViewState {
|
|
|
4482
4486
|
this.paddingTop = 0;
|
|
4483
4487
|
this.paddingBottom = 0;
|
|
4484
4488
|
this.contentWidth = 0;
|
|
4489
|
+
this.editorHeight = 0;
|
|
4485
4490
|
this.heightOracle = new HeightOracle;
|
|
4486
4491
|
// See VP.MaxDOMHeight
|
|
4487
4492
|
this.scaler = IdScaler;
|
|
@@ -4581,6 +4586,10 @@ class ViewState {
|
|
|
4581
4586
|
this.contentWidth = contentWidth;
|
|
4582
4587
|
result |= 8 /* Geometry */;
|
|
4583
4588
|
}
|
|
4589
|
+
if (this.editorHeight != docView.view.scrollDOM.clientHeight) {
|
|
4590
|
+
this.editorHeight = docView.view.scrollDOM.clientHeight;
|
|
4591
|
+
result |= 8 /* Geometry */;
|
|
4592
|
+
}
|
|
4584
4593
|
if (dTop > 0 && dBottom > 0)
|
|
4585
4594
|
bias = Math.max(dTop, dBottom);
|
|
4586
4595
|
else if (dTop < 0 && dBottom < 0)
|
|
@@ -5072,6 +5081,7 @@ class DOMObserver {
|
|
|
5072
5081
|
this.lastFlush = 0;
|
|
5073
5082
|
this.scrollTargets = [];
|
|
5074
5083
|
this.intersection = null;
|
|
5084
|
+
this.resize = null;
|
|
5075
5085
|
this.intersecting = false;
|
|
5076
5086
|
this.gapIntersection = null;
|
|
5077
5087
|
this.gaps = [];
|
|
@@ -5108,6 +5118,13 @@ class DOMObserver {
|
|
|
5108
5118
|
this.flushSoon();
|
|
5109
5119
|
};
|
|
5110
5120
|
this.onSelectionChange = this.onSelectionChange.bind(this);
|
|
5121
|
+
if (typeof ResizeObserver == "function") {
|
|
5122
|
+
this.resize = new ResizeObserver(() => {
|
|
5123
|
+
if (this.view.docView.lastUpdate < Date.now() - 100)
|
|
5124
|
+
this.view.requestMeasure();
|
|
5125
|
+
});
|
|
5126
|
+
this.resize.observe(view.scrollDOM);
|
|
5127
|
+
}
|
|
5111
5128
|
this.start();
|
|
5112
5129
|
this.onScroll = this.onScroll.bind(this);
|
|
5113
5130
|
window.addEventListener("scroll", this.onScroll);
|
|
@@ -5321,11 +5338,11 @@ class DOMObserver {
|
|
|
5321
5338
|
}
|
|
5322
5339
|
}
|
|
5323
5340
|
destroy() {
|
|
5341
|
+
var _a, _b, _c;
|
|
5324
5342
|
this.stop();
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
this.gapIntersection.disconnect();
|
|
5343
|
+
(_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
5344
|
+
(_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
5345
|
+
(_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
5329
5346
|
for (let dom of this.scrollTargets)
|
|
5330
5347
|
dom.removeEventListener("scroll", this.onScroll);
|
|
5331
5348
|
window.removeEventListener("scroll", this.onScroll);
|
|
@@ -5838,7 +5855,7 @@ class EditorView {
|
|
|
5838
5855
|
return;
|
|
5839
5856
|
if (this.measureScheduled > -1)
|
|
5840
5857
|
cancelAnimationFrame(this.measureScheduled);
|
|
5841
|
-
this.measureScheduled =
|
|
5858
|
+
this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
|
|
5842
5859
|
if (flush)
|
|
5843
5860
|
this.observer.flush();
|
|
5844
5861
|
let updated = null;
|
|
@@ -5899,8 +5916,8 @@ class EditorView {
|
|
|
5899
5916
|
}
|
|
5900
5917
|
finally {
|
|
5901
5918
|
this.updateState = 0 /* Idle */;
|
|
5919
|
+
this.measureScheduled = -1;
|
|
5902
5920
|
}
|
|
5903
|
-
this.measureScheduled = -1;
|
|
5904
5921
|
if (updated && !updated.empty)
|
|
5905
5922
|
for (let listener of this.state.facet(updateListener))
|
|
5906
5923
|
listener(updated);
|
package/dist/index.js
CHANGED
|
@@ -1939,6 +1939,9 @@ class DocView extends ContentView {
|
|
|
1939
1939
|
// we don't mess it up when reading it back it
|
|
1940
1940
|
this.impreciseAnchor = null;
|
|
1941
1941
|
this.impreciseHead = null;
|
|
1942
|
+
// Used by the resize observer to ignore resizes that we caused
|
|
1943
|
+
// ourselves
|
|
1944
|
+
this.lastUpdate = 0;
|
|
1942
1945
|
this.setDOM(view.contentDOM);
|
|
1943
1946
|
this.children = [new LineView];
|
|
1944
1947
|
this.children[0].setParent(this);
|
|
@@ -1952,6 +1955,7 @@ class DocView extends ContentView {
|
|
|
1952
1955
|
// position, if we know the editor is going to scroll that position
|
|
1953
1956
|
// into view.
|
|
1954
1957
|
update(update) {
|
|
1958
|
+
this.lastUpdate = Date.now();
|
|
1955
1959
|
let changedRanges = update.changedRanges;
|
|
1956
1960
|
if (this.minWidth > 0 && changedRanges.length) {
|
|
1957
1961
|
if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
|
|
@@ -4476,6 +4480,7 @@ class ViewState {
|
|
|
4476
4480
|
this.paddingTop = 0;
|
|
4477
4481
|
this.paddingBottom = 0;
|
|
4478
4482
|
this.contentWidth = 0;
|
|
4483
|
+
this.editorHeight = 0;
|
|
4479
4484
|
this.heightOracle = new HeightOracle;
|
|
4480
4485
|
// See VP.MaxDOMHeight
|
|
4481
4486
|
this.scaler = IdScaler;
|
|
@@ -4575,6 +4580,10 @@ class ViewState {
|
|
|
4575
4580
|
this.contentWidth = contentWidth;
|
|
4576
4581
|
result |= 8 /* Geometry */;
|
|
4577
4582
|
}
|
|
4583
|
+
if (this.editorHeight != docView.view.scrollDOM.clientHeight) {
|
|
4584
|
+
this.editorHeight = docView.view.scrollDOM.clientHeight;
|
|
4585
|
+
result |= 8 /* Geometry */;
|
|
4586
|
+
}
|
|
4578
4587
|
if (dTop > 0 && dBottom > 0)
|
|
4579
4588
|
bias = Math.max(dTop, dBottom);
|
|
4580
4589
|
else if (dTop < 0 && dBottom < 0)
|
|
@@ -5066,6 +5075,7 @@ class DOMObserver {
|
|
|
5066
5075
|
this.lastFlush = 0;
|
|
5067
5076
|
this.scrollTargets = [];
|
|
5068
5077
|
this.intersection = null;
|
|
5078
|
+
this.resize = null;
|
|
5069
5079
|
this.intersecting = false;
|
|
5070
5080
|
this.gapIntersection = null;
|
|
5071
5081
|
this.gaps = [];
|
|
@@ -5102,6 +5112,13 @@ class DOMObserver {
|
|
|
5102
5112
|
this.flushSoon();
|
|
5103
5113
|
};
|
|
5104
5114
|
this.onSelectionChange = this.onSelectionChange.bind(this);
|
|
5115
|
+
if (typeof ResizeObserver == "function") {
|
|
5116
|
+
this.resize = new ResizeObserver(() => {
|
|
5117
|
+
if (this.view.docView.lastUpdate < Date.now() - 100)
|
|
5118
|
+
this.view.requestMeasure();
|
|
5119
|
+
});
|
|
5120
|
+
this.resize.observe(view.scrollDOM);
|
|
5121
|
+
}
|
|
5105
5122
|
this.start();
|
|
5106
5123
|
this.onScroll = this.onScroll.bind(this);
|
|
5107
5124
|
window.addEventListener("scroll", this.onScroll);
|
|
@@ -5315,11 +5332,11 @@ class DOMObserver {
|
|
|
5315
5332
|
}
|
|
5316
5333
|
}
|
|
5317
5334
|
destroy() {
|
|
5335
|
+
var _a, _b, _c;
|
|
5318
5336
|
this.stop();
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
this.gapIntersection.disconnect();
|
|
5337
|
+
(_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
5338
|
+
(_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
5339
|
+
(_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
5323
5340
|
for (let dom of this.scrollTargets)
|
|
5324
5341
|
dom.removeEventListener("scroll", this.onScroll);
|
|
5325
5342
|
window.removeEventListener("scroll", this.onScroll);
|
|
@@ -5832,7 +5849,7 @@ class EditorView {
|
|
|
5832
5849
|
return;
|
|
5833
5850
|
if (this.measureScheduled > -1)
|
|
5834
5851
|
cancelAnimationFrame(this.measureScheduled);
|
|
5835
|
-
this.measureScheduled =
|
|
5852
|
+
this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
|
|
5836
5853
|
if (flush)
|
|
5837
5854
|
this.observer.flush();
|
|
5838
5855
|
let updated = null;
|
|
@@ -5893,8 +5910,8 @@ class EditorView {
|
|
|
5893
5910
|
}
|
|
5894
5911
|
finally {
|
|
5895
5912
|
this.updateState = 0 /* Idle */;
|
|
5913
|
+
this.measureScheduled = -1;
|
|
5896
5914
|
}
|
|
5897
|
-
this.measureScheduled = -1;
|
|
5898
5915
|
if (updated && !updated.empty)
|
|
5899
5916
|
for (let listener of this.state.facet(updateListener))
|
|
5900
5917
|
listener(updated);
|