prosemirror-view 1.28.0 → 1.28.1
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 +9 -5
- package/dist/index.js +9 -5
- package/package.json +1 -1
- package/src/index.ts +9 -5
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -5423,6 +5423,7 @@ var EditorView = function () {
|
|
|
5423
5423
|
key: "update",
|
|
5424
5424
|
value: function update(props) {
|
|
5425
5425
|
if (props.handleDOMEvents != this._props.handleDOMEvents) ensureListeners(this);
|
|
5426
|
+
var prevProps = this._props;
|
|
5426
5427
|
this._props = props;
|
|
5427
5428
|
|
|
5428
5429
|
if (props.plugins) {
|
|
@@ -5430,7 +5431,7 @@ var EditorView = function () {
|
|
|
5430
5431
|
this.directPlugins = props.plugins;
|
|
5431
5432
|
}
|
|
5432
5433
|
|
|
5433
|
-
this.updateStateInner(props.state,
|
|
5434
|
+
this.updateStateInner(props.state, prevProps);
|
|
5434
5435
|
}
|
|
5435
5436
|
}, {
|
|
5436
5437
|
key: "setProps",
|
|
@@ -5452,11 +5453,11 @@ var EditorView = function () {
|
|
|
5452
5453
|
}, {
|
|
5453
5454
|
key: "updateState",
|
|
5454
5455
|
value: function updateState(state) {
|
|
5455
|
-
this.updateStateInner(state, this.
|
|
5456
|
+
this.updateStateInner(state, this._props);
|
|
5456
5457
|
}
|
|
5457
5458
|
}, {
|
|
5458
5459
|
key: "updateStateInner",
|
|
5459
|
-
value: function updateStateInner(state,
|
|
5460
|
+
value: function updateStateInner(state, prevProps) {
|
|
5460
5461
|
var prev = this.state,
|
|
5461
5462
|
redraw = false,
|
|
5462
5463
|
updateSel = false;
|
|
@@ -5467,15 +5468,18 @@ var EditorView = function () {
|
|
|
5467
5468
|
}
|
|
5468
5469
|
|
|
5469
5470
|
this.state = state;
|
|
5471
|
+
var pluginsChanged = prev.plugins != state.plugins || this._props.plugins != prevProps.plugins;
|
|
5470
5472
|
|
|
5471
|
-
if (
|
|
5473
|
+
if (pluginsChanged || this._props.plugins != prevProps.plugins || this._props.nodeViews != prevProps.nodeViews) {
|
|
5472
5474
|
var nodeViews = buildNodeViews(this);
|
|
5473
5475
|
|
|
5474
5476
|
if (changedNodeViews(nodeViews, this.nodeViews)) {
|
|
5475
5477
|
this.nodeViews = nodeViews;
|
|
5476
5478
|
redraw = true;
|
|
5477
5479
|
}
|
|
5480
|
+
}
|
|
5478
5481
|
|
|
5482
|
+
if (pluginsChanged || prevProps.handleDOMEvents != this._props.handleDOMEvents) {
|
|
5479
5483
|
ensureListeners(this);
|
|
5480
5484
|
}
|
|
5481
5485
|
|
|
@@ -5483,7 +5487,7 @@ var EditorView = function () {
|
|
|
5483
5487
|
updateCursorWrapper(this);
|
|
5484
5488
|
var innerDeco = viewDecorations(this),
|
|
5485
5489
|
outerDeco = computeDocDeco(this);
|
|
5486
|
-
var scroll =
|
|
5490
|
+
var scroll = prev.plugins != state.plugins && !prev.doc.eq(state.doc) ? "reset" : state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve";
|
|
5487
5491
|
var updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);
|
|
5488
5492
|
if (updateDoc || !state.selection.eq(prev.selection)) updateSel = true;
|
|
5489
5493
|
var oldScrollPos = scroll == "preserve" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);
|
package/dist/index.js
CHANGED
|
@@ -4907,12 +4907,13 @@ class EditorView {
|
|
|
4907
4907
|
update(props) {
|
|
4908
4908
|
if (props.handleDOMEvents != this._props.handleDOMEvents)
|
|
4909
4909
|
ensureListeners(this);
|
|
4910
|
+
let prevProps = this._props;
|
|
4910
4911
|
this._props = props;
|
|
4911
4912
|
if (props.plugins) {
|
|
4912
4913
|
props.plugins.forEach(checkStateComponent);
|
|
4913
4914
|
this.directPlugins = props.plugins;
|
|
4914
4915
|
}
|
|
4915
|
-
this.updateStateInner(props.state,
|
|
4916
|
+
this.updateStateInner(props.state, prevProps);
|
|
4916
4917
|
}
|
|
4917
4918
|
/**
|
|
4918
4919
|
Update the view by updating existing props object with the object
|
|
@@ -4933,9 +4934,9 @@ class EditorView {
|
|
|
4933
4934
|
other props.
|
|
4934
4935
|
*/
|
|
4935
4936
|
updateState(state) {
|
|
4936
|
-
this.updateStateInner(state, this.
|
|
4937
|
+
this.updateStateInner(state, this._props);
|
|
4937
4938
|
}
|
|
4938
|
-
updateStateInner(state,
|
|
4939
|
+
updateStateInner(state, prevProps) {
|
|
4939
4940
|
let prev = this.state, redraw = false, updateSel = false;
|
|
4940
4941
|
// When stored marks are added, stop composition, so that they can
|
|
4941
4942
|
// be displayed.
|
|
@@ -4944,18 +4945,21 @@ class EditorView {
|
|
|
4944
4945
|
updateSel = true;
|
|
4945
4946
|
}
|
|
4946
4947
|
this.state = state;
|
|
4947
|
-
|
|
4948
|
+
let pluginsChanged = prev.plugins != state.plugins || this._props.plugins != prevProps.plugins;
|
|
4949
|
+
if (pluginsChanged || this._props.plugins != prevProps.plugins || this._props.nodeViews != prevProps.nodeViews) {
|
|
4948
4950
|
let nodeViews = buildNodeViews(this);
|
|
4949
4951
|
if (changedNodeViews(nodeViews, this.nodeViews)) {
|
|
4950
4952
|
this.nodeViews = nodeViews;
|
|
4951
4953
|
redraw = true;
|
|
4952
4954
|
}
|
|
4955
|
+
}
|
|
4956
|
+
if (pluginsChanged || prevProps.handleDOMEvents != this._props.handleDOMEvents) {
|
|
4953
4957
|
ensureListeners(this);
|
|
4954
4958
|
}
|
|
4955
4959
|
this.editable = getEditable(this);
|
|
4956
4960
|
updateCursorWrapper(this);
|
|
4957
4961
|
let innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this);
|
|
4958
|
-
let scroll =
|
|
4962
|
+
let scroll = prev.plugins != state.plugins && !prev.doc.eq(state.doc) ? "reset"
|
|
4959
4963
|
: state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve";
|
|
4960
4964
|
let updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);
|
|
4961
4965
|
if (updateDoc || !state.selection.eq(prev.selection))
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -124,12 +124,13 @@ export class EditorView {
|
|
|
124
124
|
/// the DOM.
|
|
125
125
|
update(props: DirectEditorProps) {
|
|
126
126
|
if (props.handleDOMEvents != this._props.handleDOMEvents) ensureListeners(this)
|
|
127
|
+
let prevProps = this._props
|
|
127
128
|
this._props = props
|
|
128
129
|
if (props.plugins) {
|
|
129
130
|
props.plugins.forEach(checkStateComponent)
|
|
130
131
|
this.directPlugins = props.plugins
|
|
131
132
|
}
|
|
132
|
-
this.updateStateInner(props.state,
|
|
133
|
+
this.updateStateInner(props.state, prevProps)
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/// Update the view by updating existing props object with the object
|
|
@@ -146,10 +147,10 @@ export class EditorView {
|
|
|
146
147
|
/// Update the editor's `state` prop, without touching any of the
|
|
147
148
|
/// other props.
|
|
148
149
|
updateState(state: EditorState) {
|
|
149
|
-
this.updateStateInner(state, this.
|
|
150
|
+
this.updateStateInner(state, this._props)
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
private updateStateInner(state: EditorState,
|
|
153
|
+
private updateStateInner(state: EditorState, prevProps: DirectEditorProps) {
|
|
153
154
|
let prev = this.state, redraw = false, updateSel = false
|
|
154
155
|
// When stored marks are added, stop composition, so that they can
|
|
155
156
|
// be displayed.
|
|
@@ -158,12 +159,15 @@ export class EditorView {
|
|
|
158
159
|
updateSel = true
|
|
159
160
|
}
|
|
160
161
|
this.state = state
|
|
161
|
-
|
|
162
|
+
let pluginsChanged = prev.plugins != state.plugins || this._props.plugins != prevProps.plugins
|
|
163
|
+
if (pluginsChanged || this._props.plugins != prevProps.plugins || this._props.nodeViews != prevProps.nodeViews) {
|
|
162
164
|
let nodeViews = buildNodeViews(this)
|
|
163
165
|
if (changedNodeViews(nodeViews, this.nodeViews)) {
|
|
164
166
|
this.nodeViews = nodeViews
|
|
165
167
|
redraw = true
|
|
166
168
|
}
|
|
169
|
+
}
|
|
170
|
+
if (pluginsChanged || prevProps.handleDOMEvents != this._props.handleDOMEvents) {
|
|
167
171
|
ensureListeners(this)
|
|
168
172
|
}
|
|
169
173
|
|
|
@@ -171,7 +175,7 @@ export class EditorView {
|
|
|
171
175
|
updateCursorWrapper(this)
|
|
172
176
|
let innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this)
|
|
173
177
|
|
|
174
|
-
let scroll =
|
|
178
|
+
let scroll = prev.plugins != state.plugins && !prev.doc.eq(state.doc) ? "reset"
|
|
175
179
|
: (state as any).scrollToSelection > (prev as any).scrollToSelection ? "to selection" : "preserve"
|
|
176
180
|
let updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco)
|
|
177
181
|
if (updateDoc || !state.selection.eq(prev.selection)) updateSel = true
|