UBERF-7675: Remove heading text action from compact editors (#6143)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-07-25 22:19:26 +04:00 committed by GitHub
parent 1329fb1d7a
commit 68d401a100
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View File

@ -30,6 +30,7 @@ export default mergeIds(textEditorId, textEditor, {
MoreImageActions: '' as Resource<TextActionFunction>,
IsEditableTableActive: '' as Resource<TextActionVisibleFunction>,
IsEditable: '' as Resource<TextActionVisibleFunction>
IsEditable: '' as Resource<TextActionVisibleFunction>,
IsHeadingVisible: '' as Resource<TextActionVisibleFunction>
}
})

View File

@ -16,7 +16,7 @@
import { type Resources } from '@hcengineering/platform'
import { formatLink } from './kits/default-kit'
import { isEditable } from './kits/editor-kit'
import { isEditable, isHeadingVisible } from './kits/editor-kit'
import { openTableOptions, isEditableTableActive } from './components/extension/table/table'
import { openImage, expandImage, moreImageActions } from './components/extension/imageExt'
@ -87,6 +87,7 @@ export default async (): Promise<Resources> => ({
ExpandImage: expandImage,
MoreImageActions: moreImageActions,
IsEditableTableActive: isEditableTableActive,
IsEditable: isEditable
IsEditable: isEditable,
IsHeadingVisible: isHeadingVisible
}
})

View File

@ -21,7 +21,7 @@ import TableHeader from '@tiptap/extension-table-header'
import 'prosemirror-codemark/dist/codemark.css'
import { getBlobRef, getClient } from '@hcengineering/presentation'
import { CodeBlockExtension, codeBlockOptions, CodeExtension, codeOptions } from '@hcengineering/text'
import textEditor, { type ExtensionCreator, type TextEditorMode } from '@hcengineering/text-editor'
import textEditor, { type ActionContext, type ExtensionCreator, type TextEditorMode } from '@hcengineering/text-editor'
import { DefaultKit, type DefaultKitOptions } from './default-kit'
import { HardBreakExtension } from '../components/extension/hardBreak'
@ -247,6 +247,7 @@ async function buildEditorKit (): Promise<Extension<EditorKitOptions, any>> {
element: this.options.toolbar?.element,
isHidden: this.options.toolbar?.isHidden,
ctx: {
mode,
objectId: this.options.objectId,
objectClass: this.options.objectClass,
objectSpace: this.options.objectSpace
@ -273,3 +274,7 @@ async function buildEditorKit (): Promise<Extension<EditorKitOptions, any>> {
export async function isEditable (editor: Editor): Promise<boolean> {
return editor.isEditable
}
export async function isHeadingVisible (editor: Editor, ctx: ActionContext): Promise<boolean> {
return (await isEditable(editor)) && ctx.mode === 'full'
}

View File

@ -99,6 +99,7 @@ export type TextEditorCommand = (props: TextEditorCommandProps) => boolean
* @public
*/
export interface ActionContext {
mode: TextEditorMode
objectId?: Ref<Doc>
objectClass?: Ref<Class<Doc>>
objectSpace?: Ref<Space>