prosemirror-view 1.23.5 → 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,27 @@
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
+
7
+ ## 1.23.7 (2022-02-25)
8
+
9
+ ### Bug fixes
10
+
11
+ Fix a crash when a view was being destroyed during input reading.
12
+
13
+ Fix a crash on Firefox when replacing text in some specific types of document structure.
14
+
15
+ ## 1.23.6 (2022-01-13)
16
+
17
+ ### Bug fixes
18
+
19
+ Fix an issue that could cause pieces of DOM to not be synchronized with the document after some kind of changes around marks.
20
+
21
+ Fix a bug where marks rendered with nested elements would in some situations suppress new input.
22
+
23
+ Disable Chrome-specific drag-selection workaround in non-Chrome browsers because it affected table cell selection in Safari.
24
+
1
25
  ## 1.23.5 (2021-12-27)
2
26
 
3
27
  ### 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;
@@ -1051,7 +1052,8 @@ ViewDesc.prototype.markDirty = function markDirty (from, to) {
1051
1052
  else { child.markDirty(from - startInside, to - startInside); }
1052
1053
  return
1053
1054
  } else {
1054
- child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM ? CONTENT_DIRTY : NODE_DIRTY;
1055
+ child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM && !child.children.length
1056
+ ? CONTENT_DIRTY : NODE_DIRTY;
1055
1057
  }
1056
1058
  }
1057
1059
  offset = end;
@@ -1189,7 +1191,10 @@ var MarkViewDesc = /*@__PURE__*/(function (ViewDesc) {
1189
1191
  return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom)
1190
1192
  };
1191
1193
 
1192
- MarkViewDesc.prototype.parseRule = function parseRule () { return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM} };
1194
+ MarkViewDesc.prototype.parseRule = function parseRule () {
1195
+ if ((this.dirty & NODE_DIRTY) || this.mark.type.spec.reparseInView) { return null }
1196
+ return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM}
1197
+ };
1193
1198
 
1194
1199
  MarkViewDesc.prototype.matchesMark = function matchesMark (mark) { return this.dirty != NODE_DIRTY && this.mark.eq(mark) };
1195
1200
 
@@ -2077,10 +2082,13 @@ function findTextInFragment(frag, text, from, to) {
2077
2082
  if (!next.isText) { break }
2078
2083
  str += next.text;
2079
2084
  }
2080
- if (pos >= from && childStart < to) {
2081
- var found = str.lastIndexOf(text, to - childStart - 1);
2085
+ if (pos >= from) {
2086
+ var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
2082
2087
  if (found >= 0 && found + text.length + childStart >= from)
2083
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 }
2084
2092
  }
2085
2093
  }
2086
2094
  return -1
@@ -2148,7 +2156,10 @@ function selectionToDOM(view, force) {
2148
2156
 
2149
2157
  if (!editorOwnsSelection(view)) { return }
2150
2158
 
2151
- if (!force && view.mouseDown && view.mouseDown.allowDefault) {
2159
+ // The delayed drag selection causes issues with Cell Selections
2160
+ // in Safari. And the drag selection delay is to workarond issues
2161
+ // which only present in Chrome.
2162
+ if (!force && view.mouseDown && view.mouseDown.allowDefault && result.chrome) {
2152
2163
  var domSel = view.root.getSelection(), curSel = view.domObserver.currentSelection;
2153
2164
  if (domSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset,
2154
2165
  curSel.anchorNode, curSel.anchorOffset)) {
@@ -2674,6 +2685,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2674
2685
 
2675
2686
  var sel = view.state.selection;
2676
2687
  var parse = parseBetween(view, from, to);
2688
+
2677
2689
  // Chrome sometimes leaves the cursor before the inserted text when
2678
2690
  // composing after a cursor wrapper. This moves it forward.
2679
2691
  if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
@@ -2719,9 +2731,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2719
2731
  if (view.state.selection.from < view.state.selection.to &&
2720
2732
  change.start == change.endB &&
2721
2733
  view.state.selection instanceof TextSelection) {
2722
- 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) {
2723
2736
  change.start = view.state.selection.from;
2724
- } 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) {
2725
2739
  change.endB += (view.state.selection.to - change.endA);
2726
2740
  change.endA = view.state.selection.to;
2727
2741
  }
@@ -3351,7 +3365,7 @@ DOMObserver.prototype.flush = function flush () {
3351
3365
  checkCSS(this.view);
3352
3366
  }
3353
3367
  this.handleDOMChange(from, to, typeOver, added);
3354
- if (this.view.docView.dirty) { this.view.updateState(this.view.state); }
3368
+ if (this.view.docView && this.view.docView.dirty) { this.view.updateState(this.view.state); }
3355
3369
  else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); }
3356
3370
  this.currentSelection.set(sel);
3357
3371
  }
@@ -3902,7 +3916,7 @@ function endComposition(view, forceUpdate) {
3902
3916
  if (result.android && view.domObserver.flushingSoon >= 0) { return }
3903
3917
  view.domObserver.forceFlush();
3904
3918
  clearComposition(view);
3905
- if (forceUpdate || view.docView.dirty) {
3919
+ if (forceUpdate || view.docView && view.docView.dirty) {
3906
3920
  var sel = selectionFromDOM(view);
3907
3921
  if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); }
3908
3922
  else { view.updateState(view.state); }
@@ -5444,7 +5458,10 @@ function checkStateComponent(plugin) {
5444
5458
  // The DOM serializer to use when putting content onto the
5445
5459
  // clipboard. If not given, the result of
5446
5460
  // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
5447
- // will be used.
5461
+ // will be used. This object will only have its
5462
+ // [`serializeFragment`](#model.DOMSerializer.serializeFragment)
5463
+ // method called, and you may provide an alternative object type
5464
+ // implementing a compatible method.
5448
5465
  //
5449
5466
  // clipboardTextSerializer:: ?(Slice) → string
5450
5467
  // A function that will be called to get the text for the current