@zklogic/draw.io
Version:
Draw.IO - Graph Editor integration in Angular-cli
1 lines • 3.23 kB
JavaScript
DropboxFile=function(t,i,e){DrawioFile.call(this,t,i),this.stat=e},mxUtils.extend(DropboxFile,DrawioFile),DropboxFile.prototype.getId=function(){return this.stat.path_display.substring(1)},DropboxFile.prototype.getHash=function(){return"D"+encodeURIComponent(this.getId())},DropboxFile.prototype.getMode=function(){return App.MODE_DROPBOX},DropboxFile.prototype.isAutosaveOptional=function(){return!0},DropboxFile.prototype.getTitle=function(){return this.stat.name},DropboxFile.prototype.isRenamable=function(){return!0},DropboxFile.prototype.getSize=function(){return this.stat.size},DropboxFile.prototype.isRevisionHistorySupported=function(){return!0},DropboxFile.prototype.getRevisions=function(t,i){var e=this.ui.dropbox.client.filesListRevisions({path:this.stat.path_lower,limit:100});e.then(mxUtils.bind(this,(function(e){try{for(var s=[],o=e.entries.length-1;o>=0;o--)mxUtils.bind(this,(function(t){s.push({modifiedDate:t.client_modified,fileSize:t.size,getXml:mxUtils.bind(this,(function(i,e){this.ui.dropbox.readFile({path:this.stat.path_lower,rev:t.rev},i,e)})),getUrl:mxUtils.bind(this,(function(i){return this.ui.getUrl(window.location.pathname+"?rev="+t.rev+"&chrome=0&nav=1&layers=1&edit=_blank"+(null!=i?"&page="+i:""))+window.location.hash}))})}))(e.entries[o]);t(s)}catch(t){i(t)}}))),e.catch((function(t){i(t)}))},DropboxFile.prototype.getLatestVersion=function(t,i){this.ui.dropbox.getFile(this.getId(),t,i)},DropboxFile.prototype.updateDescriptor=function(t){this.stat=t.stat},DropboxFile.prototype.save=function(t,i,e,s,o){this.doSave(this.getTitle(),t,i,e,s,o)},DropboxFile.prototype.saveAs=function(t,i,e){this.doSave(t,!1,i,e)},DropboxFile.prototype.doSave=function(t,i,e,s,o,n){var r=this.stat.name;this.stat.name=t,DrawioFile.prototype.save.apply(this,[null,mxUtils.bind(this,(function(){this.stat.name=r,this.saveFile(t,i,e,s,o,n)})),s,o,n])},DropboxFile.prototype.saveFile=function(t,i,e,s){if(this.isEditable())if(this.savingFile)null!=s&&s({code:App.ERROR_BUSY});else{var o=mxUtils.bind(this,(function(i){if(i)try{this.savingFileTime=new Date,this.setShadowModified(!1),this.savingFile=!0;var o=mxUtils.bind(this,(function(i){var o=this.stat.path_display.lastIndexOf("/"),n=o>1?this.stat.path_display.substring(1,o+1):null;this.ui.dropbox.saveFile(t,i,mxUtils.bind(this,(function(t){this.setModified(this.getShadowModified()),this.savingFile=!1,this.stat=t,this.contentChanged(),null!=e&&e()})),mxUtils.bind(this,(function(t){this.savingFile=!1,null!=s&&s(t)})),n)}));if(this.ui.useCanvasForExport&&/(\.png)$/i.test(this.getTitle())){var n=this.ui.getPngFileProperties(this.ui.fileNode);this.ui.getEmbeddedPng(mxUtils.bind(this,(function(t){o(this.ui.base64ToBlob(t,"image/png"))})),s,this.ui.getCurrentFile()!=this?this.getData():null,n.scale,n.border)}else o(this.getData())}catch(t){if(this.savingFile=!1,null==s)throw t;s(t)}else null!=s&&s()}));this.getTitle()==t?o(!0):this.ui.dropbox.checkExists(t,o)}else null!=e&&e()},DropboxFile.prototype.rename=function(t,i,e){this.ui.dropbox.renameFile(this,t,mxUtils.bind(this,(function(s){this.hasSameExtension(t,this.getTitle())?(this.stat=s,this.descriptorChanged(),null!=i&&i()):(this.stat=s,this.descriptorChanged(),this.save(!0,i,e))})),e)};