Enter asks, Ctrl+Enter breaks the line — in both chat modes
Almost every message here is one line, so the common action takes the bare key. Shift+Enter also breaks a line, because that is the reflex people arrive with.
This commit is contained in:
@@ -272,7 +272,7 @@ function vv_nc_pane_markup(string $prefix, bool $meshDefault = false,
|
||||
|
||||
<div style="display:flex;gap:6px;align-items:flex-start;margin-top:8px;flex-wrap:wrap;">
|
||||
<textarea id="vv-nc-text" rows="2" placeholder="Message the mesh…"
|
||||
onkeydown="if((event.ctrlKey||event.metaKey)&&event.key==='Enter')vvNcSend()"
|
||||
onkeydown="vvNcKey(event)"
|
||||
style="flex:1 1 260px;min-width:0;background:#0d0d0d;border:1px solid #2a2a2a;
|
||||
color:#ddd;border-radius:4px;padding:6px 8px;font-family:inherit;
|
||||
font-size:12px;resize:vertical;"></textarea>
|
||||
@@ -555,6 +555,21 @@ function vvNcGrow(fromAi) {
|
||||
}
|
||||
}
|
||||
|
||||
// Same bargain as the assistant's box, because they are two halves of one card and a key that
|
||||
// sends in one and breaks a line in the other is the kind of difference that costs a message.
|
||||
function vvNcKey(e) {
|
||||
if (e.key !== 'Enter') return;
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
const t = e.target;
|
||||
const s = t.selectionStart ?? t.value.length, n = t.selectionEnd ?? s;
|
||||
t.value = t.value.slice(0, s) + '\n' + t.value.slice(n);
|
||||
t.selectionStart = t.selectionEnd = s + 1;
|
||||
return;
|
||||
}
|
||||
if (!e.shiftKey) { e.preventDefault(); vvNcSend(); }
|
||||
}
|
||||
|
||||
function vvNcEmoji(sel) {
|
||||
const t = document.getElementById('vv-nc-text');
|
||||
if (t && sel.value) { t.value += sel.value; t.focus(); }
|
||||
|
||||
Reference in New Issue
Block a user