markdown list items erase empty
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user