Skip to content

Commit

Permalink
add import and export diagram
Browse files Browse the repository at this point in the history
- export diagram
  * add a diagram export dialog where you can choose the file name
    and download type (code, png, pdf, ...)
  * set default download type to code
  * open file save dialog via menu or Ctrl+S (or Meta+S for Mac)
- import diagram
  * similar to [draw.io](https://app.diagrams.net)
  * open a PlantUML diagram image, use metat data to get diagram code
    and load this diagram (Note: meta data is currently only supported
    by PNG and SVG diagram files)
  * support drag&drop
  * add diagram import dialog
- since three are now multiple options/action -> create a little
  editor menu
- add documentation (including gif examples)
  • Loading branch information
Florian authored and arnaudroques committed May 14, 2023
1 parent ec7b9f9 commit 6ca582f
Show file tree
Hide file tree
Showing 18 changed files with 639 additions and 112 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ insert_final_newline = false

[{Dockerfile,Dockerfile.*}]
indent_size = 4

[.vscode/*.json]
indent_size = 4
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Lalloni",
"monaco",
"plantuml",
"puml",
"Roques",
"servlet",
"servlets",
Expand All @@ -20,5 +21,6 @@
"undock",
"utxt"
],
"cSpell.allowCompoundWords": true
}
"cSpell.allowCompoundWords": true,
"svg.preview.background": "transparent"
}
Binary file added docs/WebUI/gifs/diagram-export.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/WebUI/gifs/diagram-import.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/WebUI/import-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Import and Export editable PlantUML Diagrams

Similar to [draw.io](https://app.diagrams.net) it is possible to load and continue editing PlantUML diagram images.


# Export a diagram

Via the editor menu or Ctrl+S (or Meta+S in the case of a Mac) you can open the file save dialog.
Here you can edit the file name, choose a file/diagram type and download the diagram.
The default is to download the PlantUML code.

![export](https://raw.githubusercontent.com/plantuml/plantuml-server/master/docs/WebUI/gifs/diagram-export.gif)


# Import a diagram

This feature is based on the PlantUML meta data which currently **support only PNG and SVG** diagrams.
Besides a diagram image, you can of course also load a diagram code file.
Moreover, because it is so nice and convenient, we also added a drag-and-drop feature.

![import](https://raw.githubusercontent.com/plantuml/plantuml-server/master/docs/WebUI/gifs/diagram-import.gif)
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions src/main/webapp/assets/actions/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions src/main/webapp/assets/actions/upload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,26 @@
<div>
<div class="btn-input">
<input id="url" type="text" name="url" value="png/<%= diagramUrl %>" />
<input type="image" alt="copy" src="assets/copy.svg" onclick="copyUrlToClipboard()" />
<input type="image" alt="copy" src="assets/actions/copy.svg" onclick="copyUrlToClipboard()" />
</div>
</div>
<div class="flex-main monaco-editor-container">
<textarea id="initCode" name="initCode" style="display: none;"><%= net.sourceforge.plantuml.servlet.PlantUmlServlet.stringToHTMLString(decoded) %></textarea>
<div id="monaco-editor"></div>
<input type="image" alt="copy" src="assets/copy.svg" onclick="copyCodeToClipboard()" />
<div class="editor-menu" tabindex="-1">
<div class="menu-kebab">
<div class="kebab-circle"></div>
<div class="kebab-circle"></div>
<div class="kebab-circle"></div>
<div class="kebab-circle"></div>
<div class="kebab-circle"></div>
</div>
<div class="menu-items">
<input class="menu-item" type="image" alt="copy" title="Copy code" src="assets/actions/copy.svg" onclick="copyCodeToClipboard()" />
<input class="menu-item" type="image" alt="import" title="Import diagram" src="assets/actions/upload.svg" onclick="openModal('diagram-import')" />
<input class="menu-item" type="image" alt="export" title="Export diagram" src="assets/actions/download.svg" onclick="openModal('diagram-export')" />
</div>
</div>
</div>
</div>
<div id="previewer-main-container" class="previewer flex-main">
Expand All @@ -52,6 +65,9 @@
<div class="footer">
<%@ include file="resource/footer.jsp" %>
</div>
<!-- editor modals -->
<%@ include file="resource/diagram-import.jsp" %>
<%@ include file="resource/diagram-export.jsp" %>
</div>
</body>
</html>
Loading

0 comments on commit 6ca582f

Please sign in to comment.