A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: note saving on clearing editor
ammarahm-ed9f1b457133e0
diff --git a/apps/mobile/android/app/src/main/assets/texteditor.html b/apps/mobile/android/app/src/main/assets/texteditor.htmlindex 83cd62ae6..9276aea05 100644--- a/apps/mobile/android/app/src/main/assets/texteditor.html+++ b/apps/mobile/android/app/src/main/assets/texteditor.html@@ -1640,7 +1640,7 @@switch (type) {case "reset": {editor.history.clear();- editor.setText('', 'silent');+ editor.setText('', 'api');document.getElementById('titleInput').value = '';document.getElementById('titleInput').blur();editor.blur();@@ -1682,7 +1682,7 @@}, 0)break;case "clearEditor":- editor.setText('', 'silent');+ editor.setText('', 'api');break;case "clearTitle":document.getElementById('titleInput').value = '';@@ -1716,7 +1716,6 @@break;case "delta":-const content = valueeditor.setContents(content, 'api');/* setTimeout(() => {@@ -1748,6 +1747,7 @@// Toda vez que é editado, manda os conteúdos para o RNeditor.on('text-change', function (delta, oldDelta, source) {var regex = /https?:\/\/[^\s]+$/;+ if (source === "api") return;if (delta.ops.length === 2 &&delta.ops[0].retain &&@@ -1785,7 +1785,9 @@m.html = editor.root.innerHTML;m.type = 'content';+window.ReactNativeWebView.postMessage(JSON.stringify(m));+});diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.htmlindex e45239e6d..22974d243 100644--- a/apps/mobile/html/Web.bundle/site/index.html+++ b/apps/mobile/html/Web.bundle/site/index.html@@ -1623,6 +1623,7 @@document.getElementById('titleInput').value = '';document.getElementById('titleInput').blur();editor.blur();+ window.blur();document.getElementById('infodate').innerText = "";document.getElementById('infosaved').innerText = "";document.getElementById("infowords").innerText = "";@@ -1631,6 +1632,7 @@case "blur":document.getElementById('titleInput').blur();editor.blur();+ window.blur();break;case "undo":editor.history.undo();@@ -1723,6 +1725,7 @@// Toda vez que é editado, manda os conteúdos para o RNeditor.on('text-change', function (delta, oldDelta, source) {var regex = /https?:\/\/[^\s]+$/;+ if (source === "api") return;if (delta.ops.length === 2 &&delta.ops[0].retain &&diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.jsindex eda9a81ba..8e657f7b6 100644--- a/apps/mobile/src/views/Editor/Functions.js+++ b/apps/mobile/src/views/Editor/Functions.js@@ -85,25 +85,40 @@ export function checkNote() {return note && note.id;}+async function setNote(item) {+ note = item;+ saveCounter = 0;+ noteEdited = false;+ title = note.title;+ id = note.id;+ content = {};+ content.text = await db.notes.note(id).text();+ content.delta = note.content.delta;+ if (!note.locked) {+ content.delta = await db.notes.note(id).delta();+ }+}++function clearNote() {+ note = null;+ noteEdited = false;+ title = null;+ id = null;+ content = null;+}+export async function loadNote(item) {editing.currentlyEditing = true;post('blur');if (item && item.type === 'new') {await clearEditor();+ clearNote();post('focusTitle');canSave = true;id = null;+} else {- await clearEditor();- note = item;- title = note.title;- id = note.id;- content = {};- content.text = await db.notes.note(id).text();- content.delta = note.content.delta;- if (!note.locked) {- content.delta = await db.notes.note(id).delta();- }+ await setNote(item);canSave = false;eSendEvent(eOnNoteEdited , {id: item.id});await loadNoteInEditor();@@ -137,12 +152,9 @@ export const _onMessage = async (evt) => {let message = evt.nativeEvent.data;clearTimeout(timer);timer = null;+ console.log('new message from editor')if (message === 'loaded') {} else if (message !== '' && message !== 'loaded') {- if (!canSave) {- await sleep(2000);- canSave = true;- }onChange(message);timer = setTimeout(() => {if (noteEdited) {@@ -160,18 +172,11 @@ export async function clearEditor() {if (note && note.id) {eSendEvent(eOnNoteEdited , {id: note.id, closed: true});}- noteEdited = false;- title = null;- content = null;- note = null;- //id = null;saveCounter = 0;- canSave = false;post('reset');}function checkIfContentIsSavable() {- if (!canSave) return false;if (!title && !content) return false;if (content && content.text.length < 2 && title && title?.length < 2)return false;