diff --git a/packages/text-editor/src/components/ReferenceInput.svelte b/packages/text-editor/src/components/ReferenceInput.svelte
index 2d2bf0e771..76a34281ff 100644
--- a/packages/text-editor/src/components/ReferenceInput.svelte
+++ b/packages/text-editor/src/components/ReferenceInput.svelte
@@ -54,6 +54,11 @@
let isSelectionEmpty = true
let isEmpty = true
+ $: setContent(content)
+
+ function setContent (content: string) {
+ textEditor?.setContent(content)
+ }
interface RefAction {
label: IntlString
icon: Asset | AnySvelteComponent
@@ -286,6 +291,7 @@
}}
extensions={editorExtensions}
on:selection-update={updateFormattingState}
+ on:update
/>
{#if showSend}
diff --git a/packages/text-editor/src/components/TextEditor.svelte b/packages/text-editor/src/components/TextEditor.svelte
index 8f5e8d6eed..d7958da2b8 100644
--- a/packages/text-editor/src/components/TextEditor.svelte
+++ b/packages/text-editor/src/components/TextEditor.svelte
@@ -48,7 +48,13 @@
dispatch('content', content)
}
}
-
+ export function setContent (newContent: string): void {
+ if (content !== newContent) {
+ content = newContent
+ editor.commands.setContent(content)
+ isEmpty = editor.isEmpty
+ }
+ }
export function clear (): void {
content = ''
editor.commands.clearContent(false)
@@ -181,6 +187,9 @@
Placeholder.configure({ placeholder: placeHolderStr }),
...extensions
],
+ parseOptions: {
+ preserveWhitespace: 'full'
+ },
onTransaction: () => {
// force re-render so `editor.isActive` works as expected
editor = editor
@@ -199,6 +208,9 @@
dispatch('value', content)
dispatch('update', content)
},
+ onCreate: () => {
+ isEmpty = editor.isEmpty
+ },
onSelectionUpdate: () => dispatch('selection-update')
})
})
diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte
index 54926667b1..4a1ccf8e78 100644
--- a/plugins/activity-resources/src/components/Activity.svelte
+++ b/plugins/activity-resources/src/components/Activity.svelte
@@ -142,7 +142,7 @@
{#if showCommenInput}
diff --git a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte
index da9eaf8fb0..348e69ae4c 100644
--- a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte
+++ b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte
@@ -28,6 +28,7 @@
export let _class: Ref
>
export let content: string = ''
export let showSend = true
+ export let shouldUseDraft: boolean = false
export function submit (): void {
refInput.submit()
}
@@ -39,6 +40,7 @@
const client = getClient()
const query = createQuery()
+
let attachments: Map[, Attachment> = new Map][, Attachment>()
let originalAttachments: Set][> = new Set][>()
const newAttachments: Set][> = new Set][>()
@@ -79,6 +81,9 @@
})
newAttachments.add(_id)
attachments = attachments
+ if (shouldUseDraft) {
+ await createAttachments()
+ }
} catch (err: any) {
setPlatformStatus(unknownError(err))
}
@@ -110,6 +115,9 @@
async function removeAttachment (attachment: Attachment): Promise {
removedAttachments.add(attachment)
attachments.delete(attachment._id)
+ if (shouldUseDraft) {
+ await createAttachments()
+ }
attachments = attachments
}
@@ -139,7 +147,7 @@
}
})
- async function onMessage (event: CustomEvent) {
+ export function createAttachments (): Promise {
saved = true
const promises: Promise[] = []
newAttachments.forEach((p) => {
@@ -151,10 +159,18 @@
removedAttachments.forEach((p) => {
promises.push(deleteAttachment(p))
})
- await Promise.all(promises)
+ return Promise.all(promises).then()
+ }
+
+ async function onMessage (event: CustomEvent) {
+ await createAttachments()
dispatch('message', { message: event.detail, attachments: attachments.size })
}
+ async function onUpdate (event: CustomEvent) {
+ dispatch('update', { message: event.detail, attachments: attachments.size })
+ }
+
function pasteAction (evt: ClipboardEvent): void {
let t: HTMLElement | null = evt.target as HTMLElement
let allowed = false
@@ -224,6 +240,7 @@
on:attach={() => {
inputFile.click()
}}
+ on:update={onUpdate}
/>
]
diff --git a/plugins/chunter-resources/src/components/CommentInput.svelte b/plugins/chunter-resources/src/components/CommentInput.svelte
index ca1f1dc4e7..cf064a1bc5 100644
--- a/plugins/chunter-resources/src/components/CommentInput.svelte
+++ b/plugins/chunter-resources/src/components/CommentInput.svelte
@@ -1,6 +1,6 @@