|
@@ -833,6 +833,50 @@ App.main = function(callback, createUi)
|
|
|
|
|
|
function doMain()
|
|
|
{
|
|
|
+ // Optional override for autosaveDelay and defaultEdgeLength
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (mxSettings.settings != null)
|
|
|
+ {
|
|
|
+ if (mxSettings.settings.autosaveDelay != null)
|
|
|
+ {
|
|
|
+ var val = parseInt(mxSettings.settings.autosaveDelay);
|
|
|
+
|
|
|
+ if (!isNaN(val) && val > 0)
|
|
|
+ {
|
|
|
+ DrawioFile.prototype.autosaveDelay = val;
|
|
|
+ EditorUi.debug('Setting autosaveDelay', val);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EditorUi.debug('Invalid autosaveDelay', val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mxSettings.settings.defaultEdgeLength != null)
|
|
|
+ {
|
|
|
+ var val = parseInt(mxSettings.settings.defaultEdgeLength);
|
|
|
+
|
|
|
+ if (!isNaN(val) && val > 0)
|
|
|
+ {
|
|
|
+ Graph.prototype.defaultEdgeLength = val;
|
|
|
+ EditorUi.debug('Using defaultEdgeLength', val);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EditorUi.debug('Invalid defaultEdgeLength', val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e)
|
|
|
+ {
|
|
|
+ if (window.console != null)
|
|
|
+ {
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Adds required resources (disables loading of fallback properties, this can only
|
|
|
// be used if we know that all keys are defined in the language specific file)
|
|
|
mxResources.loadDefaultBundle = false;
|
|
@@ -875,41 +919,17 @@ App.main = function(callback, createUi)
|
|
|
mxEvent.addListener(window, 'message', configHandler);
|
|
|
op.postMessage(JSON.stringify({event: 'configure'}), '*');
|
|
|
}
|
|
|
- else if (Editor.config == null)
|
|
|
+ else
|
|
|
{
|
|
|
- // Loads configuration from global scope or local storage
|
|
|
- if (window.DRAWIO_CONFIG != null)
|
|
|
+ if (Editor.config == null)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- EditorUi.debug('Using global configuration', window.DRAWIO_CONFIG);
|
|
|
- Editor.configure(window.DRAWIO_CONFIG);
|
|
|
- }
|
|
|
- catch (e)
|
|
|
- {
|
|
|
- if (window.console != null)
|
|
|
- {
|
|
|
- console.error(e);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Loads configuration from local storage
|
|
|
- if (isLocalStorage && localStorage != null && urlParams['embed'] != '1')
|
|
|
- {
|
|
|
- var configData = localStorage.getItem('.configuration');
|
|
|
-
|
|
|
- if (configData != null)
|
|
|
+ // Loads configuration from global scope or local storage
|
|
|
+ if (window.DRAWIO_CONFIG != null)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- configData = JSON.parse(configData);
|
|
|
-
|
|
|
- if (configData != null)
|
|
|
- {
|
|
|
- EditorUi.debug('Using local configuration', configData);
|
|
|
- Editor.configure(configData);
|
|
|
- }
|
|
|
+ EditorUi.debug('Using global configuration', window.DRAWIO_CONFIG);
|
|
|
+ Editor.configure(window.DRAWIO_CONFIG);
|
|
|
}
|
|
|
catch (e)
|
|
|
{
|
|
@@ -919,54 +939,37 @@ App.main = function(callback, createUi)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // Optional override for autosaveDelay and defaultEdgeLength
|
|
|
- try
|
|
|
- {
|
|
|
- if (mxSettings.settings != null)
|
|
|
- {
|
|
|
- if (mxSettings.settings.autosaveDelay != null)
|
|
|
- {
|
|
|
- var val = parseInt(mxSettings.settings.autosaveDelay);
|
|
|
-
|
|
|
- if (!isNaN(val) && val > 0)
|
|
|
- {
|
|
|
- DrawioFile.prototype.autosaveDelay = val;
|
|
|
- EditorUi.debug('Setting autosaveDelay', val);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- EditorUi.debug('Invalid autosaveDelay', val);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (mxSettings.settings.defaultEdgeLength != null)
|
|
|
+ // Loads configuration from local storage
|
|
|
+ if (isLocalStorage && localStorage != null && urlParams['embed'] != '1')
|
|
|
{
|
|
|
- var val = parseInt(mxSettings.settings.defaultEdgeLength);
|
|
|
-
|
|
|
- if (!isNaN(val) && val > 0)
|
|
|
- {
|
|
|
- Graph.prototype.defaultEdgeLength = val;
|
|
|
- EditorUi.debug('Using defaultEdgeLength', val);
|
|
|
- }
|
|
|
- else
|
|
|
+ var configData = localStorage.getItem('.configuration');
|
|
|
+
|
|
|
+ if (configData != null)
|
|
|
{
|
|
|
- EditorUi.debug('Invalid defaultEdgeLength', val);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ configData = JSON.parse(configData);
|
|
|
+
|
|
|
+ if (configData != null)
|
|
|
+ {
|
|
|
+ EditorUi.debug('Using local configuration', configData);
|
|
|
+ Editor.configure(configData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e)
|
|
|
+ {
|
|
|
+ if (window.console != null)
|
|
|
+ {
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ doMain();
|
|
|
}
|
|
|
- catch (e)
|
|
|
- {
|
|
|
- if (window.console != null)
|
|
|
- {
|
|
|
- console.error(e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- doMain();
|
|
|
};
|
|
|
|
|
|
//Extends EditorUi
|
|
@@ -3639,52 +3642,78 @@ App.prototype.saveFile = function(forceDialog, success)
|
|
|
|
|
|
var rowLimit = (serviceCount <= 4) ? 2 : (serviceCount > 6 ? 4 : 3);
|
|
|
|
|
|
- var dlg = new CreateDialog(this, filename, mxUtils.bind(this, function(name, mode)
|
|
|
+ var dlg = new CreateDialog(this, filename, mxUtils.bind(this, function(name, mode, input)
|
|
|
{
|
|
|
if (name != null && name.length > 0)
|
|
|
{
|
|
|
- if (prev == null && mode == App.MODE_DEVICE)
|
|
|
- {
|
|
|
- this.setMode(App.MODE_DEVICE);
|
|
|
- this.save(name, done);
|
|
|
- }
|
|
|
- else if (mode == 'download')
|
|
|
+ // Handles special case where PDF export is detected
|
|
|
+ if (/(\.pdf)$/i.test(name))
|
|
|
{
|
|
|
- var tmp = new LocalFile(this, null, name);
|
|
|
- tmp.save();
|
|
|
- }
|
|
|
- else if (mode == '_blank')
|
|
|
- {
|
|
|
- window.openFile = new OpenFile(function()
|
|
|
+ this.confirm(mxResources.get('didYouMeanToExportToPdf'), mxUtils.bind(this, function()
|
|
|
{
|
|
|
- window.openFile = null;
|
|
|
- });
|
|
|
-
|
|
|
- // Do not use a filename to use undefined mode
|
|
|
- window.openFile.setData(this.getFileData(true));
|
|
|
- this.openLink(this.getUrl(window.location.pathname), null, true);
|
|
|
- }
|
|
|
- else if (prev != mode)
|
|
|
- {
|
|
|
- this.pickFolder(mode, mxUtils.bind(this, function(folderId)
|
|
|
+ this.hideDialog();
|
|
|
+ this.actions.get('exportPdf').funct();
|
|
|
+ }), mxUtils.bind(this, function()
|
|
|
{
|
|
|
- this.createFile(name, this.getFileData(/(\.xml)$/i.test(name) ||
|
|
|
- name.indexOf('.') < 0 || /(\.drawio)$/i.test(name),
|
|
|
- /(\.svg)$/i.test(name), /(\.html)$/i.test(name)),
|
|
|
- null, mode, done, this.mode == null, folderId);
|
|
|
- }));
|
|
|
+ input.value = name.split('.').slice(0, -1).join('.');
|
|
|
+ input.focus();
|
|
|
+
|
|
|
+ if (mxClient.IS_GC || mxClient.IS_FF || document.documentMode >= 5 || mxClient.IS_QUIRKS)
|
|
|
+ {
|
|
|
+ input.select();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ document.execCommand('selectAll', false, null);
|
|
|
+ }
|
|
|
+ }), mxResources.get('yes'), mxResources.get('no'));
|
|
|
}
|
|
|
- else if (mode != null)
|
|
|
+ else
|
|
|
{
|
|
|
- this.save(name, done);
|
|
|
+ this.hideDialog();
|
|
|
+
|
|
|
+ if (prev == null && mode == App.MODE_DEVICE)
|
|
|
+ {
|
|
|
+ this.setMode(App.MODE_DEVICE);
|
|
|
+ this.save(name, done);
|
|
|
+ }
|
|
|
+ else if (mode == 'download')
|
|
|
+ {
|
|
|
+ var tmp = new LocalFile(this, null, name);
|
|
|
+ tmp.save();
|
|
|
+ }
|
|
|
+ else if (mode == '_blank')
|
|
|
+ {
|
|
|
+ window.openFile = new OpenFile(function()
|
|
|
+ {
|
|
|
+ window.openFile = null;
|
|
|
+ });
|
|
|
+
|
|
|
+ // Do not use a filename to use undefined mode
|
|
|
+ window.openFile.setData(this.getFileData(true));
|
|
|
+ this.openLink(this.getUrl(window.location.pathname), null, true);
|
|
|
+ }
|
|
|
+ else if (prev != mode)
|
|
|
+ {
|
|
|
+ this.pickFolder(mode, mxUtils.bind(this, function(folderId)
|
|
|
+ {
|
|
|
+ this.createFile(name, this.getFileData(/(\.xml)$/i.test(name) ||
|
|
|
+ name.indexOf('.') < 0 || /(\.drawio)$/i.test(name),
|
|
|
+ /(\.svg)$/i.test(name), /(\.html)$/i.test(name)),
|
|
|
+ null, mode, done, this.mode == null, folderId);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ else if (mode != null)
|
|
|
+ {
|
|
|
+ this.save(name, done);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}), mxUtils.bind(this, function()
|
|
|
{
|
|
|
this.hideDialog();
|
|
|
}), mxResources.get('saveAs'), mxResources.get('download'), null, null, allowTab,
|
|
|
- null, true, rowLimit, null, null, null, this.editor.fileExtensions);
|
|
|
-
|
|
|
+ null, true, rowLimit, null, null, null, this.editor.fileExtensions, false);
|
|
|
this.showDialog(dlg.container, 400, (serviceCount > rowLimit) ? 390 : 270, true, true);
|
|
|
dlg.init();
|
|
|
}
|