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 back handler in editor
Ammar Ahmed28616530b886
diff --git a/apps/mobile/src/screens/editor/tiptap/commands.ts b/apps/mobile/src/screens/editor/tiptap/commands.tsindex b1906bede..7c21fd3ff 100644--- a/apps/mobile/src/screens/editor/tiptap/commands.ts+++ b/apps/mobile/src/screens/editor/tiptap/commands.ts@@ -51,9 +51,9 @@ class Commands {this.ref = ref;}- async doAsync(job: string) {+ async doAsync<T>(job: string) {if (!this.ref) return false;- return await call(this.ref, fn(job));+ return call(this.ref, fn(job)) as Promise<T>;}focus = async () => {@@ -132,22 +132,28 @@ statusBar.current.set({date:"",saved:""});};insertAttachment = async (attachment: Attachment) => {- this.doAsync(`editor && editor.commands.insertAttachment(${JSON.stringify(attachment)})`);+ await this.doAsync(`editor && editor.commands.insertAttachment(${JSON.stringify(attachment)})`);};setAttachmentProgress = async (attachmentProgress: AttachmentProgress) => {- this.doAsync(+ await this.doAsync(`editor && editor.commands.setAttachmentProgress(${JSON.stringify(attachmentProgress)})`);};insertImage = async (image: ImageAttributes) => {console.log('image data', image);- this.doAsync(`editor && editor.commands.insertImage(${JSON.stringify(image)})`);+ await this.doAsync(`editor && editor.commands.insertImage(${JSON.stringify(image)})`);};updateImage = async (image: ImageAttributes) => {- this.doAsync(`editor && editor.commands.updateImage(${JSON.stringify(image)})`);+ await this.doAsync(`editor && editor.commands.updateImage(${JSON.stringify(image)})`);+ };++ handleBack = async () => {+ return this.doAsync<boolean>(+ `response = window.dispatchEvent(new Event("handleBackPress",{cancelable:true}));`+ );};//todo add replace image function}diff --git a/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts b/apps/mobile/src/screens/editor/tiptap/useEditorEvents.tsindex a61dc3a75..ddbf13e1d 100644--- a/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts+++ b/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts@@ -130,6 +130,11 @@ export const useEditorEvents = (editor: useEditorType) => {}, [currentEditingNote, fullscreen, isPremium, readonly, editor.sessionId, editor.loading]);const onBackPress = useCallback(async () => {+ const editorHandledBack = await editor.commands.handleBack();+ if (editorHandledBack) {+ logger.info('editor handled back event');+ return;+ }setTimeout(async () => {if (deviceMode !== 'mobile' && fullscreen) {if (fullscreen) {