Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/components/chat/ChatInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
enterkeyhint="send"
tabindex="0"
rows="1"
class="scrollbar-custom absolute top-0 m-0 h-full w-full resize-none scroll-p-3 overflow-x-hidden overflow-y-scroll border-0 bg-transparent p-3 outline-none focus:ring-0 focus-visible:ring-0"
class="scrollbar-custom absolute top-0 m-0 h-full w-full resize-none scroll-p-3 overflow-y-auto overflow-x-hidden border-0 bg-transparent p-3 outline-none focus:ring-0 focus-visible:ring-0"
class:text-gray-400={disabled}
bind:value
bind:this={textareaElement}
Expand Down
48 changes: 22 additions & 26 deletions src/lib/components/chat/ChatMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@
}

$: editMode = $convTreeStore.editing === message.id;
let editContentEl: HTMLTextAreaElement;
let editContentEl: HTMLSpanElement;
let editFormEl: HTMLFormElement;

$: if (editMode) {
tick();
if (editContentEl) {
editContentEl.value = message.content;
editContentEl.textContent = message.content;
editContentEl?.focus();
}
}
Expand Down Expand Up @@ -410,29 +410,25 @@
{/if}

<div class="flex w-full flex-row flex-nowrap">
{#if !editMode}
<p
class="disabled w-full appearance-none whitespace-break-spaces text-wrap break-words bg-inherit px-5 py-3.5 text-gray-500 dark:text-gray-400"
>
{message.content.trim()}
</p>
{:else}
<form
class="flex w-full flex-col"
bind:this={editFormEl}
on:submit|preventDefault={() => {
dispatch("retry", { content: editContentEl.value, id: message.id });
$convTreeStore.editing = null;
}}
<form
class="flex w-full flex-col"
bind:this={editFormEl}
on:submit|preventDefault={() => {
dispatch("retry", { content: editContentEl.innerText, id: message.id });
$convTreeStore.editing = null;
}}
>
<span
role="textbox"
tabindex={1}
class="w-full whitespace-break-spaces text-wrap break-words break-words rounded-xl px-5 py-3.5 text-gray-500 outline-none *:h-max dark:text-gray-400"
class:bg-gray-100={editMode}
class:dark:bg-gray-800={editMode}
bind:this={editContentEl}
on:keydown={handleKeyDown}
contenteditable={editMode}>{message.content.trim()}</span
Copy link
Collaborator

@gary149 gary149 May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can paste html and it renders:

image

I would stay with a<textarea> and do the elastic height exactly like we already do (with a max fixed height then it scrolls) on

>
<textarea
class="w-full whitespace-break-spaces break-words rounded-xl bg-gray-100 px-5 py-3.5 text-gray-500 *:h-max dark:bg-gray-800 dark:text-gray-400"
rows="5"
bind:this={editContentEl}
value={message.content.trim()}
on:keydown={handleKeyDown}
required
/>
{#if editMode}
<div class="flex w-full flex-row flex-nowrap items-center justify-center gap-2 pt-2">
<button
type="submit"
Expand All @@ -455,8 +451,8 @@
Cancel
</button>
</div>
</form>
{/if}
{/if}
</form>
{#if !loading && !editMode}
<div
class="
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/chat/ChatWindow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
loginModalOpen = true;
}
}}
maxRows={6}
maxRows={16}
disabled={isReadOnly || lastIsError}
/>
{/if}
Expand Down