updated configuration of inline commands for StyledTextBox (#7397)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
Victor Ilyushchenko 2024-12-09 21:51:44 +03:00 committed by GitHub
parent 71a306e705
commit 56896badd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 8 deletions

View File

@ -30,7 +30,8 @@
import { ImageUploadExtension } from './extension/imageUploadExt'
import { InlineCommandsExtension } from './extension/inlineCommands'
import { type FileAttachFunction } from './extension/types'
import { completionConfig, inlineCommandsConfig } from './extensions'
import { completionConfig, InlineCommandId, inlineCommandsConfig } from './extensions'
import { MermaidExtension, mermaidOptions } from './extension/mermaid'
export let label: IntlString | undefined = undefined
export let content: Markup
@ -192,6 +193,7 @@
}
extensions.push(
imageUploadPlugin,
MermaidExtension.configure(mermaidOptions),
FocusExtension.configure({ onCanBlur: (value: boolean) => (canBlur = value), onFocus: handleFocus })
)
if (enableEmojiReplace) {
@ -199,10 +201,12 @@
}
if (enableInlineCommands) {
const excludedInlineCommands: InlineCommandId[] = ['drawing-board', 'todo-list']
if (attachFile === undefined) excludedInlineCommands.push('image')
extensions.push(
InlineCommandsExtension.configure(
inlineCommandsConfig(handleCommandSelected, attachFile === undefined ? ['image'] : [])
)
InlineCommandsExtension.configure(inlineCommandsConfig(handleCommandSelected, excludedInlineCommands))
)
}
@ -226,11 +230,13 @@
}
case 'code-block':
editor.editorHandler.insertCodeBlock(pos)
break
case 'separator-line':
editor.editorHandler.insertSeparatorLine()
break
case 'mermaid':
editor.getEditor()?.commands.insertContentAt(pos, { type: 'mermaid' })
break
}
}

View File

@ -17,10 +17,9 @@
import { IntlString } from '@hcengineering/platform'
import { EmptyMarkup } from '@hcengineering/text'
import { Button, type ButtonSize, Scroller } from '@hcengineering/ui'
import { AnyExtension, mergeAttributes } from '@tiptap/core'
import { AnyExtension, mergeAttributes, type Editor } from '@tiptap/core'
import { createEventDispatcher } from 'svelte'
import textEditor, { RefAction, TextEditorHandler, TextFormatCategory } from '@hcengineering/text-editor'
import { defaultRefActions, getModelRefActions } from './editor/actions'
import TextEditor from './TextEditor.svelte'
@ -63,6 +62,9 @@
export function insertText (text: string): void {
editor?.insertText(text)
}
export function getEditor (): Editor | undefined {
return editor?.getEditor()
}
$: varsStyle =
maxHeight === 'card'

View File

@ -90,6 +90,9 @@
editor.commands.clearContent(true)
}
}
export function getEditor (): Editor {
return editor
}
export function insertText (text: string): void {
editor?.commands.insertContent(text)

View File

@ -130,7 +130,15 @@ export const completionConfig: Partial<CompletionOptions> = {
}
}
const inlineCommandsIds = ['image', 'table', 'code-block', 'separator-line', 'todo-list'] as const
const inlineCommandsIds = [
'image',
'table',
'code-block',
'separator-line',
'todo-list',
'drawing-board',
'mermaid'
] as const
export type InlineCommandId = (typeof inlineCommandsIds)[number]
/**