mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-17 12:10:49 +01:00
Merge pull request #6 from VE-FORBRYDERNE/editable-chunks
More bug fixes for editable chunks
This commit is contained in:
commit
33d76a5132
@ -1429,6 +1429,8 @@ def inlinedelete(chunk):
|
||||
# Don't delete prompt
|
||||
if(chunk == 0):
|
||||
# Send error message
|
||||
refresh_story()
|
||||
emit('from_server', {'cmd': 'errmsg', 'data': "Cannot delete the prompt."})
|
||||
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
|
||||
else:
|
||||
del vars.actions[chunk-1]
|
||||
|
@ -622,7 +622,9 @@ function setadventure(state) {
|
||||
|
||||
function autofocus(event) {
|
||||
if(connected) {
|
||||
current_editing_chunk = event.target;
|
||||
if(event.target.tagName == "CHUNK") {
|
||||
current_editing_chunk = event.target;
|
||||
}
|
||||
event.target.focus();
|
||||
} else {
|
||||
event.preventDefault();
|
||||
@ -644,11 +646,17 @@ function chunkOnKeyDown(event) {
|
||||
switch(event.keyCode) {
|
||||
case 37: // left
|
||||
case 39: // right
|
||||
old_selection_offset = getSelection().focusOffset;
|
||||
old_range = getSelection().getRangeAt(0);
|
||||
old_range_start = old_range.startOffset;
|
||||
old_range_end = old_range.endOffset;
|
||||
old_range_ancestor = old_range.commonAncestorContainer;
|
||||
old_range_start_container = old_range.startContainer;
|
||||
old_range_end_container = old_range.endContainer;
|
||||
setTimeout(function () {
|
||||
// Wait a few milliseconds and check if the caret has moved
|
||||
new_selection = getSelection();
|
||||
if(old_selection_offset != new_selection.focusOffset) {
|
||||
new_range = new_selection.getRangeAt(0);
|
||||
if(old_range_start != new_range.startOffset || old_range_end != new_range.endOffset || old_range_ancestor != new_range.commonAncestorContainer || old_range_start_container != new_range.startContainer || old_range_end_container != new_range.endContainer) {
|
||||
return;
|
||||
}
|
||||
// If it hasn't moved, we're at the beginning or end of a chunk
|
||||
@ -850,6 +858,7 @@ $(document).ready(function(){
|
||||
}, 5);
|
||||
}
|
||||
newly_loaded = false;
|
||||
hideMessage();
|
||||
} else if(msg.cmd == "scrolldown") {
|
||||
setTimeout(function () {
|
||||
$('#gamescreen').animate({scrollTop: $('#gamescreen').prop('scrollHeight')}, 1000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user