prosemirror-view 1.23.10 → 1.23.11

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,9 @@
1
+ ## 1.23.11 (2022-03-31)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where a node view with a separate content wrapper node could sometimes lose its content on Chrome when backspacing out content due to unexpected DOM element recreation.
6
+
1
7
  ## 1.23.10 (2022-03-22)
2
8
 
3
9
  ### Bug fixes
package/dist/index.es.js CHANGED
@@ -1296,8 +1296,23 @@ var NodeViewDesc = /*@__PURE__*/(function (ViewDesc) {
1296
1296
  // whether this is a problem
1297
1297
  var rule = {node: this.node.type.name, attrs: this.node.attrs};
1298
1298
  if (this.node.type.whitespace == "pre") { rule.preserveWhitespace = "full"; }
1299
- if (this.contentDOM && !this.contentLost) { rule.contentElement = this.contentDOM; }
1300
- else { rule.getContent = function () { return this$1.contentDOM ? Fragment.empty : this$1.node.content; }; }
1299
+ if (!this.contentDOM) {
1300
+ rule.getContent = function () { return this$1.node.content; };
1301
+ } else if (!this.contentLost) {
1302
+ rule.contentElement = this.contentDOM;
1303
+ } else {
1304
+ // Chrome likes to randomly recreate parent nodes when
1305
+ // backspacing things. When that happens, this tries to find the
1306
+ // new parent.
1307
+ for (var i = this.children.length - 1; i >= 0; i--) {
1308
+ var child = this.children[i];
1309
+ if (this.dom.contains(child.dom.parentNode)) {
1310
+ rule.contentElement = child.dom.parentNode;
1311
+ break
1312
+ }
1313
+ }
1314
+ if (!rule.contentElement) { rule.getContent = function () { return Fragment.empty; }; }
1315
+ }
1301
1316
  return rule
1302
1317
  };
1303
1318