mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
refactor(editor): enable the noUncheckedIndexedAccess rule for the block-database package (#9691)
close: BS-2269
This commit is contained in:
@@ -31,7 +31,7 @@ type Create<
|
||||
};
|
||||
export type PropertyModel<
|
||||
Type extends string = string,
|
||||
PropertyData extends Record<string, unknown> = Record<string, never>,
|
||||
PropertyData extends Record<string, unknown> = Record<string, unknown>,
|
||||
CellData = unknown,
|
||||
> = {
|
||||
type: Type;
|
||||
|
||||
@@ -38,12 +38,7 @@ export type PropertyConfig<
|
||||
value?: Value;
|
||||
}>
|
||||
) => unknown[];
|
||||
cellToString: (
|
||||
config: WithCommonPropertyConfig<{
|
||||
value: Value;
|
||||
data: Data;
|
||||
}>
|
||||
) => string;
|
||||
cellToString: (config: { value: Value; data: Data }) => string;
|
||||
cellFromString: (
|
||||
config: WithCommonPropertyConfig<{
|
||||
value: string;
|
||||
|
||||
@@ -286,7 +286,6 @@ export abstract class SingleViewBase<
|
||||
this.dataSource.propertyMetaGet(type).config.cellToString({
|
||||
value: this.dataSource.cellValueGet(rowId, propertyId),
|
||||
data: this.propertyDataGet(propertyId),
|
||||
dataSource: this.dataSource,
|
||||
}) ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { format } from 'date-fns/format';
|
||||
import { parse } from 'date-fns/parse';
|
||||
|
||||
import { t } from '../../core/logical/type-presets.js';
|
||||
import { propertyType } from '../../core/property/property-config.js';
|
||||
|
||||
@@ -6,12 +9,12 @@ export const datePropertyModelConfig = datePropertyType.modelConfig<number>({
|
||||
name: 'Date',
|
||||
type: () => t.date.instance(),
|
||||
defaultData: () => ({}),
|
||||
cellToString: ({ value }) => value?.toString() ?? '',
|
||||
cellToString: ({ value }) => format(value, 'yyyy-MM-dd'),
|
||||
cellFromString: ({ value }) => {
|
||||
const isDateFormat = !isNaN(Date.parse(value));
|
||||
const date = parse(value, 'yyyy-MM-dd', new Date());
|
||||
|
||||
return {
|
||||
value: isDateFormat ? +new Date(value) : null,
|
||||
value: +date,
|
||||
};
|
||||
},
|
||||
cellToJson: ({ value }) => value ?? null,
|
||||
|
||||
Reference in New Issue
Block a user