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:
L-Sun
2025-02-07 12:49:59 +00:00
parent 36ed81bcc6
commit 459972fe6c
7 changed files with 80 additions and 28 deletions

View File

@@ -29,8 +29,10 @@ export {
export {
GfxBlockElementModel,
type GfxCommonBlockProps,
GfxCommonBlockZodSchema,
GfxCompatibleBlockModel as GfxCompatible,
type GfxCompatibleProps,
GfxCompatibleZodSchema,
} from './model/gfx-block-model.js';
export { type GfxModel } from './model/model.js';
export {

View File

@@ -15,8 +15,10 @@ import {
polygonGetPointTangent,
polygonNearestPoint,
rotatePoints,
SerializedXYWHZodSchema,
} from '@blocksuite/global/utils';
import { BlockModel } from '@blocksuite/store';
import { z } from 'zod';
import {
isLockedByAncestorImpl,
@@ -33,20 +35,24 @@ import type { SurfaceBlockModel } from './surface/surface-model.js';
/**
* The props that a graphics block model should have.
*/
export type GfxCompatibleProps = {
xywh: SerializedXYWH;
index: string;
lockedBySelf?: boolean;
};
export const GfxCompatibleZodSchema = z.object({
xywh: SerializedXYWHZodSchema,
index: z.string(),
lockedBySelf: z.boolean().optional(),
});
export type GfxCompatibleProps = z.infer<typeof GfxCompatibleZodSchema>;
/**
* This type include the common props for the graphic block model.
* You can use this type with Omit to define the props of a graphic block model.
*/
export type GfxCommonBlockProps = GfxCompatibleProps & {
rotate: number;
scale: number;
};
export const GfxCommonBlockZodSchema = GfxCompatibleZodSchema.and(
z.object({
rotate: z.number(),
scale: z.number(),
})
);
export type GfxCommonBlockProps = z.infer<typeof GfxCommonBlockZodSchema>;
/**
* The graphic block model that can be rendered in the graphics mode.