Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): improve string conversion logic for checkbox property (#10433)

zzj37200e4a79959fbd
diff --git a/blocksuite/affine/data-view/src/property-presets/checkbox/define.ts b/blocksuite/affine/data-view/src/property-presets/checkbox/define.ts
index 3fda1bcb3b..ff7ebb09a2 100644
--- a/blocksuite/affine/data-view/src/property-presets/checkbox/define.ts
+++ b/blocksuite/affine/data-view/src/property-presets/checkbox/define.ts
@@ -3,17 +3,30 @@ import { propertyType } from '../../core/property/property-config.js';
export const checkboxPropertyType = propertyType('checkbox');
+const FALSE_VALUES = new Set([
+ 'false',
+ 'no',
+ '0',
+ '',
+ 'undefined',
+ 'null',
+ '否',
+ '不',
+ '错',
+ '错误',
+ '取消',
+ '关闭',
+]);
+
export const checkboxPropertyModelConfig =
checkboxPropertyType.modelConfig<boolean>({
name: 'Checkbox',
type: () => t.boolean.instance(),
defaultData: () => ({}),
cellToString: ({ value }) => (value ? 'True' : 'False'),
- cellFromString: ({ value }) => {
- return {
- value: value !== 'False',
- };
- },
+ cellFromString: ({ value }) => ({
+ value: !FALSE_VALUES.has((value?.trim() ?? '').toLowerCase()),
+ }),
cellToJson: ({ value }) => value ?? null,
cellFromJson: ({ value }) =>
typeof value !== 'boolean' ? undefined : value,