update markon

This commit is contained in:
Xuan Sang LE 2020-05-22 18:27:14 +02:00
parent 191c905ba0
commit e810eb4a14
6 changed files with 8 additions and 6 deletions

View File

@ -1 +1 @@
(function(){var e;(e=class extends this.OS.GUI.BaseApplication{constructor(e){super("MarkOn",e)}main(){var e;return e=this.find("markarea"),this.container=this.find("mycontainer"),this.previewOn=!1,this.args&&this.args.length>0?this.currfile=this.args[0].path.asFileHandle():this.currfile="Untitled".asFileHandle(),this.editormux=!1,this.editor=new SimpleMDE({element:e,autofocus:!0,tabSize:4,indentWithTabs:!0,toolbar:["bold","italic","heading","|","quote","code","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|",{name:"preview",className:"fa fa-eye no-disable",action:e=>(this.previewOn=!this.previewOn,SimpleMDE.togglePreview(e))}]}),this.editor.codemirror.on("change",()=>{if(!this.editormux)return!1===this.currfile.dirty?(this.currfile.dirty=!0,this.scheme.set("apptitle",this.currfile.basename+"*")):void 0}),this.on("hboxchange",e=>this.resizeContent()),this.bindKey("ALT-N",()=>this.actionFile(this.name+"-New")),this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.resizeContent(),this.open(this.currfile)}resizeContent(){var e,t,i,s,a;return t=$(this.container).children(),s=$(this.scheme).find(".afx-window-top")[0],a=t[1],i=t[4],e=$(this.scheme).height()-$(s).height()-$(a).height()-$(i).height()-40,$(t[2]).css("height",e+"px")}open(e){if("Untitled"!==e.path)return e.dirty=!1,e.read().then(t=>(this.currfile=e,this.editormux=!0,this.editor.value(t),this.scheme.set("apptitle",""+this.currfile.basename),this.editormux=!1)).catch(t=>this.error(__("Unable to open: {0}",e.path),t))}save(e){return e.write("text/plain").then(t=>t.error?this.error(__("Error saving file {0}: {1}",e.basename,t.error)):(e.dirty=!1,e.text=e.basename,this.scheme.set("apptitle",""+this.currfile.basename))).catch(t=>this.error(__("Unable to save file: {0}",e.path),t))}menu(){return[{text:"__(File)",child:[{text:"__(New)",dataid:this.name+"-New",shortcut:"A-N"},{text:"__(Open)",dataid:this.name+"-Open",shortcut:"A-O"},{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:e=>this.actionFile(e.data.item.get("data").dataid)}]}actionFile(e){var t;switch(t=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.currfile.setPath(`${t.path}/${e.name}`),this.save(this.currfile)}),e){case this.name+"-Open":return this.openDialog("FileDialog",{title:__("Open file")}).then(e=>this.open(e.file.path.asFileHandle()));case this.name+"-Save":return this.currfile.cache=this.editor.value(),this.currfile.basename?this.save(this.currfile):t();case this.name+"-Saveas":return this.currfile.cache=this.editor.value(),t();case this.name+"-New":return this.currfile="Untitled".asFileHandle(),this.currfile.cache="",this.editor.value("")}}cleanup(e){if(this.currfile.dirty)return e.preventDefault(),this.openDialog("YesNoDialog",e=>{if(e)return this.currfile.dirty=!1,this.quit()},__("Quit"),{text:__("Quit without saving ?")})}}).dependencies=["os://scripts/mde/simplemde.min.js","os://scripts/mde/simplemde.min.css"],this.OS.register("MarkOn",e)}).call(this);
(function(){var e;(e=class extends this.OS.GUI.BaseApplication{constructor(e){super("MarkOn",e)}main(){var e;return e=this.find("markarea"),this.container=this.find("mycontainer"),this.previewOn=!1,this.args&&this.args.length>0?this.currfile=this.args[0].path.asFileHandle():this.currfile="Untitled".asFileHandle(),this.editormux=!1,this.editor=new SimpleMDE({element:e,autofocus:!0,tabSize:4,indentWithTabs:!0,toolbar:["bold","italic","heading","|","quote","code","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|",{name:"preview",className:"fa fa-eye no-disable",action:e=>(this.previewOn=!this.previewOn,SimpleMDE.togglePreview(e))}]}),this.editor.codemirror.on("change",()=>{if(!this.editormux)return!1===this.currfile.dirty?(this.currfile.dirty=!0,this.scheme.set("apptitle",this.currfile.basename+"*")):void 0}),this.on("hboxchange",e=>this.resizeContent()),this.bindKey("ALT-N",()=>this.actionFile(this.name+"-New")),this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.resizeContent(),this.open(this.currfile)}resizeContent(){var e,t,i,s,a;return t=$(this.container).children(),s=$(this.scheme).find(".afx-window-top")[0],a=t[1],i=t[4],e=$(this.scheme).height()-$(s).height()-$(a).height()-$(i).height()-40,$(t[2]).css("height",e+"px")}open(e){if("Untitled"!==e.path)return e.dirty=!1,e.read().then(t=>(this.currfile=e,this.editormux=!0,this.editor.value(t),this.scheme.set("apptitle",""+this.currfile.basename),this.editormux=!1)).catch(t=>this.error(__("Unable to open: {0}",e.path),t))}save(e){return e.write("text/plain").then(t=>t.error?this.error(__("Error saving file {0}: {1}",e.basename,t.error)):(e.dirty=!1,e.text=e.basename,this.scheme.set("apptitle",""+this.currfile.basename))).catch(t=>this.error(__("Unable to save file: {0}",e.path),t))}menu(){return[{text:"__(File)",child:[{text:"__(New)",dataid:this.name+"-New",shortcut:"A-N"},{text:"__(Open)",dataid:this.name+"-Open",shortcut:"A-O"},{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:e=>this.actionFile(e.data.item.get("data").dataid)}]}actionFile(e){var t;switch(t=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.currfile.setPath(`${t.path}/${e.name}`),this.save(this.currfile)}),e){case this.name+"-Open":return this.openDialog("FileDialog",{title:__("Open file")}).then(e=>this.open(e.file.path.asFileHandle()));case this.name+"-Save":return this.currfile.cache=this.editor.value(),this.currfile.basename?this.save(this.currfile):t();case this.name+"-Saveas":return this.currfile.cache=this.editor.value(),t();case this.name+"-New":return this.currfile="Untitled".asFileHandle(),this.currfile.cache="",this.editor.value("")}}cleanup(e){if(this.currfile.dirty)return e.preventDefault(),this.openDialog("YesNoDialog",{title:__("Quit"),text:__("Quit without saving ?")}).then(e=>{if(e)return this.currfile.dirty=!1,this.quit()})}}).dependencies=["os://scripts/mde/simplemde.min.js","os://scripts/mde/simplemde.min.css"],this.OS.register("MarkOn",e)}).call(this);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.2-a",
"version":"0.0.3-a",
"category":"Utils",
"iconclass":"fa fa-leanpub",
"mimes":["text/.*"]

Binary file not shown.

View File

@ -150,11 +150,13 @@ class MarkOn extends this.OS.GUI.BaseApplication
cleanup: (evt) ->
return unless @currfile.dirty
evt.preventDefault()
@.openDialog "YesNoDialog", (d) =>
@.openDialog("YesNoDialog", {
title: __("Quit"),
text: __("Quit without saving ?")
}).then (d) =>
if d
@currfile.dirty = false
@quit()
, __("Quit"), { text: __("Quit without saving ?") }
MarkOn.dependencies = [
"os://scripts/mde/simplemde.min.js",

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.2-a",
"version":"0.0.3-a",
"category":"Utils",
"iconclass":"fa fa-leanpub",
"mimes":["text/.*"]

View File

@ -32,7 +32,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/README.md",
"category": "Utils",
"author": "Xuan Sang LE",
"version": "0.0.2-a",
"version": "0.0.3-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/build/release/MarkOn.zip"
},
{