prosemirror-view 1.23.7 → 1.23.8

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.8 (2022-03-10)
2
+
3
+ ### Bug fixes
4
+
5
+ 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.
6
+
1
7
  ## 1.23.7 (2022-02-25)
2
8
 
3
9
  ### Bug fixes
package/dist/index.es.js CHANGED
@@ -2082,10 +2082,13 @@ function findTextInFragment(frag, text, from, to) {
2082
2082
  if (!next.isText) { break }
2083
2083
  str += next.text;
2084
2084
  }
2085
- if (pos >= from && childStart < to) {
2086
- var found = str.lastIndexOf(text, to - childStart - 1);
2085
+ if (pos >= from) {
2086
+ var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
2087
2087
  if (found >= 0 && found + text.length + childStart >= from)
2088
2088
  { return childStart + found }
2089
+ if (from == to && str.length >= (to + text.length) - childStart &&
2090
+ str.slice(to - childStart, to - childStart + text.length) == text)
2091
+ { return to }
2089
2092
  }
2090
2093
  }
2091
2094
  return -1
@@ -2682,6 +2685,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2682
2685
 
2683
2686
  var sel = view.state.selection;
2684
2687
  var parse = parseBetween(view, from, to);
2688
+
2685
2689
  // Chrome sometimes leaves the cursor before the inserted text when
2686
2690
  // composing after a cursor wrapper. This moves it forward.
2687
2691
  if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
@@ -2727,9 +2731,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2727
2731
  if (view.state.selection.from < view.state.selection.to &&
2728
2732
  change.start == change.endB &&
2729
2733
  view.state.selection instanceof TextSelection) {
2730
- if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2) {
2734
+ if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 &&
2735
+ view.state.selection.from >= parse.from) {
2731
2736
  change.start = view.state.selection.from;
2732
- } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2) {
2737
+ } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 &&
2738
+ view.state.selection.to <= parse.to) {
2733
2739
  change.endB += (view.state.selection.to - change.endA);
2734
2740
  change.endA = view.state.selection.to;
2735
2741
  }