родител
a318a17c9f
ревизия
b1c2d86d9a
@ -0,0 +1,21 @@
|
||||
/*
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
.popup {
|
||||
background-color: var(--f7-page-bg-color);
|
||||
}
|
||||
|
||||
.page[data-name="editor"] .page-content textarea#note {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
resize: none;
|
||||
border: none;
|
||||
overflow: auto;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
font-size: 1rem;
|
||||
padding: 0.75rem;
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
var save_in_progress = false;
|
||||
|
||||
function saveme(callback) {
|
||||
if (save_in_progress) {
|
||||
console.log("Warning: save already in progress, doing nothing.");
|
||||
return;
|
||||
}
|
||||
app.toast.create({
|
||||
text: '<i class="fas fa-sync fa-spin"></i> Saving...',
|
||||
closeTimeout: 2 * 60 * 1000 // two whole minutes should be enough for *any* connection.
|
||||
}).open();
|
||||
save_in_progress = true;
|
||||
sync(); // update textareas with correct content
|
||||
|
||||
var noteid = $("#note_content").data("noteid");
|
||||
var note = new Note();
|
||||
if (noteid != "") {
|
||||
note = NOTES.get(noteid);
|
||||
if (note.getSyncStatus() != "LOCAL_ONLY") {
|
||||
note.setSyncStatus("LOCAL_EDITED");
|
||||
}
|
||||
}
|
||||
note.setText($("#note_content").val());
|
||||
note.setModified();
|
||||
NOTES.set(note);
|
||||
NOTES.syncAll(function () {
|
||||
app.toast.create({
|
||||
text: '<i class="fas fa-check"></i> Note saved.',
|
||||
closeTimeout: 3000
|
||||
}).open();
|
||||
$("#orig_content").val(note.content);
|
||||
save_in_progress = false;
|
||||
if (typeof callback == "function") {
|
||||
callback();
|
||||
}
|
||||
}, function () {
|
||||
app.toast.create({
|
||||
text: '<i class="fas fa-save"></i> Note saved locally.',
|
||||
closeTimeout: 3000
|
||||
}).open();
|
||||
$("#orig_content").val(note.content);
|
||||
save_in_progress = false;
|
||||
if (typeof callback == "function") {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
document.getElementById("noteframe").contentWindow.initEditor($("#note_content").val());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text from the editor iframe and put it in the hidden textarea
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function sync() {
|
||||
$("#note_content").val(document.getElementById("noteframe").contentWindow.getMarkdown());
|
||||
}
|
||||
|
||||
function exiteditor() {
|
||||
sync();
|
||||
if ($("#note_content").val() == "" || $("#note_content").val() === $("#orig_content").val()) {
|
||||
router.back({force: true, ignoreCache: true, reload: true});
|
||||
} else {
|
||||
saveme(function () {
|
||||
router.back({force: true, ignoreCache: true, reload: true});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(window).bind('keydown', function (event) {
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
switch (String.fromCharCode(event.which).toLowerCase()) {
|
||||
case 's':
|
||||
event.preventDefault();
|
||||
sync();
|
||||
saveme();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("#noteframe").on("load", function () {
|
||||
init();
|
||||
});
|
@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "com.netsyms.NotePostApp",
|
||||
"displayName": "NotePost",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.0",
|
||||
"description": "A cross-platform client app for NotePost.",
|
||||
"author": "Netsyms Technologies",
|
||||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.6.3",
|
||||
"easymde": "^2.4.2",
|
||||
"framework7": "^3.6.5",
|
||||
"jquery": "^3.3.1",
|
||||
"marked": "^0.6.0",
|
||||
"shufflejs": "^5.2.1"
|
||||
"@fortawesome/fontawesome-free": "^5.10.2",
|
||||
"easymde": "^2.8.0",
|
||||
"framework7": "^5.1.3",
|
||||
"jquery": "^3.4.1",
|
||||
"marked": "^0.7.0",
|
||||
"shufflejs": "^5.2.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,84 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<title>Editor</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-free/css/all.min.css">
|
||||
<link rel="stylesheet" href="../node_modules/easymde/dist/easymde.min.css">
|
||||
<script src="../node_modules/easymde/dist/easymde.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0px;
|
||||
font-family: Roboto, Noto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
border: none;
|
||||
margin-top: 45px;
|
||||
height: calc(100vh - 45px);
|
||||
}
|
||||
|
||||
.editor-toolbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 99999;
|
||||
background-color: white;
|
||||
border: none;
|
||||
border-radius: 0px;
|
||||
/* Following lines are from Framework7 .elevation-2 */
|
||||
-webkit-box-shadow: 0px 3px 1px -2px rgba(0,0,0,.2),0px 2px 2px 0px rgba(0,0,0,.14),0px 1px 5px 0px rgba(0,0,0,.12);
|
||||
box-shadow: 0px 3px 1px -2px rgba(0,0,0,.2),0px 2px 2px 0px rgba(0,0,0,.14),0px 1px 5px 0px rgba(0,0,0,.12);
|
||||
/* end Framework7 code */
|
||||
}
|
||||
</style>
|
||||
|
||||
<textarea id="note"></textarea>
|
||||
|
||||
<script>
|
||||
var easymde;
|
||||
function initEditor(markdown) {
|
||||
document.getElementById('note').value = markdown;
|
||||
easymde = new EasyMDE({
|
||||
element: document.getElementById("note"),
|
||||
autoDownloadFontAwesome: false,
|
||||
autofocus: true,
|
||||
forceSync: true,
|
||||
status: false,
|
||||
spellChecker: false,
|
||||
toolbar: [
|
||||
"bold",
|
||||
"italic",
|
||||
"heading",
|
||||
"strikethrough",
|
||||
"|",
|
||||
"quote",
|
||||
"unordered-list",
|
||||
"ordered-list",
|
||||
"horizontal-rule"
|
||||
]
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', function (event) {
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
switch (String.fromCharCode(event.which).toLowerCase()) {
|
||||
case 's':
|
||||
event.preventDefault();
|
||||
window.parent.sync();
|
||||
window.parent.saveme();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getMarkdown() {
|
||||
return document.getElementById('note').value;
|
||||
}
|
||||
</script>
|
@ -1,152 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<title>Editor</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-free/css/all.min.css">
|
||||
<script src="../js/markdowneditor.js"></script>
|
||||
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0px;
|
||||
font-family: Roboto, Noto, Helvetica, Arial, sans-serif;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.editor-toolbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 2.5rem;
|
||||
z-index: 99999;
|
||||
background-color: white;
|
||||
border: none;
|
||||
border-radius: 0px;
|
||||
/* Following lines are from Framework7 .elevation-2 */
|
||||
-webkit-box-shadow: 0px 3px 1px -2px rgba(0,0,0,.2),0px 2px 2px 0px rgba(0,0,0,.14),0px 1px 5px 0px rgba(0,0,0,.12);
|
||||
box-shadow: 0px 3px 1px -2px rgba(0,0,0,.2),0px 2px 2px 0px rgba(0,0,0,.14),0px 1px 5px 0px rgba(0,0,0,.12);
|
||||
/* end Framework7 code */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
|
||||
.toolbar-button {
|
||||
cursor: pointer;
|
||||
line-height: 2.5rem;
|
||||
padding-left: 0.25rem;
|
||||
padding-right: 0.25rem;
|
||||
}
|
||||
|
||||
.toolbar-spacer {
|
||||
line-height: 2.5rem;
|
||||
padding-left: 0.25rem;
|
||||
padding-right: 0.25rem;
|
||||
color: rgba(0,0,0,.5);
|
||||
}
|
||||
|
||||
#note {
|
||||
width: 100%;
|
||||
height: calc(100% - 2rem);
|
||||
margin-top: 2.5rem;
|
||||
resize: none;
|
||||
border: none;
|
||||
overflow: auto;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
font-size: 1rem;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="editor-toolbar" id="toolbar">
|
||||
<!--<div class="toolbar-button" data-before="**" data-after="**">
|
||||
<i class="fas fa-bold fa-fw"></i>
|
||||
</div>-->
|
||||
</div>
|
||||
|
||||
<textarea id="note"></textarea>
|
||||
|
||||
<script>
|
||||
var editor;
|
||||
function initEditor(markdown) {
|
||||
document.getElementById('note').value = markdown;
|
||||
editor = new MarkdownEditor(
|
||||
document.getElementById('note'),
|
||||
document.getElementById("toolbar"),
|
||||
[
|
||||
{
|
||||
label: "Bold",
|
||||
icon: "fas fa-bold",
|
||||
before: "**",
|
||||
after: "**"
|
||||
},
|
||||
{
|
||||
label: "Italic",
|
||||
icon: "fas fa-italic",
|
||||
before: "*",
|
||||
after: "*"
|
||||
},
|
||||
{
|
||||
label: "Heading",
|
||||
icon: "fas fa-heading",
|
||||
linestart: "#",
|
||||
padspace: true,
|
||||
maximum: 6
|
||||
},
|
||||
{
|
||||
label: "Strikethrough",
|
||||
icon: "fas fa-strikethrough",
|
||||
before: "~~",
|
||||
after: "~~"
|
||||
},
|
||||
{
|
||||
spacer: true
|
||||
},
|
||||
{
|
||||
label: "Quote",
|
||||
icon: "fas fa-quote-left",
|
||||
linestart: "> ",
|
||||
padspace: false,
|
||||
maximum: 6
|
||||
},
|
||||
{
|
||||
label: "Checklist",
|
||||
icon: "fas fa-tasks",
|
||||
linestart: "- [ ]",
|
||||
padspace: true,
|
||||
maximum: 1
|
||||
},
|
||||
{
|
||||
label: "List",
|
||||
icon: "fas fa-list-ul",
|
||||
linestart: "-",
|
||||
padspace: true,
|
||||
maximum: 1
|
||||
}
|
||||
]);
|
||||
|
||||
window.addEventListener('keydown', function (event) {
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
switch (String.fromCharCode(event.which).toLowerCase()) {
|
||||
case 's':
|
||||
event.preventDefault();
|
||||
window.parent.sync();
|
||||
window.parent.saveme();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getMarkdown() {
|
||||
return document.getElementById('note').value;
|
||||
}
|
||||
</script>
|
Зареждане…
Reference in New Issue