fix: #132 add drawio custom id

This commit is contained in:
Xilonng Zhang
2026-03-27 13:22:01 +08:00
parent d6b2242118
commit d049b9d523
2 changed files with 6 additions and 0 deletions
@@ -38,6 +38,9 @@ def add_connector(session: Session, source_id: str, target_id: str,
if drawio_xml.find_cell_by_id(session.root, target_id, diagram_index) is None:
raise ValueError(f"Target cell not found: {target_id}")
if edge_id is not None and drawio_xml.find_cell_by_id(session.root, edge_id, diagram_index) is not None:
raise ValueError(f"Cell ID already exists: {edge_id}")
session.checkpoint()
edge_id = drawio_xml.add_edge(
session.root, source_id, target_id, edge_style, label,
@@ -35,6 +35,9 @@ def add_shape(session: Session, shape_type: str = "rectangle",
if not session.is_open:
raise RuntimeError("No project is open")
if cell_id is not None and drawio_xml.find_cell_by_id(session.root, cell_id, diagram_index) is not None:
raise ValueError(f"Cell ID already exists: {cell_id}")
session.checkpoint()
cell_id = drawio_xml.add_vertex(
session.root, shape_type, x, y, width, height, label,