mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02: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:
@ -1420,9 +1420,14 @@ function chunkOnTextInput(event) {
|
|||||||
// to put the <br/> back in the right place
|
// to put the <br/> back in the right place
|
||||||
var br = $("#_EDITOR_LINEBREAK_")[0];
|
var br = $("#_EDITOR_LINEBREAK_")[0];
|
||||||
if(br.parentNode === game_text[0]) {
|
if(br.parentNode === game_text[0]) {
|
||||||
|
var parent = br.previousSibling;
|
||||||
if(br.previousSibling.nodeType !== 1) {
|
if(br.previousSibling.nodeType !== 1) {
|
||||||
|
parent = br.previousSibling.previousSibling;
|
||||||
br.previousSibling.previousSibling.appendChild(br.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);
|
br.previousSibling.appendChild(br);
|
||||||
r.selectNodeContents(br.parentNode);
|
r.selectNodeContents(br.parentNode);
|
||||||
s.removeAllRanges();
|
s.removeAllRanges();
|
||||||
|
Reference in New Issue
Block a user