Use latest EasyMDE instead of the old SimpleMDE

This commit is contained in:
DanyLE 2023-01-03 23:44:19 +01:00
parent 7171a7eb3b
commit 4a1ac8030f
21 changed files with 125 additions and 51 deletions

View File

@ -1,3 +1,6 @@
# MarkOn markdown editor
Simple Markdown editor for antOS
Simple Markdown editor for antOS
## Change log
- 0.1.0-a: Use the new EasyMDE library

View File

@ -1,3 +1,6 @@
# MarkOn markdown editor
Simple Markdown editor for antOS
Simple Markdown editor for antOS
## Change log
- 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 SimpleMDE({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,SimpleMDE.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("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);

View File

@ -6,9 +6,9 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.8-a",
"version":"0.1.0-a",
"category":"Office",
"iconclass":"fa fa-leanpub",
"dependencies": ["SimpleMDE@1.11.2-r"],
"dependencies": ["SimpleMDE@2.18.0-r"],
"mimes":["text/.*"]
}

Binary file not shown.

View File

@ -29,7 +29,7 @@ class MarkOn extends this.OS.application.BaseApplication
else
@currfile = "Untitled".asFileHandle()
@editormux = false
@editor = new SimpleMDE
@editor = new EasyMDE
element: markarea
autoDownloadFontAwesome: false
autofocus: true
@ -44,7 +44,7 @@ class MarkOn extends this.OS.application.BaseApplication
className: "fa fa-eye no-disable",
action: (e) =>
@previewOn = !@previewOn
SimpleMDE.togglePreview e
EasyMDE.togglePreview e
#if(self.previewOn) toggle the highlight
#{
# var container = self._scheme.find(self,"Text")

View File

@ -6,9 +6,9 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.8-a",
"version":"0.1.0-a",
"category":"Office",
"iconclass":"fa fa-leanpub",
"dependencies": ["SimpleMDE@1.11.2-r"],
"dependencies": ["SimpleMDE@2.18.0-r"],
"mimes":["text/.*"]
}

View File

@ -1,5 +1,5 @@
SimpleMDE - Markdown Editor library for AntOS
EasyMDE - Markdown Editor library for AntOS
A drop-in JavaScript textarea replacement for writing beautiful and understandable Markdown. The WYSIWYG-esque editor allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts. In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc. SimpleMDE is one of the first editors to feature both built-in autosaving and spell checking.
Project on Github [https://github.com/sparksuite/simplemde-markdown-editor](https://github.com/sparksuite/simplemde-markdown-editor)
Project on Github [https://easy-markdown-editor.tk/](https://easy-markdown-editor.tk/)

72
SimpleMDE/build.json Normal file
View File

@ -0,0 +1,72 @@
{
"name": "SimpleMDE",
"targets": {
"init": {
"jobs": [
{
"name": "vfs-mkdir",
"data": [
"build",
"build/debug",
"build/release"
]
}
]
},
"cat": {
"jobs": [
{
"name": "vfs-cat",
"data": {
"src": [
"home://workspace/antosdk-apps/SimpleMDE/easymde.min.js"
],
"dest": "build/debug/main.js"
}
},
{
"name": "vfs-cat",
"data": {
"src": [
"home://workspace/antosdk-apps/SimpleMDE/easymde.min.css"
],
"dest": "build/debug/main.css"
}
}
]
},
"copy": {
"jobs": [
{
"name": "vfs-cp",
"data": {
"src": [
"package.json",
"README.md"
],
"dest": "build/debug"
}
}
]
},
"release": {
"require": [
"zip"
],
"depend": [
"init",
"cat",
"copy"
],
"jobs": [
{
"name": "zip-mk",
"data": {
"src": "build/debug",
"dest": "build/release/SimpleMDE.zip"
}
}
]
}
}
}

View File

@ -1,5 +1,5 @@
SimpleMDE - Markdown Editor library for AntOS
EasyMDE - Markdown Editor library for AntOS
A drop-in JavaScript textarea replacement for writing beautiful and understandable Markdown. The WYSIWYG-esque editor allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts. In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc. SimpleMDE is one of the first editors to feature both built-in autosaving and spell checking.
Project on Github [https://github.com/sparksuite/simplemde-markdown-editor](https://github.com/sparksuite/simplemde-markdown-editor)
Project on Github [https://easy-markdown-editor.tk/](https://easy-markdown-editor.tk/)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
{
"pkgname": "SimpleMDE",
"name":"SimpleMDE library",
"name":"EasyMDE library, a fork of SimpleMDE",
"description":"SimpleMDE",
"info":{
"author": "",
"email": ""
},
"version":"1.11.2-r",
"version":"2.18.0-r",
"category":"Library",
"iconclass":"fa fa-cog",
"mimes":["none"],

View File

@ -1,3 +0,0 @@
<afx-app-window apptitle="SimpleMDE" width="500" height="400" data-id="SimpleMDE">
<afx-hbox ></afx-hbox>
</afx-app-window>

7
SimpleMDE/easymde.min.css vendored Normal file

File diff suppressed because one or more lines are too long

7
SimpleMDE/easymde.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
{
"pkgname": "SimpleMDE",
"name":"SimpleMDE library",
"name":"EasyMDE library, a fork of SimpleMDE",
"description":"SimpleMDE",
"info":{
"author": "",
"email": ""
},
"version":"1.11.2-r",
"version":"2.18.0-r",
"category":"Library",
"iconclass":"fa fa-cog",
"mimes":["none"],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -315,8 +315,8 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/MarkOn/README.md",
"category": "Office",
"author": "Xuan Sang LE",
"version": "0.0.8-a",
"dependencies": ["SimpleMDE@1.11.2-r"],"mimes":["text/.*"],
"version": "0.1.0-a",
"dependencies": ["SimpleMDE@2.18.0-r"],"mimes":["text/.*"],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/MarkOn/build/release/MarkOn.zip"
},
{
@ -401,11 +401,11 @@
},
{
"pkgname": "SimpleMDE",
"name": "SimpleMDE library",
"name": "EasyMDE library, a fork of SimpleMDE",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/SimpleMDE/README.md",
"category": "Library",
"author": "",
"version": "1.11.2-r",
"version": "2.18.0-r",
"dependencies": [],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/SimpleMDE/build/release/SimpleMDE.zip"
},