UBERF-5626: set autofocus end on message edit (#4784)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-02-27 12:31:16 +04:00 committed by GitHub
parent d8ab1316c8
commit a0ceaecbbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 9 deletions

View File

@ -24,6 +24,8 @@
checkAdaptiveMatching
} from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import { FocusPosition } from '@tiptap/core'
import { Completion } from '../Completion'
import textEditorPlugin from '../plugin'
import { RefAction, TextEditorHandler, TextFormatCategory } from '../types'
@ -47,6 +49,7 @@
export let loading: boolean = false
export let focusable: boolean = false
export let boundary: HTMLElement | undefined = undefined
export let autofocus: FocusPosition = false
const dispatch = createEventDispatcher()
const buttonSize = 'medium'
@ -126,6 +129,7 @@
<TextEditor
bind:content
bind:this={textEditor}
{autofocus}
{boundary}
on:content={(ev) => {
if (!isEmpty || haveAttachment) {

View File

@ -40,6 +40,7 @@
export let supportSubmit = true
export let editorAttributes: Record<string, string> = {}
export let boundary: HTMLElement | undefined = undefined
export let autofocus: FocusPosition = false
let element: HTMLElement
let editor: Editor
@ -123,6 +124,7 @@
element,
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, editorAttributes) },
content,
autofocus,
extensions: [
EditorKit,
...(supportSubmit ? [Handle] : []), // order important

View File

@ -17,14 +17,7 @@
import { Attachment } from '@hcengineering/attachment'
import { Account, Class, Doc, generateId, IdMap, Ref, Space, toIdMap } from '@hcengineering/core'
import { IntlString, setPlatformStatus, unknownError, Asset } from '@hcengineering/platform'
import {
createQuery,
DraftController,
draftsStore,
getClient,
getFileUrl,
getImageSize
} from '@hcengineering/presentation'
import { createQuery, DraftController, draftsStore, getClient } from '@hcengineering/presentation'
import textEditor, { AttachIcon, type RefAction, ReferenceInput } from '@hcengineering/text-editor'
import { Loading, type AnySvelteComponent } from '@hcengineering/ui'
import { deleteFile, getAttachmentMetadata, uploadFile } from '../utils'
@ -43,6 +36,7 @@
export let attachments: IdMap<Attachment> = new Map()
export let loading = false
export let focusIndex: number = -1
export let autofocus = false
export function submit (): void {
refInput.submit()
}
@ -296,6 +290,7 @@
{labelSend}
{showSend}
{showActions}
autofocus={autofocus ? 'end' : false}
loading={loading || progress}
{boundary}
extraActions={[

View File

@ -29,6 +29,7 @@
export let boundary: HTMLElement | undefined = undefined
export let loading = false
export let collection: string = 'comments'
export let autofocus = false
type MessageDraft = Pick<ChatMessage, '_id' | 'message' | 'attachments'>
@ -186,6 +187,7 @@
bind:objectId={_id}
{shouldSaveDraft}
{boundary}
{autofocus}
on:message={onMessage}
on:update={onUpdate}
on:focus

View File

@ -174,7 +174,7 @@
{isSelected}
{shouldScroll}
{embedded}
{withActions}
withActions={withActions && !isEditing}
actions={additionalActions}
{showEmbedded}
{hideFooter}
@ -213,6 +213,8 @@
bind:this={refInput}
chatMessage={value}
shouldSaveDraft={false}
focusIndex={1000}
autofocus
{object}
on:submit={() => {
isEditing = false