mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Fix for pasting text in the middle of an action
This commit is contained in:
@@ -3081,6 +3081,7 @@ function gametextwatcher(records) {
|
|||||||
//Here we want to take care of two possible events
|
//Here we want to take care of two possible events
|
||||||
//User deleted an action. For this we'll restore the action and set it's text to "" and mark it as dirty
|
//User deleted an action. For this we'll restore the action and set it's text to "" and mark it as dirty
|
||||||
//User changes text. For this we simply mark it as dirty
|
//User changes text. For this we simply mark it as dirty
|
||||||
|
console.log(records);
|
||||||
var game_text = document.getElementById("Selected Text");
|
var game_text = document.getElementById("Selected Text");
|
||||||
for (const record of records) {
|
for (const record of records) {
|
||||||
if ((record.type === "childList") && (record.removedNodes.length > 0)) {
|
if ((record.type === "childList") && (record.removedNodes.length > 0)) {
|
||||||
@@ -3129,7 +3130,7 @@ function gametextwatcher(records) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log(dirty_chunks);
|
console.log(dirty_chunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fix_dirty_game_text() {
|
function fix_dirty_game_text() {
|
||||||
@@ -3165,6 +3166,11 @@ function fix_dirty_game_text() {
|
|||||||
if (!dirty_chunks.includes(node.previousElementSibling.getAttribute("chunk"))) {
|
if (!dirty_chunks.includes(node.previousElementSibling.getAttribute("chunk"))) {
|
||||||
dirty_chunks.push(node.previousElementSibling.getAttribute("chunk"));
|
dirty_chunks.push(node.previousElementSibling.getAttribute("chunk"));
|
||||||
}
|
}
|
||||||
|
//Looks like sometimes it splits the parent. Let's look for that and fix it too
|
||||||
|
if (node.nextElementSibling && (node.nextElementSibling.getAttribute("chunk") == node.previousElementSibling.getAttribute("chunk"))) {
|
||||||
|
node.previousElementSibling.innerText = node.previousElementSibling.innerText + node.nextElementSibling.innerText;
|
||||||
|
node.nextElementSibling.remove();
|
||||||
|
}
|
||||||
node.remove();
|
node.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user