fix textareainput

This commit is contained in:
kwaroran
2024-11-02 23:18:21 +09:00
parent 24c1a8fd9b
commit ab9180c7a9

View File

@@ -67,44 +67,29 @@
} }
}} }}
></textarea> ></textarea>
{:else if isFirefox} {:else}
<div <div
class="w-full h-full bg-transparent focus-within:outline-none resize-none absolute top-0 left-0 z-50 overflow-y-auto px-4 py-2 break-words whitespace-pre-wrap" class="w-full h-full bg-transparent focus-within:outline-none resize-none absolute top-0 left-0 z-50 overflow-y-auto px-4 py-2 break-words whitespace-pre-wrap"
contenteditable="true" contenteditable="true"
bind:textContent={value} bind:textContent={value}
onkeydown={(e) => { onkeydown={(e) => {
handleKeyDown(e) handleKeyDown(e)
onInput() onInput()
}} }}
oninput={(e) => { oninput={(e) => {
autoComplete() autoComplete()
}} }}
onpaste={(e) => { onpaste={(e) => {
e.preventDefault() e.preventDefault()
const text = e.clipboardData.getData('text/plain') const text = e.clipboardData.getData('text/plain')
if(text){ if(text){
insertTextAtSelection(text) insertTextAtSelection(text)
} }
}} }}
bind:this={inputDom} bind:this={inputDom}
translate="no" translate="no"
>{value ?? ''}</div> >{value ?? ''}</div>
{:else} {/if}
<div
class="w-full h-full bg-transparent focus-within:outline-none resize-none absolute top-0 left-0 z-50 overflow-y-auto px-4 py-2 break-words whitespace-pre-wrap"
contenteditable="plaintext-only"
bind:innerText={value}
onkeydown={(e) => {
handleKeyDown(e)
onInput()
}}
oninput={(e) => {
autoComplete()
}}
bind:this={inputDom}
translate="no"
>{value ?? ''}</div>
{/if}
<div class="hidden absolute z-100 bg-bgcolor border border-darkborderc p-2 flex-col" bind:this={autoCompleteDom}> <div class="hidden absolute z-100 bg-bgcolor border border-darkborderc p-2 flex-col" bind:this={autoCompleteDom}>
{#each autocompleteContents as content, i} {#each autocompleteContents as content, i}
<button class="w-full text-left py-1 px-2 bg-bgcolor" class:text-blue-500={selectingAutoComplete === i} onclick={() => { <button class="w-full text-left py-1 px-2 bg-bgcolor" class:text-blue-500={selectingAutoComplete === i} onclick={() => {