Skip to content

Commit e8385aa

Browse files
committed
fix: backspace at start of nested list item deleted a char from the parent item
Fixes #1277
1 parent 6ffdf70 commit e8385aa

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
> - :house: [Internal]
1010
> - :nail_care: [Polish]
1111

12+
## 4.12.14
13+
14+
#### :bug: Bug Fix
15+
16+
- **Backspace / Lists**: pressing Backspace at the start of a nested list item deleted the last character of the parent item instead of removing the nesting. `checkRemoveChar` walked out of the nested `<li>`/list and removed a character from the parent item's text. It no longer crosses a list-item boundary, so the list cases handle the operation cleanly. Fixes [#1277](https://github.com/xdan/jodit/issues/1277).
17+
1218
## 4.12.13
1319

1420
#### :bug: Bug Fix

src/plugins/backspace/backspace.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ describe('Backspace/Delete key', function () {
7575
'<ol><li>ab</li></ol><p>|cd</p> => <ol><li>ab|cd</li></ol>',
7676
'<p>ab</p><ol><li>|cd</li></ol> => <p>ab</p><p>|cd</p>',
7777
'<ol><li>ab</li><li>|cd</li></ol> => <ol><li>ab|cd</li></ol>',
78+
// #1277: backspace at the start of a nested list item must not delete
79+
// a character from the parent item across the list boundary.
80+
'<ol><li>power<ol><li>|child</li></ol></li></ol> => <ol><li>power<p>|child</p></li></ol>',
81+
'<ul><li>power<ul><li>|child</li></ul></li></ul> => <ul><li>power<p>|child</p></li></ul>',
7882
'test<br>|plot => test|plot => => {"enter": "br"}',
7983
'test<br>|plot => testtext|plot => => {"enter": "br"} => text',
8084
'test<br>p|lot => test<br>|lot => => {"enter": "br"}',

src/plugins/backspace/cases/check-remove-char.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ function getNextInlineSibling(
133133

134134
if (!nextSibling && sibling.parentNode && sibling.parentNode !== root) {
135135
nextSibling = findMostNestedNeighbor(sibling, !backspace, root, true);
136+
137+
// Do not cross a list-item boundary. At the start of a list item the
138+
// neighbor can be the text of the parent/previous item; deleting a char
139+
// there is wrong — the list cases must handle the outdent/merge (#1277).
140+
if (
141+
nextSibling &&
142+
Dom.closest(sibling, 'li', root) !==
143+
Dom.closest(nextSibling, 'li', root)
144+
) {
145+
return null;
146+
}
136147
}
137148

138149
return nextSibling;

0 commit comments

Comments
 (0)