From 1266ad96df22bf38a7bd01e6840db841773e7bec Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 11 Jun 2017 21:04:04 -0400 Subject: [PATCH] various mostly smaller tweaks --- app.py | 4 +++- frontend/index.html | 34 ++++++++++++++++++++++++++-------- frontend/note.js | 17 +++++++++++++++++ frontend/style.css | 12 ++++++++++++ 4 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 frontend/style.css diff --git a/app.py b/app.py index 7dc4b8f03..b8323222e 100644 --- a/app.py +++ b/app.py @@ -76,7 +76,9 @@ class Notes(Resource): def put(self, note_id): note = request.get_json(force=True) - execute("update notes set note_text = ?, note_title = ? where note_id = ?", [note['detail']['note_text'], note['detail']['note_title'], note_id]) + now = math.floor(time.time()) + + execute("update notes set note_text = ?, note_title = ?, date_modified = ? where note_id = ?", [note['detail']['note_text'], note['detail']['note_title'], now, note_id]) delete("formatting", note_id) diff --git a/frontend/index.html b/frontend/index.html index ec8de9df1..4762a1328 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -11,17 +11,33 @@
-
+
+ + +
+
-
-
- -
+
+
+ +
-
- Nothing here right now! -
+
+

This prototype version supports basic editing, including some formatting (bold, italic, strike-through, underscore), images (just paste it into editor) and links. To edit the note, just click on title or content and you can directly modify it. Changes are saved immediatelly.

+ +

You can work with the tree using following keyboard shortcuts:

+ +
    +
  • insert - create new note on current tree level
  • +
  • shift + insert - create new sub-note
  • +
  • delete - delete current note (and it's sub-notes)
  • +
  • shift + up - move current note up in the current tree level
  • +
  • shift + down - move current note down in the current tree level
  • +
  • shift + left - move current note up in the tree hierarchy
  • +
  • shift + right - move current note down in the tree hierarchy
  • +
+
@@ -40,6 +56,8 @@ + + diff --git a/frontend/note.js b/frontend/note.js index 40dc3965d..9f5f15f39 100644 --- a/frontend/note.js +++ b/frontend/note.js @@ -9,7 +9,13 @@ let tags = { 10: "" }; +let noteChangeDisabled = false; + function noteChanged() { + if (noteChangeDisabled) { + return; + } + let note = globalNote; let contents = $('#noteDetail').summernote('code'); @@ -40,6 +46,7 @@ $(document).ready(function() { $('#noteDetail').summernote({ airMode: true, + height: 300, callbacks: { onChange: noteChanged } @@ -61,6 +68,12 @@ function setParent(noteId, newParentKey, successCallback) { }); } +function createNewTopLevelNote() { + let rootNode = $("#tree").fancytree("getRootNode"); + + createNote(rootNode, "root", "into"); +} + function createNote(node, parentKey, target) { let newNoteName = "new note"; @@ -103,6 +116,10 @@ function loadNote(noteId) { let noteText = notecase2html(note); + noteChangeDisabled = true; + $('#noteDetail').summernote('code', noteText); + + noteChangeDisabled = false; }); } \ No newline at end of file diff --git a/frontend/style.css b/frontend/style.css new file mode 100644 index 000000000..8aab96ef6 --- /dev/null +++ b/frontend/style.css @@ -0,0 +1,12 @@ +.note-editable { + /* This is because with empty content height of editor is 0 and it's impossible to click into it */ + min-height: 400px; +} + +#top-message { + display: none; /* initial state is hidden */ + background-color: greenyellow; + color: green; + padding: 5px; + border-radius: 10px; +} \ No newline at end of file