mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
fix(edit_diagram): implement cascade delete for children and edges (#451)
* fix(edit_diagram): implement cascade delete for children and edges - Add automatic cascade deletion when deleting a cell - Recursively delete all child cells (parent attribute references) - Delete all edges referencing deleted cells (source/target) - Skip silently if cell already deleted (handles AI redundant ops) - Update prompts to inform AI about cascade behavior Fixes #450 * fix: add root cell protection and sync MCP server cascade delete - Add protection for root cells '0' and '1' to prevent full diagram wipe - Sync MCP server with main app's cascade delete logic - Both lib/utils.ts and packages/mcp-server now have identical delete behavior * chore(mcp): bump version to 0.1.9 * fix(cascade-delete): recursively collect edge children (labels) - Change from cellsToDelete.add(edgeId) to collectDescendants(edgeId) - Fixes orphaned edge labels causing draw.io to crash/clear canvas - Edge labels (parent=edgeId) are now deleted with their parent edge
This commit is contained in:
@@ -605,7 +605,7 @@ Notes:
|
||||
Operations:
|
||||
- update: Replace an existing cell by its id. Provide cell_id and complete new_xml.
|
||||
- add: Add a new cell. Provide cell_id (new unique id) and new_xml.
|
||||
- delete: Remove a cell by its id. Only cell_id is needed.
|
||||
- delete: Remove a cell. Cascade is automatic: children AND edges (source/target) are auto-deleted. Only specify ONE cell_id.
|
||||
|
||||
For update/add, new_xml must be a complete mxCell element including mxGeometry.
|
||||
|
||||
@@ -614,8 +614,8 @@ For update/add, new_xml must be a complete mxCell element including mxGeometry.
|
||||
Example - Add a rectangle:
|
||||
{"operations": [{"operation": "add", "cell_id": "rect-1", "new_xml": "<mxCell id=\\"rect-1\\" value=\\"Hello\\" style=\\"rounded=0;\\" vertex=\\"1\\" parent=\\"1\\"><mxGeometry x=\\"100\\" y=\\"100\\" width=\\"120\\" height=\\"60\\" as=\\"geometry\\"/></mxCell>"}]}
|
||||
|
||||
Example - Delete a cell:
|
||||
{"operations": [{"operation": "delete", "cell_id": "rect-1"}]}`,
|
||||
Example - Delete container (children & edges auto-deleted):
|
||||
{"operations": [{"operation": "delete", "cell_id": "2"}]}`,
|
||||
inputSchema: z.object({
|
||||
operations: z
|
||||
.array(
|
||||
|
||||
Reference in New Issue
Block a user