fix textarea newline handle (#32966) (#32977)

Backport #32966 by metiftikci

Co-authored-by: metiftikci <metiftikci@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2024-12-25 13:10:14 +08:00 committed by GitHub
parent 90bd08ceef
commit 0e0ebf68d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View file

@ -92,6 +92,7 @@ function handleNewline(textarea: HTMLTextAreaElement, e: Event) {
if (!line) {
// clear current line if we only have i.e. '1. ' and the user presses enter again to finish creating a list
textarea.value = value.slice(0, lineStart) + value.slice(lineEnd);
textarea.setSelectionRange(selStart - prefix.length, selStart - prefix.length);
} else {
// start a new line with the same indention and prefix
let newPrefix = prefix;