mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(editor): add missing zod schema for edgeless frame (#10024)
Related to https://github.com/toeverything/AFFiNE/pull/9970#discussion_r1944971309 ### What changes: - Add missing zod shcema for edgeless basic props - Change `applyLastProps` to generic function for better return type inference of - Fix: add `ZodIntersection` case to `makeDeepOptional`
This commit is contained in:
@@ -25,7 +25,14 @@ import {
|
||||
TextAlignSchema,
|
||||
TextVerticalAlign,
|
||||
} from '@blocksuite/affine-model';
|
||||
import { z, ZodDefault, ZodObject, type ZodTypeAny, ZodUnion } from 'zod';
|
||||
import {
|
||||
z,
|
||||
ZodDefault,
|
||||
ZodIntersection,
|
||||
ZodObject,
|
||||
type ZodTypeAny,
|
||||
ZodUnion,
|
||||
} from 'zod';
|
||||
|
||||
const ConnectorEndpointSchema = z.nativeEnum(PointStyle);
|
||||
const LineWidthSchema = z.nativeEnum(LineWidth);
|
||||
@@ -183,6 +190,11 @@ export function makeDeepOptional(schema: ZodTypeAny): ZodTypeAny {
|
||||
return z.object(deepOptionalShape).optional();
|
||||
} else if (schema instanceof ZodUnion) {
|
||||
return schema.or(z.undefined());
|
||||
} else if (schema instanceof ZodIntersection) {
|
||||
return z.intersection(
|
||||
makeDeepOptional(schema._def.left),
|
||||
makeDeepOptional(schema._def.right)
|
||||
);
|
||||
} else {
|
||||
return schema.optional();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user