Add image input display
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
import { PreUnreroll, Prereroll } from 'src/ts/process/prereroll';
|
import { PreUnreroll, Prereroll } from 'src/ts/process/prereroll';
|
||||||
import { processMultiCommand } from 'src/ts/process/command';
|
import { processMultiCommand } from 'src/ts/process/command';
|
||||||
import { postChatFile } from 'src/ts/process/files/multisend';
|
import { postChatFile } from 'src/ts/process/files/multisend';
|
||||||
|
import { getInlayImage } from 'src/ts/process/files/image';
|
||||||
|
|
||||||
let messageInput:string = ''
|
let messageInput:string = ''
|
||||||
let messageInputTranslate:string = ''
|
let messageInputTranslate:string = ''
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
let doingChatInputTranslate = false
|
let doingChatInputTranslate = false
|
||||||
let currentCharacter:character|groupChat = $CurrentCharacter
|
let currentCharacter:character|groupChat = $CurrentCharacter
|
||||||
let toggleStickers:boolean = false
|
let toggleStickers:boolean = false
|
||||||
|
let fileInput:string[] = []
|
||||||
export let openModuleList = false
|
export let openModuleList = false
|
||||||
export let openChatList:boolean = false
|
export let openChatList:boolean = false
|
||||||
|
|
||||||
@@ -65,6 +67,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(fileInput.length > 0){
|
||||||
|
for(const file of fileInput){
|
||||||
|
messageInput += `{{inlay::${file}}}`
|
||||||
|
}
|
||||||
|
fileInput = []
|
||||||
|
}
|
||||||
|
|
||||||
if(messageInput === ''){
|
if(messageInput === ''){
|
||||||
if($DataBase.characters[selectedChar].type !== 'group'){
|
if($DataBase.characters[selectedChar].type !== 'group'){
|
||||||
@@ -436,7 +444,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if $DataBase.useAutoTranslateInput}
|
{#if $DataBase.useAutoTranslateInput}
|
||||||
<div class="flex items-center mt-2 mb-2 w-full">
|
<div class="flex items-center mt-2 mb-2">
|
||||||
<label for='messageInputTranslate' class="text-textcolor ml-4">
|
<label for='messageInputTranslate' class="text-textcolor ml-4">
|
||||||
<LanguagesIcon />
|
<LanguagesIcon />
|
||||||
</label>
|
</label>
|
||||||
@@ -462,6 +470,17 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if fileInput.length > 0}
|
||||||
|
<div class="flex items-center ml-4 flex-wrap p-2 m-2 border-darkborderc border rounded-md">
|
||||||
|
{#each fileInput as file, i}
|
||||||
|
{#await getInlayImage(file) then inlayImage}
|
||||||
|
<img src={inlayImage.data} alt="Inlay" class="max-w-24 max-h-24">
|
||||||
|
{/await}
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if toggleStickers}
|
{#if toggleStickers}
|
||||||
<div class="ml-4 flex flex-wrap">
|
<div class="ml-4 flex flex-wrap">
|
||||||
<AssetInput bind:currentCharacter={currentCharacter} onSelect={(additionalAsset)=>{
|
<AssetInput bind:currentCharacter={currentCharacter} onSelect={(additionalAsset)=>{
|
||||||
@@ -644,7 +663,7 @@
|
|||||||
<div class="flex items-center cursor-pointer hover:text-green-500 transition-colors" on:click={async () => {
|
<div class="flex items-center cursor-pointer hover:text-green-500 transition-colors" on:click={async () => {
|
||||||
const res = await postChatFile(messageInput)
|
const res = await postChatFile(messageInput)
|
||||||
if(res?.type === 'image'){
|
if(res?.type === 'image'){
|
||||||
messageInput += res.data
|
fileInput.push(res.data)
|
||||||
updateInputSizeAll()
|
updateInputSizeAll()
|
||||||
}
|
}
|
||||||
if(res?.type === 'text'){
|
if(res?.type === 'text'){
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export async function writeInlayImage(imgObj:HTMLImageElement, arg:{name?:string
|
|||||||
width: drawWidth
|
width: drawWidth
|
||||||
})
|
})
|
||||||
|
|
||||||
return `{{inlay::${imgid}}}`
|
return `${imgid}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInlayImage(id: string){
|
export async function getInlayImage(id: string){
|
||||||
|
|||||||
Reference in New Issue
Block a user