prosemirror-view 1.23.7 → 1.23.10

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,21 @@
1
+ ## 1.23.10 (2022-03-22)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a crash in `DecorationSet.map` that could occur with some kinds of lift transformations.
6
+
7
+ ## 1.23.9 (2022-03-11)
8
+
9
+ ### Bug fixes
10
+
11
+ Make sure screen readers don't read the `<img>` nodes added as kludge for cursor behavior.
12
+
13
+ ## 1.23.8 (2022-03-10)
14
+
15
+ ### Bug fixes
16
+
17
+ Fix an issue where the editor needlessly interrupted composition with IME systems that keep the cursor at the start of the composition, such as some Pinyin input methods.
18
+
1
19
  ## 1.23.7 (2022-02-25)
2
20
 
3
21
  ### Bug fixes
package/dist/index.es.js CHANGED
@@ -1924,7 +1924,10 @@ ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
1924
1924
  this.index++;
1925
1925
  } else {
1926
1926
  var dom = document.createElement(nodeName);
1927
- if (nodeName == "IMG") { dom.className = "ProseMirror-separator"; }
1927
+ if (nodeName == "IMG") {
1928
+ dom.className = "ProseMirror-separator";
1929
+ dom.alt = "";
1930
+ }
1928
1931
  if (nodeName == "BR") { dom.className = "ProseMirror-trailingBreak"; }
1929
1932
  this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));
1930
1933
  this.changed = true;
@@ -2082,10 +2085,13 @@ function findTextInFragment(frag, text, from, to) {
2082
2085
  if (!next.isText) { break }
2083
2086
  str += next.text;
2084
2087
  }
2085
- if (pos >= from && childStart < to) {
2086
- var found = str.lastIndexOf(text, to - childStart - 1);
2088
+ if (pos >= from) {
2089
+ var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
2087
2090
  if (found >= 0 && found + text.length + childStart >= from)
2088
2091
  { return childStart + found }
2092
+ if (from == to && str.length >= (to + text.length) - childStart &&
2093
+ str.slice(to - childStart, to - childStart + text.length) == text)
2094
+ { return to }
2089
2095
  }
2090
2096
  }
2091
2097
  return -1
@@ -2682,6 +2688,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2682
2688
 
2683
2689
  var sel = view.state.selection;
2684
2690
  var parse = parseBetween(view, from, to);
2691
+
2685
2692
  // Chrome sometimes leaves the cursor before the inserted text when
2686
2693
  // composing after a cursor wrapper. This moves it forward.
2687
2694
  if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
@@ -2727,9 +2734,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2727
2734
  if (view.state.selection.from < view.state.selection.to &&
2728
2735
  change.start == change.endB &&
2729
2736
  view.state.selection instanceof TextSelection) {
2730
- if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2) {
2737
+ if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 &&
2738
+ view.state.selection.from >= parse.from) {
2731
2739
  change.start = view.state.selection.from;
2732
- } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2) {
2740
+ } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 &&
2741
+ view.state.selection.to <= parse.to) {
2733
2742
  change.endB += (view.state.selection.to - change.endA);
2734
2743
  change.endA = view.state.selection.to;
2735
2744
  }
@@ -4668,9 +4677,10 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
4668
4677
  var shift = function (oldStart, oldEnd, newStart, newEnd) {
4669
4678
  for (var i = 0; i < children.length; i += 3) {
4670
4679
  var end = children[i + 1], dSize = (void 0);
4671
- if (end == -1 || oldStart > end + oldOffset) { continue }
4672
- if (oldEnd >= children[i] + oldOffset) {
4673
- children[i + 1] = -1;
4680
+ if (end < 0 || oldStart > end + oldOffset) { continue }
4681
+ var start = children[i] + oldOffset;
4682
+ if (oldEnd >= start) {
4683
+ children[i + 1] = oldStart <= start ? -2 : -1;
4674
4684
  } else if (newStart >= offset && (dSize = (newEnd - newStart) - (oldEnd - oldStart))) {
4675
4685
  children[i] += dSize;
4676
4686
  children[i + 1] += dSize;
@@ -4682,7 +4692,12 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
4682
4692
  // Find the child nodes that still correspond to a single node,
4683
4693
  // recursively call mapInner on them and update their positions.
4684
4694
  var mustRebuild = false;
4685
- for (var i$1 = 0; i$1 < children.length; i$1 += 3) { if (children[i$1 + 1] == -1) { // Touched nodes
4695
+ for (var i$1 = 0; i$1 < children.length; i$1 += 3) { if (children[i$1 + 1] < 0) { // Touched nodes
4696
+ if (children[i$1 + 1] == -2) {
4697
+ mustRebuild = true;
4698
+ children[i$1 + 1] = -1;
4699
+ continue
4700
+ }
4686
4701
  var from = mapping.map(oldChildren[i$1] + oldOffset), fromLocal = from - offset;
4687
4702
  if (fromLocal < 0 || fromLocal >= node.content.size) {
4688
4703
  mustRebuild = true;
@@ -5278,6 +5293,7 @@ function updateCursorWrapper(view) {
5278
5293
  var dom = document.createElement("img");
5279
5294
  dom.className = "ProseMirror-separator";
5280
5295
  dom.setAttribute("mark-placeholder", "true");
5296
+ dom.setAttribute("alt", "");
5281
5297
  view.cursorWrapper = {dom: dom, deco: Decoration.widget(view.state.selection.head, dom, {raw: true, marks: view.markCursor})};
5282
5298
  } else {
5283
5299
  view.cursorWrapper = null;