Skip to content

Commit 2ec97f0

Browse files
gcoutableAxelRICHARD
authored andcommitted
[enh] Diagram icons can be hidden for svg export
Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
1 parent ecbcade commit 2ec97f0

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

frontend/syson-components/src/extensions/ShowHideDiagramsIcons.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -54,16 +54,31 @@ export const ShowHideDiagramsIcons = ({ editingContextId, diagramId }: DiagramPa
5454
message: null,
5555
});
5656

57-
const handleChange = (event) => {
57+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
58+
updateDiagramIconsVisibility(event.target.checked);
59+
};
60+
61+
useEffect(() => {
62+
const timeout = setTimeout(() => {
63+
const urlParams = new URLSearchParams(window.location.search);
64+
if (urlParams.has('showIcons') && urlParams.get('showIcons') === 'false') {
65+
updateDiagramIconsVisibility(false);
66+
}
67+
}, 200);
68+
69+
return () => clearTimeout(timeout);
70+
}, []);
71+
72+
const updateDiagramIconsVisibility = (show: boolean) => {
5873
const input: GQLShowDiagramsIconsMutationInput = {
5974
id: crypto.randomUUID(),
6075
editingContextId,
6176
representationId: diagramId,
62-
show: event.target.checked,
77+
show,
6378
};
6479
showDiagramsIcons({ variables: { input } });
6580
setState((prevState) => {
66-
const checked: boolean = event.target.checked;
81+
const checked: boolean = show;
6782
return { ...prevState, checked, tooltip: checked ? showTooltip : hideTooltip };
6883
});
6984
};

frontend/syson-components/src/extensions/SysONDiagramPanelMenu.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -59,6 +59,17 @@ export const SysONDiagramPanelMenu = ({ editingContextId, diagramId }: DiagramPa
5959
prevOpen.current = open;
6060
}, [open]);
6161

62+
useEffect(() => {
63+
const timeout = setTimeout(() => {
64+
const urlParams = new URLSearchParams(window.location.search);
65+
if (urlParams.has('showIcons') && urlParams.get('showIcons') === 'false') {
66+
setOpen(true);
67+
}
68+
}, 400);
69+
70+
return () => clearTimeout(timeout);
71+
}, []);
72+
6273
return (
6374
<span>
6475
<Tooltip title="Diagrams Options" placement="right">

0 commit comments

Comments
 (0)