From 89a5508e486945b88abd21426b9b57f421ce40e7 Mon Sep 17 00:00:00 2001 From: Gaudenz Alder Date: Sun, 18 Feb 2018 18:06:23 +0100 Subject: [PATCH] 8.2.3 release Former-commit-id: 21c57d879cda93621aa103fb93a7c22122d8b7d3 --- ChangeLog | 4 + VERSION | 2 +- src/main/webapp/cache.manifest | 2 +- src/main/webapp/connect/confluence/ac.js | 181 ++-- src/main/webapp/connect/confluence/admin.html | 6 +- src/main/webapp/connect/confluence/admin.js | 475 +++++++--- .../webapp/connect/confluence/connect.json | 31 + .../webapp/connect/confluence/viewer2.html | 28 +- src/main/webapp/js/app.min.js | 274 +++--- src/main/webapp/js/atlas.min.js | 862 +++++++++--------- src/main/webapp/js/diagramly/App.js | 10 +- src/main/webapp/js/diagramly/Dialogs.js | 8 +- src/main/webapp/js/embed-static.min.js | 2 +- src/main/webapp/js/mxgraph/Sidebar.js | 2 +- src/main/webapp/js/reader.min.js | 2 +- 15 files changed, 1069 insertions(+), 820 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85dd7493..20e458bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +18-FEB-2018: 8.2.3 + +- Adds optional parameter + 17-FEB-2018: 8.2.2 - Fixes inconsistency in child change codec diff --git a/VERSION b/VERSION index 6c961643..85ce942d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.2.2 \ No newline at end of file +8.2.3 \ No newline at end of file diff --git a/src/main/webapp/cache.manifest b/src/main/webapp/cache.manifest index fd0c5503..fcfdd2ef 100644 --- a/src/main/webapp/cache.manifest +++ b/src/main/webapp/cache.manifest @@ -1,7 +1,7 @@ CACHE MANIFEST # THIS FILE WAS GENERATED. DO NOT MODIFY! -# 02/17/2018 03:39 PM +# 02/18/2018 05:57 PM app.html index.html?offline=1 diff --git a/src/main/webapp/connect/confluence/ac.js b/src/main/webapp/connect/confluence/ac.js index e2dae1c0..9dac670a 100644 --- a/src/main/webapp/connect/confluence/ac.js +++ b/src/main/webapp/connect/confluence/ac.js @@ -1052,7 +1052,10 @@ AC.init = function(baseUrl, location, pageId, editor, diagramName, initialXml, d { var resp = null; var revision = '1'; - + var contentId = null; + var contentVer = null; + + //TODO Why this code (Is it expected to have incorrect responseText?) try { resp = JSON.parse(responseText); @@ -1067,7 +1070,26 @@ AC.init = function(baseUrl, location, pageId, editor, diagramName, initialXml, d //TODO Is prev comment still needed with REST API? if (resp != null && resp.results != null && resp.results[0]) { - revision = resp.results[0].version.number; + var attObj = resp.results[0]; + revision = attObj.version.number; + //Save/update the custom content + var spaceKey = AC.getSpaceKey(attObj._expandable.space); + var pageType = attObj.container.type; + + + AC.saveCustomContent(spaceKey, pageId, pageType, diagramName, revision, + drawMsg.macroData.contentId, + drawMsg.macroData.contentVer, + function(responseText) + { + var content = JSON.parse(responseText); + + contentId = content.id; + contentVer = content.version.number; + + AC.saveDiagram(pageId, diagramName + '.png', AC.b64toBlob(imageData, 'image/png'), + successPng, saveError, false, 'image/png', 'draw.io preview', false, draftPage); + }, saveError); } else { @@ -1085,8 +1107,13 @@ AC.init = function(baseUrl, location, pageId, editor, diagramName, initialXml, d { // do nothing } + + //TODO Save png here in case responseText is incorrect (But why it can be incorrect?) + AC.saveDiagram(pageId, diagramName + '.png', AC.b64toBlob(imageData, 'image/png'), + successPng, saveError, false, 'image/png', 'draw.io preview', false, draftPage); } + function successPng(pngResponseText) { try @@ -1096,6 +1123,8 @@ AC.init = function(baseUrl, location, pageId, editor, diagramName, initialXml, d diagramName: diagramName, revision: revision, pageId: newPage ? null : pageId, + contentId: contentId, + contentVer: contentVer, baseUrl: baseUrl, width: diaWidth, height: diaHeight, @@ -1125,12 +1154,6 @@ AC.init = function(baseUrl, location, pageId, editor, diagramName, initialXml, d titleKey: 'errorSavingFile', message: e.message, buttonKey: 'ok'}), '*'); } }; - - if (diagramName != null) - { - AC.saveDiagram(pageId, diagramName + '.png', AC.b64toBlob(imageData, 'image/png'), - successPng, saveError, false, 'image/png', 'draw.io preview', false, draftPage); - } }; if (diagramName != null) @@ -1139,7 +1162,7 @@ AC.init = function(baseUrl, location, pageId, editor, diagramName, initialXml, d show: true, messageKey: 'saving'}), '*'); AC.saveDiagram(pageId, diagramName, diagramXml, - successXml, saveError, false, 'text/plain', 'draw.io diagram', false, draftPage, true); + successXml, saveError, false, 'text/plain', 'draw.io diagram', false, draftPage); } } } @@ -1196,8 +1219,66 @@ AC.loadDiagram = function (pageId, diagramName, revision, success, error, owning }); }; +AC.saveCustomContent = function(spaceKey, pageId, pageType, diagramName, revision, contentId, contentVer, success, error) +{ + var customObj = { + "type": "ac:com.mxgraph.confluence.plugins.diagramly:drawio-diagram", + "space": { + "key": spaceKey + }, + "container": { + "type": pageType, + "id": pageId + }, + "title": diagramName, + "body": { + "storage": { + "value": encodeURIComponent(JSON.stringify({ + "pageId": pageId, + "diagramName": diagramName, + "version": revision + })), + "representation": "storage" + } + }, + "status": "current" + }; + + if (contentId) + { + customObj.version = { + "number": ++contentVer + }; + } + + AP.require(['request'], function(request) + { + request({ + type: contentId? 'PUT' : 'POST', + data: JSON.stringify(customObj), + url: "/rest/api/content/" + (contentId? contentId : ""), + contentType: "application/json", + success: success, + error: function(resp) { + //User can delete a custom content externally and we will get error 403 and message will contain the given id + //Then save a new one + var err = JSON.parse(resp.responseText); + + if (contentId && err.statusCode == 403 && err.message.indexOf(contentId) > 0) + { + AC.saveCustomContent(spaceKey, pageId, pageType, diagramName, revision, null, null, success, error); + } + else + { + error(resp); + } + } + }); + }); +}; + //TODO We can upload both the diagram and its png in one call if needed? -AC.saveDiagram = function(pageId, diagramName, xml, success, error, newSave, mime, comment, sendNotif, draftPage, addCustomContent) +AC.saveDiagram = function(pageId, diagramName, xml, success, error, newSave, mime, comment, sendNotif, draftPage) { loadSucess = function(resp) { @@ -1253,85 +1334,7 @@ AC.saveDiagram = function(pageId, diagramName, xml, success, error, newSave, mim data: reqData, url: "/rest/api/content/"+ pageId +"/child/attachment" + draft, contentType: "multipart/form-data", - success: function (resp) - { - /* var attObj = JSON.parse(resp); - if (addCustomContent && attObj.results && attObj.results[0]) - { - var spaceKey = AC.getSpaceKey(attObj.results[0]._expandable.space); - //First, check if we already have a custom content related to this attachment - //Names are not unique, so should check first to decide: add or update - request({ - type: 'GET', - url: "/rest/api/search?cql=" + encodeURIComponent('creator=currentUser() and type="ac:com.mxgraph.confluence.plugins.diagramly:drawio-diagram"' + - ' and title="'+diagramName+'" and space="' + spaceKey + '"') + '&limit=100', //I don't think there could be more than 100 diagrams with the same name! - contentType: "application/json", - success: function(resp) - { - resp = JSON.parse(resp); - var list = resp.list; - - if (list && list.length > 0) - { - //We need to fetch each one to find out the page id - for (var i = 0; i < list.length; i++) - { - - } - } - else //just add it - { - - } - }, - error: error //TODO is this correct?? - }); - - var customObj = { - "type": "ac:com.mxgraph.confluence.plugins.diagramly:drawio-diagram", - "space": { - "key": spaceKey - }, - "container": { - "type": "page", - "id": pageId - }, - "title": diagramName, - "body": { - "storage": { - "value": "", - "representation": "storage" - } - }, - "metadata": { - "properties": { - "diagram-data": { - "key": "diagram-data", - "value": { - "attId": attObj.id, - "pageId": pageId, - "diagramName": diagramName, - "version": attObj.results[0].version? attObj.results[0].version.number : "" - } - } - } - } - }; - - request({ - type: 'POST', - data: JSON.stringify(customObj), - url: "/rest/api/content/", - contentType: "application/json", - success: function(resp) - { - //TODO We can ignore the resp?? - }, - error: error //TODO is this correct?? - }); - }*/ - sessionCheck(resp); - }, + success: sessionCheck, error: error }); }); diff --git a/src/main/webapp/connect/confluence/admin.html b/src/main/webapp/connect/confluence/admin.html index 56b6a019..5ea1c14a 100644 --- a/src/main/webapp/connect/confluence/admin.html +++ b/src/main/webapp/connect/confluence/admin.html @@ -8,9 +8,13 @@ +

Refresh draw.io diagrams index

+

Click "Start Indexing" button to refresh draw.io diagrams index
Please note that the indexing procedure will take some time and the browser window must remain open until the indexing is completed.
+

+

Gliffy import


Click "Start Import" button to import all Gliffy diagrams to draw.io
Please note that the import procedure will take some time and the browser window must remain open until the import is completed.

-

+

\ No newline at end of file diff --git a/src/main/webapp/connect/confluence/admin.js b/src/main/webapp/connect/confluence/admin.js index ea3d0615..535b3516 100644 --- a/src/main/webapp/connect/confluence/admin.js +++ b/src/main/webapp/connect/confluence/admin.js @@ -1,13 +1,20 @@ -var GliffyMassImporter = function(logDiv) +var MassDiagramsProcessor = function(macroName, readableName, attParams, processAttFn, logDiv) { logDiv.html("
"); - var link = document.createElement('a'); - link.href = location.href; - link.href = link.href; //to have 'host' populated under IE - var hostUrl = link.protocol + '//' + link.hostname; + //RegExp that will be used + var findMacrosRegEx = new RegExp('\\)', 'g'); + var findOneMacroRegEx = new RegExp('\\)'); + var findMacroIdRegEx = new RegExp('ac\\:macro\\-id\\=\\"([^\\"]+)'); - function searchContentForMacro(macroName, onSuccess, onError, nextUrl) + var findAttParamsRegExs = []; + + for (var i = 0; i < attParams.length; i++) + { + findAttParamsRegExs.push(new RegExp('\\([^\\<]+)')); + } + + function searchContentForMacro(onSuccess, onError, nextUrl) { AP.require(['request'], function(request) { @@ -41,10 +48,180 @@ var GliffyMassImporter = function(logDiv) }); }); }; + + var pagesCount = 0; + var processedPages = 0; - - function importGliffyAtt(pageId, attName, attId, macroId, success, error) + function pageProcessed() { + processedPages++; + + if (processedPages == pagesCount) + { + logDiv.append($('
All ' + readableName + ' diagrams processed. Process finished!
')); + } + }; + + function loadPageSuccess(page) + { + page = JSON.parse(page); + + logDiv.append($('
Started processing page "'+ AC.htmlEntities(page.title) +'"...
')); + + var originalBody = page.body.storage.value; + + var pageXml = originalBody; + + var foundMacros = pageXml.match(findMacrosRegEx); + + var macrosParsed = 0; + var drawIoMacros = {}; + var foundMarcosIds = []; + var spaceKey = AC.getSpaceKey(page._expandable.space); + + if (foundMacros && foundMacros.length > 0) + { + for (var i = 0; i < foundMacros.length; i++) + { + var macroId = foundMacros[i].match(findMacroIdRegEx)[1]; + + foundMarcosIds.push(macroId); + + var params = []; + + for (var j = 0; j < findAttParamsRegExs.length; j++) + { + var paramFound = foundMacros[i].match(findAttParamsRegExs[j]); + + params.push(paramFound? AC.fromHtmlEntities(paramFound[1]) : null); + } + + //get the attachment content + processAttFn(page.id, page.type, spaceKey, params, macroId, function(attInfo) + { + //Replace found macro with a draw.io one and use the same preview image + + //generate draw.io macro HTML + var drawIoMacro = '' + baseUrl + + '' + AC.htmlEntities(attInfo.name) + + '' + attInfo.width + + '' + (attInfo.zoom ? attInfo.zoom : '1') + + '' + page.id + + '' + (attInfo.lbox ? attInfo.lbox : '1') + + '' + attInfo.height + + '' + attInfo.revision + + (attInfo.previewPng? ('' + AC.htmlEntities(attInfo.previewPng)) : "") + + '' + attInfo.contentId + + '' + attInfo.contentVer + + ''; + + drawIoMacros[attInfo.macroId] = drawIoMacro; + macrosParsed++; + + if (foundMacros.length == macrosParsed) + { + for (var j = 0; j < macrosParsed; j++) + { + var id = foundMarcosIds[j]; + originalBody = originalBody.replace(findOneMacroRegEx, drawIoMacros[id]); + } + + //update page contents + AP.require(['request'], function(request) + { + request({ + type: 'PUT', + data: JSON.stringify({ + "body": { + "storage": { + "value": originalBody, + "representation": "storage", + "embeddedContent": [] + } + }, + "version": { + "number": page.version.number + 1 + }, + "type": page.type, + "title": page.title, + "status": "current" + }), + url: "/rest/api/content/"+ page.id, + contentType: 'application/json;charset=UTF-8', + success: function(resp) { + logDiv.append($('
' + readableName + ' diagrams in page "'+ AC.htmlEntities(page.title) +'" processed successfully.
')); + pageProcessed(); + }, + error: function(resp) { + logDiv.append($('
Updating page "'+ AC.htmlEntities(page.title) +'" failed.
')); + console.error(resp); + pageProcessed(); + } + }); + }); + } + }, + function() + { + pageProcessed(); + }, + function() + { + pageProcessed(); + }); + }; + } + else + { + logDiv.append($('
No ' + readableName + ' diagrams found in page "'+ AC.htmlEntities(page.title) +'".
')); + pageProcessed(); + } + }; + + function loadPageError(resp) + { + logDiv.append($('
Fetching the page failed.
')); + console.log(resp); + pageProcessed(); + }; + + //Code starts execution here + searchContentForMacro(function success(resp) + { + pagesCount += resp.results.length; + + for(var i = 0; i < resp.results.length; i++) + { + var page = resp.results[i]; + + logDiv.append($('
Page "'+ AC.htmlEntities(page.title) +'" found. Fetching...
')); + + getPageContent(page.id, loadPageSuccess, loadPageError); + } + + if (resp.results.length == 0) + { + logDiv.append($('
No ' + readableName + ' diagrams found. Process finished.
')); + } + }, function error(err) + { + logDiv.append($('
Searching for ' + readableName + ' diagrams failed. Please try again later.
')); + console.log(err); + }); +}; + +var GliffyMassImporter = function(logDiv) +{ + var link = document.createElement('a'); + link.href = location.href; + link.href = link.href; //to have 'host' populated under IE + var hostUrl = link.protocol + '//' + link.hostname; + + function importGliffyAtt(pageId, pageType, spaceKey, params, macroId, success, error, skip) + { + var attName = params[0]; + logDiv.append($('
Gliffy diagram "'+ AC.htmlEntities(attName) +'" found. Importing...
')); //Get the latest version (no version parameter) @@ -76,17 +253,38 @@ var GliffyMassImporter = function(logDiv) AC.saveDiagram(pageId, attName + ".drawio.xml", xml, function(resp) { - logDiv.append($('
Gliffy diagram "'+ AC.htmlEntities(attName) +'" imported successfully.
')); - resp = JSON.parse(resp); - //TODO get the width & height - success({ + var attInfo = { name: attName + ".drawio.xml", revision: resp.results[0].version.number, macroId: macroId, - previewPng: attName + ".png" - }); + previewPng: attName + ".png", + //TODO get the actual width & height + //TODO It works with this hardcoded number, but it is better to get the actual value + width: 500, + height: 500 + }; + + //Add custom content + AC.saveCustomContent(spaceKey, pageId, pageType, attName + ".drawio.xml", attInfo.revision, null, null, + function(responseText) + { + logDiv.append($('
Gliffy diagram "'+ AC.htmlEntities(attName) +'" imported successfully.
')); + + var content = JSON.parse(responseText); + + attInfo.contentId = content.id; + attInfo.contentVer = content.version.number; + + success(attInfo); + }, function(err) + { + logDiv.append($('
Saving imported Gliffy diagram "'+ AC.htmlEntities(attName) +'" failed.
')); + console.log(err); + error(); + }); + }, function(err) { logDiv.append($('
Saving imported Gliffy diagram "'+ AC.htmlEntities(attName) +'" failed.
')); @@ -115,149 +313,115 @@ var GliffyMassImporter = function(logDiv) }); }; - - var pagesCount = 0; - var processedPages = 0; - - function pageProcessed() - { - processedPages++; - - if (processedPages == pagesCount) - { - logDiv.append($('
All Gliffy diagrams processed. Import finished!
')); - } - }; - - function loadPageSuccess(page) - { - page = JSON.parse(page); - - logDiv.append($('
Started processing page "'+ AC.htmlEntities(page.title) +'"...
')); - - var originalBody = page.body.storage.value; - - var pageXml = originalBody; - - var gliffyMacros = pageXml.match(/\)/g); - - var macrosParsed = 0; - var drawIoMacros = {}; - var gliffyMarcosIds = []; - - for (var i = 0; i < gliffyMacros.length; i++) - { - var macroId = gliffyMacros[i].match(/ac\:macro\-id\=\"([^\"]+)/)[1]; - - gliffyMarcosIds.push(macroId); - var name = gliffyMacros[i].match(/\([^\<]+)/)[1]; - var attId = gliffyMacros[i].match(/\([^\<]+)/)[1]; + MassDiagramsProcessor('gliffy', 'Gliffy', ['name'], importGliffyAtt, logDiv); +}; - //get the attachment content - importGliffyAtt(page.id, AC.fromHtmlEntities(name), attId, macroId, function(attInfo) - { - //Replace gliffy macro with a draw.io one and use the gliffy preview image - //generate draw.io macro HTML - var drawIoMacro = '' + baseUrl - + '' + AC.htmlEntities(attInfo.name) - + '' + 500 //TODO It works with this hardcoded number, but it is better to get the actual value - + '1' + page.id - + '1' + 500 //TODO It works with this hardcoded number, but it is better to get the actual value - + '' + attInfo.revision - + '' + AC.htmlEntities(attInfo.previewPng) - + ''; - - drawIoMacros[attInfo.macroId] = drawIoMacro; - macrosParsed++; - - if (gliffyMacros.length == macrosParsed) - { - for (var j = 0; j < macrosParsed; j++) - { - var id = gliffyMarcosIds[j]; - originalBody = originalBody.replace(/\)/, drawIoMacros[id]); - } - - //update page contents - AP.require(['request'], function(request) - { - request({ - type: 'PUT', - data: JSON.stringify({ - "body": { - "storage": { - "value": originalBody, - "representation": "storage", - "embeddedContent": [] - } - }, - "version": { - "number": page.version.number + 1 - }, - "type": "page", - "title": page.title, - "status": "current" - }), - url: "/rest/api/content/"+ page.id, - contentType: 'application/json;charset=UTF-8', - success: function(resp) { - logDiv.append($('
Gliffy diagrams in page "'+ AC.htmlEntities(page.title) +'" imported successfully.
')); - pageProcessed(); - }, - error: function(resp) { - logDiv.append($('
Updating page "'+ AC.htmlEntities(page.title) +'" failed.
')); - console.error(resp); - pageProcessed(); - } - }); - }); - } - }, - function() - { - pageProcessed(); - }); +var DrawIoDiagramsIndexer = function(logDiv) +{ + function fixDrawIoCustomContent(pageId, pageType, spaceKey, params, macroId, success, error, skip) + { + //['diagramName', 'contentId', 'contentVer', 'revision', 'width', 'height', 'tempPreview', 'zoom', 'lbox'] + var attName = params[0]; + var contentId = params[1]; + var contentVer = params[2]; + var revision = params[3]; + var width = params[4]; + var height = params[5]; + var tempPreview = params[6]; + var zoom = params[7]; + var lbox = params[8]; + + logDiv.append($('
Diagram "'+ AC.htmlEntities(attName) +'" found. Indexing...
')); + + var attInfo = { + macroId: macroId, + name: attName, + contentId: contentId, + contentVer: contentVer, + revision: revision, + width: width, + height: height, + previewPng: tempPreview, + zoom: zoom, + lbox: lbox }; - if (gliffyMacros.length == 0) + + function addNewCustomContent() { - logDiv.append($('
No Gliffy diagrams found in page "'+ AC.htmlEntities(page.title) +'".
')); - pageProcessed(); + AC.saveCustomContent(spaceKey, pageId, pageType, attName, revision, null, null, + function(responseText) + { + logDiv.append($('
Diagram "'+ AC.htmlEntities(attName) +'" indexed successfully.
')); + + var content = JSON.parse(responseText); + + attInfo.contentId = content.id; + attInfo.contentVer = content.version.number; + + success(attInfo); + }, function(err) + { + logDiv.append($('
Indexing diagram "'+ AC.htmlEntities(attName) +'" failed.
')); + console.log(err); + error(); + }); + }; + + //If contentId exists, make sure it exists and is valid + if (contentId) + { + AP.require(['request'], function(request) + { + request({ + type: 'GET', + url: '/rest/api/content/' + contentId + '/?expand=body.storage', + contentType: 'application/json;charset=UTF-8', + success: function (resp) + { + resp = JSON.parse(resp); + + var info = JSON.parse(decodeURIComponent(resp.body.storage.value)); + + if (info.pageId == pageId && info.diagramName == attName && info.version == revision) + { + //nothing needs to be done, just skip + logDiv.append($('
Diagram "'+ AC.htmlEntities(attName) +'" is up to date.
')); + skip(); + } + else + { + //We add a new one and leave the current one intact since this is most probably a copied diagram + addNewCustomContent(); + } + }, + error: function (err) + { + //If not found, add it + if (err.status == 404) + { + addNewCustomContent(); + } + else + { + logDiv.append($('
Indexing diagram "'+ AC.htmlEntities(attName) +'" failed.
')); + console.log(err); + error(); + } + } + }); + }); + } + else //If no contentId exists, just add one + { + addNewCustomContent(); } - }; - - function loadPageError(resp) - { - logDiv.append($('
Fetching the page failed.
')); - console.log(resp); - pageProcessed(); }; - //Code starts execution here - searchContentForMacro('gliffy', function success(resp) - { - pagesCount += resp.results.length; - - for(var i = 0; i < resp.results.length; i++) - { - var page = resp.results[i]; - - logDiv.append($('
Page "'+ AC.htmlEntities(page.title) +'" found. Fetching...
')); - - getPageContent(page.id, loadPageSuccess, loadPageError); - } - - if (resp.results.length == 0) - { - logDiv.append($('
No Gliffy diagrams found. Import finished.
')); - } - }, function error(err) - { - logDiv.append($('
Searching for Gliffy diagrams failed. Please try again later.
')); - console.log(err); - }); + MassDiagramsProcessor('drawio', 'Draw.io', + ['diagramName', 'contentId', 'contentVer', 'revision', 'width', 'height', 'tempPreview', 'zoom', 'lbox'], + fixDrawIoCustomContent, logDiv); }; var baseUrl = AC.getUrlParam('xdm_e', true) + AC.getUrlParam('cp', true); @@ -267,13 +431,24 @@ var script = document.createElement('script'); script.onload = function() { //JQuery is loaded in this page, so we can use it + var logDiv = $('#operationLog'); + var importBtn = $('#importBtn'); importBtn.attr("disabled", null); importBtn.click(function() { - GliffyMassImporter($('#importLog')); + GliffyMassImporter(logDiv); + }); + + var indexBtn = $('#indexBtn'); + + indexBtn.attr("disabled", null); + + indexBtn.click(function() + { + DrawIoDiagramsIndexer(logDiv); }); }; diff --git a/src/main/webapp/connect/confluence/connect.json b/src/main/webapp/connect/confluence/connect.json index 25f6d412..e19233f8 100644 --- a/src/main/webapp/connect/confluence/connect.json +++ b/src/main/webapp/connect/confluence/connect.json @@ -35,6 +35,37 @@ "name": { "value": "Lightbox" } + }, + { + "key": "customContentViewer", + "url": "/connect/confluence/viewer2.html?custom=1&contentId={content.id}", + "name": { + "value": "Draw.io Viewer" + } + } + ], + "customContent": [{ + "key": "drawio-diagram", + "name": { + "value": "Draw.io Diagrams" + }, + "uiSupport": { + "contentViewComponent": { + "moduleKey": "customContentViewer" + }, + "icons": { + "item": { + "url": "/images/drawlogo48.png" + } + } + }, + "apiSupport": { + "supportedContainerTypes": ["page", "comment", "space", "blogpost"], + "supportedChildTypes": ["attachment"], + "indexing": { + "enabled": true + } + } } ], "dynamicContentMacros": diff --git a/src/main/webapp/connect/confluence/viewer2.html b/src/main/webapp/connect/confluence/viewer2.html index de80f88e..441ee801 100644 --- a/src/main/webapp/connect/confluence/viewer2.html +++ b/src/main/webapp/connect/confluence/viewer2.html @@ -43,6 +43,7 @@ SHAPES_PATH = '/shapes'; // Overrides browser language with Confluence user language var lang = getUrlParam('loc'); var lightbox = getUrlParam('lightbox') == '1'; +var customContent = getUrlParam('custom') == '1'; if (lightbox) { @@ -339,7 +340,7 @@ if (lang != null) function() { //nothing! - }, false, 'text/plain', 'Diagram imported by Draw.io', false, false, true); + }, false, 'text/plain', 'Diagram imported by Draw.io', false, false); //TODO save preview png @@ -383,7 +384,30 @@ if (lang != null) } }; - if (lightbox) + if (customContent) + { + var contentId = getUrlParam('contentId'); + + request({ + type: 'GET', + url: '/rest/api/content/' + contentId + '/?expand=body.storage', + contentType: 'application/json;charset=UTF-8', + success: function (resp) + { + resp = JSON.parse(resp); + + var info = JSON.parse(decodeURIComponent(resp.body.storage.value)); + + showDiagram(info.pageId, info.pageId, info.diagramName, info.version, null, links); + }, + error: function (resp) + { + showError('Diagram not found!'); + } + }); + + } + else if (lightbox) { // Gets the paramters from the customData object in lightbox mode // LATER: Add XML to custom data (does not seem to work) diff --git a/src/main/webapp/js/app.min.js b/src/main/webapp/js/app.min.js index 1ab5932c..67a1b041 100644 --- a/src/main/webapp/js/app.min.js +++ b/src/main/webapp/js/app.min.js @@ -2230,7 +2230,7 @@ a.vertex=!0;this.graph.setAttributeForCell(a,"placeholders","1");return this.cre 20,120,"","Curly Bracket"),this.createVertexTemplateEntry("line;strokeWidth=2;html=1;",160,10,"","Horizontal Line"),this.createVertexTemplateEntry("line;strokeWidth=2;direction=south;html=1;",10,160,"","Vertical Line"),this.createVertexTemplateEntry("line;strokeWidth=4;html=1;perimeter=backbonePerimeter;points=[];outlineConnect=0;",160,10,"","Horizontal Backbone",!1,null,"backbone bus network"),this.createVertexTemplateEntry("line;strokeWidth=4;direction=south;html=1;perimeter=backbonePerimeter;points=[];outlineConnect=0;", 10,160,"","Vertical Backbone",!1,null,"backbone bus network"),this.createVertexTemplateEntry("shape=crossbar;whiteSpace=wrap;html=1;rounded=1;",120,20,"","Crossbar",!1,null,"crossbar distance measure dimension unit"),this.createVertexTemplateEntry("shape=image;html=1;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;imageAspect=1;aspect=fixed;image="+this.gearImage,52,61,"","Image (Fixed Aspect)",!1,null,"fixed image icon symbol"),this.createVertexTemplateEntry("shape=image;html=1;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;imageAspect=0;image="+ this.gearImage,50,60,"","Image (Variable Aspect)",!1,null,"strechted image icon symbol"),this.createVertexTemplateEntry("icon;html=1;image="+this.gearImage,60,60,"Icon","Icon",!1,null,"icon image symbol"),this.createVertexTemplateEntry("label;whiteSpace=wrap;html=1;image="+this.gearImage,140,60,"Label","Label 1",null,null,"label image icon symbol"),this.createVertexTemplateEntry("label;whiteSpace=wrap;html=1;align=center;verticalAlign=bottom;spacingLeft=0;spacingBottom=4;imageAlign=center;imageVerticalAlign=top;image="+ -this.gearImage,120,80,"Label","Label 2",null,null,"label image icon symbol"),this.addEntry("shape group container",function(){var a=new mxCell("",new mxGeometry(0,0,200,100),"html=1;whiteSpace=wrap;container=1;recursiveResize=0;collapsible=0;");a.vertex=!0;var b=new mxCell("",new mxGeometry(20,20,20,30),"triangle;html=1;whiteSpace=wrap;");b.vertex=!0;a.insert(b);return sb.createVertexTemplateFromCells([a],a.geometry.width,a.geometry.height,"Shape Group")}),this.createVertexTemplateEntry("shape=partialRectangle;whiteSpace=wrap;html=1;left=0;right=0;fillColor=none;", +this.gearImage,120,80,"Label","Label 2",null,null,"label image icon symbol"),this.addEntry("shape group container",function(){var a=new mxCell("Label",new mxGeometry(0,0,200,100),"html=1;whiteSpace=wrap;container=1;recursiveResize=0;collapsible=0;");a.vertex=!0;var b=new mxCell("",new mxGeometry(20,20,20,30),"triangle;html=1;whiteSpace=wrap;");b.vertex=!0;a.insert(b);return sb.createVertexTemplateFromCells([a],a.geometry.width,a.geometry.height,"Shape Group")}),this.createVertexTemplateEntry("shape=partialRectangle;whiteSpace=wrap;html=1;left=0;right=0;fillColor=none;", 120,60,"","Partial Rectangle"),this.createVertexTemplateEntry("shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;top=0;bottom=1;fillColor=none;routingCenterX=-0.5;",120,60,"","Partial Rectangle"),this.createEdgeTemplateEntry("edgeStyle=segmentEdgeStyle;endArrow=classic;html=1;",50,50,"","Manual Line",null,"line lines connector connectors connection connections arrow arrows manual"),this.createEdgeTemplateEntry("shape=filledEdge;rounded=0;fixDash=1;endArrow=none;strokeWidth=10;fillColor=#ffffff;edgeStyle=orthogonalEdgeStyle;", 60,40,"","Filled Edge"),this.createEdgeTemplateEntry("edgeStyle=elbowEdgeStyle;elbow=horizontal;endArrow=classic;html=1;",50,50,"","Horizontal Elbow",null,"line lines connector connectors connection connections arrow arrows elbow horizontal"),this.createEdgeTemplateEntry("edgeStyle=elbowEdgeStyle;elbow=vertical;endArrow=classic;html=1;",50,50,"","Vertical Elbow",null,"line lines connector connectors connection connections arrow arrows elbow vertical")];this.addPaletteFunctions("misc",mxResources.get("misc"), null!=a?a:!0,c)};Sidebar.prototype.addAdvancedPalette=function(a){this.addPaletteFunctions("advanced",mxResources.get("advanced"),null!=a?a:!1,this.createAdvancedShapes())}; @@ -6375,9 +6375,9 @@ StorageFile.prototype.saveFile=function(a,b,d,c){if(this.isEditable()){var e=mxU [a]),e,c):e()}))}else null!=d&&d()};StorageFile.prototype.rename=function(a,b,d){var c=this.getTitle();c!=a?this.ui.getLocalData(a,mxUtils.bind(this,function(e){var f=mxUtils.bind(this,function(){this.title=a;this.hasSameExtension(c,a)||this.setData(this.ui.getFileData());this.saveFile(a,!1,mxUtils.bind(this,function(){this.ui.removeLocalData(c,b)}),d)});null!=e?this.ui.confirm(mxResources.get("replaceIt",[a]),f,d):f()})):b()}; StorageFile.prototype.open=function(){DrawioFile.prototype.open.apply(this,arguments);this.saveFile(this.getTitle())};StorageFile.prototype.destroy=function(){DrawioFile.prototype.destroy.apply(this,arguments);null!=this.storageListener&&(mxEvent.removeListener(window,"storage",this.storageListener),this.storageListener=null)};StorageLibrary=function(a,b,d){StorageFile.call(this,a,b,d)};mxUtils.extend(StorageLibrary,StorageFile);StorageLibrary.prototype.isAutosave=function(){return!0};StorageLibrary.prototype.saveAs=function(a,b,d){this.saveFile(a,!1,b,d)};StorageLibrary.prototype.getHash=function(){return"L"+encodeURIComponent(this.title)};StorageLibrary.prototype.getTitle=function(){return".scratchpad"==this.title?mxResources.get("scratchpad"):this.title}; StorageLibrary.prototype.isRenamable=function(a,b,d){return".scratchpad"!=this.title};StorageLibrary.prototype.open=function(){};UrlLibrary=function(a,b,d){StorageFile.call(this,a,b,d);a=d;b=a.lastIndexOf("/");0<=b&&(a=a.substring(b+1));this.fname=a};mxUtils.extend(UrlLibrary,StorageFile);UrlLibrary.prototype.getHash=function(){return"U"+encodeURIComponent(this.title)};UrlLibrary.prototype.getTitle=function(){return this.fname};UrlLibrary.prototype.isAutosave=function(){return!1};UrlLibrary.prototype.isEditable=function(a,b,d){return!1};UrlLibrary.prototype.saveAs=function(a,b,d){};UrlLibrary.prototype.open=function(){};var StorageDialog=function(a,b,d){function c(c,e,f,t,u,q){function w(){mxEvent.addListener(p,"click",null!=q?q:function(){f!=App.MODE_GOOGLE||a.isDriveDomain()?f==App.MODE_GOOGLE&&a.spinner.spin(document.body,mxResources.get("authorizing"))?a.drive.checkToken(mxUtils.bind(this,function(){a.spinner.stop();a.setMode(f,g.checked);b()})):(a.setMode(f,g.checked),b()):window.location.hostname=DriveClient.prototype.newAppHostname})}var p=document.createElement("a");p.style.overflow="hidden";p.style.display= -mxClient.IS_QUIRKS?"inline":"inline-block";p.className="geBaseButton";p.style.boxSizing="border-box";p.style.fontSize="11px";p.style.position="relative";p.style.margin="4px";p.style.padding="8px 10px 12px 10px";p.style.width="88px";p.style.height="100px";p.style.whiteSpace="nowrap";p.setAttribute("title",e);mxClient.IS_QUIRKS&&(p.style.cssFloat="left",p.style.zoom="1");var h=document.createElement("div");h.style.textOverflow="ellipsis";h.style.overflow="hidden";if(null!=c){var y=document.createElement("img"); -y.setAttribute("src",c);y.setAttribute("border","0");y.setAttribute("align","absmiddle");y.style.width="60px";y.style.height="60px";y.style.paddingBottom="6px";p.appendChild(y)}else h.style.paddingTop="5px",h.style.whiteSpace="normal",mxClient.IS_IOS?(p.style.padding="0px 10px 20px 10px",p.style.top="6px"):mxClient.IS_FF&&(h.style.paddingTop="0px",h.style.marginTop="-2px");p.appendChild(h);mxUtils.write(h,e);if(null!=u)for(c=0;c=d&&(mxUtils.br(m),k=0)}d=null!=d?d:2;var e=document.createElement("div");e.style.textAlign="center";e.style.whiteSpace="nowrap";e.style.paddingTop="0px";e.style.paddingBottom="20px";var f=a.addLanguageMenu(e,!0);null!=f&&(f.style.bottom=parseInt("28px")-2+"px");if(!a.isOffline()&&1b.length){var k=mxUtils.button("",function(){tr " max)");k.style.verticalAlign="bottom";k.style.paddingTop="4px";k.style.minWidth="46px";k.className="geBtn";h.appendChild(k)}7168>b.length&&(k=mxUtils.button("",function(){try{var b="https://twitter.com/intent/tweet?text="+encodeURIComponent("Check out the diagram I made using @drawio")+"&url="+encodeURIComponent(l.value);a.openLink(b)}catch(p){a.handleError({message:p.message||mxResources.get("drawingTooLarge")})}}),g=document.createElement("img"),g.setAttribute("src",Editor.tweetImage),g.setAttribute("width", "18"),g.setAttribute("height","18"),g.setAttribute("border","0"),g.style.marginBottom="5px",k.appendChild(g),k.setAttribute("title",mxResources.get("twitter")+" ("+a.formatFileSize(7168)+" max)"),k.style.verticalAlign="bottom",k.style.paddingTop="4px",k.style.minWidth="46px",k.className="geBtn",h.appendChild(k))}g=mxUtils.button(mxResources.get("close"),function(){a.hideDialog()});h.appendChild(g);k=mxUtils.button(mxResources.get("copy"),function(){l.focus();mxClient.IS_GC||mxClient.IS_FF||5<=document.documentMode|| mxClient.IS_QUIRKS?l.select():document.execCommand("selectAll",!1,null);document.execCommand("copy");a.alert(mxResources.get("copiedToClipboard"))});5E5>b.length?mxClient.IS_SF||null!=document.documentMode?g.className="geBtn gePrimaryBtn":(h.appendChild(k),k.className="geBtn gePrimaryBtn",g.className="geBtn"):(h.appendChild(m),g.className="geBtn",m.className="geBtn gePrimaryBtn");c.appendChild(h);this.container=c},GoogleSitesDialog=function(a,b){function d(){var a=null!=C.getTitle()?C.getTitle(): -this.defaultFilename;if(x.checked&&""!=p.value){var b="https://www.draw.io/gadget.xml?type=4&diagram="+encodeURIComponent(mxUtils.htmlEntities(p.value));null!=a&&(b+="&title="+encodeURIComponent(a));0=a.getStatus()&&(B(t,a.getText(),b),n&&v())}))});mxEvent.addListener(t,"dblclick",function(a){n=!0})}else t.innerHTML='
'+mxResources.get(c)+"
",g&&B(t),mxEvent.addListener(t,"click",function(a){B(t)}),mxEvent.addListener(t,"dblclick",function(a){v()}); +f.appendChild(m);this.container=f},NewDialog=function(a,b,d,c,e,f,h,l,m,g,k,n,p,u){function q(){for(var a=!0;H=a.getStatus()&&(A(t,a.getText(),b),n&&v())}))});mxEvent.addListener(t,"dblclick",function(a){n=!0})}else t.innerHTML='
'+mxResources.get(c)+"
",g&&A(t),mxEvent.addListener(t,"click",function(a){A(t)}),mxEvent.addListener(t,"dblclick",function(a){v()}); J.appendChild(t)}function t(){mxEvent.addListener(J,"scroll",function(a){J.scrollTop+J.clientHeight>=J.scrollHeight&&(q(),mxEvent.consume(a))});var a=null,b;for(b in N){var c=document.createElement("div"),d=mxResources.get(b),k=N[b];null==d&&(d=b.substring(0,1).toUpperCase()+b.substring(1));18b.lastIndexOf(".")&&0>k){var c=null!=c?c:C.value,t="";c==App.MODE_GOOGLE?t=a.drive.extension:c== -App.MODE_GITHUB?t=a.gitHub.extension:c==App.MODE_TRELLO?t=a.trello.extension:c==App.MODE_DROPBOX?t=a.dropbox.extension:c==App.MODE_ONEDRIVE?t=a.oneDrive.extension:c==App.MODE_DEVICE&&(t=".xml");0<=k&&(d=d.substring(0,k));w.value=d+t}}B(g)})}var t=document.createElement("a");t.style.overflow="hidden";var f=document.createElement("img");f.src=c;f.setAttribute("border","0");f.setAttribute("align","absmiddle");f.style.width="60px";f.style.height="60px";f.style.paddingBottom="6px";t.style.display=mxClient.IS_QUIRKS? +App.MODE_GITHUB?t=a.gitHub.extension:c==App.MODE_TRELLO?t=a.trello.extension:c==App.MODE_DROPBOX?t=a.dropbox.extension:c==App.MODE_ONEDRIVE?t=a.oneDrive.extension:c==App.MODE_DEVICE&&(t=".xml");0<=k&&(d=d.substring(0,k));w.value=d+t}}A(g)})}var t=document.createElement("a");t.style.overflow="hidden";var f=document.createElement("img");f.src=c;f.setAttribute("border","0");f.setAttribute("align","absmiddle");f.style.width="60px";f.style.height="60px";f.style.paddingBottom="6px";t.style.display=mxClient.IS_QUIRKS? "inline":"inline-block";t.className="geBaseButton";t.style.position="relative";t.style.margin="4px";t.style.padding="8px 8px 10px 8px";t.style.whiteSpace="nowrap";t.appendChild(f);mxClient.IS_QUIRKS&&(t.style.cssFloat="left",t.style.zoom="1");t.style.color="gray";t.style.fontSize="11px";var p=document.createElement("div");t.appendChild(p);mxUtils.write(p,d);if(null!=k&&null==a[k]){f.style.visibility="hidden";mxUtils.setOpacity(p,10);var u=new Spinner({lines:12,length:12,width:5,radius:10,rotate:0, -color:"#000",speed:1.5,trail:60,shadow:!1,hwaccel:!1,top:"40%",zIndex:2E9});u.spin(t);var l=window.setTimeout(function(){null==a[k]&&(u.stop(),t.style.display="none")},3E4);a.addListener("clientLoaded",mxUtils.bind(this,function(){null!=a[k]&&(window.clearTimeout(l),mxUtils.setOpacity(p,100),f.style.visibility="",u.stop(),e())}))}else e();x.appendChild(t);++z==n&&(mxUtils.br(x),z=0)}function B(b){var c=w.value;if(null==b||null!=c&&0JGraph Ltd.
All Rights Reserved.';b.appendChild(d);mxEvent.addListener(b,"click",function(b){"A"!=mxEvent.getSource(b).nodeName&&a.hideDialog()});this.container= b},FeedbackDialog=function(a){var b=document.createElement("div"),d=document.createElement("div");mxUtils.write(d,mxResources.get("sendYourFeedbackToDrawIo"));d.style.fontSize="18px";d.style.marginBottom="18px";b.appendChild(d);d=document.createElement("div");mxUtils.write(d,mxResources.get("yourEmailAddress")+" ("+mxResources.get("required")+")");b.appendChild(d);var c=document.createElement("input");c.setAttribute("type","text");c.style.marginTop="6px";c.style.width="600px";var e=mxUtils.button(mxResources.get("sendMessage"), @@ -6525,36 +6525,36 @@ var l=document.createElement("span");mxUtils.write(l," "+mxResources.get("includ b.appendChild(m);d=document.createElement("div");d.style.marginTop="26px";d.style.textAlign="right";l=mxUtils.button(mxResources.get("cancel"),function(){a.hideDialog()});l.className="geBtn";a.editor.cancelFirst?(d.appendChild(l),d.appendChild(e)):(d.appendChild(e),d.appendChild(l));b.appendChild(d);this.container=b};FeedbackDialog.maxAttachmentSize=1E6; var RevisionDialog=function(a,b,d){var c=document.createElement("div"),e=document.createElement("h3");e.style.marginTop="0px";mxUtils.write(e,mxResources.get("revisionHistory"));c.appendChild(e);var f=document.createElement("div");f.style.position="absolute";f.style.overflow="auto";f.style.width="170px";f.style.height="378px";c.appendChild(f);var h=document.createElement("div");h.style.position="absolute";h.style.border="1px solid lightGray";h.style.left="199px";h.style.width="470px";h.style.height= "376px";h.style.overflow="hidden";mxEvent.disableContextMenu(h);c.appendChild(h);var l=new Graph(h);l.setEnabled(!1);l.setPanning(!0);l.panningHandler.ignoreCell=!0;l.panningHandler.useLeftButtonForPanning=!0;l.minFitScale=null;l.maxFitScale=null;l.centerZoom=!0;var m=0,g=null,k=0,n=l.getGlobalVariable;l.getGlobalVariable=function(a){return"page"==a&&null!=g&&null!=g[k]?g[k].getAttribute("name"):"pagenumber"==a?k+1:n.apply(this,arguments)};l.getLinkForCell=function(){return null};Editor.MathJaxRender&& -l.addListener(mxEvent.SIZE,mxUtils.bind(this,function(b,c){a.editor.graph.mathEnabled&&Editor.MathJaxRender(l.container)}));var p=new Spinner({lines:11,length:15,width:6,radius:10,corners:1,rotate:0,direction:1,color:"#000",speed:1.4,trail:60,shadow:!1,hwaccel:!1,className:"spinner",zIndex:2E9,top:"50%",left:"50%"}),u=a.getCurrentFile(),q=null,v=null,B=null,y=null,t=mxUtils.button("",function(){null!=B&&l.zoomIn()});t.className="geSprite geSprite-zoomin";t.setAttribute("title",mxResources.get("zoomIn")); -t.style.outline="none";t.style.border="none";t.style.margin="2px";t.setAttribute("disabled","disabled");mxUtils.setOpacity(t,20);var w=mxUtils.button("",function(){null!=B&&l.zoomOut()});w.className="geSprite geSprite-zoomout";w.setAttribute("title",mxResources.get("zoomOut"));w.style.outline="none";w.style.border="none";w.style.margin="2px";w.setAttribute("disabled","disabled");mxUtils.setOpacity(w,20);var x=mxUtils.button("",function(){null!=B&&(l.maxFitScale=8,l.fit(8),l.center())});x.className= -"geSprite geSprite-fit";x.setAttribute("title",mxResources.get("fit"));x.style.outline="none";x.style.border="none";x.style.margin="2px";x.setAttribute("disabled","disabled");mxUtils.setOpacity(x,20);var z=mxUtils.button("",function(){null!=B&&(l.zoomActual(),l.center())});z.className="geSprite geSprite-actualsize";z.setAttribute("title",mxResources.get("actualSize"));z.style.outline="none";z.style.border="none";z.style.margin="2px";z.setAttribute("disabled","disabled");mxUtils.setOpacity(z,20);var C= -document.createElement("div");C.style.position="absolute";C.style.textAlign="right";C.style.color="gray";C.style.marginTop="10px";C.style.backgroundColor="transparent";C.style.top="440px";C.style.right="32px";C.style.maxWidth="380px";C.style.cursor="default";var H=mxUtils.button(mxResources.get("download"),function(){if(null!=B){var b=a.getCurrentFile(),b=null!=b&&null!=b.getTitle()?b.getTitle():a.defaultFilename,c=mxUtils.getXml(B.documentElement);a.isLocalFileSave()?a.saveLocalFile(c,b,"text/xml"): -(c="undefined"===typeof pako?"&xml="+encodeURIComponent(c):"&data="+encodeURIComponent(a.editor.graph.compress(c)),(new mxXmlRequest(SAVE_URL,"filename="+encodeURIComponent(b)+"&format=xml"+c)).simulate(document,"_blank"))}});H.className="geBtn";H.setAttribute("disabled","disabled");var E=mxUtils.button(mxResources.get("restore"),function(){null!=B&&null!=y&&a.confirm(mxResources.get("areYouSure"),function(){null!=d?d(y):a.spinner.spin(document.body,mxResources.get("restoring"))&&u.save(!0,function(b){a.spinner.stop(); -a.replaceFileData(y);a.hideDialog()},function(b){a.spinner.stop();a.editor.setStatus("");a.handleError(b,null!=b?mxResources.get("errorSavingFile"):null)})})});E.className="geBtn";E.setAttribute("disabled","disabled");var D=document.createElement("select");D.setAttribute("disabled","disabled");D.style.maxWidth="80px";D.style.position="relative";D.style.top="-2px";D.style.verticalAlign="bottom";D.style.marginRight="6px";D.style.display="none";var G=null;mxEvent.addListener(D,"change",function(a){null!= -G&&(G(a),mxEvent.consume(a))});var A=mxUtils.button(mxResources.get("openInNewWindow"),function(){null!=B&&(window.openFile=new OpenFile(function(){window.openFile=null}),window.openFile.setData(mxUtils.getXml(B.documentElement)),window.openWindow(a.getUrl()))});A.className="geBtn";A.setAttribute("disabled","disabled");null!=d&&(A.style.display="none");var F=mxUtils.button(mxResources.get("show"),function(){null!=v&&a.openLink(v.getUrl())});F.className="geBtn gePrimaryBtn";F.setAttribute("disabled", +l.addListener(mxEvent.SIZE,mxUtils.bind(this,function(b,c){a.editor.graph.mathEnabled&&Editor.MathJaxRender(l.container)}));var p=new Spinner({lines:11,length:15,width:6,radius:10,corners:1,rotate:0,direction:1,color:"#000",speed:1.4,trail:60,shadow:!1,hwaccel:!1,className:"spinner",zIndex:2E9,top:"50%",left:"50%"}),u=a.getCurrentFile(),q=null,v=null,A=null,B=null,t=mxUtils.button("",function(){null!=A&&l.zoomIn()});t.className="geSprite geSprite-zoomin";t.setAttribute("title",mxResources.get("zoomIn")); +t.style.outline="none";t.style.border="none";t.style.margin="2px";t.setAttribute("disabled","disabled");mxUtils.setOpacity(t,20);var w=mxUtils.button("",function(){null!=A&&l.zoomOut()});w.className="geSprite geSprite-zoomout";w.setAttribute("title",mxResources.get("zoomOut"));w.style.outline="none";w.style.border="none";w.style.margin="2px";w.setAttribute("disabled","disabled");mxUtils.setOpacity(w,20);var x=mxUtils.button("",function(){null!=A&&(l.maxFitScale=8,l.fit(8),l.center())});x.className= +"geSprite geSprite-fit";x.setAttribute("title",mxResources.get("fit"));x.style.outline="none";x.style.border="none";x.style.margin="2px";x.setAttribute("disabled","disabled");mxUtils.setOpacity(x,20);var y=mxUtils.button("",function(){null!=A&&(l.zoomActual(),l.center())});y.className="geSprite geSprite-actualsize";y.setAttribute("title",mxResources.get("actualSize"));y.style.outline="none";y.style.border="none";y.style.margin="2px";y.setAttribute("disabled","disabled");mxUtils.setOpacity(y,20);var C= +document.createElement("div");C.style.position="absolute";C.style.textAlign="right";C.style.color="gray";C.style.marginTop="10px";C.style.backgroundColor="transparent";C.style.top="440px";C.style.right="32px";C.style.maxWidth="380px";C.style.cursor="default";var H=mxUtils.button(mxResources.get("download"),function(){if(null!=A){var b=a.getCurrentFile(),b=null!=b&&null!=b.getTitle()?b.getTitle():a.defaultFilename,c=mxUtils.getXml(A.documentElement);a.isLocalFileSave()?a.saveLocalFile(c,b,"text/xml"): +(c="undefined"===typeof pako?"&xml="+encodeURIComponent(c):"&data="+encodeURIComponent(a.editor.graph.compress(c)),(new mxXmlRequest(SAVE_URL,"filename="+encodeURIComponent(b)+"&format=xml"+c)).simulate(document,"_blank"))}});H.className="geBtn";H.setAttribute("disabled","disabled");var E=mxUtils.button(mxResources.get("restore"),function(){null!=A&&null!=B&&a.confirm(mxResources.get("areYouSure"),function(){null!=d?d(B):a.spinner.spin(document.body,mxResources.get("restoring"))&&u.save(!0,function(b){a.spinner.stop(); +a.replaceFileData(B);a.hideDialog()},function(b){a.spinner.stop();a.editor.setStatus("");a.handleError(b,null!=b?mxResources.get("errorSavingFile"):null)})})});E.className="geBtn";E.setAttribute("disabled","disabled");var D=document.createElement("select");D.setAttribute("disabled","disabled");D.style.maxWidth="80px";D.style.position="relative";D.style.top="-2px";D.style.verticalAlign="bottom";D.style.marginRight="6px";D.style.display="none";var G=null;mxEvent.addListener(D,"change",function(a){null!= +G&&(G(a),mxEvent.consume(a))});var z=mxUtils.button(mxResources.get("openInNewWindow"),function(){null!=A&&(window.openFile=new OpenFile(function(){window.openFile=null}),window.openFile.setData(mxUtils.getXml(A.documentElement)),window.openWindow(a.getUrl()))});z.className="geBtn";z.setAttribute("disabled","disabled");null!=d&&(z.style.display="none");var F=mxUtils.button(mxResources.get("show"),function(){null!=v&&a.openLink(v.getUrl())});F.className="geBtn gePrimaryBtn";F.setAttribute("disabled", "disabled");null!=d&&(F.style.display="none",E.className="geBtn gePrimaryBtn");e=document.createElement("div");e.style.position="absolute";e.style.top="482px";e.style.width="640px";e.style.textAlign="right";var I=document.createElement("div");I.className="geToolbarContainer";I.style.backgroundColor="transparent";I.style.padding="2px";I.style.border="none";I.style.left="199px";I.style.top="442px";var K=null;if(null!=b&&0a.maxImageSize||n>a.maxImageSize){var C=Math.min(1,Math.min(a.maxImageSize/Math.max(1,e)),a.maxImageSize/Math.max(1,n));e*=C;n*=C}z>A?(A=Math.round(100*A/z),z=100):(z=Math.round(100*z/A),A=100);var F=document.createElement("div");F.setAttribute("draggable","true");F.style.display=mxClient.IS_QUIRKS?"inline":"inline-block";F.style.position="relative";F.style.cursor="move"; -mxUtils.setPrefixedStyle(F.style,"transition","transform .1s ease-in-out");if(null!=b){var I=document.createElement("img");I.setAttribute("src",w.convert(b));I.style.width=z+"px";I.style.height=A+"px";I.style.margin="10px";I.style.paddingBottom=Math.floor((100-A)/2)+"px";I.style.paddingLeft=Math.floor((100-z)/2)+"px";F.appendChild(I)}else if(null!=f){var K=a.stringToCells(a.editor.graph.decompress(f.xml));0a.maxImageSize||n>a.maxImageSize){var C=Math.min(1,Math.min(a.maxImageSize/Math.max(1,e)),a.maxImageSize/Math.max(1,n));e*=C;n*=C}y>z?(z=Math.round(100*z/y),y=100):(y=Math.round(100*y/z),z=100);var F=document.createElement("div");F.setAttribute("draggable","true");F.style.display=mxClient.IS_QUIRKS?"inline":"inline-block";F.style.position="relative";F.style.cursor="move"; +mxUtils.setPrefixedStyle(F.style,"transition","transform .1s ease-in-out");if(null!=b){var I=document.createElement("img");I.setAttribute("src",w.convert(b));I.style.width=y+"px";I.style.height=z+"px";I.style.margin="10px";I.style.paddingBottom=Math.floor((100-z)/2)+"px";I.style.paddingLeft=Math.floor((100-y)/2)+"px";F.appendChild(I)}else if(null!=f){var K=a.stringToCells(a.editor.graph.decompress(f.xml));0B?y-1:y,0,k.splice(B,1)[0]),u.insertBefore(u.children[B],u.children[y])):(k.push(k.splice(B,1)[0]),u.appendChild(u.children[B])); -else if(0A?B-1:B,0,k.splice(A,1)[0]),u.insertBefore(u.children[A],u.children[B])):(k.push(k.splice(A,1)[0]),u.appendChild(u.children[A])); +else if(0=c.status&&(l(c.responseText,d,g,k,e,n,t,"fixed",mxEvent.isAltDown(b)?null:t.substring(0,t.lastIndexOf(".")).replace(/_/g," ")),u.scrollTop=u.scrollHeight))})):(l(c,d,g,k,e,n,t,"fixed",mxEvent.isAltDown(b)?null:t.substring(0, t.lastIndexOf(".")).replace(/_/g," ")),u.scrollTop=u.scrollHeight)}};mxEvent.addListener(u,"dragover",m);mxEvent.addListener(u,"drop",g);mxEvent.addListener(q,"dragover",m);mxEvent.addListener(q,"drop",g);d.appendChild(u);c=document.createElement("div");c.style.textAlign="right";c.style.marginTop="20px";b=mxUtils.button(mxResources.get("cancel"),function(){a.hideDialog(!0)});b.setAttribute("id","btnCancel");b.className="geBtn";a.editor.cancelFirst&&c.appendChild(b);n=mxUtils.button(mxResources.get("export"), function(){var b=a.createLibraryDataFromImages(k),c=p.value;/(\.xml)$/i.test(c)||(c+=".xml");a.isLocalFileSave()?a.saveLocalFile(b,c,"text/xml",null,null,!0):(new mxXmlRequest(SAVE_URL,"filename="+encodeURIComponent(c)+"&format=xml&xml="+encodeURIComponent(b))).simulate(document,"_blank")});n.setAttribute("id","btnDownload");n.className="geBtn";c.appendChild(n);var C=document.createElement("input");C.setAttribute("multiple","multiple");C.setAttribute("type","file");null==document.documentMode&&(mxEvent.addListener(C, -"change",function(b){x=!1;a.importFiles(C.files,0,0,a.maxImageSize,function(a,c,d,g,k,e,n,t,f){z(b)(a,c,d,g,k,e,n,t,f);C.value=""});u.scrollTop=u.scrollHeight}),n=mxUtils.button(mxResources.get("import"),function(){null!=t&&(t(),t=null);C.click()}),n.setAttribute("id","btnAddImage"),n.className="geBtn",c.appendChild(n));n=mxUtils.button(mxResources.get("addImageUrl"),function(){null!=t&&(t(),t=null);a.showImageDialog(mxResources.get("addImageUrl"),"",function(a,b,c){x=!1;if(null!=a){if("data:image/"== +"change",function(b){x=!1;a.importFiles(C.files,0,0,a.maxImageSize,function(a,c,d,g,k,e,n,t,f){y(b)(a,c,d,g,k,e,n,t,f);C.value=""});u.scrollTop=u.scrollHeight}),n=mxUtils.button(mxResources.get("import"),function(){null!=t&&(t(),t=null);C.click()}),n.setAttribute("id","btnAddImage"),n.className="geBtn",c.appendChild(n));n=mxUtils.button(mxResources.get("addImageUrl"),function(){null!=t&&(t(),t=null);a.showImageDialog(mxResources.get("addImageUrl"),"",function(a,b,c){x=!1;if(null!=a){if("data:image/"== a.substring(0,11)){var d=a.indexOf(",");0'),b.writeln(a.editor.fontCss),b.writeln(""))};if("undefined"!==typeof MathJax){var u=c.renderPage;c.renderPage= function(a,b,c,d,g,k){var e=u.apply(this,arguments);this.graph.mathEnabled?this.mathEnabled=!0:e.className="geDisableMathJax";return e}}c.open(null,null,g,!0)}else{f=b.background;if(null==f||""==f||f==mxConstants.NONE)f="#ffffff";c.backgroundColor=f;c.autoOrigin=h;c.appendGraph(b,t,e,n,g,!0)}return c}var d=parseInt(W.value)/100;isNaN(d)&&(d=1,W.value="100 %");var d=.75*d,k=u.value,e=q.value,n=!p.checked,t=null;n&&(n=k==f&&e==f);if(!n&&null!=a.pages&&a.pages.length){var h=0,n=a.pages.length-1;p.checked|| (h=parseInt(k)-1,n=parseInt(e)-1);for(var l=h;l<=n;l++){var m=a.pages[l],k=m==a.currentPage?g:null;if(null==k){var k=a.createTemporaryGraph(g.getStylesheet()),e=!0,h=!1,w=null,v=null;null==m.viewState&&null==m.mapping&&null==m.root&&a.updatePageRoot(m);null!=m.viewState?(e=m.viewState.pageVisible,h=m.viewState.mathEnabled,w=m.viewState.background,v=m.viewState.backgroundImage):null!=m.mapping&&null!=m.mapping.diagramMap&&(h="0"!=m.mapping.diagramMap.get("mathEnabled"),w=m.mapping.diagramMap.get("background"), -v=m.mapping.diagramMap.get("backgroundImage"),v=null!=v&&0'),n.writeln("MathJax.Hub.Config({"),n.writeln('messageStyle: "none",'),n.writeln('jax: ["input/TeX", "input/MathML", "input/AsciiMath", "output/HTML-CSS"],'),n.writeln('extensions: ["tex2jax.js", "mml2jax.js", "asciimath2jax.js"],'),n.writeln("TeX: {"),n.writeln('extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]'),n.writeln("},"),n.writeln("tex2jax: {"),n.writeln('\tignoreClass: "geDisableMathJax"'),n.writeln("},"), n.writeln("asciimath2jax: {"),n.writeln('\tignoreClass: "geDisableMathJax"'),n.writeln("}"),n.writeln("});"),b&&(n.writeln("MathJax.Hub.Queue(function () {"),n.writeln("window.print();"),n.writeln("});")),n.writeln("\x3c/script>"),n.writeln('