Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add cors proxy settings

ammarahm-ed1b471a2fdad3
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index 4173482c4..7df250f16 100644
--- a/apps/mobile/app/screens/editor/tiptap/types.ts
+++ b/apps/mobile/app/screens/editor/tiptap/types.ts
@@ -47,6 +47,7 @@ export type Settings = {
noHeader?: boolean;
keyboardShown?: boolean;
doubleSpacedLines?: boolean;
+ corsProxy: string;
};
export type EditorProps = {
@@ -82,7 +83,7 @@ export type Content = {
data?: string;
type: string;
noteId: string;
- id?:string
+ id?: string;
};
export type SavePayload = {
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
index ab85a073a..977f5a110 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
@@ -149,6 +149,7 @@ export const useEditorEvents = (
) => {
const deviceMode = useSettingStore((state) => state.deviceMode);
const fullscreen = useSettingStore((state) => state.fullscreen);
+ const corsProxy = useSettingStore(state => state.settings.corsProxy);
const handleBack = useRef<NativeEventSubscription>();
const readonly = useEditorStore((state) => state.readonly);
const isPremium = useUserStore((state) => state.premium);
@@ -168,7 +169,8 @@ export const useEditorEvents = (
noHeader: noHeader,
noToolbar: readonly || editorPropReadonly || noToolbar,
keyboardShown: keyboardShown || false,
- doubleSpacedLines: doubleSpacedLines
+ doubleSpacedLines: doubleSpacedLines,
+ corsProxy:corsProxy
});
}, [
fullscreen,
@@ -183,7 +185,8 @@ export const useEditorEvents = (
doubleSpacedLines,
editorPropReadonly,
noHeader,
- noToolbar
+ noToolbar,
+ corsProxy
]);
const onBackPress = useCallback(async () => {
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 9aa5311a8..bfdc80018 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -515,6 +515,18 @@ export const settingsGroups: SettingSection[] = [
"Contribute towards a better Notesnook. All tracking information is anonymous.",
property: "telemetry"
},
+ {
+ id: "cors-bypass",
+ type: "input",
+ name: "CORS bypass proxy",
+ description: "You can set a custom proxy URL to increase your privacy.",
+ inputProperties: {
+ defaultValue: "https://cors.notesnook.com"
+ },
+ property: "corsProxy",
+ icon: "arrow-decision-outline"
+ },
+
{
id: "vault",
type: "screen",
@@ -846,7 +858,7 @@ export const settingsGroups: SettingSection[] = [
keyboardType: "decimal-pad",
defaultValue: 5 + "",
placeholder: "Set snooze time in minutes",
- onSubmitEditing:() => {
+ onSubmitEditing: () => {
Notifications.setupReminders();
}
}
diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.ts
index 434ec2165..b6448ebb5 100644
--- a/apps/mobile/app/stores/use-setting-store.ts
+++ b/apps/mobile/app/stores/use-setting-store.ts
@@ -67,6 +67,7 @@ export type Settings = {
disableSync?: boolean;
reminderNotifications?: boolean;
defaultSnoozeTime?: string;
+ corsProxy: string;
};
type DimensionsType = {
@@ -140,7 +141,8 @@ export const useSettingStore = create<SettingStore>((set) => ({
version: null,
doubleSpacedLines: true,
reminderNotifications: true,
- defaultSnoozeTime: "5"
+ defaultSnoozeTime: "5",
+ corsProxy: "https://cors.notesnook.com"
},
sheetKeyboardHandler: true,
fullscreen: false,
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index 9e191c8e9..c0356e8cd 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -91,6 +91,9 @@ const Tiptap = ({
doubleSpacedLines: settings.doubleSpacedLines,
onOpenLink: (url) => {
return global.editorController.openLink(url);
+ },
+ downloadOptions: {
+ corsHost: settings.corsProxy
}
},
[layout, settings.readonly, tick]
diff --git a/packages/editor-mobile/src/utils/index.ts b/packages/editor-mobile/src/utils/index.ts
index 223dd2360..65d31e31c 100644
--- a/packages/editor-mobile/src/utils/index.ts
+++ b/packages/editor-mobile/src/utils/index.ts
@@ -39,6 +39,7 @@ export type Settings = {
noHeader?: boolean;
keyboardShown?: boolean;
doubleSpacedLines?: boolean;
+ corsProxy: string;
};
/* eslint-disable no-var */