prosemirror-view 1.31.0 → 1.31.2

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,17 @@
1
+ ## 1.31.2 (2023-05-10)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a bug that broke backspace after empty lines in code blocks on Firefox.
6
+
7
+ Make it possible for the `attributes` prop to override the `translate` attribute.
8
+
9
+ ## 1.31.1 (2023-05-01)
10
+
11
+ ### Bug fixes
12
+
13
+ Fix a bug that could cause a view crash on some kind of document updates.
14
+
1
15
  ## 1.31.0 (2023-04-26)
2
16
 
3
17
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1134,21 +1134,6 @@ var ViewDesc = function () {
1134
1134
 
1135
1135
  if (node.nodeType == 3) {
1136
1136
  brKludge = !!(_offset && node.nodeValue[_offset - 1] == "\n");
1137
-
1138
- if (brKludge && _offset == node.nodeValue.length) {
1139
- for (var scan = node, after; scan; scan = scan.parentNode) {
1140
- if (after = scan.nextSibling) {
1141
- if (after.nodeName == "BR") anchorDOM = headDOM = {
1142
- node: after.parentNode,
1143
- offset: domIndex(after) + 1
1144
- };
1145
- break;
1146
- }
1147
-
1148
- var desc = scan.pmViewDesc;
1149
- if (desc && desc.node && desc.node.isBlock) break;
1150
- }
1151
- }
1152
1137
  } else {
1153
1138
  var prev = node.childNodes[_offset - 1];
1154
1139
  brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
@@ -1156,8 +1141,8 @@ var ViewDesc = function () {
1156
1141
  }
1157
1142
 
1158
1143
  if (gecko && domSel.focusNode && domSel.focusNode != headDOM.node && domSel.focusNode.nodeType == 1) {
1159
- var _after2 = domSel.focusNode.childNodes[domSel.focusOffset];
1160
- if (_after2 && _after2.contentEditable == "false") force = true;
1144
+ var after = domSel.focusNode.childNodes[domSel.focusOffset];
1145
+ if (after && after.contentEditable == "false") force = true;
1161
1146
  }
1162
1147
 
1163
1148
  if (!(force || brKludge && safari) && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, domSel.focusNode, domSel.focusOffset)) return;
@@ -2190,6 +2175,9 @@ var ViewTreeUpdater = function () {
2190
2175
  return true;
2191
2176
  } else if (!locked && (updated = this.recreateWrapper(next, node, outerDeco, innerDeco, view, pos))) {
2192
2177
  this.top.children[this.index] = updated;
2178
+ updated.dirty = CONTENT_DIRTY;
2179
+ updated.updateChildren(view, pos + 1);
2180
+ updated.dirty = NOT_DIRTY;
2193
2181
  this.changed = true;
2194
2182
  this.index++;
2195
2183
  return true;
@@ -2224,9 +2212,6 @@ var ViewTreeUpdater = function () {
2224
2212
  _iterator.f();
2225
2213
  }
2226
2214
 
2227
- wrapper.dirty = CONTENT_DIRTY;
2228
- wrapper.updateChildren(view, pos + 1);
2229
- wrapper.dirty = NOT_DIRTY;
2230
2215
  return wrapper;
2231
2216
  }
2232
2217
  }, {
@@ -5959,17 +5944,13 @@ function computeDocDeco(view) {
5959
5944
  var attrs = Object.create(null);
5960
5945
  attrs["class"] = "ProseMirror";
5961
5946
  attrs.contenteditable = String(view.editable);
5962
- attrs.translate = "no";
5963
5947
  view.someProp("attributes", function (value) {
5964
5948
  if (typeof value == "function") value = value(view.state);
5965
5949
  if (value) for (var attr in value) {
5966
- if (attr == "class") attrs["class"] += " " + value[attr];
5967
-
5968
- if (attr == "style") {
5969
- attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
5970
- } else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName") attrs[attr] = String(value[attr]);
5950
+ if (attr == "class") attrs["class"] += " " + value[attr];else if (attr == "style") attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName") attrs[attr] = String(value[attr]);
5971
5951
  }
5972
5952
  });
5953
+ if (!attrs.translate) attrs.translate = "no";
5973
5954
  return [Decoration.node(0, view.state.doc.content.size, attrs)];
5974
5955
  }
5975
5956
 
package/dist/index.js CHANGED
@@ -957,19 +957,6 @@ class ViewDesc {
957
957
  let { node, offset } = anchorDOM;
958
958
  if (node.nodeType == 3) {
959
959
  brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
960
- // Issue #1128
961
- if (brKludge && offset == node.nodeValue.length) {
962
- for (let scan = node, after; scan; scan = scan.parentNode) {
963
- if (after = scan.nextSibling) {
964
- if (after.nodeName == "BR")
965
- anchorDOM = headDOM = { node: after.parentNode, offset: domIndex(after) + 1 };
966
- break;
967
- }
968
- let desc = scan.pmViewDesc;
969
- if (desc && desc.node && desc.node.isBlock)
970
- break;
971
- }
972
- }
973
960
  }
974
961
  else {
975
962
  let prev = node.childNodes[offset - 1];
@@ -1808,6 +1795,9 @@ class ViewTreeUpdater {
1808
1795
  }
1809
1796
  else if (!locked && (updated = this.recreateWrapper(next, node, outerDeco, innerDeco, view, pos))) {
1810
1797
  this.top.children[this.index] = updated;
1798
+ updated.dirty = CONTENT_DIRTY;
1799
+ updated.updateChildren(view, pos + 1);
1800
+ updated.dirty = NOT_DIRTY;
1811
1801
  this.changed = true;
1812
1802
  this.index++;
1813
1803
  return true;
@@ -1830,9 +1820,6 @@ class ViewTreeUpdater {
1830
1820
  next.children = [];
1831
1821
  for (let ch of wrapper.children)
1832
1822
  ch.parent = wrapper;
1833
- wrapper.dirty = CONTENT_DIRTY;
1834
- wrapper.updateChildren(view, pos + 1);
1835
- wrapper.dirty = NOT_DIRTY;
1836
1823
  return wrapper;
1837
1824
  }
1838
1825
  // Insert the node as a newly created node desc.
@@ -5435,7 +5422,6 @@ function computeDocDeco(view) {
5435
5422
  let attrs = Object.create(null);
5436
5423
  attrs.class = "ProseMirror";
5437
5424
  attrs.contenteditable = String(view.editable);
5438
- attrs.translate = "no";
5439
5425
  view.someProp("attributes", value => {
5440
5426
  if (typeof value == "function")
5441
5427
  value = value(view.state);
@@ -5443,13 +5429,14 @@ function computeDocDeco(view) {
5443
5429
  for (let attr in value) {
5444
5430
  if (attr == "class")
5445
5431
  attrs.class += " " + value[attr];
5446
- if (attr == "style") {
5432
+ else if (attr == "style")
5447
5433
  attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
5448
- }
5449
5434
  else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName")
5450
5435
  attrs[attr] = String(value[attr]);
5451
5436
  }
5452
5437
  });
5438
+ if (!attrs.translate)
5439
+ attrs.translate = "no";
5453
5440
  return [Decoration.node(0, view.state.doc.content.size, attrs)];
5454
5441
  }
5455
5442
  function updateCursorWrapper(view) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.31.0",
3
+ "version": "1.31.2",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/index.ts CHANGED
@@ -478,20 +478,19 @@ function computeDocDeco(view: EditorView) {
478
478
  let attrs = Object.create(null)
479
479
  attrs.class = "ProseMirror"
480
480
  attrs.contenteditable = String(view.editable)
481
- attrs.translate = "no"
482
481
 
483
482
  view.someProp("attributes", value => {
484
483
  if (typeof value == "function") value = value(view.state)
485
484
  if (value) for (let attr in value) {
486
485
  if (attr == "class")
487
486
  attrs.class += " " + value[attr]
488
- if (attr == "style") {
487
+ else if (attr == "style")
489
488
  attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr]
490
- }
491
489
  else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName")
492
490
  attrs[attr] = String(value[attr])
493
491
  }
494
492
  })
493
+ if (!attrs.translate) attrs.translate = "no"
495
494
 
496
495
  return [Decoration.node(0, view.state.doc.content.size, attrs)]
497
496
  }
package/src/viewdesc.ts CHANGED
@@ -385,18 +385,6 @@ export class ViewDesc {
385
385
  let {node, offset} = anchorDOM
386
386
  if (node.nodeType == 3) {
387
387
  brKludge = !!(offset && node.nodeValue![offset - 1] == "\n")
388
- // Issue #1128
389
- if (brKludge && offset == node.nodeValue!.length) {
390
- for (let scan: DOMNode | null = node, after; scan; scan = scan.parentNode) {
391
- if (after = scan.nextSibling) {
392
- if (after.nodeName == "BR")
393
- anchorDOM = headDOM = {node: after.parentNode!, offset: domIndex(after) + 1}
394
- break
395
- }
396
- let desc = scan.pmViewDesc
397
- if (desc && desc.node && desc.node.isBlock) break
398
- }
399
- }
400
388
  } else {
401
389
  let prev = node.childNodes[offset - 1]
402
390
  brKludge = prev && (prev.nodeName == "BR" || (prev as HTMLElement).contentEditable == "false")
@@ -1244,6 +1232,9 @@ class ViewTreeUpdater {
1244
1232
  return true
1245
1233
  } else if (!locked && (updated = this.recreateWrapper(next, node, outerDeco, innerDeco, view, pos))) {
1246
1234
  this.top.children[this.index] = updated
1235
+ updated.dirty = CONTENT_DIRTY
1236
+ updated.updateChildren(view, pos + 1)
1237
+ updated.dirty = NOT_DIRTY
1247
1238
  this.changed = true
1248
1239
  this.index++
1249
1240
  return true
@@ -1265,9 +1256,7 @@ class ViewTreeUpdater {
1265
1256
  wrapper.children = next.children
1266
1257
  next.children = []
1267
1258
  for (let ch of wrapper.children) ch.parent = wrapper
1268
- wrapper.dirty = CONTENT_DIRTY
1269
- wrapper.updateChildren(view, pos + 1)
1270
- wrapper.dirty = NOT_DIRTY
1259
+
1271
1260
  return wrapper
1272
1261
  }
1273
1262