Skip to content

Commit

Permalink
solve #9
Browse files Browse the repository at this point in the history
  • Loading branch information
vareb committed Nov 19, 2024
1 parent 7be1c81 commit 82014d5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/plantuml_gui/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,19 @@ async function renderPlantUml() {
displayErrorMessage(`Error with fetch API: ${error.message}`, error);
}

if (checkIfStateDiagram(pumlcontent)) { // If state diagram render without interactivity (not supported)
fetchSvgFromPlantUml().then((svgContent) => {
element.innerHTML = svgContent;
})
toggleLoadingOverlay();
}
else {
setHandlersForActivityDiagram(pumlcontent, element);
}

}

async function setHandlersForActivityDiagram(pumlcontent, element) {
fetchSvgFromPlantUml().then((svgContent) => {
element.innerHTML = svgContent;
const svg = element.querySelector('g');
Expand Down Expand Up @@ -3527,3 +3539,15 @@ function restoreeditor() {
setPuml(history[historyPointer])
}
}

function checkIfStateDiagram(puml) {
const lines = puml.split('\n');
for (let index = 0; index < lines.length; index++) {
const line = lines[index];
const trimmedLine = line.trim();
if (trimmedLine.startsWith('state')) {
return true
}
}
return false
}

0 comments on commit 82014d5

Please sign in to comment.