diff --git a/crates/web-host/src/client/narrative.ts b/crates/web-host/src/client/narrative.ts index f1d28f15..8165279a 100644 --- a/crates/web-host/src/client/narrative.ts +++ b/crates/web-host/src/client/narrative.ts @@ -418,13 +418,11 @@ const InputArea = (context: Context, player: State) => { e.preventDefault(); const pastedData = e.clipboardData?.getData("text") || ""; if (pastedData) { - // Append to the input field with the pasted content as-is, not interpreted as - // key-strokes. - i.value += pastedData; + // Insert the pasted data at the current cursor position. + i.value = i.value.substring(0, i.selectionStart) + pastedData + i.value.substring(i.selectionEnd); - // Jump the selection to the end of the line - i.selectionStart = i.value.length; - i.selectionEnd = i.value.length; + // Jump the selection to the end of the pasted part + i.selectionStart = i.selectionEnd = i.selectionStart + pastedData.length; } }); i.addEventListener("keydown", e => {