mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Bug Fix for text highlighting and deleting old code
This commit is contained in:
@@ -566,9 +566,9 @@ function do_story_text_updates(action) {
|
|||||||
item.classList.add("rawtext");
|
item.classList.add("rawtext");
|
||||||
item.setAttribute("chunk", action.id);
|
item.setAttribute("chunk", action.id);
|
||||||
item.setAttribute("tabindex", parseInt(action.id)+1);
|
item.setAttribute("tabindex", parseInt(action.id)+1);
|
||||||
item.addEventListener("focus", (event) => {
|
//item.addEventListener("focus", (event) => {
|
||||||
set_edit(event.target);
|
// set_edit(event.target);
|
||||||
});
|
//});
|
||||||
|
|
||||||
//need to find the closest element
|
//need to find the closest element
|
||||||
closest_element = document.getElementById("story_prompt");
|
closest_element = document.getElementById("story_prompt");
|
||||||
@@ -3044,11 +3044,23 @@ function toggle_adventure_mode(button) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_edit(element) {
|
function set_edit(event) {
|
||||||
for (item of document.getElementsByClassName("editing")) {
|
//get the element sitting on
|
||||||
item.classList.remove("editing");
|
var game_text = document.getElementById("Selected Text");
|
||||||
|
if ((event.key === undefined) || (event.key == 'ArrowDown') || (event.key == 'ArrowUp') || (event.key == 'ArrowLeft') || (event.key == 'ArrowRight')) {
|
||||||
|
var chunk = window.getSelection().anchorNode;
|
||||||
|
while (chunk != game_text) {
|
||||||
|
if ((chunk instanceof HTMLElement) && (chunk.hasAttribute("chunk"))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chunk = chunk.parentNode;
|
||||||
|
}
|
||||||
|
for (item of document.getElementsByClassName("editing")) {
|
||||||
|
item.classList.remove("editing");
|
||||||
|
}
|
||||||
|
chunk.classList.add("editing");
|
||||||
}
|
}
|
||||||
element.classList.add("editing");
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function gametextwatcher(records) {
|
function gametextwatcher(records) {
|
||||||
@@ -3089,9 +3101,9 @@ function gametextwatcher(records) {
|
|||||||
} else {
|
} else {
|
||||||
//For some reason we've deleted a chunk but it still exists in the DOM. Something is wrong here
|
//For some reason we've deleted a chunk but it still exists in the DOM. Something is wrong here
|
||||||
//Seems to loose the events on the item, but otherwise is OK. DEPLOY HACK!!!
|
//Seems to loose the events on the item, but otherwise is OK. DEPLOY HACK!!!
|
||||||
document.getElementById("Selected Text Chunk " + chunk.getAttribute("chunk")).addEventListener("focus", (event) => {
|
//document.getElementById("Selected Text Chunk " + chunk.getAttribute("chunk")).addEventListener("focus", (event) => {
|
||||||
set_edit(event.target);
|
// set_edit(event.target);
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,8 +53,8 @@
|
|||||||
<div id="welcome_text" class="var_sync_model_welcome" draggable="False"></div>
|
<div id="welcome_text" class="var_sync_model_welcome" draggable="False"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="gametext" id="Selected Text" contenteditable=false tabindex=0 onfocusout="savegametextchanges();">
|
<div class="gametext" id="Selected Text" contenteditable=false tabindex=0 onfocusout="savegametextchanges();" onclick="return set_edit(event)" onkeyup="return set_edit(event)">
|
||||||
<span id="story_prompt" class="var_sync_story_prompt var_sync_alt_story_prompt_in_ai rawtext hidden" tabindex=0 chunk="-1" onfocus="set_edit(this);"></span></div><!--don't move the /div down or it'll cause odd spacing issues in the UI--->
|
<span id="story_prompt" class="var_sync_story_prompt var_sync_alt_story_prompt_in_ai rawtext hidden" chunk="-1"></span></div><!--don't move the /div down or it'll cause odd spacing issues in the UI--->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!------------ Sequences --------------------->
|
<!------------ Sequences --------------------->
|
||||||
|
Reference in New Issue
Block a user