12.9.13 release

This commit is contained in:
David Benson [draw.io] 2020-04-15 17:54:58 +01:00
parent fc65222d9c
commit 247767c8e1
20 changed files with 2644 additions and 2278 deletions

View file

@ -1,3 +1,7 @@
15-APR-2020: 12.9.13
- Adds file properties dialog
14-APR-2020: 12.9.12
- Adds edit style to context menu

View file

@ -1 +1 @@
12.9.12
12.9.13

View file

@ -1,5 +1,5 @@
/**
* Draw.io Diagrams Sheets add-on v1.0
* diagrams.net Diagrams Sheets add-on v1.0
* Copyright (c) 2019, JGraph Ltd
*/
var EXPORT_URL = "https://exp.draw.io/ImageExport4/export";
@ -41,7 +41,7 @@ function onInstall()
* @return {string} The user's OAuth 2.0 access token.
*/
function getOAuthToken() {
DriveApp.getRootFolder();
DriveApp.getFolders();
return ScriptApp.getOAuthToken();
}
@ -53,7 +53,7 @@ function insertDiagrams()
var html = HtmlService.createHtmlOutputFromFile('Picker.html')
.setWidth(620).setHeight(440)
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getUi().showModalDialog(html, 'Select draw.io Diagrams:');
SpreadsheetApp.getUi().showModalDialog(html, 'Select Diagrams:');
}
function refreshSheet()

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;url=index.html?offline=1">
<meta http-equiv="refresh" content="0;url=https://app.diagrams.net/">
</head>
</html>

File diff suppressed because one or more lines are too long

View file

@ -10455,3 +10455,183 @@ AspectDialog.prototype.createLayerItem = function(layer, pageId, graph, pageNode
onClick();
}
};
/**
* Constructs a new page setup dialog.
*/
var FilePropertiesDialog = function(editorUi)
{
var row, td;
var table = document.createElement('table');
var tbody = document.createElement('tbody');
table.style.width = '100%';
table.style.marginTop = '8px';
var file = editorUi.getCurrentFile();
var filename = (file != null && file.getTitle() != null) ?
file.getTitle() : this.editorUi.defaultFilename;
var isPng = /(\.png)$/i.test(filename);
var apply = null;
if (isPng)
{
var scale = 1;
var border = 0;
var node = editorUi.fileNode;
if (node != null)
{
if (node.hasAttribute('scale'))
{
scale = parseFloat(node.getAttribute('scale'));
}
if (node.hasAttribute('border'))
{
border = parseInt(node.getAttribute('border'));
}
}
row = document.createElement('tr');
td = document.createElement('td');
td.style.whiteSpace = 'nowrap';
td.style.fontSize = '10pt';
td.style.width = '120px';
mxUtils.write(td, mxResources.get('zoom') + ':');
row.appendChild(td);
var zoomInput = document.createElement('input');
zoomInput.setAttribute('value', (scale * 100) + '%');
zoomInput.style.marginLeft = '4px';
zoomInput.style.width ='180px';
td = document.createElement('td');
td.style.whiteSpace = 'nowrap';
td.appendChild(zoomInput);
row.appendChild(td);
tbody.appendChild(row);
row = document.createElement('tr');
td = document.createElement('td');
td.style.whiteSpace = 'nowrap';
td.style.fontSize = '10pt';
td.style.width = '120px';
mxUtils.write(td, mxResources.get('borderWidth') + ':');
row.appendChild(td);
var borderInput = document.createElement('input');
borderInput.setAttribute('value', border);
borderInput.style.marginLeft = '4px';
borderInput.style.width ='180px';
td = document.createElement('td');
td.style.whiteSpace = 'nowrap';
td.appendChild(borderInput);
row.appendChild(td);
tbody.appendChild(row);
this.init = function()
{
zoomInput.focus();
if (mxClient.IS_GC || mxClient.IS_FF || document.documentMode >= 5 || mxClient.IS_QUIRKS)
{
zoomInput.select();
}
else
{
document.execCommand('selectAll', false, null);
}
};
apply = function()
{
if (editorUi.fileNode != null)
{
editorUi.fileNode.setAttribute('scale', Math.max(0, parseInt(zoomInput.value) / 100));
editorUi.fileNode.setAttribute('border', Math.max(0, parseInt(borderInput.value)));
}
editorUi.hideDialog();
};
}
else
{
var compressed = (file != null) ? file.isCompressed() : Editor.compressXml;
row = document.createElement('tr');
td = document.createElement('td');
td.style.whiteSpace = 'nowrap';
td.style.fontSize = '10pt';
td.style.width = '120px';
mxUtils.write(td, mxResources.get('compressed') + ':');
row.appendChild(td);
var compressedInput = document.createElement('input');
compressedInput.setAttribute('type', 'checkbox');
if (compressed)
{
compressedInput.setAttribute('checked', 'checked');
compressedInput.defaultChecked = true;
}
td = document.createElement('td');
td.style.whiteSpace = 'nowrap';
td.appendChild(compressedInput);
row.appendChild(td);
tbody.appendChild(row);
this.init = function()
{
compressedInput.focus();
};
apply = function()
{
if (editorUi.fileNode != null)
{
editorUi.fileNode.setAttribute('compressed', (compressedInput.checked) ? 'true' : 'false');
}
editorUi.hideDialog();
};
}
var genericBtn = mxUtils.button(mxResources.get('apply'), apply);
genericBtn.className = 'geBtn gePrimaryBtn';
row = document.createElement('tr');
td = document.createElement('td');
td.colSpan = 2;
td.style.paddingTop = '20px';
td.style.whiteSpace = 'nowrap';
td.setAttribute('align', 'right');
var cancelBtn = mxUtils.button(mxResources.get('cancel'), function()
{
editorUi.hideDialog();
});
cancelBtn.className = 'geBtn';
if (editorUi.editor.cancelFirst)
{
td.appendChild(cancelBtn);
}
td.appendChild(genericBtn);
if (!editorUi.editor.cancelFirst)
{
td.appendChild(cancelBtn);
}
row.appendChild(td);
tbody.appendChild(row);
table.appendChild(tbody);
this.container = table;
};

View file

@ -872,7 +872,12 @@ DrawioFile.prototype.isCompressed = function()
}
};
/**
* Translates this point by the given vector.
*
* @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation.
*/
DrawioFile.prototype.decompress = function()
{
this.updateFileData(false);
@ -885,6 +890,12 @@ DrawioFile.prototype.decompress = function()
this.fileChanged();
};
/**
* Translates this point by the given vector.
*
* @param {number} dx X-coordinate of the translation.
* @param {number} dy Y-coordinate of the translation.
*/
DrawioFile.prototype.compress = function()
{
this.updateFileData(true);

View file

@ -1770,10 +1770,13 @@ DriveClient.prototype.saveFile = function(file, revision, success, errFn, noChec
if (saveAsPng)
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{
doExecuteRequest(data, true);
}), error, (this.ui.getCurrentFile() != file) ? savedData : null);
}), error, (this.ui.getCurrentFile() != file) ?
savedData : null, p.scale, p.border);
}
else
{

View file

@ -281,10 +281,13 @@ DropboxFile.prototype.saveFile = function(title, revision, success, error)
if (this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()))
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{
doSave(this.ui.base64ToBlob(data, 'image/png'));
}), error, (this.ui.getCurrentFile() != this) ? this.getData() : null);
}), error, (this.ui.getCurrentFile() != this) ?
this.getData() : null, p.scale, p.border);
}
else
{

View file

@ -4123,6 +4123,15 @@
*/
EditorUi.prototype.doSaveLocalFile = function(data, filename, mimeType, base64Encoded, format)
{
// Appends .drawio extension for XML files with no extension
// to avoid the browser to automatically append .xml instead
if (mimeType == 'text/xml' &&
!/(\.drawio)$/i.test(filename) &&
!/(\.xml)$/i.test(filename))
{
filename = filename + '.drawio';
}
// Newer versions of IE
if (window.Blob && navigator.msSaveOrOpenBlob)
{
@ -6092,10 +6101,45 @@
return node;
};
/**
*
*/
EditorUi.prototype.getEmbeddedPng = function(success, error, optionalData)
EditorUi.prototype.getPngFileProperties = function(node)
{
var scale = 1;
var border = 0;
if (node != null)
{
if (node.hasAttribute('scale'))
{
var temp = parseFloat(node.getAttribute('scale'));
if (!isNaN(temp) && temp > 0)
{
scale = temp;
}
}
if (node.hasAttribute('border'))
{
var temp = parseInt(node.getAttribute('border'));
if (!isNaN(temp) && temp > 0)
{
border = temp;
}
}
}
return {scale: scale, border: border};
};
/**
*
*/
EditorUi.prototype.getEmbeddedPng = function(success, error, optionalData, scale, border)
{
try
{
@ -6170,7 +6214,7 @@
{
error(e);
}
}), null, null, null, null, graph.shadowVisible, null, graph);
}), null, null, scale, null, graph.shadowVisible, null, graph, border);
}
catch (e)
{

View file

@ -142,12 +142,39 @@ mxStencilRegistry.allowEval = false;
menu.addSeparator(parent);
this.addSubmenu('embed', menu, parent);
menu.addSeparator(parent);
this.addMenuItems(menu, ['newLibrary', 'openLibrary', '-', 'pageSetup',
'print', '-', 'close'], parent);
this.addMenuItems(menu, ['newLibrary', 'openLibrary'], parent);
var file = editorUi.getCurrentFile();
if (file != null && editorUi.fileNode != null)
{
var filename = (file.getTitle() != null) ?
file.getTitle() : editorUi.defaultFilename;
if (!/(\.html)$/i.test(filename) &&
!/(\.svg)$/i.test(filename))
{
this.addMenuItems(menu, ['-', 'properties']);
}
}
this.addMenuItems(menu, ['-', 'pageSetup', 'print', '-', 'close'], parent);
// LATER: Find API for application.quit
})));
};
function getDocumentsFolder()
{
//On windows, misconfigured Documents folder cause an exception
try
{
return require('electron').remote.app.getPath('documents');
}
catch(e) {}
return '.';
};
var graphCreateLinkForHint = Graph.prototype.createLinkForHint;
Graph.prototype.createLinkForHint = function(href, label)
@ -218,7 +245,7 @@ mxStencilRegistry.allowEval = false;
var lastDir = localStorage.getItem('.lastImpDir');
var paths = dialog.showOpenDialogSync({
defaultPath: lastDir || remote.app.getPath('documents'),
defaultPath: lastDir || getDocumentsFolder(),
properties: ['openFile']
});
@ -661,7 +688,7 @@ mxStencilRegistry.allowEval = false;
var lastDir = localStorage.getItem('.lastOpenDir');
var paths = dialog.showOpenDialogSync({
defaultPath: lastDir || remote.app.getPath('documents'),
defaultPath: lastDir || getDocumentsFolder(),
filters: [
{ name: 'draw.io Diagrams', extensions: ['drawio', 'xml'] },
{ name: 'VSDX Documents', extensions: ['vsdx'] },
@ -949,6 +976,20 @@ mxStencilRegistry.allowEval = false;
return stat != null && this.stat != null && stat.mtimeMs != this.stat.mtimeMs;
};
LocalFile.prototype.getFilename = function()
{
var filename = this.title;
// Adds default extension
if (filename.length > 0 && (!/(\.xml)$/i.test(filename) && !/(\.html)$/i.test(filename) &&
!/(\.svg)$/i.test(filename) && !/(\.png)$/i.test(filename) && !/(\.drawio)$/i.test(filename)))
{
filename += '.drawio';
}
return filename;
};
LocalFile.prototype.saveFile = function(revision, success, error, unloading, overwrite)
{
if (!this.savingFile)
@ -1080,10 +1121,12 @@ mxStencilRegistry.allowEval = false;
}
else
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(function(data)
{
doSave(atob(data), 'binary');
}, error);
}, error, null, p.scale, p.border);
}
});
@ -1095,7 +1138,7 @@ mxStencilRegistry.allowEval = false;
const sysPath = require('path')
var lastDir = localStorage.getItem('.lastSaveDir');
var path = dialog.showSaveDialogSync({defaultPath: (lastDir || remote.app.getPath('documents')) + '/' + this.title});
var path = dialog.showSaveDialogSync({defaultPath: (lastDir || getDocumentsFolder()) + '/' + this.getFilename()});
if (path != null)
{
@ -1123,18 +1166,19 @@ mxStencilRegistry.allowEval = false;
const electron = require('electron');
var remote = electron.remote;
var dialog = remote.dialog;
var filename = this.title;
const sysPath = require('path')
var lastDir = localStorage.getItem('.lastSaveDir');
// Adds default extension
if (filename.length > 0 && (!/(\.xml)$/i.test(filename) && !/(\.html)$/i.test(filename) &&
!/(\.svg)$/i.test(filename) && !/(\.png)$/i.test(filename) && !/(\.drawio)$/i.test(filename)))
{
filename += '.drawio';
}
var path = dialog.showSaveDialogSync({defaultPath: (lastDir || remote.app.getPath('documents')) + '/' + filename});
var path = dialog.showSaveDialogSync({
defaultPath: (lastDir || getDocumentsFolder()) + '/' + this.getFilename(),
filters: [
{ name: 'XML File (.drawio)', extensions: ['drawio'] },
{ name: 'Editable Bitmap Image (.png)', extensions: ['png'] },
{ name: 'Editable Vector Image (.svg)', extensions: ['svg'] },
{ name: 'HTML File (.html)', extensions: ['html'] },
{ name: 'XML File (.xml)', extensions: ['xml'] }
]
});
if (path != null)
{
@ -1505,7 +1549,7 @@ mxStencilRegistry.allowEval = false;
// to give the spinner some time to stop spinning
window.setTimeout(mxUtils.bind(this, function()
{
var dlgConfig = {defaultPath: (lastDir || remote.app.getPath('documents')) + '/' + filename};
var dlgConfig = {defaultPath: (lastDir || getDocumentsFolder()) + '/' + filename};
var filters = null;
switch (format)

View file

@ -715,10 +715,13 @@ GitHubClient.prototype.saveFile = function(file, success, error, overwrite, mess
{
if (this.ui.useCanvasForExport && /(\.png)$/i.test(path))
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{
fn(file.meta.sha, data);
}), error, (this.ui.getCurrentFile() != file) ? file.getData() : null);
}), error, (this.ui.getCurrentFile() != file) ?
file.getData() : null, p.scale, p.border);
}
else
{

View file

@ -631,10 +631,13 @@ GitLabClient.prototype.saveFile = function(file, success, error, overwrite, mess
{
if (this.ui.useCanvasForExport && /(\.png)$/i.test(path))
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{
fn(file.meta.last_commit_id, data);
}), error, (this.ui.getCurrentFile() != file) ? file.getData() : null);
}), error, (this.ui.getCurrentFile() != file) ?
file.getData() : null, p.scale, p.border);
}
else
{

View file

@ -141,10 +141,13 @@ LocalFile.prototype.saveFile = function(title, revision, success, error)
if (binary)
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(imageData)
{
doSave(imageData);
}), error, (this.ui.getCurrentFile() != this) ? this.getData() : null);
}), error, (this.ui.getCurrentFile() != this) ?
this.getData() : null, p.scale, p.border);
}
else
{

View file

@ -181,6 +181,13 @@
rulerAction.setToggleAction(true);
rulerAction.setSelectedCallback(function() { return editorUi.ruler != null; });
editorUi.actions.addAction('properties...', function()
{
var dlg = new FilePropertiesDialog(editorUi);
editorUi.showDialog(dlg.container, 320, 120, true, true);
dlg.init();
}).isEnabled = isGraphEnabled;
if (window.mxFreehand)
{
editorUi.actions.put('insertFreehand', new Action(mxResources.get('freehand') + '...', function(evt)
@ -3524,6 +3531,18 @@
this.addMenuItems(menu, ['-', 'revisionHistory'], parent);
}
if (file != null && editorUi.fileNode != null)
{
var filename = (file.getTitle() != null) ?
file.getTitle() : editorUi.defaultFilename;
if (!/(\.html)$/i.test(filename) &&
!/(\.svg)$/i.test(filename))
{
this.addMenuItems(menu, ['-', 'properties']);
}
}
this.addMenuItems(menu, ['-', 'pageSetup'], parent);
// Cannot use print in standalone mode on iOS as we cannot open new windows
@ -3554,8 +3573,6 @@
ChangeExtFonts.prototype.execute = function()
{
var graph = this.ui.editor.graph;
this.customFonts = this.prevCustomFonts;
this.prevCustomFonts = this.ui.menus.customFonts;
this.ui.fireEvent(new mxEventObject('customFontsChanged', 'customFonts', this.customFonts));

View file

@ -135,7 +135,7 @@ EditorUi.initMinimalTheme = function()
}
};
function toggleFormat(ui)
function toggleFormat(ui, visible)
{
var graph = ui.editor.graph;
graph.popupMenuHandler.hideMenu();
@ -157,7 +157,8 @@ EditorUi.initMinimalTheme = function()
}
else
{
ui.formatWindow.window.setVisible(!ui.formatWindow.window.isVisible());
ui.formatWindow.window.setVisible((visible != null) ?
visible : !ui.formatWindow.window.isVisible());
}
if (ui.formatWindow.window.isVisible())
@ -166,7 +167,7 @@ EditorUi.initMinimalTheme = function()
}
};
function toggleShapes(ui)
function toggleShapes(ui, visible)
{
var graph = ui.editor.graph;
graph.popupMenuHandler.hideMenu();
@ -283,7 +284,8 @@ EditorUi.initMinimalTheme = function()
}
else
{
ui.sidebarWindow.window.setVisible(!ui.sidebarWindow.window.isVisible());
ui.sidebarWindow.window.setVisible((visible != null) ?
visible : !ui.sidebarWindow.window.isVisible());
}
if (ui.sidebarWindow.window.isVisible())
@ -660,6 +662,23 @@ EditorUi.initMinimalTheme = function()
this.formatWindow.window.setVisible(false);
}
}
else
{
var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
if (iw >= 1000)
{
if (this.sidebarWindow != null)
{
this.sidebarWindow.window.setVisible(true);
}
if (this.formatWindow != null)
{
this.formatWindow.window.setVisible(true);
}
}
}
};
// Disables centering of graph after iframe resize
@ -791,6 +810,18 @@ EditorUi.initMinimalTheme = function()
ui.menus.addMenuItems(menu, ['-', 'find', 'tags'], parent);
if (file != null && ui.fileNode != null)
{
var filename = (file.getTitle() != null) ?
file.getTitle() : ui.defaultFilename;
if (!/(\.html)$/i.test(filename) &&
!/(\.svg)$/i.test(filename))
{
this.addMenuItems(menu, ['-', 'properties']);
}
}
// Cannot use print in standalone mode on iOS as we cannot open new windows
if (!mxClient.IS_IOS || !navigator.standalone)
{
@ -970,9 +1001,14 @@ EditorUi.initMinimalTheme = function()
div.style.bottom = (urlParams['embed'] != '1' || urlParams['libraries'] == '1') ? '63px' : '32px';
this.sidebar = this.createSidebar(div);
if (urlParams['clibs'] != null || urlParams['libs'] != null)
if (iw >= 1000 || urlParams['clibs'] != null || urlParams['libs'] != null)
{
toggleShapes(this);
toggleShapes(this, true);
}
if (iw >= 1000)
{
toggleFormat(this, true);
}
// Needed for creating elements in Format panel

View file

@ -873,10 +873,13 @@ OneDriveClient.prototype.saveFile = function(file, success, error, etag)
if (this.ui.useCanvasForExport && /(\.png)$/i.test(file.meta.name))
{
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{
fn(this.ui.base64ToBlob(data, 'image/png'));
}), error, (this.ui.getCurrentFile() != file) ? savedData : null);
}), error, (this.ui.getCurrentFile() != file) ?
savedData : null, p.scale, p.border);
}
else
{

View file

@ -2267,6 +2267,7 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
};
mxEvent.addListener(nameInput, 'change', nameInputChanged);
mxEvent.addListener(nameInput, 'keyup', nameInputChanged);
nameInputChanged();
return typeSelect;

File diff suppressed because one or more lines are too long

View file

@ -6,7 +6,7 @@ if (workbox)
workbox.precaching.precacheAndRoute([
{
"url": "js/app.min.js",
"revision": "497dc7fc0f4c3063866bc58c68462fbd"
"revision": "7c084103ede1e74669accd87f65fd5b8"
},
{
"url": "js/extensions.min.js",
@ -30,7 +30,7 @@ if (workbox)
},
{
"url": "app.html",
"revision": "d3b6efffecb556234c73284cb9922806"
"revision": "e28e1516e715420680ab6f3bc3fe2288"
},
{
"url": "styles/grapheditor.css",