Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions sdkjs-plugins/content/drawio/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,44 @@
justify-content: center;
align-items: center;
}
.format-selector {
position: fixed;
top: 8px;
right: 70px;
z-index: 1000;
display: flex;
align-items: center;
gap: 6px;
font-size: 11px;
}
.format-selector label {
color: #999;
}
.format-selector select {
padding: 3px 6px;
border: 1px solid #404040;
border-radius: 3px;
background: #2a2a2a;
color: #ccc;
font-size: 11px;
cursor: pointer;
outline: none;
}
.format-selector select:hover,
.format-selector select:focus {
border-color: #0066cc;
}
</style>
</head>
<body class="noselect">
<div id="div_preview" class="div_preview noselect hidden"></div>
<div id="loader-container" class="asc-loader-container div-loader"></div>
<div class="format-selector">
<label for="format-select">Export as:</label>
<select id="format-select">
<option value="xmlsvg">SVG (Scalable)</option>
<option value="xmlpng">PNG (Raster)</option>
</select>
</div>
</body>
</html>
43 changes: 42 additions & 1 deletion sdkjs-plugins/content/drawio/scripts/drawio.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,41 @@
var loader;
var lang = "";
var title = "Click on diagram to edit."
var STORAGE_KEY = "drawio_export_format";

function getExportFormat()
{
try {
return localStorage.getItem(STORAGE_KEY) || 'xmlsvg';
} catch (e) {
return 'xmlsvg';
}
};

function setExportFormat(format)
{
try {
localStorage.setItem(STORAGE_KEY, format);
} catch (e) {
// localStorage may be blocked in sandboxed environments
}
};

function initFormatSelector()
{
var select = document.getElementById('format-select');

if (select) {
select.value = getExportFormat();
select.addEventListener('change', function() {
setExportFormat(this.value);

if (editor) {
editor.format = this.value;
}
});
}
};

window.Asc.plugin.init = function(data)
{
Expand All @@ -50,12 +85,18 @@

img.setAttribute('src', data);
var config = {css: "button.geBigButton:nth-of-type(1) {background-color:transparent !important; color:"+ (UI == 'dark' ? '#ccc' : '#000') +" !important;} body>a {display: none !important;} body {-khtml-user-select: none; user-select: none; -moz-user-select: none; -webkit-user-select: none;} div>img:not([title]) { pointer-events: none; }"};
initFormatSelector();
img.onclick = function() {
makeLoader();
editor = DiagramEditor.editElement([this, document.getElementById("div_preview")], config, UI, null, ['lang=' + lang], closePlugin, hideLoader);
editor.isChanged = true;
if (editor) {
editor.format = getExportFormat();
editor.isChanged = true;
}
}
editor = DiagramEditor.editElement([img, document.getElementById("div_preview")], config, UI, null, ['lang=' + lang + '&gapi=0&embed=1&dev=1&spin=0'], closePlugin, hideLoader);
if (editor)
editor.format = getExportFormat();
window.Asc.plugin.resizeWindow(1200, 1000, 800, 600, 0, 0);
};

Expand Down