mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-08-28 06:42:35 +02:00
move some optional packages to new repository
This commit is contained in:
3
MarkOn/README.md
Normal file
3
MarkOn/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# MarkOn markdown editor
|
||||
|
||||
markdown editor for antOS
|
3
MarkOn/build/debug/README.md
Normal file
3
MarkOn/build/debug/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# MarkOn markdown editor
|
||||
|
||||
markdown editor for antOS
|
4
MarkOn/build/debug/main.css
Normal file
4
MarkOn/build/debug/main.css
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
afx-app-window[data-id ='markon-win'] div.editor-toolbar{
|
||||
background-color: white;
|
||||
}
|
242
MarkOn/build/debug/main.js
Normal file
242
MarkOn/build/debug/main.js
Normal file
@@ -0,0 +1,242 @@
|
||||
(function() {
|
||||
void 0;
|
||||
var MarkOn;
|
||||
|
||||
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
|
||||
|
||||
// AnTOS Web desktop is is licensed under the GNU General Public
|
||||
// License v3.0, see the LICENCE file for more information
|
||||
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of
|
||||
// the License, or (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
//along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
MarkOn = class MarkOn extends this.OS.GUI.BaseApplication {
|
||||
constructor(args) {
|
||||
super("MarkOn", args);
|
||||
}
|
||||
|
||||
main() {
|
||||
var markarea;
|
||||
markarea = this.find("markarea");
|
||||
this.container = this.find("mycontainer");
|
||||
this.previewOn = false;
|
||||
if (this.args && this.args.length > 0) {
|
||||
this.currfile = this.args[0].path.asFileHandle();
|
||||
} else {
|
||||
this.currfile = "Untitled".asFileHandle();
|
||||
}
|
||||
this.editormux = false;
|
||||
this.editor = new SimpleMDE({
|
||||
element: markarea,
|
||||
autofocus: true,
|
||||
tabSize: 4,
|
||||
indentWithTabs: true,
|
||||
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;
|
||||
return SimpleMDE.togglePreview(e);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
//if(self.previewOn) toggle the highlight
|
||||
//{
|
||||
// var container = self._scheme.find(self,"Text")
|
||||
// .$element.getElementsByClassName("editor-preview");
|
||||
// if(container.length == 0) return;
|
||||
// var codes = container[0].getElementsByTagName('pre');
|
||||
// codes.forEach(function(el){
|
||||
// hljs.highlightBlock(el);
|
||||
// });
|
||||
// //console.log(code);
|
||||
//}
|
||||
this.editor.codemirror.on("change", () => {
|
||||
if (this.editormux) {
|
||||
return;
|
||||
}
|
||||
if (this.currfile.dirty === false) {
|
||||
this.currfile.dirty = true;
|
||||
return this.scheme.set("apptitle", `${this.currfile.basename}*`);
|
||||
}
|
||||
});
|
||||
this.on("hboxchange", (e) => {
|
||||
return this.resizeContent();
|
||||
});
|
||||
this.bindKey("ALT-N", () => {
|
||||
return this.actionFile(`${this.name}-New`);
|
||||
});
|
||||
this.bindKey("ALT-O", () => {
|
||||
return this.actionFile(`${this.name}-Open`);
|
||||
});
|
||||
this.bindKey("CTRL-S", () => {
|
||||
return this.actionFile(`${this.name}-Save`);
|
||||
});
|
||||
this.bindKey("ALT-W", () => {
|
||||
return this.actionFile(`${this.name}-Saveas`);
|
||||
});
|
||||
this.resizeContent();
|
||||
return this.open(this.currfile);
|
||||
}
|
||||
|
||||
resizeContent() {
|
||||
var cheight, children, statusbar, titlebar, toolbar;
|
||||
children = ($(this.container)).children();
|
||||
titlebar = (($(this.scheme)).find(".afx-window-top"))[0];
|
||||
toolbar = children[1];
|
||||
statusbar = children[4];
|
||||
cheight = ($(this.scheme)).height() - ($(titlebar)).height() - ($(toolbar)).height() - ($(statusbar)).height() - 40;
|
||||
return ($(children[2])).css("height", cheight + "px");
|
||||
}
|
||||
|
||||
open(file) {
|
||||
//find table
|
||||
if (file.path === "Untitled") {
|
||||
return;
|
||||
}
|
||||
file.dirty = false;
|
||||
return file.read().then((d) => {
|
||||
this.currfile = file;
|
||||
this.editormux = true;
|
||||
this.editor.value(d);
|
||||
this.scheme.set("apptitle", `${this.currfile.basename}`);
|
||||
return this.editormux = false;
|
||||
}).catch((e) => {
|
||||
return this.error(__("Unable to open: {0}", file.path), e);
|
||||
});
|
||||
}
|
||||
|
||||
save(file) {
|
||||
return file.write("text/plain").then((d) => {
|
||||
if (d.error) {
|
||||
return this.error(__("Error saving file {0}: {1}", file.basename, d.error));
|
||||
}
|
||||
file.dirty = false;
|
||||
file.text = file.basename;
|
||||
return this.scheme.set("apptitle", `${this.currfile.basename}`);
|
||||
}).catch((e) => {
|
||||
return this.error(__("Unable to save file: {0}", file.path), e);
|
||||
});
|
||||
}
|
||||
|
||||
menu() {
|
||||
var menu;
|
||||
menu = [
|
||||
{
|
||||
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) => {
|
||||
return this.actionFile(e.data.item.get("data").dataid);
|
||||
}
|
||||
}
|
||||
];
|
||||
return menu;
|
||||
}
|
||||
|
||||
actionFile(e) {
|
||||
var saveas;
|
||||
saveas = () => {
|
||||
return this.openDialog("FileDialog", {
|
||||
title: __("Save as"),
|
||||
file: this.currfile
|
||||
}).then((f) => {
|
||||
var d;
|
||||
d = f.file.path.asFileHandle();
|
||||
if (f.file.type === "file") {
|
||||
d = d.parent();
|
||||
}
|
||||
this.currfile.setPath(`${d.path}/${f.name}`);
|
||||
return this.save(this.currfile);
|
||||
});
|
||||
};
|
||||
switch (e) {
|
||||
case `${this.name}-Open`:
|
||||
return this.openDialog("FileDialog", {
|
||||
title: __("Open file")
|
||||
}).then((f) => {
|
||||
return this.open(f.file.path.asFileHandle());
|
||||
});
|
||||
case `${this.name}-Save`:
|
||||
this.currfile.cache = this.editor.value();
|
||||
if (this.currfile.basename) {
|
||||
return this.save(this.currfile);
|
||||
}
|
||||
return saveas();
|
||||
case `${this.name}-Saveas`:
|
||||
this.currfile.cache = this.editor.value();
|
||||
return saveas();
|
||||
case `${this.name}-New`:
|
||||
this.currfile = "Untitled".asFileHandle();
|
||||
this.currfile.cache = "";
|
||||
return this.editor.value("");
|
||||
}
|
||||
}
|
||||
|
||||
cleanup(evt) {
|
||||
if (!this.currfile.dirty) {
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
return this.openDialog("YesNoDialog", (d) => {
|
||||
if (d) {
|
||||
this.currfile.dirty = false;
|
||||
return this.quit();
|
||||
}
|
||||
}, __("Quit"), {
|
||||
text: __("Quit without saving ?")
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MarkOn.dependencies = ["os://scripts/mde/simplemde.min.js", "os://scripts/mde/simplemde.min.css"];
|
||||
|
||||
this.OS.register("MarkOn", MarkOn);
|
||||
|
||||
}).call(this);
|
13
MarkOn/build/debug/package.json
Normal file
13
MarkOn/build/debug/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"MarkOn",
|
||||
"name":"Markdown editor",
|
||||
"description":"Simple markdown editor",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Utils",
|
||||
"iconclass":"fa fa-leanpub",
|
||||
"mimes":["text/.*"]
|
||||
}
|
7
MarkOn/build/debug/scheme.html
Normal file
7
MarkOn/build/debug/scheme.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<afx-app-window data-id = "markon-win" apptitle="Markon" width="600" height="450">
|
||||
<afx-hbox >
|
||||
<div data-id = "mycontainer">
|
||||
<textarea data-id="markarea" ></textarea>
|
||||
</div>
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
BIN
MarkOn/build/release/MarkOn.zip
Normal file
BIN
MarkOn/build/release/MarkOn.zip
Normal file
Binary file not shown.
164
MarkOn/main.coffee
Normal file
164
MarkOn/main.coffee
Normal file
@@ -0,0 +1,164 @@
|
||||
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
|
||||
|
||||
# AnTOS Web desktop is is licensed under the GNU General Public
|
||||
# License v3.0, see the LICENCE file for more information
|
||||
|
||||
# This program is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
#along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
class MarkOn extends this.OS.GUI.BaseApplication
|
||||
constructor: (args) ->
|
||||
super "MarkOn", args
|
||||
|
||||
main: () ->
|
||||
markarea = @find "markarea"
|
||||
@container = @find "mycontainer"
|
||||
@previewOn = false
|
||||
if @args and @args.length > 0
|
||||
@currfile = @args[0].path.asFileHandle()
|
||||
else
|
||||
@currfile = "Untitled".asFileHandle()
|
||||
@editormux = false
|
||||
@editor = new SimpleMDE
|
||||
element: markarea
|
||||
autofocus: true
|
||||
tabSize: 4
|
||||
indentWithTabs: true
|
||||
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) =>
|
||||
@previewOn = !@previewOn
|
||||
SimpleMDE.togglePreview e
|
||||
#if(self.previewOn) toggle the highlight
|
||||
#{
|
||||
# var container = self._scheme.find(self,"Text")
|
||||
# .$element.getElementsByClassName("editor-preview");
|
||||
# if(container.length == 0) return;
|
||||
# var codes = container[0].getElementsByTagName('pre');
|
||||
# codes.forEach(function(el){
|
||||
# hljs.highlightBlock(el);
|
||||
# });
|
||||
# //console.log(code);
|
||||
#}
|
||||
}
|
||||
]
|
||||
|
||||
@editor.codemirror.on "change", () =>
|
||||
return if @editormux
|
||||
if @currfile.dirty is false
|
||||
@currfile.dirty = true
|
||||
@scheme.set "apptitle", "#{@currfile.basename}*"
|
||||
@on "hboxchange", (e) => @resizeContent()
|
||||
@bindKey "ALT-N", () => @actionFile "#{@name}-New"
|
||||
@bindKey "ALT-O", () => @actionFile "#{@name}-Open"
|
||||
@bindKey "CTRL-S", () => @actionFile "#{@name}-Save"
|
||||
@bindKey "ALT-W", () => @actionFile "#{@name}-Saveas"
|
||||
@resizeContent()
|
||||
@open @currfile
|
||||
|
||||
resizeContent: () ->
|
||||
children = ($ @container).children()
|
||||
titlebar = (($ @scheme).find ".afx-window-top")[0]
|
||||
toolbar = children[1]
|
||||
statusbar = children[4]
|
||||
cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 40
|
||||
($ children[2]).css("height", cheight + "px")
|
||||
|
||||
open: (file) ->
|
||||
#find table
|
||||
return if file.path is "Untitled"
|
||||
file.dirty = false
|
||||
file.read()
|
||||
.then (d) =>
|
||||
@currfile = file
|
||||
@editormux = true
|
||||
@editor.value d
|
||||
@scheme.set "apptitle", "#{@currfile.basename}"
|
||||
@editormux = false
|
||||
.catch (e) => @error __("Unable to open: {0}", file.path), e
|
||||
|
||||
|
||||
save: (file) ->
|
||||
file.write("text/plain")
|
||||
.then (d) =>
|
||||
return @error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
|
||||
file.dirty = false
|
||||
file.text = file.basename
|
||||
@scheme.set "apptitle", "#{@currfile.basename}"
|
||||
.catch (e) => @error __("Unable to save file: {0}", file.path), e
|
||||
|
||||
menu: () ->
|
||||
menu = [{
|
||||
text: "__(File)",
|
||||
child: [
|
||||
{ text: "__(New)", dataid: "#{@name}-New", shortcut: "A-N" },
|
||||
{ text: "__(Open)", dataid: "#{@name}-Open", shortcut: "A-O" },
|
||||
{ text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" },
|
||||
{ text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" }
|
||||
],
|
||||
onchildselect: (e) => @actionFile e.data.item.get("data").dataid
|
||||
}]
|
||||
menu
|
||||
|
||||
actionFile: (e) ->
|
||||
saveas = () =>
|
||||
@openDialog("FileDialog", {
|
||||
title: __("Save as"),
|
||||
file: @currfile
|
||||
})
|
||||
.then (f) =>
|
||||
d = f.file.path.asFileHandle()
|
||||
d = d.parent() if f.file.type is "file"
|
||||
@currfile.setPath "#{d.path}/#{f.name}"
|
||||
@save @currfile
|
||||
|
||||
switch e
|
||||
when "#{@name}-Open"
|
||||
@openDialog("FileDialog", {
|
||||
title: __("Open file")
|
||||
})
|
||||
.then (f) =>
|
||||
@open f.file.path.asFileHandle()
|
||||
|
||||
when "#{@name}-Save"
|
||||
@currfile.cache = @editor.value()
|
||||
return @save @currfile if @currfile.basename
|
||||
saveas()
|
||||
when "#{@name}-Saveas"
|
||||
@currfile.cache = @editor.value()
|
||||
saveas()
|
||||
when "#{@name}-New"
|
||||
@currfile = "Untitled".asFileHandle()
|
||||
@currfile.cache = ""
|
||||
@editor.value("")
|
||||
|
||||
cleanup: (evt) ->
|
||||
return unless @currfile.dirty
|
||||
evt.preventDefault()
|
||||
@.openDialog "YesNoDialog", (d) =>
|
||||
if d
|
||||
@currfile.dirty = false
|
||||
@quit()
|
||||
, __("Quit"), { text: __("Quit without saving ?") }
|
||||
|
||||
MarkOn.dependencies = [
|
||||
"os://scripts/mde/simplemde.min.js",
|
||||
"os://scripts/mde/simplemde.min.css"
|
||||
]
|
||||
|
||||
this.OS.register "MarkOn", MarkOn
|
3
MarkOn/main.css
Normal file
3
MarkOn/main.css
Normal file
@@ -0,0 +1,3 @@
|
||||
afx-app-window[data-id ='markon-win'] div.editor-toolbar{
|
||||
background-color: white;
|
||||
}
|
13
MarkOn/package.json
Normal file
13
MarkOn/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"MarkOn",
|
||||
"name":"Markdown editor",
|
||||
"description":"Simple markdown editor",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Utils",
|
||||
"iconclass":"fa fa-leanpub",
|
||||
"mimes":["text/.*"]
|
||||
}
|
8
MarkOn/project.json
Normal file
8
MarkOn/project.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "MarkOn",
|
||||
"root": "home://workspace/antosdk-apps/MarkOn",
|
||||
"css": ["main.css"],
|
||||
"javascripts": [],
|
||||
"coffees": ["main.coffee"],
|
||||
"copies": ["scheme.html", "package.json", "README.md"]
|
||||
}
|
7
MarkOn/scheme.html
Normal file
7
MarkOn/scheme.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<afx-app-window data-id = "markon-win" apptitle="Markon" width="600" height="450">
|
||||
<afx-hbox >
|
||||
<div data-id = "mycontainer">
|
||||
<textarea data-id="markarea" ></textarea>
|
||||
</div>
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
Reference in New Issue
Block a user