Files
AFFiNE-Mirror/blocksuite/affine/blocks/database/src/properties/created-time/define.ts
T
zzj3720 6689bd1914 feat(editor): add created-time and created-by property for database block (#12156)
close: BS-3431

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

- **New Features**
  - Added "Created By" property type and cell renderer, displaying creator's avatar and name in database blocks.
  - Introduced "Created Time" property type and cell renderer, showing formatted creation timestamps.

- **Improvements**
  - Enhanced table and Kanban views with improved column and row movement, hiding, and statistics capabilities.
  - Streamlined property and row management with unified object handling and reactive signals for better performance and reliability.
  - Improved avatar display logic to handle removed or unnamed users gracefully.
  - Refactored property and row APIs to consolidate access patterns and support reactive updates.
  - Updated icon retrieval and reactive value access for improved UI responsiveness in database and Kanban cells.
  - Consolidated property and cell access methods to use "get or create" patterns ensuring consistent data availability.
  - Added locking mechanism to stabilize computed signals during locked states.
  - Modularized table and Kanban column and row abstractions for better encapsulation and maintainability.

- **Bug Fixes**
  - Corrected row and column deletion, movement, and selection behaviors across table and Kanban views.
  - Fixed issues with property and row referencing, ensuring consistent handling of identifiers and objects.
  - Removed debugging logs and fixed method calls to align with updated APIs.

- **Style**
  - Updated and simplified table column header styles for a cleaner appearance.

- **Chores**
  - Added `@emotion/css` dependency for styling support.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-08 11:35:37 +00:00

36 lines
944 B
TypeScript

import { propertyType, t } from '@blocksuite/data-view';
import { format } from 'date-fns/format';
import zod from 'zod';
export const createdTimeColumnType = propertyType('created-time');
export const createdTimePropertyModelConfig = createdTimeColumnType.modelConfig(
{
name: 'Created Time',
propertyData: {
schema: zod.object({}),
default: () => ({}),
},
jsonValue: {
schema: zod.number().nullable(),
isEmpty: () => false,
type: () => t.date.instance(),
},
rawValue: {
schema: zod.number().nullable(),
default: () => null,
toString: ({ value }) =>
value != null ? format(value, 'yyyy-MM-dd HH:mm:ss') : '',
fromString: () => {
return { value: null };
},
toJson: ({ value }) => value,
fromJson: ({ value }) => value,
},
fixed: {
defaultData: {},
defaultShow: false,
defaultOrder: 'end',
},
}
);