markdown list items erase empty

This commit is contained in:
Yuri Kuznetsov
2025-02-07 22:59:06 +02:00
parent bf2813c241
commit 4ce40dd85c
+11 -1
View File
@@ -630,7 +630,7 @@ class TextFieldView extends BaseFieldView {
const after = value.substring(selectionEnd);
// Last line, a list item syntax.
const match = before.match(/(^|\n)( *[-*]|\d+\.)[^\n]*$/);
const match = before.match(/(^|\n)( *[-*]|\d+\.)([^\n]*)$/);
if (!match) {
return;
@@ -638,6 +638,15 @@ class TextFieldView extends BaseFieldView {
event.preventDefault();
if (match[3].trim() === '') {
target.value = before.substring(0, match.index) + '\n' + after;
target.selectionStart = target.selectionEnd = target.value.length - after.length;
this.controlTextareaHeight();
return;
}
let itemPart = match[2];
const matchPart = itemPart.match(/( *)(\d+)/);
@@ -653,6 +662,7 @@ class TextFieldView extends BaseFieldView {
const newLine = "\n" + itemPart + " ";
target.value = before + newLine + after;
target.selectionStart = target.selectionEnd = target.value.length - after.length;
this.controlTextareaHeight();
}