prosemirror-view 1.23.4 → 1.23.7

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.7 (2022-02-25)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a crash when a view was being destroyed during input reading.
6
+
7
+ Fix a crash on Firefox when replacing text in some specific types of document structure.
8
+
9
+ ## 1.23.6 (2022-01-13)
10
+
11
+ ### Bug fixes
12
+
13
+ Fix an issue that could cause pieces of DOM to not be synchronized with the document after some kind of changes around marks.
14
+
15
+ Fix a bug where marks rendered with nested elements would in some situations suppress new input.
16
+
17
+ Disable Chrome-specific drag-selection workaround in non-Chrome browsers because it affected table cell selection in Safari.
18
+
19
+ ## 1.23.5 (2021-12-27)
20
+
21
+ ### Bug fixes
22
+
23
+ Use the `whitespace` node prop where appropriate.
24
+
1
25
  ## 1.23.4 (2021-12-22)
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
 
@@ -1290,7 +1295,7 @@ var NodeViewDesc = /*@__PURE__*/(function (ViewDesc) {
1290
1295
  // attrs in the dom, that won't be picked up. Not entirely sure
1291
1296
  // whether this is a problem
1292
1297
  var rule = {node: this.node.type.name, attrs: this.node.attrs};
1293
- if (this.node.type.spec.code) { rule.preserveWhitespace = "full"; }
1298
+ if (this.node.type.whitespace == "pre") { rule.preserveWhitespace = "full"; }
1294
1299
  if (this.contentDOM && !this.contentLost) { rule.contentElement = this.contentDOM; }
1295
1300
  else { rule.getContent = function () { return this$1.contentDOM ? Fragment.empty : this$1.node.content; }; }
1296
1301
  return rule
@@ -2148,7 +2153,10 @@ function selectionToDOM(view, force) {
2148
2153
 
2149
2154
  if (!editorOwnsSelection(view)) { return }
2150
2155
 
2151
- if (!force && view.mouseDown && view.mouseDown.allowDefault) {
2156
+ // The delayed drag selection causes issues with Cell Selections
2157
+ // in Safari. And the drag selection delay is to workarond issues
2158
+ // which only present in Chrome.
2159
+ if (!force && view.mouseDown && view.mouseDown.allowDefault && result.chrome) {
2152
2160
  var domSel = view.root.getSelection(), curSel = view.domObserver.currentSelection;
2153
2161
  if (domSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset,
2154
2162
  curSel.anchorNode, curSel.anchorOffset)) {
@@ -2620,7 +2628,7 @@ function parseBetween(view, from_, to_) {
2620
2628
  topOpen: true,
2621
2629
  from: fromOffset,
2622
2630
  to: toOffset,
2623
- preserveWhitespace: $from.parent.type.spec.code ? "full" : true,
2631
+ preserveWhitespace: $from.parent.type.whitespace == "pre" ? "full" : true,
2624
2632
  editableContent: true,
2625
2633
  findPositions: find,
2626
2634
  ruleFromNode: ruleFromNode,
@@ -3351,7 +3359,7 @@ DOMObserver.prototype.flush = function flush () {
3351
3359
  checkCSS(this.view);
3352
3360
  }
3353
3361
  this.handleDOMChange(from, to, typeOver, added);
3354
- if (this.view.docView.dirty) { this.view.updateState(this.view.state); }
3362
+ if (this.view.docView && this.view.docView.dirty) { this.view.updateState(this.view.state); }
3355
3363
  else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); }
3356
3364
  this.currentSelection.set(sel);
3357
3365
  }
@@ -3902,7 +3910,7 @@ function endComposition(view, forceUpdate) {
3902
3910
  if (result.android && view.domObserver.flushingSoon >= 0) { return }
3903
3911
  view.domObserver.forceFlush();
3904
3912
  clearComposition(view);
3905
- if (forceUpdate || view.docView.dirty) {
3913
+ if (forceUpdate || view.docView && view.docView.dirty) {
3906
3914
  var sel = selectionFromDOM(view);
3907
3915
  if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); }
3908
3916
  else { view.updateState(view.state); }
@@ -5444,7 +5452,10 @@ function checkStateComponent(plugin) {
5444
5452
  // The DOM serializer to use when putting content onto the
5445
5453
  // clipboard. If not given, the result of
5446
5454
  // [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)
5447
- // will be used.
5455
+ // will be used. This object will only have its
5456
+ // [`serializeFragment`](#model.DOMSerializer.serializeFragment)
5457
+ // method called, and you may provide an alternative object type
5458
+ // implementing a compatible method.
5448
5459
  //
5449
5460
  // clipboardTextSerializer:: ?(Slice) → string
5450
5461
  // A function that will be called to get the text for the current