|
50 | 50 | const selectionCanvas = selectionLayer.firstElementChild;
|
51 | 51 | let selectionCanvasContext;
|
52 | 52 |
|
| 53 | + const hierarchicalOptionsDirectionSelect = document.getElementById('direction'); |
| 54 | + |
53 | 55 | // add button event listeners
|
54 | 56 | const saveAsPngButton = document.getElementById('saveAsPngButton');
|
55 | 57 | saveAsPngButton.addEventListener('click', saveAsPng);
|
|
249 | 251 | nodes.forEach(node => {
|
250 | 252 | nodeExport.push({
|
251 | 253 | id: node.id,
|
252 |
| - label: node.label, |
253 |
| - color: node.color, |
254 |
| - position: network.getPosition(node.id) |
| 254 | + label: cleanLabel(node.label), |
| 255 | + position: network.getPosition(node.id), |
| 256 | + boundingBox: network.getBoundingBox(node.id) |
255 | 257 | });
|
256 | 258 | });
|
| 259 | + const direction = hierarchicalOptionsDirectionSelect.value ? hierarchicalOptionsDirectionSelect.value : 'UD'; |
257 | 260 | vscode.postMessage({
|
258 | 261 | command: 'saveAsDgml',
|
259 |
| - text: nodeExport |
| 262 | + text: JSON.stringify({ |
| 263 | + nodes: nodeExport, |
| 264 | + direction: direction |
| 265 | + }) |
260 | 266 | });
|
261 | 267 | }
|
262 | 268 |
|
| 269 | + function cleanLabel(label) { |
| 270 | + let regex = /(<([^>]+)>)/ig; |
| 271 | + let cleanedLabel = label.replace(regex, ''); |
| 272 | + regex = /\s+/g; |
| 273 | + cleanedLabel = cleanedLabel.replace(regex, ' '); |
| 274 | + return cleanedLabel; |
| 275 | + } |
| 276 | + |
263 | 277 | function copyToClipboard() {
|
264 | 278 | console.log('Not implemented yet...');
|
265 | 279 | }
|
|
304 | 318 | const showHierarchicalOptionsCheckbox = document.getElementById('showHierarchicalOptions');
|
305 | 319 | hierarchicalOptionsDirection.style['display'] = showHierarchicalOptionsCheckbox.checked ? 'block' : 'none';
|
306 | 320 | hierarchicalOptionsSortMethod.style['display'] = showHierarchicalOptionsCheckbox.checked ? 'block' : 'none';
|
307 |
| - const hierarchicalOptionsDirectionSelect = document.getElementById('direction'); |
308 | 321 | const hierarchicalOptionsSortMethodSelect = document.getElementById('sortMethod');
|
309 | 322 | if (showHierarchicalOptionsCheckbox.checked) {
|
310 | 323 | if (hierarchicalOptionsDirectionSelect.value && hierarchicalOptionsDirectionSelect.value === 'Random') {
|
|
0 commit comments