Skip to content

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

mobile: toggle markdown shortcuts

Ammar Ahmed3d1726c5aab9
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index 154dbb332..c342c56c1 100644
--- a/apps/mobile/app/screens/editor/tiptap/types.ts
+++ b/apps/mobile/app/screens/editor/tiptap/types.ts
@@ -53,6 +53,7 @@ export type Settings = {
dateFormat: string;
timeFormat: string;
fontScale: number;
+ markdownShortcuts: boolean;
};
export type EditorProps = {
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 c32cac079..0af592b3e 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
@@ -157,6 +157,9 @@ export const useEditorEvents = (
const defaultFontFamily = useSettingStore(
(state) => state.settings.defaultFontFamily
);
+ const markdownShortcuts = useSettingStore(
+ (state) => state.settings.markdownShortcuts
+ );
const tools = useDragState((state) => state.data);
@@ -202,7 +205,8 @@ export const useEditorEvents = (
fontFamily: SettingsService.get().defaultFontFamily,
dateFormat: db.settings?.getDateFormat(),
timeFormat: db.settings?.getTimeFormat(),
- fontScale
+ fontScale,
+ markdownShortcuts
});
}, [
fullscreen,
@@ -222,7 +226,8 @@ export const useEditorEvents = (
dateFormat,
timeFormat,
loading,
- fontScale
+ fontScale,
+ markdownShortcuts
]);
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 20abd08d6..28fdc9a9d 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -584,6 +584,13 @@ export const settingsGroups: SettingSection[] = [
component: "title-format",
description: "Customize the formatting for new note title",
type: "component"
+ },
+ {
+ id: "toggle-markdown",
+ name: "Markdown shortcuts",
+ property: "markdownShortcuts",
+ description: "Toggle markdown in the editor",
+ type: "switch"
}
]
}
diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.ts
index af6398f1a..a9ee793ba 100644
--- a/apps/mobile/app/stores/use-setting-store.ts
+++ b/apps/mobile/app/stores/use-setting-store.ts
@@ -74,6 +74,7 @@ export type Settings = {
colorScheme: "dark" | "light";
lighTheme: ThemeDefinition;
darkTheme: ThemeDefinition;
+ markdownShortcuts?: boolean;
};
type DimensionsType = {
@@ -154,7 +155,8 @@ export const defaultSettings: SettingStore["settings"] = {
defaultFontSize: 16,
colorScheme: "light",
lighTheme: ThemeLight,
- darkTheme: ThemeDark
+ darkTheme: ThemeDark,
+ markdownShortcuts: true
};
export const useSettingStore = create<SettingStore>((set, get) => ({
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index 8b830c60c..1453b5d27 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -100,9 +100,16 @@ const Tiptap = ({ settings }: { settings: Settings }) => {
corsHost: settings.corsProxy
},
dateFormat: settings.dateFormat,
- timeFormat: settings.timeFormat as "12-hour" | "24-hour" | undefined
+ timeFormat: settings.timeFormat as "12-hour" | "24-hour" | undefined,
+ enableInputRules: settings.markdownShortcuts
},
- [layout, settings.readonly, tick, settings.doubleSpacedLines]
+ [
+ layout,
+ settings.readonly,
+ tick,
+ settings.doubleSpacedLines,
+ settings.markdownShortcuts
+ ]
);
const update = useCallback(() => {
diff --git a/packages/editor-mobile/src/utils/index.ts b/packages/editor-mobile/src/utils/index.ts
index 7e5302903..5b3cc154a 100644
--- a/packages/editor-mobile/src/utils/index.ts
+++ b/packages/editor-mobile/src/utils/index.ts
@@ -52,6 +52,7 @@ export type Settings = {
timeFormat: string;
dateFormat: string;
fontScale: number;
+ markdownShortcuts: boolean;
};
/* eslint-disable no-var */