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/dist/index.js CHANGED
@@ -68,7 +68,8 @@ function scanFor(node, off, targetNode, targetOff, dir) {
68
68
  if (node == targetNode && off == targetOff) { return true }
69
69
  if (off == (dir < 0 ? 0 : nodeSize(node))) {
70
70
  var parent = node.parentNode;
71
- if (parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false")
71
+ if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
72
+ node.contentEditable == "false")
72
73
  { return false }
73
74
  off = domIndex(node) + (dir < 0 ? 0 : 1);
74
75
  node = parent;
@@ -1055,7 +1056,8 @@ ViewDesc.prototype.markDirty = function markDirty (from, to) {
1055
1056
  else { child.markDirty(from - startInside, to - startInside); }
1056
1057
  return
1057
1058
  } else {
1058
- child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM ? CONTENT_DIRTY : NODE_DIRTY;
1059
+ child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM && !child.children.length
1060
+ ? CONTENT_DIRTY : NODE_DIRTY;
1059
1061
  }
1060
1062
  }
1061
1063
  offset = end;
@@ -1193,7 +1195,10 @@ var MarkViewDesc = /*@__PURE__*/(function (ViewDesc) {
1193
1195
  return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom)
1194
1196
  };
1195
1197
 
1196
- MarkViewDesc.prototype.parseRule = function parseRule () { return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM} };
1198
+ MarkViewDesc.prototype.parseRule = function parseRule () {
1199
+ if ((this.dirty & NODE_DIRTY) || this.mark.type.spec.reparseInView) { return null }
1200
+ return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM}
1201
+ };
1197
1202
 
1198
1203
  MarkViewDesc.prototype.matchesMark = function matchesMark (mark) { return this.dirty != NODE_DIRTY && this.mark.eq(mark) };
1199
1204
 
@@ -2081,10 +2086,13 @@ function findTextInFragment(frag, text, from, to) {
2081
2086
  if (!next.isText) { break }
2082
2087
  str += next.text;
2083
2088
  }
2084
- if (pos >= from && childStart < to) {
2085
- var found = str.lastIndexOf(text, to - childStart - 1);
2089
+ if (pos >= from) {
2090
+ var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;
2086
2091
  if (found >= 0 && found + text.length + childStart >= from)
2087
2092
  { return childStart + found }
2093
+ if (from == to && str.length >= (to + text.length) - childStart &&
2094
+ str.slice(to - childStart, to - childStart + text.length) == text)
2095
+ { return to }
2088
2096
  }
2089
2097
  }
2090
2098
  return -1
@@ -2152,7 +2160,10 @@ function selectionToDOM(view, force) {
2152
2160
 
2153
2161
  if (!editorOwnsSelection(view)) { return }
2154
2162
 
2155
- if (!force && view.mouseDown && view.mouseDown.allowDefault) {
2163
+ // The delayed drag selection causes issues with Cell Selections
2164
+ // in Safari. And the drag selection delay is to workarond issues
2165
+ // which only present in Chrome.
2166
+ if (!force && view.mouseDown && view.mouseDown.allowDefault && result.chrome) {
2156
2167
  var domSel = view.root.getSelection(), curSel = view.domObserver.currentSelection;
2157
2168
  if (domSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset,
2158
2169
  curSel.anchorNode, curSel.anchorOffset)) {
@@ -2678,6 +2689,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2678
2689
 
2679
2690
  var sel = view.state.selection;
2680
2691
  var parse = parseBetween(view, from, to);
2692
+
2681
2693
  // Chrome sometimes leaves the cursor before the inserted text when
2682
2694
  // composing after a cursor wrapper. This moves it forward.
2683
2695
  if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {
@@ -2723,9 +2735,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
2723
2735
  if (view.state.selection.from < view.state.selection.to &&
2724
2736
  change.start == change.endB &&
2725
2737
  view.state.selection instanceof prosemirrorState.TextSelection) {
2726
- if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2) {
2738
+ if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 &&
2739
+ view.state.selection.from >= parse.from) {
2727
2740
  change.start = view.state.selection.from;
2728
- } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2) {
2741
+ } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 &&
2742
+ view.state.selection.to <= parse.to) {
2729
2743
  change.endB += (view.state.selection.to - change.endA);
2730
2744
  change.endA = view.state.selection.to;
2731
2745
  }
@@ -3355,7 +3369,7 @@ DOMObserver.prototype.flush = function flush () {
3355
3369
  checkCSS(this.view);
3356
3370
  }
3357
3371
  this.handleDOMChange(from, to, typeOver, added);
3358
- if (this.view.docView.dirty) { this.view.updateState(this.view.state); }
3372
+ if (this.view.docView && this.view.docView.dirty) { this.view.updateState(this.view.state); }
3359
3373
  else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); }
3360
3374
  this.currentSelection.set(sel);
3361
3375
  }
@@ -3906,7 +3920,7 @@ function endComposition(view, forceUpdate) {
3906
3920
  if (result.android && view.domObserver.flushingSoon >= 0) { return }
3907
3921
  view.domObserver.forceFlush();
3908
3922
  clearComposition(view);
3909
- if (forceUpdate || view.docView.dirty) {
3923
+ if (forceUpdate || view.docView && view.docView.dirty) {
3910
3924
  var sel = selectionFromDOM(view);
3911
3925
  if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); }
3912
3926
  else { view.updateState(view.state); }
@@ -5448,7 +5462,10 @@ function checkStateComponent(plugin) {
5448
5462
  // The DOM serializer to use when putting content onto the
5449
5463
  // clipboard. If not given, the result of
5450
5464
  // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
5451
- // 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.
5452
5469
  //
5453
5470
  // clipboardTextSerializer:: ?(Slice) → string
5454
5471
  // A function that will be called to get the text for the current