From cb6cf1e34bcd8d36fc192f85fabc973cc102e872 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 23 Feb 2022 09:41:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96drawio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/drawio/webapp/README.md | 2 ++ docker/drawio/webapp/index.html | 3 +++ docker/drawio/webapp/js/app.min.js | 10 +++++----- electron/main.js | 20 +++++++++---------- resources/assets/js/components/Drawio.vue | 7 ++++++- .../pages/manage/components/FileContent.vue | 2 +- .../pages/manage/components/FilePreview.vue | 2 +- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/docker/drawio/webapp/README.md b/docker/drawio/webapp/README.md index 4865c1e1..83b1c592 100644 --- a/docker/drawio/webapp/README.md +++ b/docker/drawio/webapp/README.md @@ -8,6 +8,8 @@ - 隐藏帮助菜单 - 取消未保存关闭窗口提示 +- `EmbedFile.prototype.getTitle=...` 改为 `EmbedFile.prototype.getTitle=function(){return this.desc.title||(urlParams.title?decodeURIComponent(urlParams.title):"")}` +- `390:270` 改为 `390:285` ## index.html diff --git a/docker/drawio/webapp/index.html b/docker/drawio/webapp/index.html index dfcc62bf..89affb16 100644 --- a/docker/drawio/webapp/index.html +++ b/docker/drawio/webapp/index.html @@ -409,6 +409,9 @@ cursor:pointer; margin:5px; } + .geDialog h2 { + line-height: 1.2; + } diff --git a/docker/drawio/webapp/js/app.min.js b/docker/drawio/webapp/js/app.min.js index 9e047edf..02bd7996 100644 --- a/docker/drawio/webapp/js/app.min.js +++ b/docker/drawio/webapp/js/app.min.js @@ -10131,7 +10131,7 @@ StorageFile.listLocalStorageFiles=function(b){for(var e=[],d=0;dd&&(mxUtils.br(l),n=1);var t=document.createElement("a");t.style.overflow="hidden";t.style.display="inline-block";t.className="geBaseButton";t.style.boxSizing="border-box";t.style.fontSize="11px";t.style.position="relative";t.style.margin="4px";t.style.marginTop="8px";t.style.marginBottom="0px";t.style.padding="8px 10px 8px 10px";t.style.width="88px";t.style.height="100px";t.style.whiteSpace="nowrap";t.setAttribute("title", @@ -10881,7 +10881,7 @@ f.textarea.style.height="380px";this.showDialog(f.container,620,460,!0,!0,null,n k=65==(l?parseInt(l[2],10):!1)?!1:k}if(k||this.isOffline()){f.href=URL.createObjectURL(e?this.base64ToBlob(b,d):new Blob([b],{type:d}));k?f.download=c:f.setAttribute("target","_blank");document.body.appendChild(f);try{window.setTimeout(function(){URL.revokeObjectURL(f.href)},2E4),f.click(),f.parentNode.removeChild(f)}catch(y){}}else this.createEchoRequest(b,c,d,e,g).simulate(document,"_blank")}};EditorUi.prototype.createEchoRequest=function(b,c,d,e,g,k){b="xml="+encodeURIComponent(b);return new mxXmlRequest(SAVE_URL, b+(null!=d?"&mime="+d:"")+(null!=g?"&format="+g:"")+(null!=k?"&base64="+k:"")+(null!=c?"&filename="+encodeURIComponent(c):"")+(e?"&binary=1":""))};EditorUi.prototype.base64ToBlob=function(b,c){c=c||"";for(var f=atob(b),d=f.length,e=Math.ceil(d/1024),l=Array(e),g=0;g=g?2:6"+mxUtils.htmlEntities(b, -!1)+""),g.document.close())}else f==App.MODE_DEVICE||"download"==f?this.doSaveLocalFile(b,c,d,e,null,v):null!=c&&0f?390:270:160;this.showDialog(c.container,420,k,!0,!0);c.init()};EditorUi.prototype.openInNewWindow= +!1)+""),g.document.close())}else f==App.MODE_DEVICE||"download"==f?this.doSaveLocalFile(b,c,d,e,null,v):null!=c&&0f?390:285:160;this.showDialog(c.container,420,k,!0,!0);c.init()};EditorUi.prototype.openInNewWindow= function(b,c,d){var f=window.open("about:blank");null==f||null==f.document?mxUtils.popup(b,!0):("image/svg+xml"!=c||mxClient.IS_SVG?"image/svg+xml"==c?f.document.write(""+b+""):(b=d?b:btoa(unescape(encodeURIComponent(b))),f.document.write('')):f.document.write("
"+mxUtils.htmlEntities(b,!1)+"
"),f.document.close())};var c=EditorUi.prototype.addChromelessToolbarItems;EditorUi.prototype.isChromelessImageExportEnabled= function(){return"draw.io"!=this.getServiceName()||/.*\.draw\.io$/.test(window.location.hostname)||/.*\.diagrams\.net$/.test(window.location.hostname)};EditorUi.prototype.addChromelessToolbarItems=function(b){if(null!=urlParams.tags){this.tagsDialog=this.tagsComponent=null;var f=b(mxUtils.bind(this,function(b){null==this.tagsComponent&&(this.tagsComponent=this.editor.graph.createTagsDialog(mxUtils.bind(this,function(){return null!=this.tagsDialog}),!0),this.tagsComponent.div.getElementsByTagName("div")[0].style.position= "",mxUtils.setPrefixedStyle(this.tagsComponent.div.style,"borderRadius","5px"),this.tagsComponent.div.className="geScrollable",this.tagsComponent.div.style.maxHeight="160px",this.tagsComponent.div.style.maxWidth="120px",this.tagsComponent.div.style.padding="4px",this.tagsComponent.div.style.overflow="auto",this.tagsComponent.div.style.height="auto",this.tagsComponent.div.style.position="fixed",this.tagsComponent.div.style.fontFamily=Editor.defaultHtmlFont,mxClient.IS_IE||mxClient.IS_IE11?(this.tagsComponent.div.style.backgroundColor= @@ -10896,7 +10896,7 @@ function(b){e.stop();this.exportDialog.style.width="auto";this.exportDialog.styl function(){this.openInNewWindow(f.substring(f.indexOf(",")+1),"image/png",!0);c.apply(this,arguments)}))}),null,this.thumbImageCache,null,mxUtils.bind(this,function(b){this.spinner.stop();this.handleError(b)}),null,null,null,null,null,null,null,Editor.defaultBorder);mxEvent.addListener(this.editor.graph.container,"click",c);document.body.appendChild(this.exportDialog)}mxEvent.consume(b)}),Editor.cameraImage,mxResources.get("export"))}};EditorUi.prototype.saveData=function(b,c,d,e,g){this.isLocalFileSave()? this.saveLocalFile(d,b,e,g,c):this.saveRequest(b,c,mxUtils.bind(this,function(b,f){return this.createEchoRequest(d,b,e,g,c,f)}),d,g,e)};EditorUi.prototype.saveRequest=function(b,c,d,e,g,k,n){n=null!=n?n:!mxClient.IS_IOS||!navigator.standalone;var f=this.getServiceCount(!1);isLocalStorage&&f++;var l=4>=f?2:6=l.getStatus())try{this.exportFile(l.getText(),b,k,!0,f,d)}catch(C){this.handleError(C)}else this.handleError({message:mxResources.get("errorSavingFile")})}), -function(b){this.spinner.stop();this.handleError(b)})})))}}),mxUtils.bind(this,function(){this.hideDialog()}),mxResources.get("saveAs"),mxResources.get("download"),!1,!1,n,null,1=window.location.hash.length)&&null!=d&&0=b?2:6d?390:270,!0,!1,mxUtils.bind(this,function(b){b&& +c,mxUtils.bind(this,function(b,c){if(null==c){this.hideDialog();var d=Editor.useLocalStorage;this.createFile(0d?390:285,!0,!1,mxUtils.bind(this,function(b){b&& null==this.getCurrentFile()&&this.showSplash()}));c.init()}}),d=decodeURIComponent(d);if("http://"!=d.substring(0,7)&&"https://"!=d.substring(0,8))try{null!=window.opener&&null!=window.opener[d]?g(window.opener[d]):this.handleError(null,mxResources.get("errorLoadingFile"))}catch(k){this.handleError(k,mxResources.get("errorLoadingFile"))}else this.loadTemplate(d,function(b){g(b)},mxUtils.bind(this,function(){this.handleError(null,mxResources.get("errorLoadingFile"),c)}))}else(null==window.location.hash|| 1>=window.location.hash.length)&&null!=urlParams.state&&null!=this.stateArg&&"open"==this.stateArg.action?null!=this.stateArg.ids&&(window.history&&window.history.replaceState&&window.history.replaceState(null,null,window.location.pathname+this.getSearch(["state"])),window.location.hash="G"+this.stateArg.ids[0]):(null==window.location.hash||1>=window.location.hash.length)&&null!=this.drive&&null!=this.stateArg&&"create"==this.stateArg.action?(window.history&&window.history.replaceState&&window.history.replaceState(null, null,window.location.pathname+this.getSearch(["state"])),this.setMode(App.MODE_GOOGLE),"0"==urlParams.splash?this.createFile(null!=urlParams.title?decodeURIComponent(urlParams.title):this.defaultFilename):this.actions.get("new").funct()):(null!=urlParams.open&&window.history&&window.history.replaceState&&(window.history.replaceState(null,null,window.location.pathname+this.getSearch(["open"])),window.location.hash=urlParams.open),e())}}catch(k){this.handleError(k)}}; @@ -11759,7 +11759,7 @@ App.prototype.saveFile=function(b,e){var d=this.getCurrentFile();if(null!=d){var function(b,e){d.invalidFileHandle=null;d.fileHandle=b;d.title=e.name;d.desc=e;this.save(e.name,c)}),null,this.createFileSystemOptions(d.getTitle()));else{var g=null!=d.getTitle()?d.getTitle():this.defaultFilename,k=!mxClient.IS_IOS||!navigator.standalone,n=this.mode,f=this.getServiceCount(!0);isLocalStorage&&f++;var l=4>=f?2:6b.indexOf(".")||/(\.drawio)$/i.test(b),/(\.svg)$/i.test(b),/(\.html)$/i.test(b)),null,e,c,null==this.mode,d)})):null!=e&&this.save(b,c)))}),mxUtils.bind(this,function(){this.hideDialog()}),mxResources.get("saveAs"),mxResources.get("download"),null,null,k,null,!0,l,null,null,null,this.editor.fileExtensions,!1);this.showDialog(g.container,420,f>l?390:270,!0,!0);g.init()}else this.save(d.getTitle(),c)}}; +this.getFileData(/(\.xml)$/i.test(b)||0>b.indexOf(".")||/(\.drawio)$/i.test(b),/(\.svg)$/i.test(b),/(\.html)$/i.test(b)),null,e,c,null==this.mode,d)})):null!=e&&this.save(b,c)))}),mxUtils.bind(this,function(){this.hideDialog()}),mxResources.get("saveAs"),mxResources.get("download"),null,null,k,null,!0,l,null,null,null,this.editor.fileExtensions,!1);this.showDialog(g.container,420,f>l?390:285,!0,!0);g.init()}else this.save(d.getTitle(),c)}}; App.prototype.loadTemplate=function(b,e,d,c,g){var k=!1,n=b;this.editor.isCorsEnabledForUrl(n)||(n="t="+(new Date).getTime(),n=PROXY_URL+"?url="+encodeURIComponent(b)+"&base64=1&"+n,k=!0);var f=null!=c?c:b;this.editor.loadUrl(n,mxUtils.bind(this,function(c){try{var l=k?!window.atob||mxClient.IS_IE||mxClient.IS_IE11?Base64.decode(c):atob(c):c,n=/(\.v(dx|sdx?))($|\?)/i.test(f)||/(\.vs(x|sx?))($|\?)/i.test(f);if(n||this.isVisioData(l))n||(f=g?this.isRemoteVisioData(l)?"raw.vss":"raw.vssx":this.isRemoteVisioData(l)? "raw.vsd":"raw.vsdx"),this.importVisio(this.base64ToBlob(c.substring(c.indexOf(",")+1)),function(b){e(b)},d,f);else if(!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(l,f))this.parseFileData(l,mxUtils.bind(this,function(b){4==b.readyState&&200<=b.status&&299>=b.status&&" { @@ -551,15 +553,13 @@ function exportVsdx(event, args, directFinalize) { let win = new BrowserWindow({ width: 1280, height: 800, - center: true, show: false, - autoHideMenuBar: true, webPreferences: { preload: path.join(__dirname, 'preload.js'), - devTools: args.devTools !== false, webSecurity: true, nodeIntegration: true, - contextIsolation: true + contextIsolation: true, + nativeWindowOpen: true }, }) @@ -613,13 +613,13 @@ async function mergePdfs(pdfFiles, xml) { try { const pdfDoc = await PDFDocument.create(); - pdfDoc.setCreator('diagrams.net'); + pdfDoc.setCreator(config.name); if (xml != null) { //Embed diagram XML as file attachment - await pdfDoc.attach(Buffer.from(xml).toString('base64'), 'diagram.xml', { + await pdfDoc.attach(Buffer.from(xml).toString('base64'), config.name + '.xml', { mimeType: 'application/vnd.jgraph.mxfile', - description: 'Diagram Content' + description: config.name + ' Content' }); } @@ -980,7 +980,7 @@ async function writeFile(path, data, enc) { function getAppDataFolder() { try { let appDataDir = app.getPath('appData'); - let drawioDir = appDataDir + '/dootask.com'; + let drawioDir = appDataDir + '/' + config.name; if (!fs.existsSync(drawioDir)) //Usually this dir already exists { diff --git a/resources/assets/js/components/Drawio.vue b/resources/assets/js/components/Drawio.vue index a3e1cfa4..e02c74b8 100644 --- a/resources/assets/js/components/Drawio.vue +++ b/resources/assets/js/components/Drawio.vue @@ -46,6 +46,10 @@ export default { return {} } }, + title: { + type: String, + default: '' + }, readOnly: { type: Boolean, default: false @@ -70,7 +74,8 @@ export default { let lightbox = this.readOnly ? 1 : 0; let chrome = this.readOnly ? 0 : 1; let theme = this.themeIsDark ? 'dark' : 'kennedy'; - let query = `?chrome=${chrome}&lightbox=${lightbox}&ui=${theme}&lang=${language}&embed=1&noLangIcon=1&noExitBtn=1&noSaveBtn=1&saveAndExit=0&spin=1&proto=json`; + let title = this.title ? encodeURIComponent(this.title) : ''; + let query = `?title=${title}&chrome=${chrome}&lightbox=${lightbox}&ui=${theme}&lang=${language}&offline=1&embed=1&noLangIcon=1&noExitBtn=1&noSaveBtn=1&saveAndExit=0&spin=1&proto=json`; if (this.$Electron) { this.url = $A.originUrl(`drawio/webapp/index.html${query}`); } else { diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue index 6d97f781..1d9ca769 100644 --- a/resources/assets/js/pages/manage/components/FileContent.vue +++ b/resources/assets/js/pages/manage/components/FileContent.vue @@ -50,7 +50,7 @@ - + diff --git a/resources/assets/js/pages/manage/components/FilePreview.vue b/resources/assets/js/pages/manage/components/FilePreview.vue index cf32b451..b70a9a92 100644 --- a/resources/assets/js/pages/manage/components/FilePreview.vue +++ b/resources/assets/js/pages/manage/components/FilePreview.vue @@ -27,7 +27,7 @@ - +