prosemirror-view 1.23.6 → 1.23.9

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,23 @@
1
+ ## 1.23.9 (2022-03-11)
2
+
3
+ ### Bug fixes
4
+
5
+ Make sure screen readers don't read the `<img>` nodes added as kludge for cursor behavior.
6
+
7
+ ## 1.23.8 (2022-03-10)
8
+
9
+ ### Bug fixes
10
+
11
+ 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.
12
+
13
+ ## 1.23.7 (2022-02-25)
14
+
15
+ ### Bug fixes
16
+
17
+ Fix a crash when a view was being destroyed during input reading.
18
+
19
+ Fix a crash on Firefox when replacing text in some specific types of document structure.
20
+
1
21
  ## 1.23.6 (2022-01-13)
2
22
 
3
23
  ### Bug fixes
package/dist/index.es.js CHANGED
@@ -64,7 +64,8 @@ function scanFor(node, off, targetNode, targetOff, dir) {
64
64
  if (node == targetNode && off == targetOff) { return true }
65
65
  if (off == (dir < 0 ? 0 : nodeSize(node))) {
66
66
  var parent = node.parentNode;
67
- if (parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false")
67
+ if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
68
+ node.contentEditable == "false")
68
69
  { return false }
69
70
  off = domIndex(node) + (dir < 0 ? 0 : 1);
70
71
  node = parent;
@@ -1923,7 +1924,10 @@ ViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {
1923
1924
  this.index++;
1924
1925
  } else {
1925
1926
  var dom = document.createElement(nodeName);
1926
- if (nodeName == "IMG") { dom.className = "ProseMirror-separator"; }
1927
+ if (nodeName == "IMG") {
1928
+ dom.className = "ProseMirror-separator";
1929
+ dom.alt = "";
1930
+ }
1927
1931
  if (nodeName == "BR") { dom.className = "ProseMirror-trailingBreak"; }
1928
1932
  this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));
1929
1933
  this.changed = true;
@@ -2081,10 +2085,13 @@ function findTextInFragment(frag, text, from, to) {
2081
2085
  if (!next.isText) { break }
2082
2086
  str += next.text;
2083
2087
  }
2084
- if (pos >= from && childStart < to) {
2085
- var found = str.lastIndexOf(text, to - childStart - 1);
2088
+ if (pos >= from) {
2089
+ var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
2086
2090
  if (found >= 0 && found + text.length + childStart >= from)
2087
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 }
2088
2095
  }
2089
2096
  }
2090
2097
  return -1
@@ -2681,6 +2688,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2681
2688
 
2682
2689
  var sel = view.state.selection;
2683
2690
  var parse = parseBetween(view, from, to);
2691
+
2684
2692
  // Chrome sometimes leaves the cursor before the inserted text when
2685
2693
  // composing after a cursor wrapper. This moves it forward.
2686
2694
  if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
@@ -2726,9 +2734,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2726
2734
  if (view.state.selection.from < view.state.selection.to &&
2727
2735
  change.start == change.endB &&
2728
2736
  view.state.selection instanceof TextSelection) {
2729
- 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) {
2730
2739
  change.start = view.state.selection.from;
2731
- } 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) {
2732
2742
  change.endB += (view.state.selection.to - change.endA);
2733
2743
  change.endA = view.state.selection.to;
2734
2744
  }
@@ -3358,7 +3368,7 @@ DOMObserver.prototype.flush = function flush () {
3358
3368
  checkCSS(this.view);
3359
3369
  }
3360
3370
  this.handleDOMChange(from, to, typeOver, added);
3361
- if (this.view.docView.dirty) { this.view.updateState(this.view.state); }
3371
+ if (this.view.docView && this.view.docView.dirty) { this.view.updateState(this.view.state); }
3362
3372
  else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); }
3363
3373
  this.currentSelection.set(sel);
3364
3374
  }
@@ -3909,7 +3919,7 @@ function endComposition(view, forceUpdate) {
3909
3919
  if (result.android && view.domObserver.flushingSoon >= 0) { return }
3910
3920
  view.domObserver.forceFlush();
3911
3921
  clearComposition(view);
3912
- if (forceUpdate || view.docView.dirty) {
3922
+ if (forceUpdate || view.docView && view.docView.dirty) {
3913
3923
  var sel = selectionFromDOM(view);
3914
3924
  if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); }
3915
3925
  else { view.updateState(view.state); }
@@ -5277,6 +5287,7 @@ function updateCursorWrapper(view) {
5277
5287
  var dom = document.createElement("img");
5278
5288
  dom.className = "ProseMirror-separator";
5279
5289
  dom.setAttribute("mark-placeholder", "true");
5290
+ dom.setAttribute("alt", "");
5280
5291
  view.cursorWrapper = {dom: dom, deco: Decoration.widget(view.state.selection.head, dom, {raw: true, marks: view.markCursor})};
5281
5292
  } else {
5282
5293
  view.cursorWrapper = null;
@@ -5451,7 +5462,10 @@ function checkStateComponent(plugin) {
5451
5462
  // The DOM serializer to use when putting content onto the
5452
5463
  // clipboard. If not given, the result of
5453
5464
  // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
5454
- // will be used.
5465
+ // will be used. This object will only have its
5466
+ // [`serializeFragment`](#model.DOMSerializer.serializeFragment)
5467
+ // method called, and you may provide an alternative object type
5468
+ // implementing a compatible method.
5455
5469
  //
5456
5470
  // clipboardTextSerializer:: ?(Slice) → string
5457
5471
  // A function that will be called to get the text for the current