From 43142f0285f5bb276cf40c4f262751103ca04b2c Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sun, 13 Jan 2019 01:41:03 -0700 Subject: [PATCH] Fix issue #1 by moving the editor to an iframe --- www/js/editnote.js | 20 ++++++++++++- www/pages/editnote.html | 34 +++------------------ www/pages/editor.html | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 31 deletions(-) create mode 100644 www/pages/editor.html diff --git a/www/js/editnote.js b/www/js/editnote.js index 7d41f0e..16b9790 100644 --- a/www/js/editnote.js +++ b/www/js/editnote.js @@ -19,6 +19,7 @@ function saveme(callback) { } } + sync(); var noteid = $("#note_content").data("noteid"); if (noteid == "") { var note = { @@ -39,6 +40,7 @@ function saveme(callback) { } function exiteditor() { + sync(); if ($("#note_content").val() == "" || $("#note_content").val() === $("#orig_content").val()) { router.back({force: true, ignoreCache: true, reload: true}); } else { @@ -46,4 +48,20 @@ function exiteditor() { router.back({force: true, ignoreCache: true, reload: true}); }); } -} \ No newline at end of file +} + +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()); +} + +$("#noteframe").on("load", function () { + init(); +}); \ No newline at end of file diff --git a/www/pages/editnote.html b/www/pages/editnote.html index bb6df4d..629cce5 100644 --- a/www/pages/editnote.html +++ b/www/pages/editnote.html @@ -26,40 +26,14 @@ -
- - +
+ + +
- -
\ No newline at end of file diff --git a/www/pages/editor.html b/www/pages/editor.html new file mode 100644 index 0000000..b8e3cb8 --- /dev/null +++ b/www/pages/editor.html @@ -0,0 +1,66 @@ + + +Editor + + + + + + + + + + + \ No newline at end of file