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 id replaced by delta
ammarahm-ed0f5ba808b4e8
diff --git a/apps/mobile/android/app/src/main/assets/texteditor.html b/apps/mobile/android/app/src/main/assets/texteditor.htmlindex 2656a1ba6..a64153438 100644--- a/apps/mobile/android/app/src/main/assets/texteditor.html+++ b/apps/mobile/android/app/src/main/assets/texteditor.html@@ -1662,7 +1662,7 @@let m = {};- m.delta = editor.getContents();+ m.delta = { ops: editor.getContents().ops }m.text = editor.getText();diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.htmlindex 748f5c7bd..56b965295 100644--- a/apps/mobile/html/Web.bundle/site/index.html+++ b/apps/mobile/html/Web.bundle/site/index.html@@ -1677,7 +1677,7 @@let m = {};- m.delta = editor.getContents();+ m.delta = { ops: editor.getContents().ops }m.text = editor.getText();diff --git a/apps/mobile/index.tablet.js b/apps/mobile/index.tablet.jsindex d40576bbb..8918e3592 100644--- a/apps/mobile/index.tablet.js+++ b/apps/mobile/index.tablet.js@@ -8,10 +8,11 @@ import NavigationService, {AppContainer,} from './src/services/NavigationService';import Editor from './src/views/Editor';-import {eSubscribeEvent} from './src/services/eventManager';+import {eSubscribeEvent, eSendEvent} from './src/services/eventManager';import {eOpenFullscreenEditor,eCloseFullscreenEditor,+ eOnLoadNote,} from './src/services/events';const editorRef = createRef();@@ -55,6 +56,7 @@ export const Initialize = () => {};useEffect(() => {+ eSendEvent(eOnLoadNote, {type: 'new'});eSubscribeEvent(eOpenFullscreenEditor, showFullScreenEditor);eSubscribeEvent(eCloseFullscreenEditor, closeFullScreenEditor);diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lockindex 937e9e94a..ad8177cef 100644--- a/apps/mobile/ios/Podfile.lock+++ b/apps/mobile/ios/Podfile.lock@@ -19,7 +19,7 @@ PODS:- DoubleConversion- glog- glog (0.3.5)- - MMKV (1.0.23)+ - MMKV (1.0.24)- RCTRequired (0.61.5)- RCTTypeSafety (0.61.5):- FBLazyVector (= 0.61.5)@@ -185,8 +185,8 @@ PODS:- React-jsinspector (0.61.5)- react-native-aes (1.3.6):- React- - react-native-mmkv-storage (0.1.5):- - MMKV (= 1.0.23)+ - react-native-mmkv-storage (0.2.2):+ - MMKV (= 1.0.24)- React- react-native-orientation (3.1.3):- React@@ -365,7 +365,7 @@ SPEC CHECKSUMS:FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51glog: 1f3da668190260b06b429bb211bfbee5cd790c28- MMKV: 031ae51aedc0af1b250922f7ed8a6b6ee2f94c4c+ MMKV: 758b2edee46b08bdd958db4169191afb9a6d4ebdRCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78@@ -376,7 +376,7 @@ SPEC CHECKSUMS:React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0react-native-aes: 22ea989d641f53ea7722fe6b146349ed66e6455d- react-native-mmkv-storage: fe0db5290c1321b4be87765a88c6fd302ccd541e+ react-native-mmkv-storage: 4f85ac485ff25ad5b9f7b3c6cd4c8bb067b1028creact-native-orientation: f1caf84d65f1a4fd4511a18f2b924e634ad7a628react-native-webview: 2aadbfef6b9eaa9e89b306ae3e31e6e870a6306dReact-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76diff --git a/apps/mobile/src/utils/storage.js b/apps/mobile/src/utils/storage.jsindex 3eea98960..1bf629e77 100644--- a/apps/mobile/src/utils/storage.js+++ b/apps/mobile/src/utils/storage.js@@ -35,6 +35,7 @@ async function readMulti(keys) {return [];} else {let data = await MMKV.getMultipleItemsAsync(keys.slice());+return !data ? undefined : data;}}diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.jsindex 532f1ea5f..b95de42b1 100755--- a/apps/mobile/src/views/Editor/index.js+++ b/apps/mobile/src/views/Editor/index.js@@ -29,11 +29,11 @@ import {eUnSubscribeEvent,} from '../../services/eventManager';import {+ eClearEditor,eCloseFullscreenEditor,eOnLoadNote,eOpenFullscreenEditor,refreshNotesPage,- eClearEditor,} from '../../services/events';import {exitEditorAnimation} from '../../utils/animations';import {sideMenuRef} from '../../utils/refs';@@ -47,7 +47,7 @@ var title = null;let timer = null;let saveCounter = 0;let tapCount = 0;-let canSave = true;+let canSave = false;const Editor = ({noMenu}) => {// Global Stateconst [state, dispatch] = useTracked();@@ -118,7 +118,6 @@ const Editor = ({noMenu}) => {const clearEditor = async () => {await saveNote(true);-setDateEdited(0);title = null;content = null;@@ -187,8 +186,12 @@ const Editor = ({noMenu}) => {) {clearTimeout(timer);timer = null;+ if (!canSave) {+ setTimeout(() => {+ canSave = true;+ }, 2000);+ }onChange(evt.nativeEvent.data);-timer = setTimeout(() => {saveNote.call(this, true);}, 500);@@ -204,26 +207,55 @@ const Editor = ({noMenu}) => {}};+ const addToCollection = async id => {+ switch (editing.actionAfterFirstSave.type) {+ case 'topic': {+ await db.notes.move(+ {+ topic: editing.actionAfterFirstSave.id,+ id: editing.actionAfterFirstSave.notebook,+ },+ id,+ );+ editing.actionAfterFirstSave = {+ type: null,+ };++ break;+ }+ case 'tag': {+ await db.notes.note(note.id).tag(editing.actionAfterFirstSave.id);+ editing.actionAfterFirstSave = {+ type: null,+ };++ break;+ }+ case 'color': {+ await db.notes.note(id).color(editing.actionAfterFirstSave.id);++ editing.actionAfterFirstSave = {+ type: null,+ };++ break;+ }+ default: {+ break;+ }+ }+ };+const saveNote = async (lockNote = true) => {if (!canSave) return;if (!title && !content) return;- if (!title && content && content.text.length <= 2) return;- if (!title && content && !content.text) return;- if (- title &&- title.trim().length <= 1 &&- content &&- content.text &&- content.text.length <= 2- )- return;-if (!content) {content = {text: '',delta: {ops: []},};}+let lockedNote = id ? db.notes.note(id).data.locked : null;if (!lockedNote) {let rId = await db.notes.add({@@ -250,42 +282,7 @@ const Editor = ({noMenu}) => {}if (id) {- switch (editing.actionAfterFirstSave.type) {- case 'topic': {- await db.notes.move(- {- topic: editing.actionAfterFirstSave.id,- id: editing.actionAfterFirstSave.notebook,- },- id,- );- editing.actionAfterFirstSave = {- type: null,- };-- break;- }- case 'tag': {- await db.notes.note(note.id).tag(editing.actionAfterFirstSave.id);- editing.actionAfterFirstSave = {- type: null,- };-- break;- }- case 'color': {- await db.notes.note(id).color(editing.actionAfterFirstSave.id);-- editing.actionAfterFirstSave = {- type: null,- };-- break;- }- default: {- break;- }- }+ await addToCollection(id);dispatch({type: ACTIONS.CURRENT_EDITING_NOTE,id: id,@@ -359,7 +356,7 @@ const Editor = ({noMenu}) => {title = note.title;id = note.id;setDateEdited(note.dateEdited);- content = note.content;+ content = {...note.content};if (!note.locked) {content.delta = await db.notes.note(id).delta();}@@ -386,10 +383,10 @@ const Editor = ({noMenu}) => {post({type: 'clearEditor',});- } else if (note.content.delta) {+ } else if (content.delta) {let delta;- if (typeof note.content.delta !== 'string') {- delta = note.content.delta;+ if (typeof content.delta !== 'string') {+ delta = content.delta;} else {delta = await db.notes.note(id).delta();}@@ -400,7 +397,6 @@ const Editor = ({noMenu}) => {} else {post({type: 'text', value: note.content.text});}- canSave = true;};const params = 'platform=' + Platform.OS;