TSK-412 Do not allow to post empty comments

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2022-11-14 22:37:13 +07:00
parent 2df58960d2
commit 7e829e3724
No known key found for this signature in database
GPG Key ID: 3320C3B3324E934C
2 changed files with 20 additions and 3 deletions

View File

@ -51,6 +51,7 @@
let isFormatting = false
let activeModes = new Set<FormatMode>()
let isSelectionEmpty = true
let isEmpty = true
interface RefAction {
label: IntlString
@ -275,6 +276,7 @@
<div class="inputMsg">
<TextEditor
bind:content
bind:isEmpty
bind:this={textEditor}
on:content={(ev) => {
dispatch('message', ev.detail)
@ -286,7 +288,9 @@
/>
</div>
{#if showSend}
<button class="sendButton" on:click={submit}><div class="icon"><Send size={'medium'} /></div></button>
<button class="sendButton" on:click={submit} disabled={isEmpty}>
<div class="icon"><Send size={'medium'} /></div>
</button>
{/if}
</div>
<div class="buttons-group large-gap ml-4 mt-2">
@ -418,6 +422,15 @@
color: var(--theme-caption-color);
}
}
&:disabled {
pointer-events: none;
.icon {
opacity: 0.5;
cursor: not-allowed;
}
}
}
}
}

View File

@ -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')