mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
22 lines
660 B
TypeScript
22 lines
660 B
TypeScript
import { isInsidePageEditor } from '@blocksuite/affine-shared/utils';
|
|
import type { EditorHost } from '@blocksuite/block-std';
|
|
|
|
import type { AIItemGroupConfig } from '../../../_common/components/ai-item/types.js';
|
|
|
|
export function filterAIItemGroup(
|
|
host: EditorHost,
|
|
configs: AIItemGroupConfig[]
|
|
): AIItemGroupConfig[] {
|
|
const editorMode = isInsidePageEditor(host) ? 'page' : 'edgeless';
|
|
return configs
|
|
.map(group => ({
|
|
...group,
|
|
items: group.items.filter(item =>
|
|
item.showWhen
|
|
? item.showWhen(host.command.chain(), editorMode, host)
|
|
: true
|
|
),
|
|
}))
|
|
.filter(group => group.items.length > 0);
|
|
}
|