Fix group_elements and ungroup_elements operations
This commit is contained in:
+16
-2
@@ -167,7 +167,9 @@ const ElementSchema = z.object({
|
||||
opacity: z.number().optional(),
|
||||
text: z.string().optional(),
|
||||
fontSize: z.number().optional(),
|
||||
fontFamily: z.string().optional()
|
||||
fontFamily: z.string().optional(),
|
||||
groupIds: z.array(z.string()).optional(),
|
||||
locked: z.boolean().optional()
|
||||
});
|
||||
|
||||
const ElementIdSchema = z.object({
|
||||
@@ -643,6 +645,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
|
||||
|
||||
const groupId = generateId();
|
||||
sceneState.groups.set(groupId, elementIds);
|
||||
|
||||
for (const id of elementIds) {
|
||||
await updateElementOnCanvas({ id, groupIds: [groupId] });
|
||||
}
|
||||
|
||||
logger.info('Grouping elements', { elementIds, groupId });
|
||||
|
||||
const result = { groupId, elementIds };
|
||||
return {
|
||||
@@ -660,7 +668,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
|
||||
|
||||
const elementIds = sceneState.groups.get(groupId);
|
||||
sceneState.groups.delete(groupId);
|
||||
|
||||
|
||||
for (const id of elementIds ?? []) {
|
||||
await updateElementOnCanvas({ id, groupIds: [] });
|
||||
}
|
||||
|
||||
logger.info('Ungrouping elements', { groupId, elementIds });
|
||||
|
||||
const result = { groupId, ungrouped: true, elementIds };
|
||||
return {
|
||||
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }]
|
||||
|
||||
+6
-2
@@ -105,7 +105,9 @@ const CreateElementSchema = z.object({
|
||||
text: z.string()
|
||||
}).optional(),
|
||||
fontSize: z.number().optional(),
|
||||
fontFamily: z.string().optional()
|
||||
fontFamily: z.string().optional(),
|
||||
groupIds: z.array(z.string()).optional(),
|
||||
locked: z.boolean().optional()
|
||||
});
|
||||
|
||||
const UpdateElementSchema = z.object({
|
||||
@@ -125,7 +127,9 @@ const UpdateElementSchema = z.object({
|
||||
text: z.string()
|
||||
}).optional(),
|
||||
fontSize: z.number().optional(),
|
||||
fontFamily: z.string().optional()
|
||||
fontFamily: z.string().optional(),
|
||||
groupIds: z.array(z.string()).optional(),
|
||||
locked: z.boolean().optional()
|
||||
});
|
||||
|
||||
// API Routes
|
||||
|
||||
Reference in New Issue
Block a user