|
192 | 192 | }
|
193 | 193 |
|
194 | 194 | $: editMode = $convTreeStore.editing === message.id;
|
195 |
| - let editContentEl: HTMLTextAreaElement; |
| 195 | + let editContentEl: HTMLSpanElement; |
196 | 196 | let editFormEl: HTMLFormElement;
|
197 | 197 |
|
198 | 198 | $: if (editMode) {
|
199 | 199 | tick();
|
200 | 200 | if (editContentEl) {
|
201 |
| - editContentEl.value = message.content; |
| 201 | + editContentEl.innerText = message.content; |
202 | 202 | editContentEl?.focus();
|
203 | 203 | }
|
204 | 204 | }
|
|
485 | 485 | {/if}
|
486 | 486 |
|
487 | 487 | <div class="flex w-full flex-row flex-nowrap">
|
488 |
| - {#if !editMode} |
489 |
| - <p |
490 |
| - 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" |
491 |
| - > |
492 |
| - {message.content.trim()} |
493 |
| - </p> |
494 |
| - {:else} |
495 |
| - <form |
496 |
| - class="flex w-full flex-col" |
497 |
| - bind:this={editFormEl} |
498 |
| - on:submit|preventDefault={() => { |
499 |
| - dispatch("retry", { content: editContentEl.value, id: message.id }); |
500 |
| - $convTreeStore.editing = null; |
501 |
| - }} |
| 488 | + <form |
| 489 | + class="flex w-full flex-col" |
| 490 | + bind:this={editFormEl} |
| 491 | + on:submit|preventDefault={() => { |
| 492 | + dispatch("retry", { content: editContentEl.innerText, id: message.id }); |
| 493 | + $convTreeStore.editing = null; |
| 494 | + }} |
| 495 | + > |
| 496 | + <span |
| 497 | + role="textbox" |
| 498 | + tabindex={1} |
| 499 | + 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" |
| 500 | + class:bg-gray-100={editMode} |
| 501 | + class:dark:bg-gray-800={editMode} |
| 502 | + bind:this={editContentEl} |
| 503 | + on:keydown={handleKeyDown} |
| 504 | + contenteditable={editMode}>{message.content.trim()}</span |
502 | 505 | >
|
503 |
| - <textarea |
504 |
| - 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" |
505 |
| - rows="5" |
506 |
| - bind:this={editContentEl} |
507 |
| - value={message.content.trim()} |
508 |
| - on:keydown={handleKeyDown} |
509 |
| - required |
510 |
| - /> |
| 506 | + {#if editMode} |
511 | 507 | <div class="flex w-full flex-row flex-nowrap items-center justify-center gap-2 pt-2">
|
512 | 508 | <button
|
513 | 509 | type="submit"
|
|
530 | 526 | Cancel
|
531 | 527 | </button>
|
532 | 528 | </div>
|
533 |
| - </form> |
534 |
| - {/if} |
| 529 | + {/if} |
| 530 | + </form> |
535 | 531 | {#if !loading && !editMode}
|
536 | 532 | <div
|
537 | 533 | class="
|
|
0 commit comments