Files
AFFiNE-Mirror/blocksuite/affine/blocks/database/src/block-icons.ts
zzj3720 1ea73456ca refactor(editor): support virtual scroll for table view of database block (#11642)
close: BS-3378

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced a modular virtualized table view with grouping, selection, drag-and-drop, clipboard support, and batch task management for optimized rendering.
  - Added comprehensive keyboard shortcuts, drag-to-fill functionality, and clipboard operations for efficient table editing.
  - Enabled dynamic column statistics, number formatting controls, and flexible switching between virtual and standard table views via a feature flag.
  - Provided detailed row and group header/footer components with context menus, row management actions, and column reordering/resizing.
  - Added a table view selector component to toggle between virtual and standard table views based on feature flags.
- **Style**
  - Added extensive styling modules for virtual table elements including headers, footers, rows, cells, and interactive controls.
- **Chores**
  - Registered numerous custom elements via modular effect functions to streamline component initialization.
  - Updated feature flag system to include virtual table scrolling toggle.
  - Added new dependencies to support styling and component functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-04-29 09:52:08 +00:00

46 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';
const icons: Record<string, TemplateResult> = {
text: TextIcon(),
quote: QuoteIcon(),
h1: Heading1Icon(),
h2: Heading2Icon(),
h3: Heading3Icon(),
h4: Heading4Icon(),
h5: Heading5Icon(),
h6: Heading6Icon(),
bulleted: BulletedListIcon(),
numbered: NumberedListIcon(),
todo: CheckBoxCheckLinearIcon(),
};
export const getIcon = (
model: BlockModel & {
props: {
type?: string;
};
}
): TemplateResult => {
if (model.flavour === 'affine:paragraph') {
const type = model.props.type as ParagraphType;
return icons[type] ?? TextIcon();
}
if (model.flavour === 'affine:list') {
return icons[model.props.type ?? 'bulleted'] ?? BulletedListIcon();
}
return TextIcon();
};