优化drawio

This commit is contained in:
kuaifan 2022-02-23 09:41:19 +08:00
parent 953e924aa2
commit cb6cf1e34b
7 changed files with 28 additions and 18 deletions

View File

@ -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

View File

@ -409,6 +409,9 @@
cursor:pointer;
margin:5px;
}
.geDialog h2 {
line-height: 1.2;
}
</style>
<!-- Workaround for binary XHR in IE 9/10, see App.loadUrl -->
<!--[if (IE 9)|(IE 10)]><!-->

View File

@ -10131,7 +10131,7 @@ StorageFile.listLocalStorageFiles=function(b){for(var e=[],d=0;d<localStorage.le
StorageFile.migrate=function(b){var e=StorageFile.listLocalStorageFiles();e.push({title:".scratchpad",type:"L"});var d=b.transaction(["files","filesInfo"],"readwrite");b=d.objectStore("files");for(var d=d.objectStore("filesInfo"),c=0;c<e.length;c++){var g=e[c],k=localStorage.getItem(g.title);b.add({title:g.title,data:k});d.add(g)}};
StorageFile.listFiles=function(b,e,d,c){b.getDatabaseItems(function(b){var c=[];if(null!=b)for(var g=0;g<b.length;g++)"."==b[g].title.charAt(0)||null!=e&&b[g].type!=e||c.push(b[g]);d(c)},function(){null==b.database?d(StorageFile.listLocalStorageFiles(e)):null!=c&&c()},"filesInfo")};StorageFile.deleteFile=function(b,e,d,c){b.removeDatabaseItem([e,e],d,function(){null==b.database?(localStorage.removeItem(e),d()):null!=c&&c()},["files","filesInfo"])};StorageLibrary=function(b,e,d){StorageFile.call(this,b,e,d)};mxUtils.extend(StorageLibrary,StorageFile);StorageLibrary.prototype.type="L";StorageLibrary.prototype.isAutosave=function(){return!0};StorageLibrary.prototype.saveAs=function(b,e,d){this.saveFile(b,!1,e,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(b,e,d){return".scratchpad"!=this.title};StorageLibrary.prototype.open=function(){};RemoteFile=function(b,e,d){DrawioFile.call(this,b,e);this.title=d;this.mode=null};mxUtils.extend(RemoteFile,DrawioFile);RemoteFile.prototype.isAutosave=function(){return!1};RemoteFile.prototype.getMode=function(){return this.mode};RemoteFile.prototype.getTitle=function(){return this.title};RemoteFile.prototype.isRenamable=function(){return!1};RemoteFile.prototype.open=function(){this.ui.setFileData(this.getData());this.installListeners()};RemoteLibrary=function(b,e,d){RemoteFile.call(this,b,e,d.title);this.libObj=d};mxUtils.extend(RemoteLibrary,LocalFile);RemoteLibrary.prototype.getHash=function(){return"R"+encodeURIComponent(JSON.stringify([this.libObj.id,this.libObj.title,this.libObj.downloadUrl]))};RemoteLibrary.prototype.isEditable=function(){return!1};RemoteLibrary.prototype.isRenamable=function(){return!1};RemoteLibrary.prototype.isAutosave=function(){return!1};RemoteLibrary.prototype.save=function(b,e,d){};
RemoteLibrary.prototype.saveAs=function(b,e,d){};RemoteLibrary.prototype.updateFileData=function(){};RemoteLibrary.prototype.open=function(){};UrlLibrary=function(b,e,d){StorageFile.call(this,b,e,d);b=d;e=b.lastIndexOf("/");0<=e&&(b=b.substring(e+1));this.fname=b};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(b,e,d){return!1};UrlLibrary.prototype.saveAs=function(b,e,d){};UrlLibrary.prototype.open=function(){};EmbedFile=function(b,e,d){DrawioFile.call(this,b,e);this.desc=d||{};this.mode=App.MODE_EMBED};mxUtils.extend(EmbedFile,DrawioFile);EmbedFile.prototype.getMode=function(){return this.mode};EmbedFile.prototype.getTitle=function(){return this.desc.title||""};/*
RemoteLibrary.prototype.saveAs=function(b,e,d){};RemoteLibrary.prototype.updateFileData=function(){};RemoteLibrary.prototype.open=function(){};UrlLibrary=function(b,e,d){StorageFile.call(this,b,e,d);b=d;e=b.lastIndexOf("/");0<=e&&(b=b.substring(e+1));this.fname=b};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(b,e,d){return!1};UrlLibrary.prototype.saveAs=function(b,e,d){};UrlLibrary.prototype.open=function(){};EmbedFile=function(b,e,d){DrawioFile.call(this,b,e);this.desc=d||{};this.mode=App.MODE_EMBED};mxUtils.extend(EmbedFile,DrawioFile);EmbedFile.prototype.getMode=function(){return this.mode};EmbedFile.prototype.getTitle=function(){return this.desc.title||(urlParams.title?decodeURIComponent(urlParams.title):"")};/*
mxClient.IS_IOS || */
var StorageDialog=function(b,e,d){function c(c,g,k,p,y,A){function q(){mxEvent.addListener(t,"click",null!=A?A:function(){k!=App.MODE_GOOGLE||b.isDriveDomain()?k==App.MODE_GOOGLE&&b.spinner.spin(document.body,mxResources.get("authorizing"))?b.drive.checkToken(mxUtils.bind(this,function(){b.spinner.stop();b.setMode(k,!0);e()})):k==App.MODE_ONEDRIVE&&b.spinner.spin(document.body,mxResources.get("authorizing"))?b.oneDrive.checkToken(mxUtils.bind(this,function(){b.spinner.stop();b.setMode(k,!0);e()})):
(b.setMode(k,!0),e()):window.location.hostname=DriveClient.prototype.newAppHostname})}f++;++n>d&&(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<e;++g){for(var k=1024*g,n=Math.min(k+1024,d),A=Array(n-k),z=0;k<n;++z,++k)A[z]=f[k].charCodeAt(0);l[g]=new Uint8Array(A)}return new Blob(l,{type:c})};EditorUi.prototype.saveLocalFile=function(b,c,d,e,g,k,n,v){k=null!=k?k:!1;n=null!=n?
n:"vsdx"!=g&&(!mxClient.IS_IOS||!navigator.standalone);g=this.getServiceCount(k);isLocalStorage&&g++;var f=4>=g?2:6<g?4:3;c=new CreateDialog(this,c,mxUtils.bind(this,function(c,f){try{if("_blank"==f)if(null!=d&&"image/"==d.substring(0,6))this.openInNewWindow(b,d,e);else if(null!=d&&"text/html"==d.substring(0,9)){var l=new EmbedDialog(this,b);this.showDialog(l.container,450,240,!0,!0);l.init()}else{var g=window.open("about:blank");null==g?mxUtils.popup(b,!0):(g.document.write("<pre>"+mxUtils.htmlEntities(b,
!1)+"</pre>"),g.document.close())}else f==App.MODE_DEVICE||"download"==f?this.doSaveLocalFile(b,c,d,e,null,v):null!=c&&0<c.length&&this.pickFolder(f,mxUtils.bind(this,function(l){try{this.exportFile(b,c,d,e,f,l)}catch(E){this.handleError(E)}}))}catch(C){this.handleError(C)}}),mxUtils.bind(this,function(){this.hideDialog()}),mxResources.get("saveAs"),mxResources.get("download"),!1,k,n,null,1<g,f,b,d,e);k=this.isServices(g)?g>f?390:270:160;this.showDialog(c.container,420,k,!0,!0);c.init()};EditorUi.prototype.openInNewWindow=
!1)+"</pre>"),g.document.close())}else f==App.MODE_DEVICE||"download"==f?this.doSaveLocalFile(b,c,d,e,null,v):null!=c&&0<c.length&&this.pickFolder(f,mxUtils.bind(this,function(l){try{this.exportFile(b,c,d,e,f,l)}catch(E){this.handleError(E)}}))}catch(C){this.handleError(C)}}),mxUtils.bind(this,function(){this.hideDialog()}),mxResources.get("saveAs"),mxResources.get("download"),!1,k,n,null,1<g,f,b,d,e);k=this.isServices(g)?g>f?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("<html>"+b+"</html>"):(b=d?b:btoa(unescape(encodeURIComponent(b))),f.document.write('<html><img style="max-width:100%;" src="data:'+c+";base64,"+b+'"/></html>')):f.document.write("<html><pre>"+mxUtils.htmlEntities(b,!1)+"</pre></html>"),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<f?4:3;b=new CreateDialog(this,b,mxUtils.bind(this,function(b,f){if("_blank"==f||null!=b&&0<b.length){var l=d("_blank"==f?null:b,f==App.MODE_DEVICE||"download"==f||null==f||"_blank"==f?"0":"1");
null!=l&&(f==App.MODE_DEVICE||"download"==f||"_blank"==f?l.simulate(document,"_blank"):this.pickFolder(f,mxUtils.bind(this,function(d){k=null!=k?k:"pdf"==c?"application/pdf":"image/"+c;if(null!=e)try{this.exportFile(e,b,k,!0,f,d)}catch(C){this.handleError(C)}else this.spinner.spin(document.body,mxResources.get("saving"))&&l.send(mxUtils.bind(this,function(){this.spinner.stop();if(200<=l.getStatus()&&299>=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<f,l,e,k,g);f=this.isServices(f)?4<f?390:270:160;this.showDialog(b.container,420,f,!0,!0);b.init()};EditorUi.prototype.isServices=function(b){return 1!=b};EditorUi.prototype.getEditBlankXml=function(){return this.getFileData(!0)};EditorUi.prototype.exportFile=function(b,c,d,e,g,k){};EditorUi.prototype.pickFolder=function(b,
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<f,l,e,k,g);f=this.isServices(f)?4<f?390:285:160;this.showDialog(b.container,420,f,!0,!0);b.init()};EditorUi.prototype.isServices=function(b){return 1!=b};EditorUi.prototype.getEditBlankXml=function(){return this.getFileData(!0)};EditorUi.prototype.exportFile=function(b,c,d,e,g,k){};EditorUi.prototype.pickFolder=function(b,
c,d){c(null)};EditorUi.prototype.exportSvg=function(b,c,d,e,g,k,n,v,y,A,z,B,x,C){if(this.spinner.spin(document.body,mxResources.get("export")))try{var f=this.editor.graph.isSelectionEmpty();d=null!=d?d:f;var l=c?null:this.editor.graph.background;l==mxConstants.NONE&&(l=null);null==l&&0==c&&(l=z?this.editor.graph.defaultPageBackgroundColor:"#ffffff");var m=this.editor.graph.getSvg(l,b,n,v,null,d,null,null,"blank"==A?"_blank":"self"==A?"_top":null,null,!0,z,B);e&&this.editor.graph.addSvgShadow(m);var p=
this.getBaseFilename()+(g?".drawio":"")+".svg";C=null!=C?C:mxUtils.bind(this,function(b){this.isLocalFileSave()||b.length<=MAX_REQUEST_SIZE?this.saveData(p,"svg",b,"image/svg+xml"):this.handleError({message:mxResources.get("drawingTooLarge")},mxResources.get("error"),mxUtils.bind(this,function(){mxUtils.popup(b)}))});var q=mxUtils.bind(this,function(b){this.spinner.stop();g&&b.setAttribute("content",this.getFileData(!0,null,null,null,d,y,null,null,null,!1));C(Graph.xmlDeclaration+"\n"+(g?Graph.svgFileComment+
"\n":"")+Graph.svgDoctype+"\n"+mxUtils.getXml(b))});this.editor.graph.mathEnabled&&this.editor.addMathCss(m);var t=mxUtils.bind(this,function(b){k?(null==this.thumbImageCache&&(this.thumbImageCache={}),this.editor.convertImages(b,q,this.thumbImageCache)):q(b)});x?this.embedFonts(m,t):(this.editor.addFontCss(m),t(m))}catch(L){this.handleError(L)}};EditorUi.prototype.addRadiobox=function(b,c,d,e,g,k,n){return this.addCheckbox(b,d,e,g,k,n,!0,c)};EditorUi.prototype.addCheckbox=function(b,c,d,e,g,k,n,
@ -11721,7 +11721,7 @@ this.defaultFilename;b=new LocalFile(this,b,c,!0);null!=window.location.hash&&"#
this.dialog)if("1"==urlParams.demo)d=Editor.useLocalStorage,this.createFile(this.defaultFilename,null,null,null,null,null,null,!0),Editor.useLocalStorage=d;else{d=!1;try{d=null!=window.opener&&null!=window.opener.openFile}catch(l){}d?this.spinner.spin(document.body,mxResources.get("loading")):(d=this.getDiagramId(),!EditorUi.enableDrafts||null!=urlParams.mode||"draw.io"!=this.getServiceName()||null!=d&&0!=d.length||this.editor.isChromelessView()?null!=d&&0<d.length?this.loadFile(d,null,null,mxUtils.bind(this,
function(){var b=decodeURIComponent(urlParams.viewbox||"");if(""!=b)try{var c=JSON.parse(b);this.editor.graph.fitWindow(c,c.border)}catch(p){console.error(p)}})):"0"!=urlParams.splash?this.loadFile():this.createFile(this.defaultFilename,this.getFileData(),null,null,null,null,null,!0):this.checkDrafts())}}),d=decodeURIComponent(urlParams.create||"");if((null==window.location.hash||1>=window.location.hash.length)&&null!=d&&0<d.length&&this.spinner.spin(document.body,mxResources.get("loading"))){var c=
mxUtils.bind(this,function(){this.spinner.spin(document.body,mxResources.get("reconnecting"))&&(window.location.search=this.getSearch(["create","title"]))}),g=mxUtils.bind(this,function(b){this.spinner.stop();if("0"!=urlParams.splash){this.fileLoaded(new LocalFile(this,b,null));this.editor.graph.setEnabled(!1);this.mode=urlParams.mode;var c=urlParams.title,c=null!=c?decodeURIComponent(c):this.defaultFilename;b=this.getServiceCount(!0);isLocalStorage&&b++;var d=4>=b?2:6<b?4:3,c=new CreateDialog(this,
c,mxUtils.bind(this,function(b,c){if(null==c){this.hideDialog();var d=Editor.useLocalStorage;this.createFile(0<b.length?b:this.defaultFilename,this.getFileData(),null,null,null,!0,null,!0);Editor.useLocalStorage=d}else this.pickFolder(c,mxUtils.bind(this,function(d){this.createFile(b,this.getFileData(!0),null,c,null,!0,d)}))}),null,null,null,null,"1"==urlParams.browser,null,null,!0,d,null,null,null,this.editor.fileExtensions);this.showDialog(c.container,420,b>d?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(0<b.length?b:this.defaultFilename,this.getFileData(),null,null,null,!0,null,!0);Editor.useLocalStorage=d}else this.pickFolder(c,mxUtils.bind(this,function(d){this.createFile(b,this.getFileData(!0),null,c,null,!0,d)}))}),null,null,null,null,"1"==urlParams.browser,null,null,!0,d,null,null,null,this.editor.fileExtensions);this.showDialog(c.container,420,b>d?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:6<f?4:3,g=new CreateDialog(this,g,mxUtils.bind(this,function(b,e,f){null!=b&&0<b.length&&(/(\.pdf)$/i.test(b)?this.confirm(mxResources.get("didYouMeanToExportToPdf"),mxUtils.bind(this,
function(){this.hideDialog();this.actions.get("exportPdf").funct()}),mxUtils.bind(this,function(){f.value=b.split(".").slice(0,-1).join(".");f.focus();mxClient.IS_GC||mxClient.IS_FF||5<=document.documentMode?f.select():document.execCommand("selectAll",!1,null)}),mxResources.get("yes"),mxResources.get("no")):(this.hideDialog(),null==n&&e==App.MODE_DEVICE?null!=d&&EditorUi.nativeFileSupport?this.showSaveFilePicker(mxUtils.bind(this,function(b,e){d.fileHandle=b;d.mode=App.MODE_DEVICE;d.title=e.name;
d.desc=e;this.setMode(App.MODE_DEVICE);this.save(e.name,c)}),mxUtils.bind(this,function(b){"AbortError"!=b.name&&this.handleError(b)}),this.createFileSystemOptions(b)):(this.setMode(App.MODE_DEVICE),this.save(b,c)):"download"==e?(new LocalFile(this,null,b)).save():"_blank"==e?(window.openFile=new OpenFile(function(){window.openFile=null}),window.openFile.setData(this.getFileData(!0)),this.openLink(this.getUrl(window.location.pathname),null,!0)):n!=e?this.pickFolder(e,mxUtils.bind(this,function(d){this.createFile(b,
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: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&&"<mxGraphModel"==b.responseText.substring(0,13)&&e(b.responseText)}),b);else if(this.isLucidChartData(l))this.convertLucidChart(l,mxUtils.bind(this,function(b){e(b)}),mxUtils.bind(this,function(b){d(b)}));else{if(/(\.png)($|\?)/i.test(f)||
Editor.isPngData(l))l=Editor.extractGraphModelFromPng(c);e(l)}}catch(q){d(q)}}),d,/(\.png)($|\?)/i.test(f)||/(\.v(dx|sdx?))($|\?)/i.test(f)||/(\.vs(x|sx?))($|\?)/i.test(f),null,null,k)};App.prototype.getPeerForMode=function(b){return b==App.MODE_GOOGLE?this.drive:b==App.MODE_GITHUB?this.gitHub:b==App.MODE_GITLAB?this.gitLab:b==App.MODE_DROPBOX?this.dropbox:b==App.MODE_ONEDRIVE?this.oneDrive:b==App.MODE_TRELLO?this.trello:b==App.MODE_NOTION?this.notion:null};

20
electron/main.js vendored
View File

@ -74,7 +74,8 @@ function createMainWindow() {
webSecurity: true,
nodeIntegration: true,
nodeIntegrationInSubFrames: true,
contextIsolation: true
contextIsolation: true,
nativeWindowOpen: true
}
})
mainWindow.webContents.setUserAgent(mainWindow.webContents.getUserAgent() + " MainTaskWindow/" + process.platform + "/" + os.arch() + "/1.0");
@ -158,7 +159,8 @@ function createSubWindow(args) {
webSecurity: true,
nodeIntegration: true,
nodeIntegrationInSubFrames: true,
contextIsolation: true
contextIsolation: true,
nativeWindowOpen: true
},
}, config))
browser.on('page-title-updated', (event, title) => {
@ -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
{

View File

@ -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 {

View File

@ -50,7 +50,7 @@
<MDEditor v-if="contentDetail.type=='md'" v-model="contentDetail.content" height="100%"/>
<TEditor v-else v-model="contentDetail.content" height="100%" @editorSave="handleClick('saveBefore')"/>
</template>
<Drawio v-else-if="file.type=='drawio'" ref="myFlow" v-model="contentDetail" @saveData="handleClick('saveBefore')"/>
<Drawio v-else-if="file.type=='drawio'" ref="myFlow" v-model="contentDetail" :title="file.name" @saveData="handleClick('saveBefore')"/>
<Minder v-else-if="file.type=='mind'" ref="myMind" v-model="contentDetail" @saveData="handleClick('saveBefore')"/>
<OnlyOffice v-else-if="['word', 'excel', 'ppt'].includes(file.type)" v-model="contentDetail" :documentKey="documentKey"/>
<AceEditor v-else-if="['code', 'txt'].includes(file.type)" v-model="contentDetail.content" :ext="file.ext" @saveData="handleClick('saveBefore')"/>

View File

@ -27,7 +27,7 @@
<MDPreview v-if="contentDetail.type=='md'" :initialValue="contentDetail.content"/>
<TEditor v-else v-model="contentDetail.content" height="100%" readOnly/>
</template>
<Drawio v-else-if="file.type=='drawio'" ref="myFlow" v-model="contentDetail" readOnly/>
<Drawio v-else-if="file.type=='drawio'" ref="myFlow" v-model="contentDetail" :title="file.name" readOnly/>
<Minder v-else-if="file.type=='mind'" ref="myMind" v-model="contentDetail" readOnly/>
<OnlyOffice v-else-if="['word', 'excel', 'ppt'].includes(file.type)" v-model="contentDetail" :code="code" :documentKey="documentKey" readOnly/>
<AceEditor v-else-if="['code', 'txt'].includes(file.type)" v-model="contentDetail.content" :ext="file.ext" readOnly/>