prosemirror-view 1.41.6 → 1.41.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,11 @@
1
+ ## 1.41.7 (2026-03-18)
2
+
3
+ ### Bug fixes
4
+
5
+ Work around a Chrome bug where it sometimes inserts a random `<br>` node when you press backspace before a widget.
6
+
7
+ Fix a crash that could happen when deleting content during a node drag.
8
+
1
9
  ## 1.41.6 (2026-02-06)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -4413,7 +4413,13 @@ var DOMObserver = function () {
4413
4413
  var node = _step3.value;
4414
4414
  if (node.nodeName == "BR" && node.parentNode) {
4415
4415
  var after = node.nextSibling;
4416
- if (after && after.nodeType == 1 && after.contentEditable == "false") node.parentNode.removeChild(node);
4416
+ while (after && after.nodeType == 1) {
4417
+ if (after.contentEditable == "false") {
4418
+ node.parentNode.removeChild(node);
4419
+ break;
4420
+ }
4421
+ after = after.firstChild;
4422
+ }
4417
4423
  }
4418
4424
  }
4419
4425
  } catch (err) {
@@ -5129,11 +5135,11 @@ var EditorView = function () {
5129
5135
  value: function updateDraggedNode(dragging, prev) {
5130
5136
  var sel = dragging.node,
5131
5137
  found = -1;
5132
- if (this.state.doc.nodeAt(sel.from) == sel.node) {
5138
+ if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {
5133
5139
  found = sel.from;
5134
5140
  } else {
5135
5141
  var movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size);
5136
- var moved = movedPos > 0 && this.state.doc.nodeAt(movedPos);
5142
+ var moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos);
5137
5143
  if (moved == sel.node) found = movedPos;
5138
5144
  }
5139
5145
  this.dragging = new Dragging(dragging.slice, dragging.move, found < 0 ? undefined : prosemirrorState.NodeSelection.create(this.state.doc, found));
package/dist/index.js CHANGED
@@ -4730,8 +4730,13 @@ class DOMObserver {
4730
4730
  for (let node of added)
4731
4731
  if (node.nodeName == "BR" && node.parentNode) {
4732
4732
  let after = node.nextSibling;
4733
- if (after && after.nodeType == 1 && after.contentEditable == "false")
4734
- node.parentNode.removeChild(node);
4733
+ while (after && after.nodeType == 1) {
4734
+ if (after.contentEditable == "false") {
4735
+ node.parentNode.removeChild(node);
4736
+ break;
4737
+ }
4738
+ after = after.firstChild;
4739
+ }
4735
4740
  }
4736
4741
  }
4737
4742
  else if (gecko && added.length) {
@@ -5578,12 +5583,12 @@ class EditorView {
5578
5583
  }
5579
5584
  updateDraggedNode(dragging, prev) {
5580
5585
  let sel = dragging.node, found = -1;
5581
- if (this.state.doc.nodeAt(sel.from) == sel.node) {
5586
+ if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {
5582
5587
  found = sel.from;
5583
5588
  }
5584
5589
  else {
5585
5590
  let movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size);
5586
- let moved = movedPos > 0 && this.state.doc.nodeAt(movedPos);
5591
+ let moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos);
5587
5592
  if (moved == sel.node)
5588
5593
  found = movedPos;
5589
5594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.41.6",
3
+ "version": "1.41.7",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -197,8 +197,13 @@ export class DOMObserver {
197
197
  // backspace out the last bit of text before an inline-flex node (#1552)
198
198
  for (let node of added) if (node.nodeName == "BR" && node.parentNode) {
199
199
  let after = node.nextSibling
200
- if (after && after.nodeType == 1 && (after as HTMLElement).contentEditable == "false")
201
- node.parentNode.removeChild(node)
200
+ while (after && after.nodeType == 1) {
201
+ if ((after as HTMLElement).contentEditable == "false") {
202
+ node.parentNode.removeChild(node)
203
+ break
204
+ }
205
+ after = after.firstChild
206
+ }
202
207
  }
203
208
  } else if (browser.gecko && added.length) {
204
209
  let brs = added.filter(n => n.nodeName == "BR") as HTMLElement[]
package/src/index.ts CHANGED
@@ -274,11 +274,11 @@ export class EditorView {
274
274
 
275
275
  private updateDraggedNode(dragging: Dragging, prev: EditorState) {
276
276
  let sel = dragging.node!, found = -1
277
- if (this.state.doc.nodeAt(sel.from) == sel.node) {
277
+ if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {
278
278
  found = sel.from
279
279
  } else {
280
280
  let movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size)
281
- let moved = movedPos > 0 && this.state.doc.nodeAt(movedPos)
281
+ let moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos)
282
282
  if (moved == sel.node) found = movedPos
283
283
  }
284
284
  this.dragging = new Dragging(dragging.slice, dragging.move,