@codemirror/view 0.20.5 → 0.20.6
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 +21 -19
- package/dist/index.js +21 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1063,14 +1063,16 @@ function attrsEq(a, b) {
|
|
|
1063
1063
|
return true;
|
|
1064
1064
|
}
|
|
1065
1065
|
function updateAttrs(dom, prev, attrs) {
|
|
1066
|
+
let changed = null;
|
|
1066
1067
|
if (prev)
|
|
1067
1068
|
for (let name in prev)
|
|
1068
1069
|
if (!(attrs && name in attrs))
|
|
1069
|
-
dom.removeAttribute(name);
|
|
1070
|
+
dom.removeAttribute(changed = name);
|
|
1070
1071
|
if (attrs)
|
|
1071
1072
|
for (let name in attrs)
|
|
1072
1073
|
if (!(prev && prev[name] == attrs[name]))
|
|
1073
|
-
dom.setAttribute(name, attrs[name]);
|
|
1074
|
+
dom.setAttribute(changed = name, attrs[name]);
|
|
1075
|
+
return !!changed;
|
|
1074
1076
|
}
|
|
1075
1077
|
|
|
1076
1078
|
/**
|
|
@@ -4747,24 +4749,22 @@ class ViewState {
|
|
|
4747
4749
|
this.defaultTextDirection = style.direction == "rtl" ? exports.Direction.RTL : exports.Direction.LTR;
|
|
4748
4750
|
let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
|
|
4749
4751
|
let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
|
|
4752
|
+
this.contentDOMHeight = dom.clientHeight;
|
|
4753
|
+
this.mustMeasureContent = false;
|
|
4750
4754
|
let result = 0, bias = 0;
|
|
4755
|
+
// Vertical padding
|
|
4756
|
+
let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
|
|
4757
|
+
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4758
|
+
this.paddingTop = paddingTop;
|
|
4759
|
+
this.paddingBottom = paddingBottom;
|
|
4760
|
+
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4761
|
+
}
|
|
4751
4762
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4752
4763
|
if (oracle.lineWrapping)
|
|
4753
4764
|
measureContent = true;
|
|
4754
4765
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4755
4766
|
result |= 8 /* Geometry */;
|
|
4756
4767
|
}
|
|
4757
|
-
if (measureContent) {
|
|
4758
|
-
this.mustMeasureContent = false;
|
|
4759
|
-
this.contentDOMHeight = dom.clientHeight;
|
|
4760
|
-
// Vertical padding
|
|
4761
|
-
let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
|
|
4762
|
-
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4763
|
-
result |= 8 /* Geometry */;
|
|
4764
|
-
this.paddingTop = paddingTop;
|
|
4765
|
-
this.paddingBottom = paddingBottom;
|
|
4766
|
-
}
|
|
4767
|
-
}
|
|
4768
4768
|
// Pixel viewport
|
|
4769
4769
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
4770
4770
|
let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
|
|
@@ -6053,7 +6053,7 @@ class EditorView {
|
|
|
6053
6053
|
update(transactions) {
|
|
6054
6054
|
if (this.updateState != 0 /* Idle */)
|
|
6055
6055
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6056
|
-
let redrawn = false, update;
|
|
6056
|
+
let redrawn = false, attrsChanged = false, update;
|
|
6057
6057
|
let state$1 = this.state;
|
|
6058
6058
|
for (let tr of transactions) {
|
|
6059
6059
|
if (tr.startState != state$1)
|
|
@@ -6091,7 +6091,7 @@ class EditorView {
|
|
|
6091
6091
|
redrawn = this.docView.update(update);
|
|
6092
6092
|
if (this.state.facet(styleModule) != this.styleModules)
|
|
6093
6093
|
this.mountStyles();
|
|
6094
|
-
this.updateAttrs();
|
|
6094
|
+
attrsChanged = this.updateAttrs();
|
|
6095
6095
|
this.showAnnouncements(transactions);
|
|
6096
6096
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6097
6097
|
}
|
|
@@ -6100,7 +6100,7 @@ class EditorView {
|
|
|
6100
6100
|
}
|
|
6101
6101
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6102
6102
|
this.viewState.mustMeasureContent = true;
|
|
6103
|
-
if (redrawn || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
|
|
6103
|
+
if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
|
|
6104
6104
|
this.requestMeasure();
|
|
6105
6105
|
if (!update.empty)
|
|
6106
6106
|
for (let listener of this.state.facet(updateListener))
|
|
@@ -6280,12 +6280,14 @@ class EditorView {
|
|
|
6280
6280
|
if (this.state.readOnly)
|
|
6281
6281
|
contentAttrs["aria-readonly"] = "true";
|
|
6282
6282
|
attrsFromFacet(this, contentAttributes, contentAttrs);
|
|
6283
|
-
this.observer.ignore(() => {
|
|
6284
|
-
updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
|
|
6285
|
-
updateAttrs(this.dom, this.editorAttrs, editorAttrs);
|
|
6283
|
+
let changed = this.observer.ignore(() => {
|
|
6284
|
+
let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
|
|
6285
|
+
let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);
|
|
6286
|
+
return changedContent || changedEditor;
|
|
6286
6287
|
});
|
|
6287
6288
|
this.editorAttrs = editorAttrs;
|
|
6288
6289
|
this.contentAttrs = contentAttrs;
|
|
6290
|
+
return changed;
|
|
6289
6291
|
}
|
|
6290
6292
|
showAnnouncements(trs) {
|
|
6291
6293
|
let first = true;
|
package/dist/index.js
CHANGED
|
@@ -1059,14 +1059,16 @@ function attrsEq(a, b) {
|
|
|
1059
1059
|
return true;
|
|
1060
1060
|
}
|
|
1061
1061
|
function updateAttrs(dom, prev, attrs) {
|
|
1062
|
+
let changed = null;
|
|
1062
1063
|
if (prev)
|
|
1063
1064
|
for (let name in prev)
|
|
1064
1065
|
if (!(attrs && name in attrs))
|
|
1065
|
-
dom.removeAttribute(name);
|
|
1066
|
+
dom.removeAttribute(changed = name);
|
|
1066
1067
|
if (attrs)
|
|
1067
1068
|
for (let name in attrs)
|
|
1068
1069
|
if (!(prev && prev[name] == attrs[name]))
|
|
1069
|
-
dom.setAttribute(name, attrs[name]);
|
|
1070
|
+
dom.setAttribute(changed = name, attrs[name]);
|
|
1071
|
+
return !!changed;
|
|
1070
1072
|
}
|
|
1071
1073
|
|
|
1072
1074
|
/**
|
|
@@ -4740,24 +4742,22 @@ class ViewState {
|
|
|
4740
4742
|
this.defaultTextDirection = style.direction == "rtl" ? Direction.RTL : Direction.LTR;
|
|
4741
4743
|
let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
|
|
4742
4744
|
let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
|
|
4745
|
+
this.contentDOMHeight = dom.clientHeight;
|
|
4746
|
+
this.mustMeasureContent = false;
|
|
4743
4747
|
let result = 0, bias = 0;
|
|
4748
|
+
// Vertical padding
|
|
4749
|
+
let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
|
|
4750
|
+
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4751
|
+
this.paddingTop = paddingTop;
|
|
4752
|
+
this.paddingBottom = paddingBottom;
|
|
4753
|
+
result |= 8 /* Geometry */ | 2 /* Height */;
|
|
4754
|
+
}
|
|
4744
4755
|
if (this.editorWidth != view.scrollDOM.clientWidth) {
|
|
4745
4756
|
if (oracle.lineWrapping)
|
|
4746
4757
|
measureContent = true;
|
|
4747
4758
|
this.editorWidth = view.scrollDOM.clientWidth;
|
|
4748
4759
|
result |= 8 /* Geometry */;
|
|
4749
4760
|
}
|
|
4750
|
-
if (measureContent) {
|
|
4751
|
-
this.mustMeasureContent = false;
|
|
4752
|
-
this.contentDOMHeight = dom.clientHeight;
|
|
4753
|
-
// Vertical padding
|
|
4754
|
-
let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
|
|
4755
|
-
if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
|
|
4756
|
-
result |= 8 /* Geometry */;
|
|
4757
|
-
this.paddingTop = paddingTop;
|
|
4758
|
-
this.paddingBottom = paddingBottom;
|
|
4759
|
-
}
|
|
4760
|
-
}
|
|
4761
4761
|
// Pixel viewport
|
|
4762
4762
|
let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
|
|
4763
4763
|
let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
|
|
@@ -6046,7 +6046,7 @@ class EditorView {
|
|
|
6046
6046
|
update(transactions) {
|
|
6047
6047
|
if (this.updateState != 0 /* Idle */)
|
|
6048
6048
|
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
|
|
6049
|
-
let redrawn = false, update;
|
|
6049
|
+
let redrawn = false, attrsChanged = false, update;
|
|
6050
6050
|
let state = this.state;
|
|
6051
6051
|
for (let tr of transactions) {
|
|
6052
6052
|
if (tr.startState != state)
|
|
@@ -6084,7 +6084,7 @@ class EditorView {
|
|
|
6084
6084
|
redrawn = this.docView.update(update);
|
|
6085
6085
|
if (this.state.facet(styleModule) != this.styleModules)
|
|
6086
6086
|
this.mountStyles();
|
|
6087
|
-
this.updateAttrs();
|
|
6087
|
+
attrsChanged = this.updateAttrs();
|
|
6088
6088
|
this.showAnnouncements(transactions);
|
|
6089
6089
|
this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
|
|
6090
6090
|
}
|
|
@@ -6093,7 +6093,7 @@ class EditorView {
|
|
|
6093
6093
|
}
|
|
6094
6094
|
if (update.startState.facet(theme) != update.state.facet(theme))
|
|
6095
6095
|
this.viewState.mustMeasureContent = true;
|
|
6096
|
-
if (redrawn || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
|
|
6096
|
+
if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
|
|
6097
6097
|
this.requestMeasure();
|
|
6098
6098
|
if (!update.empty)
|
|
6099
6099
|
for (let listener of this.state.facet(updateListener))
|
|
@@ -6273,12 +6273,14 @@ class EditorView {
|
|
|
6273
6273
|
if (this.state.readOnly)
|
|
6274
6274
|
contentAttrs["aria-readonly"] = "true";
|
|
6275
6275
|
attrsFromFacet(this, contentAttributes, contentAttrs);
|
|
6276
|
-
this.observer.ignore(() => {
|
|
6277
|
-
updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
|
|
6278
|
-
updateAttrs(this.dom, this.editorAttrs, editorAttrs);
|
|
6276
|
+
let changed = this.observer.ignore(() => {
|
|
6277
|
+
let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
|
|
6278
|
+
let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);
|
|
6279
|
+
return changedContent || changedEditor;
|
|
6279
6280
|
});
|
|
6280
6281
|
this.editorAttrs = editorAttrs;
|
|
6281
6282
|
this.contentAttrs = contentAttrs;
|
|
6283
|
+
return changed;
|
|
6282
6284
|
}
|
|
6283
6285
|
showAnnouncements(trs) {
|
|
6284
6286
|
let first = true;
|