diff --git a/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte b/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte index 88e14768bd..97f8f73316 100644 --- a/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte +++ b/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte @@ -35,6 +35,7 @@ export let buttonSize: IconSize = 'small' export let maxHeight: 'max' | 'card' | 'limited' | string = 'max' export let focusable: boolean = false + export let refContainer: HTMLElement | undefined = undefined export function attach (): void { inputFile.click() @@ -163,7 +164,28 @@ return Promise.all(promises).then() } + function isAllowedPaste (evt: ClipboardEvent) { + let t: HTMLElement | null = evt.target as HTMLElement + + if (!refContainer) { + return true + } + + while (t != null) { + t = t.parentElement + if (t === refContainer) { + return true + } + } + + return false + } + function pasteAction (evt: ClipboardEvent): void { + if (!isAllowedPaste(evt)) { + return + } + const items = evt.clipboardData?.items ?? [] for (const index in items) { const item = items[index] diff --git a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte index cd34a176d2..6ef224845e 100644 --- a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte @@ -16,7 +16,6 @@ import { createEventDispatcher } from 'svelte' import core, { Account, AttachedData, Doc, generateId, Ref, SortingOrder, WithLookup } from '@hcengineering/core' import presentation, { getClient, KeyedAttribute } from '@hcengineering/presentation' - import { StyledTextArea } from '@hcengineering/text-editor' import { IssueStatus, IssuePriority, Issue, Team, calcRank } from '@hcengineering/tracker' import { addNotification, Button, Component, EditBox } from '@hcengineering/ui' import tags, { TagElement, TagReference } from '@hcengineering/tags' @@ -25,6 +24,7 @@ import StatusEditor from '../StatusEditor.svelte' import PriorityEditor from '../PriorityEditor.svelte' import EstimationEditor from '../timereport/EstimationEditor.svelte' + import { AttachmentStyledBox } from '@hcengineering/attachment-resources' import IssueNotification from '../IssueNotification.svelte' import { translate } from '@hcengineering/platform' @@ -39,7 +39,9 @@ let thisRef: HTMLDivElement let focusIssueTitle: () => void let labels: TagReference[] = [] + let descriptionBox: AttachmentStyledBox + const objectId: Ref = generateId() const key: KeyedAttribute = { key: 'labels', attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels') @@ -110,14 +112,18 @@ parents: [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents] } - const objectId = await client.addCollection( + await client.addCollection( tracker.class.Issue, space, parentIssue._id, parentIssue._class, 'subIssues', - value + value, + objectId ) + + await descriptionBox.createAttachments() + for (const label of labels) { await client.addCollection(label._class, label.space, objectId, tracker.class.Issue, 'labels', { title: label.title, @@ -185,13 +191,19 @@ focus />
- {#key newIssue.description} - - {/key} + dispatch('changeContent')} + />