mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-17 12:10:49 +01:00
Fix enter key sometimes putting two newlines in editor
This happens when, in a Chromium-based browser, you try to insert a newline at the end of the last action of your story.
This commit is contained in:
parent
ce5f4d3dda
commit
cccf8296fc
@ -1420,9 +1420,14 @@ function chunkOnTextInput(event) {
|
||||
// to put the <br/> back in the right place
|
||||
var br = $("#_EDITOR_LINEBREAK_")[0];
|
||||
if(br.parentNode === game_text[0]) {
|
||||
var parent = br.previousSibling;
|
||||
if(br.previousSibling.nodeType !== 1) {
|
||||
parent = br.previousSibling.previousSibling;
|
||||
br.previousSibling.previousSibling.appendChild(br.previousSibling);
|
||||
}
|
||||
if(parent.lastChild.tagName === "BR") {
|
||||
parent.lastChild.remove(); // Chrome also inserts an extra <br/> in this case for some reason so we need to remove it
|
||||
}
|
||||
br.previousSibling.appendChild(br);
|
||||
r.selectNodeContents(br.parentNode);
|
||||
s.removeAllRanges();
|
||||
|
Loading…
x
Reference in New Issue
Block a user