From c32f985ec45e2e56babbf017a90e9b9142280e09 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 7 Jan 2019 21:34:24 -0700 Subject: [PATCH] Add editor page --- www/css/editor.css | 13 +++++++++ www/index.html | 3 +++ www/js/Notes.class.js | 12 ++++++--- www/js/home.js | 12 +++++++++ www/package.json | 1 + www/pages/editnote.html | 58 +++++++++++++++++++++++++++++++++++++++++ www/routes.js | 6 ++--- www/yarn.lock | 31 ++++++++++++++++++++++ 8 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 www/css/editor.css create mode 100644 www/pages/editnote.html diff --git a/www/css/editor.css b/www/css/editor.css new file mode 100644 index 0000000..f23ac0e --- /dev/null +++ b/www/css/editor.css @@ -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; +} \ No newline at end of file diff --git a/www/index.html b/www/index.html index 5f86239..5b3900b 100644 --- a/www/index.html +++ b/www/index.html @@ -10,6 +10,8 @@ + + NotePost @@ -26,6 +28,7 @@ + diff --git a/www/js/Notes.class.js b/www/js/Notes.class.js index b470bb8..2e354e4 100644 --- a/www/js/Notes.class.js +++ b/www/js/Notes.class.js @@ -40,7 +40,6 @@ Notes.prototype.add = function (note, callback) { } Notes.prototype.fix = function (note) { - console.log("Fixing note " + note.id); // Set background color if (typeof note.color !== 'string') { note.color = "FFF59D"; @@ -50,9 +49,6 @@ Notes.prototype.fix = function (note) { var r = parseInt(note.color.substring(0, 2), 16); var g = parseInt(note.color.substring(2, 4), 16); var b = parseInt(note.color.substring(4, 6), 16); - console.log(r); - console.log(g); - console.log(b); var contrast = Math.sqrt( r * r * 0.241 + @@ -66,6 +62,14 @@ Notes.prototype.fix = function (note) { 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 if (typeof note.html !== 'string') { note.html = marked(note.content); diff --git a/www/js/home.js b/www/js/home.js index 3be6264..7b5cdba 100644 --- a/www/js/home.js +++ b/www/js/home.js @@ -29,6 +29,14 @@ $(".view-main").on("ptr:refresh", ".ptr-content", function () { }); function editNote(id) { + var note = notes.get(id); + router.navigate("/editnote", { + context: { + noteid: id, + content: note.content, + notetitle: note.title, + } + }); console.log("Editing " + id); } @@ -46,18 +54,22 @@ function deleteNote(id) { $("#app").on("click", ".edit-note-btn", function () { editNote($(this).data("note")); + app.popover.close(); }); $("#app").on("click", ".favorite-note-btn", function () { favoriteNote($(this).data("note")); + app.popover.close(); }); $("#app").on("click", ".listify-note-btn", function () { makeList($(this).data("note")); + app.popover.close(); }); $("#app").on("click", ".delete-note-btn", function () { deleteNote($(this).data("note")); + app.popover.close(); }); function openNoteActionMenu(notecard) { diff --git a/www/package.json b/www/package.json index 40e4aaa..768d010 100644 --- a/www/package.json +++ b/www/package.json @@ -7,6 +7,7 @@ "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" diff --git a/www/pages/editnote.html b/www/pages/editnote.html new file mode 100644 index 0000000..b4f6efa --- /dev/null +++ b/www/pages/editnote.html @@ -0,0 +1,58 @@ + +
+ + + +
+ + + +
+ + + +
\ No newline at end of file diff --git a/www/routes.js b/www/routes.js index 9f075ee..f238c45 100644 --- a/www/routes.js +++ b/www/routes.js @@ -17,8 +17,8 @@ var routes = [ name: 'credits' }, { - path: '/loaderror', - url: './pages/loaderror.html', - name: 'loaderror' + path: '/editnote', + templateUrl: './pages/editnote.html', + name: 'editnote' }, ]; \ No newline at end of file diff --git a/www/yarn.lock b/www/yarn.lock index f3580ac..12de718 100644 --- a/www/yarn.lock +++ b/www/yarn.lock @@ -7,6 +7,18 @@ resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.6.3.tgz#61c122c420d7a91613f393d6a06e5a4c6ae6abf3" 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: version "2.1.2" resolved "https://registry.yarnpkg.com/dom7/-/dom7-2.1.2.tgz#a914070c0abe8465384997a9c4f34475f67f75bd" @@ -14,6 +26,15 @@ dom7@^2.1.2: dependencies: 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: version "3.6.5" 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" 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: version "0.6.0" resolved "https://registry.yarnpkg.com/marked/-/marked-0.6.0.tgz#a18d01cfdcf8d15c3c455b71c8329e5e0f01faa1" @@ -48,3 +74,8 @@ template7@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/template7/-/template7-1.4.0.tgz#d400af49ea56fc08cc835a20e6167a26b288fb1b" 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=