Skip to content
Merged
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
15 changes: 14 additions & 1 deletion plugins/card-resources/src/components/MarkupProperties.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
-->

<script lang="ts">
import attachment from '@hcengineering/attachment'
import { Card, Tag } from '@hcengineering/card'
import core, { Class, Doc, Ref, toRank } from '@hcengineering/core'
import core, { Blob, Class, Doc, Ref, toRank } from '@hcengineering/core'
import { getResource, setPlatformStatus, unknownError } from '@hcengineering/platform'
import { getClient, KeyedAttribute, updateAttribute } from '@hcengineering/presentation'
import { Label } from '@hcengineering/ui'
import { MarkupEditor } from '@hcengineering/view-resources'
Expand Down Expand Up @@ -60,6 +62,16 @@
objectId: doc._id
})
}

async function attachFile (file: File): Promise<{ file: Ref<Blob>, type: string } | undefined> {
try {
const uploadFile = await getResource(attachment.helper.UploadFile)
const { uuid } = await uploadFile(file)
return { file: uuid, type: file.type }
} catch (err: any) {
await setPlatformStatus(unknownError(err))
}
}
</script>

{#each keys as key}
Expand All @@ -73,6 +85,7 @@
onChange(value, key)
}}
{readonly}
{attachFile}
/>
</div>
{/each}
6 changes: 4 additions & 2 deletions plugins/view-resources/src/components/MarkupEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { Button, eventToHTMLElement, Label, showPopup } from '@hcengineering/ui'
import MarkupEditorPopup from './MarkupEditorPopup.svelte'
import { StyledTextBox } from '@hcengineering/text-editor-resources'
import type { EditorKitOptions } from '@hcengineering/text-editor-resources'
import type { EditorKitOptions, ImageUploadOptions } from '@hcengineering/text-editor-resources'
import textEditorPlugin from '@hcengineering/text-editor'

// export let label: IntlString
Expand All @@ -33,6 +33,7 @@
export let justify: 'left' | 'center' = 'center'
export let width: string | undefined = 'fit-content'
export let kitOptions: Partial<EditorKitOptions> = { reference: true, emoji: true }
export let attachFile: ImageUploadOptions['attachFile'] | undefined = undefined

let shown: boolean = false
</script>
Expand All @@ -46,7 +47,7 @@
height={value ? 'auto' : undefined}
on:click={(ev) => {
if (!shown && !readonly) {
showPopup(MarkupEditorPopup, { value, kitOptions }, eventToHTMLElement(ev), (res) => {
showPopup(MarkupEditorPopup, { value, kitOptions, attachFile }, eventToHTMLElement(ev), (res) => {
if (res != null) {
value = res
onChange(value)
Expand Down Expand Up @@ -74,6 +75,7 @@
{kitOptions}
mode={2}
{readonly}
{attachFile}
on:value={(e) => {
onChange(e.detail)
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
<script lang="ts">
import { Card } from '@hcengineering/presentation'
import { StyledTextBox } from '@hcengineering/text-editor-resources'
import type { EditorKitOptions } from '@hcengineering/text-editor-resources'
import type { EditorKitOptions, ImageUploadOptions } from '@hcengineering/text-editor-resources'
import { createEventDispatcher } from 'svelte'
import view from '../plugin'

export let value: string
export let kitOptions: Partial<EditorKitOptions> = { reference: true, emoji: true }
export let attachFile: ImageUploadOptions['attachFile'] | undefined = undefined

const dispatch = createEventDispatcher()
export let maxHeight: string = '40vh'
Expand Down Expand Up @@ -53,6 +54,7 @@
mode={2}
hideExtraButtons
{maxHeight}
{attachFile}
on:value={checkValue}
/>
</div>
Expand Down
Loading