diff --git a/packages/super-editor/src/core/commands/backspaceNextToRun.js b/packages/super-editor/src/core/commands/backspaceNextToRun.js index 6047f6b841..186c11efe8 100644 --- a/packages/super-editor/src/core/commands/backspaceNextToRun.js +++ b/packages/super-editor/src/core/commands/backspaceNextToRun.js @@ -23,17 +23,7 @@ export const backspaceNextToRun = if (prevNode?.type !== runType || prevNode.content.size === 0) return false; } - // Constrain the text scan to the adjacent run so we never delete - // text from a previous paragraph or an unrelated run. - let runContentStart; - if ($pos.nodeBefore) { - runContentStart = $pos.pos - $pos.nodeBefore.nodeSize + 1; - } else { - const prevNode = state.doc.resolve($pos.start() - 1).nodeBefore; - runContentStart = $pos.start() - 1 - prevNode.nodeSize + 1; - } - - const deleteRange = findPreviousTextDeleteRange(state.doc, $pos.pos, runContentStart); + const deleteRange = findPreviousTextDeleteRange(state.doc, $pos.pos); if (!deleteRange) return false; tr.delete(deleteRange.from, deleteRange.to).setSelection(Selection.near(tr.doc.resolve(deleteRange.from))); diff --git a/packages/super-editor/src/core/commands/backspaceNextToRun.test.js b/packages/super-editor/src/core/commands/backspaceNextToRun.test.js index 215b6e1568..80b59a8a10 100644 --- a/packages/super-editor/src/core/commands/backspaceNextToRun.test.js +++ b/packages/super-editor/src/core/commands/backspaceNextToRun.test.js @@ -109,27 +109,4 @@ describe('backspaceNextToRun', () => { }); expect(bookmarkCount).toBe(1); }); - - it('does not scan into previous paragraphs when adjacent run has only non-text inline content', () => { - const schema = makeSchema(); - const doc = schema.node('doc', null, [ - schema.node('paragraph', null, [schema.node('run', null, schema.text('A'))]), - schema.node('paragraph', null, [ - schema.node('run', null, [schema.node('bookmarkEnd')]), - schema.node('run', null, schema.text('B')), - ]), - ]); - - const boundary = posBetweenRuns(doc, ''); - expect(boundary).not.toBeNull(); - - const state = EditorState.create({ schema, doc, selection: TextSelection.create(doc, boundary ?? 1) }); - const dispatch = vi.fn(); - - const ok = backspaceNextToRun()({ state, tr: state.tr, dispatch }); - - expect(ok).toBe(false); - expect(dispatch).not.toHaveBeenCalled(); - expect(state.doc.textContent).toBe('AB'); - }); });