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 14-APR-2020: 12.9.12
- Adds edit style to context menu - 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 * Copyright (c) 2019, JGraph Ltd
*/ */
var EXPORT_URL = "https://exp.draw.io/ImageExport4/export"; 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. * @return {string} The user's OAuth 2.0 access token.
*/ */
function getOAuthToken() { function getOAuthToken() {
DriveApp.getRootFolder(); DriveApp.getFolders();
return ScriptApp.getOAuthToken(); return ScriptApp.getOAuthToken();
} }
@ -53,7 +53,7 @@ function insertDiagrams()
var html = HtmlService.createHtmlOutputFromFile('Picker.html') var html = HtmlService.createHtmlOutputFromFile('Picker.html')
.setWidth(620).setHeight(440) .setWidth(620).setHeight(440)
.setSandboxMode(HtmlService.SandboxMode.IFRAME); .setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getUi().showModalDialog(html, 'Select draw.io Diagrams:'); SpreadsheetApp.getUi().showModalDialog(html, 'Select Diagrams:');
} }
function refreshSheet() function refreshSheet()

View file

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="refresh" content="0;url=index.html?offline=1"> <meta http-equiv="refresh" content="0;url=https://app.diagrams.net/">
</head> </head>
</html> </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(); 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() DrawioFile.prototype.decompress = function()
{ {
this.updateFileData(false); this.updateFileData(false);
@ -885,6 +890,12 @@ DrawioFile.prototype.decompress = function()
this.fileChanged(); 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() DrawioFile.prototype.compress = function()
{ {
this.updateFileData(true); this.updateFileData(true);

View file

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

View file

@ -281,10 +281,13 @@ DropboxFile.prototype.saveFile = function(title, revision, success, error)
if (this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle())) 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) this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{ {
doSave(this.ui.base64ToBlob(data, 'image/png')); 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 else
{ {

View file

@ -1771,7 +1771,7 @@
{ {
if (data.length <= MAX_REQUEST_SIZE) if (data.length <= MAX_REQUEST_SIZE)
{ {
this.saveData(filename, 'svg', data, 'image/svg+xml'); this.saveData(filename, 'svg', data, 'image/svg+xml');
} }
else else
{ {
@ -4123,6 +4123,15 @@
*/ */
EditorUi.prototype.doSaveLocalFile = function(data, filename, mimeType, base64Encoded, format) 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 // Newer versions of IE
if (window.Blob && navigator.msSaveOrOpenBlob) if (window.Blob && navigator.msSaveOrOpenBlob)
{ {
@ -6092,10 +6101,45 @@
return node; 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 try
{ {
@ -6170,7 +6214,7 @@
{ {
error(e); error(e);
} }
}), null, null, null, null, graph.shadowVisible, null, graph); }), null, null, scale, null, graph.shadowVisible, null, graph, border);
} }
catch (e) catch (e)
{ {

View file

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

View file

@ -631,10 +631,13 @@ GitLabClient.prototype.saveFile = function(file, success, error, overwrite, mess
{ {
if (this.ui.useCanvasForExport && /(\.png)$/i.test(path)) if (this.ui.useCanvasForExport && /(\.png)$/i.test(path))
{ {
var p = this.ui.getPngFileProperties(this.ui.fileNode);
this.ui.getEmbeddedPng(mxUtils.bind(this, function(data) this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{ {
fn(file.meta.last_commit_id, 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 else
{ {

View file

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

View file

@ -181,6 +181,13 @@
rulerAction.setToggleAction(true); rulerAction.setToggleAction(true);
rulerAction.setSelectedCallback(function() { return editorUi.ruler != null; }); 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) if (window.mxFreehand)
{ {
editorUi.actions.put('insertFreehand', new Action(mxResources.get('freehand') + '...', function(evt) editorUi.actions.put('insertFreehand', new Action(mxResources.get('freehand') + '...', function(evt)
@ -3524,6 +3531,18 @@
this.addMenuItems(menu, ['-', 'revisionHistory'], parent); 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); this.addMenuItems(menu, ['-', 'pageSetup'], parent);
// Cannot use print in standalone mode on iOS as we cannot open new windows // Cannot use print in standalone mode on iOS as we cannot open new windows
@ -3554,8 +3573,6 @@
ChangeExtFonts.prototype.execute = function() ChangeExtFonts.prototype.execute = function()
{ {
var graph = this.ui.editor.graph; var graph = this.ui.editor.graph;
this.customFonts = this.prevCustomFonts; this.customFonts = this.prevCustomFonts;
this.prevCustomFonts = this.ui.menus.customFonts; this.prevCustomFonts = this.ui.menus.customFonts;
this.ui.fireEvent(new mxEventObject('customFontsChanged', 'customFonts', this.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; var graph = ui.editor.graph;
graph.popupMenuHandler.hideMenu(); graph.popupMenuHandler.hideMenu();
@ -157,7 +157,8 @@ EditorUi.initMinimalTheme = function()
} }
else 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()) if (ui.formatWindow.window.isVisible())
@ -166,7 +167,7 @@ EditorUi.initMinimalTheme = function()
} }
}; };
function toggleShapes(ui) function toggleShapes(ui, visible)
{ {
var graph = ui.editor.graph; var graph = ui.editor.graph;
graph.popupMenuHandler.hideMenu(); graph.popupMenuHandler.hideMenu();
@ -283,7 +284,8 @@ EditorUi.initMinimalTheme = function()
} }
else 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()) if (ui.sidebarWindow.window.isVisible())
@ -650,9 +652,9 @@ EditorUi.initMinimalTheme = function()
if (!enabled) if (!enabled)
{ {
if (this.sidebarWindow != null) if (this.sidebarWindow != null)
{ {
this.sidebarWindow.window.setVisible(false); this.sidebarWindow.window.setVisible(false);
} }
if (this.formatWindow != null) if (this.formatWindow != null)
@ -660,6 +662,23 @@ EditorUi.initMinimalTheme = function()
this.formatWindow.window.setVisible(false); 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 // Disables centering of graph after iframe resize
@ -791,13 +810,25 @@ EditorUi.initMinimalTheme = function()
ui.menus.addMenuItems(menu, ['-', 'find', 'tags'], parent); 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 // Cannot use print in standalone mode on iOS as we cannot open new windows
if (!mxClient.IS_IOS || !navigator.standalone) if (!mxClient.IS_IOS || !navigator.standalone)
{ {
ui.menus.addMenuItems(menu, ['-', 'print', '-'], parent); ui.menus.addMenuItems(menu, ['-', 'print', '-'], parent);
} }
ui.menus.addSubmenu('help', menu, parent); ui.menus.addSubmenu('help', menu, parent);
if (urlParams['embed'] == '1') if (urlParams['embed'] == '1')
{ {
@ -965,103 +996,108 @@ EditorUi.initMinimalTheme = function()
{ {
editorUiInit.apply(this, arguments); editorUiInit.apply(this, arguments);
var div = document.createElement('div'); var div = document.createElement('div');
div.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;overflow-y:auto;overflow-x:hidden;'; div.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;overflow-y:auto;overflow-x:hidden;';
div.style.bottom = (urlParams['embed'] != '1' || urlParams['libraries'] == '1') ? '63px' : '32px'; div.style.bottom = (urlParams['embed'] != '1' || urlParams['libraries'] == '1') ? '63px' : '32px';
this.sidebar = this.createSidebar(div); 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);
} }
// Needed for creating elements in Format panel if (iw >= 1000)
var ui = this; {
var graph = ui.editor.graph; toggleFormat(this, true);
ui.toolbar = this.createToolbar(ui.createDiv('geToolbar')); }
ui.defaultLibraryName = mxResources.get('untitledLibrary');
var menubar = document.createElement('div'); // Needed for creating elements in Format panel
menubar.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;height:30px;padding:8px;border-bottom:1px solid lightgray;background-color:#ffffff;text-align:left;white-space:nowrap;'; var ui = this;
var graph = ui.editor.graph;
ui.toolbar = this.createToolbar(ui.createDiv('geToolbar'));
ui.defaultLibraryName = mxResources.get('untitledLibrary');
var before = null; var menubar = document.createElement('div');
var menuObj = new Menubar(ui, menubar); menubar.style.cssText = 'position:absolute;left:0px;right:0px;top:0px;height:30px;padding:8px;border-bottom:1px solid lightgray;background-color:#ffffff;text-align:left;white-space:nowrap;';
function addMenu(id, small, img) var before = null;
{ var menuObj = new Menubar(ui, menubar);
var menu = ui.menus.get(id);
var elt = menuObj.addMenu(mxResources.get(id), mxUtils.bind(this, function() function addMenu(id, small, img)
{ {
// Allows extensions of menu.functid var menu = ui.menus.get(id);
menu.funct.apply(this, arguments);
}), before);
elt.className = 'geMenuItem'; var elt = menuObj.addMenu(mxResources.get(id), mxUtils.bind(this, function()
elt.style.display = 'inline-block'; {
elt.style.boxSizing = 'border-box'; // Allows extensions of menu.functid
elt.style.top = '6px'; menu.funct.apply(this, arguments);
elt.style.marginRight = '6px'; }), before);
elt.style.height = '30px';
elt.style.paddingTop = '6px';
elt.style.paddingBottom = '6px';
elt.style.cursor = 'pointer';
elt.setAttribute('title', mxResources.get(id));
ui.menus.menuCreated(menu, elt, 'geMenuItem');
if (img != null) elt.className = 'geMenuItem';
{ elt.style.display = 'inline-block';
elt.style.backgroundImage = 'url(' + img + ')'; elt.style.boxSizing = 'border-box';
elt.style.backgroundPosition = 'center center'; elt.style.top = '6px';
elt.style.backgroundRepeat = 'no-repeat'; elt.style.marginRight = '6px';
elt.style.backgroundSize = '24px 24px'; elt.style.height = '30px';
elt.style.width = '34px'; elt.style.paddingTop = '6px';
elt.innerHTML = ''; elt.style.paddingBottom = '6px';
} elt.style.cursor = 'pointer';
else if (!small) elt.setAttribute('title', mxResources.get(id));
{ ui.menus.menuCreated(menu, elt, 'geMenuItem');
elt.style.backgroundImage = 'url(' + mxWindow.prototype.normalizeImage + ')';
elt.style.backgroundPosition = 'right 6px center';
elt.style.backgroundRepeat = 'no-repeat';
elt.style.paddingRight = '22px';
}
return elt; if (img != null)
}; {
elt.style.backgroundImage = 'url(' + img + ')';
elt.style.backgroundPosition = 'center center';
elt.style.backgroundRepeat = 'no-repeat';
elt.style.backgroundSize = '24px 24px';
elt.style.width = '34px';
elt.innerHTML = '';
}
else if (!small)
{
elt.style.backgroundImage = 'url(' + mxWindow.prototype.normalizeImage + ')';
elt.style.backgroundPosition = 'right 6px center';
elt.style.backgroundRepeat = 'no-repeat';
elt.style.paddingRight = '22px';
}
function addMenuItem(label, fn, small, tooltip, action, img) return elt;
{ };
var btn = document.createElement('a');
btn.className = 'geMenuItem';
btn.style.display = 'inline-block';
btn.style.boxSizing = 'border-box';
btn.style.height = '30px';
btn.style.padding = '6px';
btn.style.position = 'relative';
btn.style.verticalAlign = 'top';
btn.style.top = '0px';
if (ui.statusContainer != null) function addMenuItem(label, fn, small, tooltip, action, img)
{ {
menubar.insertBefore(btn, ui.statusContainer); var btn = document.createElement('a');
} btn.className = 'geMenuItem';
else btn.style.display = 'inline-block';
{ btn.style.boxSizing = 'border-box';
menubar.appendChild(btn); btn.style.height = '30px';
} btn.style.padding = '6px';
btn.style.position = 'relative';
btn.style.verticalAlign = 'top';
btn.style.top = '0px';
if (img != null) if (ui.statusContainer != null)
{ {
btn.style.backgroundImage = 'url(' + img + ')'; menubar.insertBefore(btn, ui.statusContainer);
btn.style.backgroundPosition = 'center center'; }
btn.style.backgroundRepeat = 'no-repeat'; else
btn.style.backgroundSize = '24px 24px'; {
btn.style.width = '34px'; menubar.appendChild(btn);
} }
else
{ if (img != null)
mxUtils.write(btn, label); {
} btn.style.backgroundImage = 'url(' + img + ')';
btn.style.backgroundPosition = 'center center';
btn.style.backgroundRepeat = 'no-repeat';
btn.style.backgroundSize = '24px 24px';
btn.style.width = '34px';
}
else
{
mxUtils.write(btn, label);
}
// Prevents focus // Prevents focus
mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown', mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown',

View file

@ -873,10 +873,13 @@ OneDriveClient.prototype.saveFile = function(file, success, error, etag)
if (this.ui.useCanvasForExport && /(\.png)$/i.test(file.meta.name)) 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) this.ui.getEmbeddedPng(mxUtils.bind(this, function(data)
{ {
fn(this.ui.base64ToBlob(data, 'image/png')); 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 else
{ {

View file

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

File diff suppressed because one or more lines are too long

View file

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