UBER-395: Allow to drop images into description (#3382)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2023-06-07 15:38:20 +06:00
committed by GitHub
parent 3c5648c87f
commit aa09fa62c9
8 changed files with 162 additions and 42 deletions
@@ -138,7 +138,7 @@
}
}
async function createAttachment (file: File) {
async function createAttachment (file: File): Promise<{ file: string; type: string } | undefined> {
if (space === undefined || objectId === undefined || _class === undefined) return
try {
const uuid = await uploadFile(file)
@@ -164,6 +164,7 @@
saveDraft()
dispatch('attach', { action: 'saved', value: attachments.size })
dispatch('attached', _id)
return { file: uuid, type: file.type }
} catch (err: any) {
setPlatformStatus(unknownError(err))
}
@@ -199,6 +200,7 @@
removedAttachments.add(attachment)
attachments.delete(attachment._id)
attachments = attachments
refInput.removeAttachment(attachment.file)
saveDraft()
dispatch('detached', attachment._id)
}
@@ -367,6 +369,9 @@
on:attach={() => {
attach()
}}
attachFile={async (file) => {
return createAttachment(file)
}}
/>
</div>
{#if attachments.size && enableAttachments}