mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
c28f918527
Part of: [BS-2269](https://linear.app/affine-design/issue/BS-2269/%E8%BF%81%E7%A7%BB-database-block-%E5%88%B0-affine-%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%8B%E5%B9%B6%E5%BC%80%E5%90%AF-nouncheckedindexedaccess)
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import type { ParagraphType } from '@blocksuite/affine-model';
|
|
import {
|
|
BulletedListIcon,
|
|
CheckBoxCheckLinearIcon,
|
|
Heading1Icon,
|
|
Heading2Icon,
|
|
Heading3Icon,
|
|
Heading4Icon,
|
|
Heading5Icon,
|
|
Heading6Icon,
|
|
NumberedListIcon,
|
|
QuoteIcon,
|
|
TextIcon,
|
|
} from '@blocksuite/icons/lit';
|
|
import type { BlockModel } from '@blocksuite/store';
|
|
import type { TemplateResult } from 'lit';
|
|
|
|
export const getIcon = (
|
|
model: BlockModel & { type?: string }
|
|
): TemplateResult => {
|
|
if (model.flavour === 'affine:paragraph') {
|
|
const type = model.type as ParagraphType;
|
|
return (
|
|
{
|
|
text: TextIcon(),
|
|
quote: QuoteIcon(),
|
|
h1: Heading1Icon(),
|
|
h2: Heading2Icon(),
|
|
h3: Heading3Icon(),
|
|
h4: Heading4Icon(),
|
|
h5: Heading5Icon(),
|
|
h6: Heading6Icon(),
|
|
} as Record<ParagraphType, TemplateResult>
|
|
)[type];
|
|
}
|
|
if (model.flavour === 'affine:list') {
|
|
return (
|
|
{
|
|
bulleted: BulletedListIcon(),
|
|
numbered: NumberedListIcon(),
|
|
todo: CheckBoxCheckLinearIcon(),
|
|
}[model.type ?? 'bulleted'] ?? BulletedListIcon()
|
|
);
|
|
}
|
|
return TextIcon();
|
|
};
|