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
add missing methods for editor
ammarahm-ede4e395525d96
diff --git a/apps/mobile/src/screens/editor/header.js b/apps/mobile/src/screens/editor/header.jsindex bc3606a07..8e6d656fe 100644--- a/apps/mobile/src/screens/editor/header.js+++ b/apps/mobile/src/screens/editor/header.js@@ -44,7 +44,6 @@ const EditorHeader = ({ editor }) => {const insets = useSafeAreaInsets();const handleBack = useRef();const keyboardListener = useRef();- const closing = useRef(false);const searchReplace = useEditorStore(state => state.searchReplace);const readonly = useEditorStore(state => state.readonly);@@ -69,12 +68,6 @@ const EditorHeader = ({ editor }) => {editorState().currentlyEditing = false;keyboardListener.current?.remove();editor?.reset();- Navigation.setRoutesToUpdate([- Navigation.routeNames.NotesPage,- Navigation.routeNames.Favorites,- Navigation.routeNames.Notes,- Navigation.routeNames.Notebook- ]);}, 1);};diff --git a/apps/mobile/src/screens/editor/index.js b/apps/mobile/src/screens/editor/index.jsindex 914c49ed4..3f7f9adc9 100755--- a/apps/mobile/src/screens/editor/index.js+++ b/apps/mobile/src/screens/editor/index.js@@ -25,6 +25,11 @@ const Editor = React.memo(const editor = useEditor();editorController.current = editor;+ const onError = () => {+ editorController.current?.setLoading(true);+ setTimeout(() => editorController.current?.setLoading(false), 10);+ };+return editor.loading ? null : (<><View@@ -39,15 +44,12 @@ const Editor = React.memo(testID={notesnook.editor.id}ref={editor.ref}onLoad={editor.onLoad}- // onRenderProcessGone={() => {- // onResetRequested();- // }}- // onError={() => {- // onResetRequested();- // }}+ onRenderProcessGone={onError}+ onError={onError}injectedJavaScript={`globalThis.sessionId="${editor.sessionId}";`}javaScriptEnabled={true}focusable={true}+ overScrollMode="never"keyboardDisplayRequiresUserAction={false}// onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}cacheMode="LOAD_DEFAULT"@@ -64,7 +66,7 @@ const Editor = React.memo(allowUniversalAccessFromFileURLs={true}originWhitelist={['*']}source={{- uri: 'http://192.168.10.5:3000'+ uri: 'http://192.168.10.8:3000'}}style={style}autoManageStatusBarEnabled={false}diff --git a/apps/mobile/src/screens/editor/tiptap/types.ts b/apps/mobile/src/screens/editor/tiptap/types.tsindex 4db13ee2a..a7a95e7b8 100644--- a/apps/mobile/src/screens/editor/tiptap/types.ts+++ b/apps/mobile/src/screens/editor/tiptap/types.ts@@ -16,6 +16,12 @@ export type EditorState = {saveCount: 0;};+export type EditorMessage = {+ sessionId: string;+ value: any;+ type: string;+};+export type Note = {[name: string]: any;id: string | null;diff --git a/apps/mobile/src/screens/editor/tiptap/useEditor.ts b/apps/mobile/src/screens/editor/tiptap/useEditor.tsindex 916d41742..c358c9763 100644--- a/apps/mobile/src/screens/editor/tiptap/useEditor.ts+++ b/apps/mobile/src/screens/editor/tiptap/useEditor.ts@@ -10,10 +10,13 @@ import { useThemeStore } from '../../../stores/use-theme-store';import { db } from '../../../utils/database';import { MMKV } from '../../../utils/database/mmkv';import { eOnLoadNote, eOpenTagsDialog } from '../../../utils/events';+import filesystem from '../../../utils/filesystem';import { tabBarRef } from '../../../utils/global-refs';import { timeConverter } from '../../../utils/time';+import { AttachmentType } from '../../../utils/types';import Commands from './commands';-import { EditorState, Note, Content, AppState, SavePayload } from './types';+import picker from './picker';+import { EditorState, Note, Content, AppState, SavePayload, EditorMessage } from './types';import { defaultState, EditorEvents, isEditorLoaded, makeSessionId, post } from './utils';export const useEditor = () => {@@ -234,36 +237,37 @@ export const useEditor = () => {const onMessage = useCallback(event => {- let message = event.nativeEvent.data;- message = JSON.parse(message);+ const data = event.nativeEvent.data;+ let editorMessage = JSON.parse(data) as EditorMessage;- console.log(message.type);-- if (message.sessionId !== sessionId && message.type !== EditorEvents.status) {- console.log(- 'useEditor: message recieved from invalid session',- message.type,+ logger.info('editor', editorMessage.type);+ if (editorMessage.sessionId !== sessionId && editorMessage.type !== EditorEvents.status) {+ logger.error(+ 'editor',+ 'invalid session',+ editorMessage.type,sessionId,- message.sessionId+ editorMessage.sessionId);+return;}- switch (message.type) {+ switch (editorMessage.type) {case EditorEvents.logger:- console.log(message.type, message.value);+ logger.info('editor-webview', editorMessage.value);break;case 'editor-event:content':saveContent({- type: message.type,- content: message.value+ type: editorMessage.type,+ content: editorMessage.value});break;case 'editor-event:selection':break;case 'editor-event:title':saveContent({- type: message.type,- title: message.value+ type: editorMessage.type,+ title: editorMessage.value});break;case 'editor-event:newtag':@@ -271,12 +275,12 @@ export const useEditor = () => {eSendEvent(eOpenTagsDialog, currentNote.current);break;case 'editor-event:tag':- if (message.value) {+ if (editorMessage.value) {if (!currentNote.current) return;db.notes//@ts-ignore?.note(currentNote.current?.id)- .untag(message.value)+ .untag(editorMessage.value).then(async () => {useTagStore.getState().setTags();await commands.setTags(currentNote.current);@@ -290,8 +294,21 @@ export const useEditor = () => {});}break;+ case 'editor-event:picker':+ picker.pick();+ break;+ case 'editor-event:download-attachment':+ filesystem.downloadAttachment(editorMessage.value?.hash, true);+ break;+ default:+ console.log(+ 'unhandled event recieved from editor: ',+ editorMessage.type,+ editorMessage.value+ );+ break;}- eSendEvent(message.type, message);+ eSendEvent(editorMessage.type, editorMessage);},[sessionId]);