fix(editor): add childElementIds to ai generated frame (#9537)

Close [BS-1354](https://linear.app/affine-design/issue/BS-1354/更新-ai-slide-template-到新的-frame)

This PR add `childElementIds` to frame block in ai presentation templates
This commit is contained in:
L-Sun
2025-01-07 04:19:09 +00:00
parent 52f2e8d5d5
commit ded17abf7e
7 changed files with 247 additions and 27 deletions

View File

@@ -110,6 +110,16 @@ export const replaceIdMiddleware = (job: TemplateJob) => {
blockJson.props.elements = elements;
}
// remap childElementIds of frame
if (blockJson.flavour === 'affine:frame') {
assertType<Record<string, boolean>>(blockJson.props.childElementIds);
const newChildElementIds: Record<string, boolean> = {};
Object.entries(blockJson.props.childElementIds).forEach(([key, val]) => {
newChildElementIds[regeneratedIdMap.get(key) ?? key] = val;
});
blockJson.props.childElementIds = newChildElementIds;
}
};
};

View File

@@ -23,7 +23,11 @@ import type * as Y from 'yjs';
* Those block contains other block's id
* should defer the loading
*/
const DEFERED_BLOCK = ['affine:surface', 'affine:surface-ref'] as const;
const DEFERED_BLOCK = [
'affine:surface',
'affine:surface-ref',
'affine:frame',
] as const;
/**
* Those block should not be inserted directly