UBERF-8575 Exclude markups from inline attrs bar (#7117)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-11-07 14:02:46 +07:00 committed by GitHub
parent afa485deb1
commit dfb8507d32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 4 deletions

View File

@ -1,8 +1,8 @@
<script lang="ts">
import { Class, Data, Doc, Ref } from '@hcengineering/core'
import { Class, Data, Doc, Hierarchy, Ref } from '@hcengineering/core'
import { InlineAttributeBarEditor } from '..'
import { KeyedAttribute } from '../attributes'
import { getClient, getFiltredKeys, isCollectionAttr } from '../utils'
import { getClient, getFiltredKeys, isCollectionAttr, isCollabAttr, isMarkupAttr } from '../utils'
export let object: Doc | Data<Doc>
export let _class: Ref<Class<Doc>>
@ -15,10 +15,15 @@
const client = getClient()
function isInlineAttr (hierarchy: Hierarchy, key: KeyedAttribute): boolean {
return !isCollectionAttr(hierarchy, key) && !isCollabAttr(hierarchy, key) && !isMarkupAttr(hierarchy, key)
}
function updateKeys (_class: Ref<Class<Doc>>, ignoreKeys: string[], to: Ref<Class<Doc>> | undefined): void {
const filtredKeys = getFiltredKeys(client.getHierarchy(), _class, ignoreKeys, to)
const hierarchy = client.getHierarchy()
const filtredKeys = getFiltredKeys(hierarchy, _class, ignoreKeys, to)
keys = filtredKeys.filter(
(key) => (extraKeys.includes(key.key) || !isCollectionAttr(client.getHierarchy(), key)) && !key.attr.readonly
(key) => (extraKeys.includes(key.key) || isInlineAttr(hierarchy, key)) && key.attr.readonly !== true
)
}

View File

@ -654,6 +654,20 @@ export function isCollectionAttr (hierarchy: Hierarchy, key: KeyedAttribute): bo
return hierarchy.isDerived(key.attr.type._class, core.class.Collection)
}
/**
* @public
*/
export function isMarkupAttr (hierarchy: Hierarchy, key: KeyedAttribute): boolean {
return hierarchy.isDerived(key.attr.type._class, core.class.TypeMarkup)
}
/**
* @public
*/
export function isCollabAttr (hierarchy: Hierarchy, key: KeyedAttribute): boolean {
return hierarchy.isDerived(key.attr.type._class, core.class.TypeCollaborativeDoc)
}
/**
* @public
*/