mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 09:01:29 +03:00
bc86f0a672
define editor setting schema in `packages/frontend/core/src/modules/editor-settting/schema.ts` e.g. ```ts const BSEditorSettingSchema = z.object({ connector: z.object({ stroke: z .union([ z.string(), z.object({ dark: z.string(), light: z.string(), }), ]) .default('#000000'), // default is necessary }), }); ``` schema can be defined in a nested way. EditorSetting api is in flat way: editorSetting api: ```ts editorSetting.settings$ === { 'connector.stroke': '#000000' } editorSetting.set('connector.stroke', '#000') ``` and use `expandFlattenObject` function can restore the flattened structure to a nested structure. nested structure is required by blocksuite ```ts editorSetting.settings$.map(expandFlattenObject) === { connector: { stroke: '#000000' } } ``` |
||
---|---|---|
.. | ||
admin | ||
component | ||
core | ||
electron | ||
electron-api | ||
graphql | ||
i18n | ||
mobile | ||
native | ||
templates | ||
web |