Add editor page
This commit is contained in:
parent
9d0ab3f38d
commit
c32f985ec4
13
www/css/editor.css
Normal file
13
www/css/editor.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
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/.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
Created on : Jan 7, 2019, 9:30:35 PM
|
||||||
|
Author : Skylar Ittner
|
||||||
|
*/
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
@ -10,6 +10,8 @@
|
|||||||
<link rel="stylesheet" href="fonts/material.css">
|
<link rel="stylesheet" href="fonts/material.css">
|
||||||
<link rel="stylesheet" href="css/notecards.css">
|
<link rel="stylesheet" href="css/notecards.css">
|
||||||
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css">
|
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css">
|
||||||
|
<link rel="stylesheet" href="node_modules/easymde/dist/easymde.min.css">
|
||||||
|
<link rel="stylesheet" href="css/editor.css">
|
||||||
|
|
||||||
<title>NotePost</title>
|
<title>NotePost</title>
|
||||||
|
|
||||||
@ -26,6 +28,7 @@
|
|||||||
<script src="node_modules/jquery/dist/jquery.min.js"></script>
|
<script src="node_modules/jquery/dist/jquery.min.js"></script>
|
||||||
<script src="node_modules/framework7/js/framework7.min.js"></script>
|
<script src="node_modules/framework7/js/framework7.min.js"></script>
|
||||||
<script src="node_modules/marked/marked.min.js"></script>
|
<script src="node_modules/marked/marked.min.js"></script>
|
||||||
|
<script src="node_modules/easymde/dist/easymde.min.js"></script>
|
||||||
|
|
||||||
<script src="js/Notes.class.js"></script>
|
<script src="js/Notes.class.js"></script>
|
||||||
<script src="js/home.js"></script>
|
<script src="js/home.js"></script>
|
||||||
|
@ -40,7 +40,6 @@ Notes.prototype.add = function (note, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Notes.prototype.fix = function (note) {
|
Notes.prototype.fix = function (note) {
|
||||||
console.log("Fixing note " + note.id);
|
|
||||||
// Set background color
|
// Set background color
|
||||||
if (typeof note.color !== 'string') {
|
if (typeof note.color !== 'string') {
|
||||||
note.color = "FFF59D";
|
note.color = "FFF59D";
|
||||||
@ -50,9 +49,6 @@ Notes.prototype.fix = function (note) {
|
|||||||
var r = parseInt(note.color.substring(0, 2), 16);
|
var r = parseInt(note.color.substring(0, 2), 16);
|
||||||
var g = parseInt(note.color.substring(2, 4), 16);
|
var g = parseInt(note.color.substring(2, 4), 16);
|
||||||
var b = parseInt(note.color.substring(4, 6), 16);
|
var b = parseInt(note.color.substring(4, 6), 16);
|
||||||
console.log(r);
|
|
||||||
console.log(g);
|
|
||||||
console.log(b);
|
|
||||||
|
|
||||||
var contrast = Math.sqrt(
|
var contrast = Math.sqrt(
|
||||||
r * r * 0.241 +
|
r * r * 0.241 +
|
||||||
@ -66,6 +62,14 @@ Notes.prototype.fix = function (note) {
|
|||||||
note.textcolor = "FFFFFF";
|
note.textcolor = "FFFFFF";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Just in case
|
||||||
|
if (typeof note.content !== 'string') {
|
||||||
|
note.content = "";
|
||||||
|
}
|
||||||
|
// Set title
|
||||||
|
if (typeof note.title !== 'string') {
|
||||||
|
note.title = note.content.split('\n')[0].replace(/[#\-]+/gi, "").trim();
|
||||||
|
}
|
||||||
// Render Markdown to HTML
|
// Render Markdown to HTML
|
||||||
if (typeof note.html !== 'string') {
|
if (typeof note.html !== 'string') {
|
||||||
note.html = marked(note.content);
|
note.html = marked(note.content);
|
||||||
|
@ -29,6 +29,14 @@ $(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function editNote(id) {
|
function editNote(id) {
|
||||||
|
var note = notes.get(id);
|
||||||
|
router.navigate("/editnote", {
|
||||||
|
context: {
|
||||||
|
noteid: id,
|
||||||
|
content: note.content,
|
||||||
|
notetitle: note.title,
|
||||||
|
}
|
||||||
|
});
|
||||||
console.log("Editing " + id);
|
console.log("Editing " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,18 +54,22 @@ function deleteNote(id) {
|
|||||||
|
|
||||||
$("#app").on("click", ".edit-note-btn", function () {
|
$("#app").on("click", ".edit-note-btn", function () {
|
||||||
editNote($(this).data("note"));
|
editNote($(this).data("note"));
|
||||||
|
app.popover.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#app").on("click", ".favorite-note-btn", function () {
|
$("#app").on("click", ".favorite-note-btn", function () {
|
||||||
favoriteNote($(this).data("note"));
|
favoriteNote($(this).data("note"));
|
||||||
|
app.popover.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#app").on("click", ".listify-note-btn", function () {
|
$("#app").on("click", ".listify-note-btn", function () {
|
||||||
makeList($(this).data("note"));
|
makeList($(this).data("note"));
|
||||||
|
app.popover.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#app").on("click", ".delete-note-btn", function () {
|
$("#app").on("click", ".delete-note-btn", function () {
|
||||||
deleteNote($(this).data("note"));
|
deleteNote($(this).data("note"));
|
||||||
|
app.popover.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
function openNoteActionMenu(notecard) {
|
function openNoteActionMenu(notecard) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^5.6.3",
|
"@fortawesome/fontawesome-free": "^5.6.3",
|
||||||
|
"easymde": "^2.4.2",
|
||||||
"framework7": "^3.6.5",
|
"framework7": "^3.6.5",
|
||||||
"jquery": "^3.3.1",
|
"jquery": "^3.3.1",
|
||||||
"marked": "^0.6.0"
|
"marked": "^0.6.0"
|
||||||
|
58
www/pages/editnote.html
Normal file
58
www/pages/editnote.html
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<!-- 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/. -->
|
||||||
|
<div class="page" data-name="editnote">
|
||||||
|
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<div class="left">
|
||||||
|
<a href="#" class="link icon-only back">
|
||||||
|
<i class="icon icon-back"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
{{if notetitle}}
|
||||||
|
{{notetitle}}
|
||||||
|
{{else}}
|
||||||
|
New note
|
||||||
|
{{/if}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page-content ptr-content">
|
||||||
|
|
||||||
|
<textarea id="note_content" data-noteid="{{noteid}}">{{content}}</textarea>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var easymde = new EasyMDE({
|
||||||
|
element: $("#note_content")[0],
|
||||||
|
autoDownloadFontAwesome: false,
|
||||||
|
autofocus: true,
|
||||||
|
forceSync: true,
|
||||||
|
status: false,
|
||||||
|
toolbar: [
|
||||||
|
{
|
||||||
|
name: "save",
|
||||||
|
action: function saveNote(editor) {
|
||||||
|
$("#noteform").submit();
|
||||||
|
},
|
||||||
|
className: "fas fa-save",
|
||||||
|
title: "Save",
|
||||||
|
},
|
||||||
|
"|",
|
||||||
|
"bold",
|
||||||
|
"italic",
|
||||||
|
"heading",
|
||||||
|
"|",
|
||||||
|
"quote",
|
||||||
|
"unordered-list",
|
||||||
|
"ordered-list",
|
||||||
|
"horizontal-rule"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</div>
|
@ -17,8 +17,8 @@ var routes = [
|
|||||||
name: 'credits'
|
name: 'credits'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/loaderror',
|
path: '/editnote',
|
||||||
url: './pages/loaderror.html',
|
templateUrl: './pages/editnote.html',
|
||||||
name: 'loaderror'
|
name: 'editnote'
|
||||||
},
|
},
|
||||||
];
|
];
|
@ -7,6 +7,18 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.6.3.tgz#61c122c420d7a91613f393d6a06e5a4c6ae6abf3"
|
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.6.3.tgz#61c122c420d7a91613f393d6a06e5a4c6ae6abf3"
|
||||||
integrity sha512-s5PLdI9NYgjBvfrv6rhirPHlAHWx+Sfo/IjsAeiXYfmemC/GSjwsyz1wLnGPazbLPXWfk62ks980o9AmsxYUEQ==
|
integrity sha512-s5PLdI9NYgjBvfrv6rhirPHlAHWx+Sfo/IjsAeiXYfmemC/GSjwsyz1wLnGPazbLPXWfk62ks980o9AmsxYUEQ==
|
||||||
|
|
||||||
|
codemirror-spell-checker@1.1.2:
|
||||||
|
version "1.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/codemirror-spell-checker/-/codemirror-spell-checker-1.1.2.tgz#1c660f9089483ccb5113b9ba9ca19c3f4993371e"
|
||||||
|
integrity sha1-HGYPkIlIPMtRE7m6nKGcP0mTNx4=
|
||||||
|
dependencies:
|
||||||
|
typo-js "*"
|
||||||
|
|
||||||
|
codemirror@^5.41.0:
|
||||||
|
version "5.42.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.42.2.tgz#801ab715a7a7e1c7ed4162b78e9d8138b98de8f0"
|
||||||
|
integrity sha512-Tkv6im39VuhduFMsDA3MlXcC/kKas3Z0PI1/8N88QvFQbtOeiiwnfFJE4juGyC8/a4sb1BSxQlzsil8XLQdxRw==
|
||||||
|
|
||||||
dom7@^2.1.2:
|
dom7@^2.1.2:
|
||||||
version "2.1.2"
|
version "2.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/dom7/-/dom7-2.1.2.tgz#a914070c0abe8465384997a9c4f34475f67f75bd"
|
resolved "https://registry.yarnpkg.com/dom7/-/dom7-2.1.2.tgz#a914070c0abe8465384997a9c4f34475f67f75bd"
|
||||||
@ -14,6 +26,15 @@ dom7@^2.1.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ssr-window "^1.0.1"
|
ssr-window "^1.0.1"
|
||||||
|
|
||||||
|
easymde@^2.4.2:
|
||||||
|
version "2.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/easymde/-/easymde-2.4.2.tgz#c91f79893b6fa6f5cb4184c234fc49e1c2e51884"
|
||||||
|
integrity sha512-LQ+kt98qKBUiykFG8e4E+UJezIowpeku5vowdPeVMKLtEV8sU7xxPxqS3GgDZWwhO3HghEngNa70eJInSMHh6A==
|
||||||
|
dependencies:
|
||||||
|
codemirror "^5.41.0"
|
||||||
|
codemirror-spell-checker "1.1.2"
|
||||||
|
marked "^0.5.1"
|
||||||
|
|
||||||
framework7@^3.6.5:
|
framework7@^3.6.5:
|
||||||
version "3.6.5"
|
version "3.6.5"
|
||||||
resolved "https://registry.yarnpkg.com/framework7/-/framework7-3.6.5.tgz#dbd3c044ad36df73a9ed57cde5467e3c7c0d137e"
|
resolved "https://registry.yarnpkg.com/framework7/-/framework7-3.6.5.tgz#dbd3c044ad36df73a9ed57cde5467e3c7c0d137e"
|
||||||
@ -29,6 +50,11 @@ jquery@^3.3.1:
|
|||||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
|
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
|
||||||
integrity sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==
|
integrity sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==
|
||||||
|
|
||||||
|
marked@^0.5.1:
|
||||||
|
version "0.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/marked/-/marked-0.5.2.tgz#3efdb27b1fd0ecec4f5aba362bddcd18120e5ba9"
|
||||||
|
integrity sha512-fdZvBa7/vSQIZCi4uuwo2N3q+7jJURpMVCcbaX0S1Mg65WZ5ilXvC67MviJAsdjqqgD+CEq4RKo5AYGgINkVAA==
|
||||||
|
|
||||||
marked@^0.6.0:
|
marked@^0.6.0:
|
||||||
version "0.6.0"
|
version "0.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/marked/-/marked-0.6.0.tgz#a18d01cfdcf8d15c3c455b71c8329e5e0f01faa1"
|
resolved "https://registry.yarnpkg.com/marked/-/marked-0.6.0.tgz#a18d01cfdcf8d15c3c455b71c8329e5e0f01faa1"
|
||||||
@ -48,3 +74,8 @@ template7@^1.4.0:
|
|||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/template7/-/template7-1.4.0.tgz#d400af49ea56fc08cc835a20e6167a26b288fb1b"
|
resolved "https://registry.yarnpkg.com/template7/-/template7-1.4.0.tgz#d400af49ea56fc08cc835a20e6167a26b288fb1b"
|
||||||
integrity sha512-NMJWbKIoowHixUYIHq+DLvcBM47t/oZ/xfvBbYuMusjjS6BUjC02+gLWctntJuTTiEqILfefBNCXbfp/EMt/zQ==
|
integrity sha512-NMJWbKIoowHixUYIHq+DLvcBM47t/oZ/xfvBbYuMusjjS6BUjC02+gLWctntJuTTiEqILfefBNCXbfp/EMt/zQ==
|
||||||
|
|
||||||
|
typo-js@*:
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/typo-js/-/typo-js-1.0.3.tgz#54d8ebc7949f1a7810908b6002c6841526c99d5a"
|
||||||
|
integrity sha1-VNjrx5SfGngQkItgAsaEFSbJnVo=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user