prosemirror-view 1.23.9 → 1.23.12

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/dist/index.js CHANGED
@@ -1300,8 +1300,23 @@ var NodeViewDesc = /*@__PURE__*/(function (ViewDesc) {
1300
1300
  // whether this is a problem
1301
1301
  var rule = {node: this.node.type.name, attrs: this.node.attrs};
1302
1302
  if (this.node.type.whitespace == "pre") { rule.preserveWhitespace = "full"; }
1303
- if (this.contentDOM && !this.contentLost) { rule.contentElement = this.contentDOM; }
1304
- else { rule.getContent = function () { return this$1.contentDOM ? prosemirrorModel.Fragment.empty : this$1.node.content; }; }
1303
+ if (!this.contentDOM) {
1304
+ rule.getContent = function () { return this$1.node.content; };
1305
+ } else if (!this.contentLost) {
1306
+ rule.contentElement = this.contentDOM;
1307
+ } else {
1308
+ // Chrome likes to randomly recreate parent nodes when
1309
+ // backspacing things. When that happens, this tries to find the
1310
+ // new parent.
1311
+ for (var i = this.children.length - 1; i >= 0; i--) {
1312
+ var child = this.children[i];
1313
+ if (this.dom.contains(child.dom.parentNode)) {
1314
+ rule.contentElement = child.dom.parentNode;
1315
+ break
1316
+ }
1317
+ }
1318
+ if (!rule.contentElement) { rule.getContent = function () { return prosemirrorModel.Fragment.empty; }; }
1319
+ }
1305
1320
  return rule
1306
1321
  };
1307
1322
 
@@ -2714,15 +2729,17 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2714
2729
  view.lastKeyCode = null;
2715
2730
 
2716
2731
  var change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
2732
+ if ((result.ios && view.lastIOSEnter > Date.now() - 225 || result.android) &&
2733
+ addedNodes.some(function (n) { return n.nodeName == "DIV" || n.nodeName == "P"; }) &&
2734
+ (!change || change.endA >= change.endB) &&
2735
+ view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); })) {
2736
+ view.lastIOSEnter = 0;
2737
+ return
2738
+ }
2717
2739
  if (!change) {
2718
2740
  if (typeOver && sel instanceof prosemirrorState.TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) &&
2719
2741
  !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {
2720
2742
  change = {start: sel.from, endA: sel.to, endB: sel.to};
2721
- } else if ((result.ios && view.lastIOSEnter > Date.now() - 225 || result.android) &&
2722
- addedNodes.some(function (n) { return n.nodeName == "DIV" || n.nodeName == "P"; }) &&
2723
- view.someProp("handleKeyDown", function (f) { return f(view, keyEvent(13, "Enter")); })) {
2724
- view.lastIOSEnter = 0;
2725
- return
2726
2743
  } else {
2727
2744
  if (parse.sel) {
2728
2745
  var sel$1 = resolveSelection(view, view.state.doc, parse.sel);
@@ -4681,9 +4698,10 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
4681
4698
  var shift = function (oldStart, oldEnd, newStart, newEnd) {
4682
4699
  for (var i = 0; i < children.length; i += 3) {
4683
4700
  var end = children[i + 1], dSize = (void 0);
4684
- if (end == -1 || oldStart > end + oldOffset) { continue }
4685
- if (oldEnd >= children[i] + oldOffset) {
4686
- children[i + 1] = -1;
4701
+ if (end < 0 || oldStart > end + oldOffset) { continue }
4702
+ var start = children[i] + oldOffset;
4703
+ if (oldEnd >= start) {
4704
+ children[i + 1] = oldStart <= start ? -2 : -1;
4687
4705
  } else if (newStart >= offset && (dSize = (newEnd - newStart) - (oldEnd - oldStart))) {
4688
4706
  children[i] += dSize;
4689
4707
  children[i + 1] += dSize;
@@ -4695,7 +4713,12 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
4695
4713
  // Find the child nodes that still correspond to a single node,
4696
4714
  // recursively call mapInner on them and update their positions.
4697
4715
  var mustRebuild = false;
4698
- for (var i$1 = 0; i$1 < children.length; i$1 += 3) { if (children[i$1 + 1] == -1) { // Touched nodes
4716
+ for (var i$1 = 0; i$1 < children.length; i$1 += 3) { if (children[i$1 + 1] < 0) { // Touched nodes
4717
+ if (children[i$1 + 1] == -2) {
4718
+ mustRebuild = true;
4719
+ children[i$1 + 1] = -1;
4720
+ continue
4721
+ }
4699
4722
  var from = mapping.map(oldChildren[i$1] + oldOffset), fromLocal = from - offset;
4700
4723
  if (fromLocal < 0 || fromLocal >= node.content.size) {
4701
4724
  mustRebuild = true;