From 7e829e37249fa95a70f28fb842c70b107cfa92af Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Mon, 14 Nov 2022 22:37:13 +0700 Subject: [PATCH] TSK-412 Do not allow to post empty comments Signed-off-by: Alexander Onnikov --- .../src/components/ReferenceInput.svelte | 15 ++++++++++++++- .../text-editor/src/components/TextEditor.svelte | 8 ++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/text-editor/src/components/ReferenceInput.svelte b/packages/text-editor/src/components/ReferenceInput.svelte index ddff9a8539..4d1e77a474 100644 --- a/packages/text-editor/src/components/ReferenceInput.svelte +++ b/packages/text-editor/src/components/ReferenceInput.svelte @@ -51,6 +51,7 @@ let isFormatting = false let activeModes = new Set() let isSelectionEmpty = true + let isEmpty = true interface RefAction { label: IntlString @@ -275,6 +276,7 @@
{ dispatch('message', ev.detail) @@ -286,7 +288,9 @@ />
{#if showSend} - + {/if}
@@ -418,6 +422,15 @@ color: var(--theme-caption-color); } } + + &:disabled { + pointer-events: none; + + .icon { + opacity: 0.5; + cursor: not-allowed; + } + } } } } diff --git a/packages/text-editor/src/components/TextEditor.svelte b/packages/text-editor/src/components/TextEditor.svelte index d4b472fdf0..39a8f884c7 100644 --- a/packages/text-editor/src/components/TextEditor.svelte +++ b/packages/text-editor/src/components/TextEditor.svelte @@ -28,6 +28,7 @@ export let placeholder: IntlString = textEditorPlugin.string.EditorPlaceholder export let extensions: AnyExtension[] = [] export let supportSubmit = true + export let isEmpty = true let element: HTMLElement let editor: Editor @@ -41,8 +42,10 @@ const dispatch = createEventDispatcher() export function submit (): void { - content = editor.getHTML() - dispatch('content', content) + if (!editor.isEmpty) { + content = editor.getHTML() + dispatch('content', content) + } } export function clear (): void { @@ -159,6 +162,7 @@ }, onUpdate: () => { content = editor.getHTML() + isEmpty = editor.isEmpty dispatch('value', content) }, onSelectionUpdate: () => dispatch('selection-update')