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 share extension
ammarahm-ed7a3980af9c2f
diff --git a/apps/mobile/index.js b/apps/mobile/index.jsindex a9a6a3042..e991a4121 100644--- a/apps/mobile/index.js+++ b/apps/mobile/index.js@@ -8,7 +8,6 @@ import Config from 'react-native-config';import { SafeAreaProvider } from 'react-native-safe-area-context';import appJson from './app.json';import Notifications from './src/services/notifications';-import App from './App';const appName = appJson.name;if (Config.isTesting) {Date.prototype.toLocaleString = () => 'XX-XX-XX';@@ -24,6 +23,7 @@ Notifications.init();let QuickNoteIOS;const AppProvider = () => {+ const App = require('./App.js').default;return <App />;};diff --git a/apps/mobile/patches/react-native-mmkv-storage+0.7.6.patch b/apps/mobile/patches/react-native-mmkv-storage+0.7.6.patchnew file mode 100644index 000000000..c60d7d42f--- /dev/null+++ b/apps/mobile/patches/react-native-mmkv-storage+0.7.6.patch@@ -0,0 +1,42 @@+diff --git a/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm b/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm+index 9af089d..f64a04a 100644+--- a/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm++++ b/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm+@@ -30,13 +30,23 @@ - (instancetype)init+ {+ self = [super init];+ RCTExecuteOnMainQueue(^{+- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,+- NSUserDomainMask, YES);+- NSString *libraryPath = (NSString *)[paths firstObject];+- NSString *rootDir = [libraryPath stringByAppendingPathComponent:@"mmkv"];++// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,++// NSUserDomainMask, YES);++// NSString *libraryPath = (NSString *)[paths firstObject];++++ NSString *myGroupID = @"group.org.streetwriters.notesnook"; // the group dir that can be accessed by App & extensions++++ NSString *groupDir = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:myGroupID].path;++ NSString *rootDir = [groupDir stringByAppendingPathComponent:@"mmkv"];++++ // Do not include this directory in cloud backups.++ NSError *error = nil;++ NSURL *url = [NSURL fileURLWithPath:rootDir isDirectory:YES];++ [url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];+ rPath = rootDir;++ // Set the groupDir+ _secureStorage = [[SecureStorage alloc] init];+- [MMKV initializeMMKV:rootDir];++ [MMKV initializeMMKV:nil groupDir:rootDir logLevel:MMKVLogInfo];+ });+++@@ -706,7 +716,7 @@ static void install(jsi::Runtime &jsiRuntime) {+ }++ - (void)migrate {+- MMKV *kv = [MMKV mmkvWithID:@"mmkvIdStore"];++ MMKV *kv = [MMKV mmkvWithID:@"mmkvIdStore" mode:MMKVMultiProcess];+ [mmkvInstances setObject:kv forKey:@"mmkvIdStore"];+ if ([kv containsKey:@"mmkvIdData"]) {+ NSMutableDictionary *oldStore =diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.jsindex c571c4a7e..da46aa434 100644--- a/apps/mobile/share/share.js+++ b/apps/mobile/share/share.js@@ -19,16 +19,15 @@ import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-contimport Icon from 'react-native-vector-icons/MaterialCommunityIcons';import ShareExtension from 'rn-extensions-share';import isURL from 'validator/lib/isURL';+import Editor from '../src/screens/editor';import { eSendEvent } from '../src/services/event-manager';import { getElevation } from '../src/utils';import { db } from '../src/utils/database';import Storage from '../src/utils/database/storage';import { eOnLoadNote } from '../src/utils/events';-import { useAppState } from '../src/utils/hooks/use-app-state';import { sleep } from '../src/utils/time';import { Search } from './search';import { useShareStore } from './store';-let Editor = null;const getLinkPreview = url => {return getPreviewData(url, 5000);};@@ -190,7 +189,6 @@ const ShareView = ({ quicknote = false }) => {const [showSearch, setShowSearch] = useState(false);const [kh, setKh] = useState(0);const editorRef = useRef();- const appState = useAppState();const onKeyboardDidShow = event => {let kHeight = event.endCoordinates.height;@@ -268,15 +266,8 @@ const ShareView = ({ quicknote = false }) => {};useEffect(() => {- console.log('setting value in storage');- if (appState !== 'active') {- console.log('app state is not active');- return;- }- console.log('app state is active');(async () => {//await loadDatabase();- Editor = require('../src/screens/editor/index').default;setLoadingExtension(false);loadData();useShareStore.getState().restoreAppendNote();@@ -286,7 +277,7 @@ const ShareView = ({ quicknote = false }) => {});});})();- }, [appState]);+ }, []);const close = async () => {setNote({ ...defaultNote });@@ -582,7 +573,7 @@ const ShareView = ({ quicknote = false }) => {flex: 1}}>- {Editor && (+ {!loadingExtension && (<Editorref={editorRef}theme={{diff --git a/apps/mobile/src/screens/editor/index.tsx b/apps/mobile/src/screens/editor/index.tsxindex 34bd94d66..97d3b0cf1 100755--- a/apps/mobile/src/screens/editor/index.tsx+++ b/apps/mobile/src/screens/editor/index.tsx@@ -1,16 +1,15 @@+/* eslint-disable @typescript-eslint/no-var-requires */import { EV, EVENTS } from 'notes-core/common';-import React, { forwardRef, useEffect, useImperativeHandle } from 'react';+import React, { forwardRef, ReactElement, useEffect, useImperativeHandle, useState } from 'react';import { Platform, ViewStyle } from 'react-native';import WebView from 'react-native-webview';import { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes';import { notesnook } from '../../../e2e/test.ids';-import { IconButton } from '../../components/ui/icon-button';import { useEditorStore } from '../../stores/use-editor-store';import { getElevation } from '../../utils';import { db } from '../../utils/database';import { openLinkInBrowser } from '../../utils/functions';import { NoteType } from '../../utils/types';-import EditorOverlay from './loading';import { EDITOR_URI } from './source';import { EditorProps, useEditorType } from './tiptap/types';import { useEditor } from './tiptap/use-editor';@@ -136,14 +135,13 @@ const Editor = React.memo(allowUniversalAccessFromFileURLs={true}originWhitelist={['*']}source={{- uri: __DEV__ ? 'http://192.168.10.7:3000' : EDITOR_URI+ uri: __DEV__ ? EDITOR_URI : EDITOR_URI}}style={style}autoManageStatusBarEnabled={false}onMessage={onMessage || undefined}/>- {theme ? null : <EditorOverlay editorId={editorId || ''} editor={editor} />}- <ReadonlyButton editor={editor} />+ {editorId === 'shareEditor' ? null : <AppSection editor={editor} editorId={editorId} />}</>);}@@ -153,9 +151,30 @@ const Editor = React.memo(export default Editor;+//@ts-ignore+let EditorOverlay: React.ElementType;+//@ts-ignore+let IconButton: React.ElementType;+//@ts-ignore+const AppSection = ({ editor, editorId }) => {+ const [loaded, setLoaded] = useState(false);+ useEffect(() => {+ //@ts-ignore+ EditorOverlay = require('./loading.js').default;+ //@ts-ignore+ IconButton = require('../../components/ui/icon-button/index.tsx').IconButton;+ setLoaded(true);+ }, []);+ return loaded ? (+ <>+ {EditorOverlay ? <EditorOverlay editorId={editorId || ''} editor={editor} /> : null}+ <ReadonlyButton editor={editor} />+ </>+ ) : null;+};+const ReadonlyButton = ({ editor }: { editor: useEditorType }) => {const readonly = useEditorStore(state => state.readonly);-const onPress = async () => {if (editor.note.current) {await db.notes?.note(editor.note.current.id).readonly();@@ -163,7 +182,8 @@ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => {useEditorStore.getState().setReadonly(false);}};- return readonly ? (++ return readonly && IconButton ? (<IconButtonname="pencil-lock"type="grayBg"diff --git a/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts b/apps/mobile/src/screens/editor/tiptap/useEditorEvents.tsindex 18964fcdc..50a95583b 100644--- a/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts+++ b/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts@@ -1,8 +1,8 @@+/* eslint-disable no-case-declarations */+/* eslint-disable @typescript-eslint/no-var-requires */import { useCallback, useEffect, useRef } from 'react';import { BackHandler, InteractionManager, NativeEventSubscription } from 'react-native';import { WebViewMessageEvent } from 'react-native-webview';-import { AuthMode } from '../../../components/auth';-import { Properties } from '../../../components/properties';import { DDS } from '../../../services/device-detection';import {eSendEvent,@@ -31,7 +31,6 @@ import filesystem from '../../../utils/filesystem';import { tabBarRef } from '../../../utils/global-refs';import { NoteType } from '../../../utils/types';import { useDragState } from '../../settings/editor/state';-import picker from './picker';import { EditorMessage, EditorProps, useEditorType } from './types';import { EditorEvents, editorState } from './utils';@@ -102,7 +101,7 @@ const showActionsheet = async (editor: useEditorType) => {if (editorState().isFocused || editorState().isFocused) {editorState().isFocused = true;}-+ const { Properties } = require('../../../components/properties/index.js');Properties.present(note, ['Dark Mode']);} else {ToastEvent.show({@@ -294,7 +293,8 @@ export const useEditorEvents = (}break;case EventTypes.filepicker:- picker.pick({ type: editorMessage.value });+ const { pick } = require('./picker.js').default;+ pick({ type: 'image' });break;case EventTypes.download:console.log('download attachment request', editorMessage.value);diff --git a/apps/mobile/src/utils/database/MMKV.js b/apps/mobile/src/utils/database/MMKV.jsindex b8523eb4b..5b3b4a933 100644--- a/apps/mobile/src/utils/database/MMKV.js+++ b/apps/mobile/src/utils/database/MMKV.js@@ -1,3 +1,8 @@-import MMKVStorage from 'react-native-mmkv-storage';+import { Platform } from 'react-native';+import MMKVStorage, { ProcessingModes } from 'react-native-mmkv-storage';-export const MMKV = new MMKVStorage.Loader().initialize();+export const MMKV = new MMKVStorage.Loader()+ .setProcessingMode(+ Platform.OS === 'ios' ? ProcessingModes.MULTI_PROCESS : ProcessingModes.SINGLE_PROCESS+ )+ .initialize();diff --git a/apps/mobile/workspace.code-workspace b/apps/mobile/workspace.code-workspacenew file mode 100644index 000000000..2b95a900d--- /dev/null+++ b/apps/mobile/workspace.code-workspace@@ -0,0 +1,11 @@+{+ "folders": [+ {+ "path": "."+ },+ {+ "path": "../notesnook-mobile-editor"+ }+],+ "settings": {}+}