mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-23 06:57:44 +01:00
Attempt to fix issue where |
appears in editor after pressing enter
This commit is contained in:
parent
6f6f22801b
commit
ddc9be00d6
@ -1483,26 +1483,29 @@ function chunkOnBeforeInput(event) {
|
||||
if(buildChunkSetFromNodeArray(getSelectedNodes()).size === 0) {
|
||||
var s = rangy.getSelection();
|
||||
var r = s.getRangeAt(0);
|
||||
var rand = Math.random();
|
||||
if(document.queryCommandSupported && document.execCommand && document.queryCommandSupported('insertHTML')) {
|
||||
document.execCommand('insertHTML', false, '<span id="_EDITOR_SENTINEL_">|</span>');
|
||||
document.execCommand('insertHTML', false, '<span id="_EDITOR_SENTINEL_' + rand + '_">|</span>');
|
||||
} else {
|
||||
var t = document.createTextNode('|');
|
||||
var b = document.createElement('span');
|
||||
b.id = "_EDITOR_SENTINEL_";
|
||||
b.id = "_EDITOR_SENTINEL_" + rand + "_";
|
||||
b.insertNode(t);
|
||||
r.insertNode(b);
|
||||
}
|
||||
var sentinel = document.getElementById("_EDITOR_SENTINEL_");
|
||||
if(sentinel.nextSibling && sentinel.nextSibling.tagName === "CHUNK") {
|
||||
r.selectNodeContents(sentinel.nextSibling);
|
||||
r.collapse(true);
|
||||
} else if(sentinel.previousSibling && sentinel.previousSibling.tagName === "CHUNK") {
|
||||
r.selectNodeContents(sentinel.previousSibling);
|
||||
r.collapse(false);
|
||||
}
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
sentinel.parentNode.removeChild(sentinel);
|
||||
setTimeout(function() {
|
||||
var sentinel = document.getElementById("_EDITOR_SENTINEL_" + rand + "_");
|
||||
if(sentinel.nextSibling && sentinel.nextSibling.tagName === "CHUNK") {
|
||||
r.selectNodeContents(sentinel.nextSibling);
|
||||
r.collapse(true);
|
||||
} else if(sentinel.previousSibling && sentinel.previousSibling.tagName === "CHUNK") {
|
||||
r.selectNodeContents(sentinel.previousSibling);
|
||||
r.collapse(false);
|
||||
}
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
sentinel.parentNode.removeChild(sentinel);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<script src="static/bootstrap.min.js"></script>
|
||||
<script src="static/bootstrap-toggle.min.js"></script>
|
||||
<script src="static/rangy-core.min.js"></script>
|
||||
<script src="static/application.js?ver=1.18.1a"></script>
|
||||
<script src="static/application.js?ver=1.18.1d"></script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="file" id="remote-save-select" accept="application/json" style="display:none">
|
||||
|
Loading…
x
Reference in New Issue
Block a user