Fix window resize bug on Markon

This commit is contained in:
DanyLE 2023-01-04 00:08:32 +01:00
parent 2c5666e809
commit de639e6d39
8 changed files with 11 additions and 9 deletions

View File

@ -3,4 +3,5 @@
Simple Markdown editor for antOS Simple Markdown editor for antOS
## Change log ## Change log
- 0.1.1-a: Fix window resize bug
- 0.1.0-a: Use the new EasyMDE library - 0.1.0-a: Use the new EasyMDE library

View File

@ -3,4 +3,5 @@
Simple Markdown editor for antOS Simple Markdown editor for antOS
## Change log ## Change log
- 0.1.1-a: Fix window resize bug
- 0.1.0-a: Use the new EasyMDE library - 0.1.0-a: Use the new EasyMDE library

View File

@ -1 +1 @@
(function(){var e;(e=class extends this.OS.application.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 EasyMDE({element:e,autoDownloadFontAwesome:!1,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,EasyMDE.togglePreview(e))}]}),this.editor.codemirror.on("change",()=>{if(!this.editormux)return!1===this.currfile.dirty?(this.currfile.dirty=!0,this.scheme.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,a,s;return t=$(this.container).children(),a=$(this.scheme).find(".afx-window-top")[0],s=t[1],i=t[4],e=$(this.scheme).height()-$(a).height()-$(s).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.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.apptitle=""+this.currfile.basename)).catch(t=>this.error(__("Unable to save file: {0}",e.path),t))}menu(){return[{text:"__(File)",nodes:[{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.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=["pkg://SimpleMDE/main.js","pkg://SimpleMDE/main.css"],this.OS.register("MarkOn",e)}).call(this); (function(){var e;(e=class extends this.OS.application.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 EasyMDE({element:e,autoDownloadFontAwesome:!1,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,EasyMDE.togglePreview(e))}]}),this.editor.codemirror.on("change",()=>{if(!this.editormux)return!1===this.currfile.dirty?(this.currfile.dirty=!0,this.scheme.apptitle=this.currfile.basename+"*"):void 0}),this.on("resize",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,a,s;return t=$(".EasyMDEContainer",this.mycontainer).children(),a=$(this.scheme).find(".afx-window-top")[0],s=t[0],i=t[3],e=$(this.scheme).height()-$(a).height()-$(s).height()-$(i).height()-40,$(t[1]).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.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.apptitle=""+this.currfile.basename)).catch(t=>this.error(__("Unable to save file: {0}",e.path),t))}menu(){return[{text:"__(File)",nodes:[{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.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=["pkg://SimpleMDE/main.js","pkg://SimpleMDE/main.css"],this.OS.register("MarkOn",e)}).call(this);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"email": "xsang.le@gmail.com" "email": "xsang.le@gmail.com"
}, },
"version":"0.1.0-a", "version":"0.1.1-a",
"category":"Office", "category":"Office",
"iconclass":"fa fa-leanpub", "iconclass":"fa fa-leanpub",
"dependencies": ["SimpleMDE@2.18.0-r"], "dependencies": ["SimpleMDE@2.18.0-r"],

Binary file not shown.

View File

@ -64,7 +64,7 @@ class MarkOn extends this.OS.application.BaseApplication
if @currfile.dirty is false if @currfile.dirty is false
@currfile.dirty = true @currfile.dirty = true
@scheme.apptitle = "#{@currfile.basename}*" @scheme.apptitle = "#{@currfile.basename}*"
@on "hboxchange", (e) => @resizeContent() @on "resize", (e) => @resizeContent()
@bindKey "ALT-N", () => @actionFile "#{@name}-New" @bindKey "ALT-N", () => @actionFile "#{@name}-New"
@bindKey "ALT-O", () => @actionFile "#{@name}-Open" @bindKey "ALT-O", () => @actionFile "#{@name}-Open"
@bindKey "CTRL-S", () => @actionFile "#{@name}-Save" @bindKey "CTRL-S", () => @actionFile "#{@name}-Save"
@ -73,12 +73,12 @@ class MarkOn extends this.OS.application.BaseApplication
@open @currfile @open @currfile
resizeContent: () -> resizeContent: () ->
children = ($ @container).children() children = ($ ".EasyMDEContainer", @mycontainer).children()
titlebar = (($ @scheme).find ".afx-window-top")[0] titlebar = (($ @scheme).find ".afx-window-top")[0]
toolbar = children[1] toolbar = children[0]
statusbar = children[4] statusbar = children[3]
cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 40 cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 40
($ children[2]).css("height", cheight + "px") ($ children[1]).css("height", cheight + "px")
open: (file) -> open: (file) ->
#find table #find table

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"email": "xsang.le@gmail.com" "email": "xsang.le@gmail.com"
}, },
"version":"0.1.0-a", "version":"0.1.1-a",
"category":"Office", "category":"Office",
"iconclass":"fa fa-leanpub", "iconclass":"fa fa-leanpub",
"dependencies": ["SimpleMDE@2.18.0-r"], "dependencies": ["SimpleMDE@2.18.0-r"],

View File

@ -315,7 +315,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/MarkOn/README.md", "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/MarkOn/README.md",
"category": "Office", "category": "Office",
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"version": "0.1.0-a", "version": "0.1.1-a",
"dependencies": ["SimpleMDE@2.18.0-r"],"mimes":["text/.*"], "dependencies": ["SimpleMDE@2.18.0-r"],"mimes":["text/.*"],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/MarkOn/build/release/MarkOn.zip" "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/MarkOn/build/release/MarkOn.zip"
}, },