Skip to content

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

mobile: add spellcheck toggle in note properties

Ammar Ahmed537521d56831
diff --git a/apps/mobile/app/components/properties/items.tsx b/apps/mobile/app/components/properties/items.tsx
index 1607543a6..ffcea4df4 100644
--- a/apps/mobile/app/components/properties/items.tsx
+++ b/apps/mobile/app/components/properties/items.tsx
@@ -42,7 +42,8 @@ const TOP_BAR_ITEMS: ActionId[] = [
"publish",
"local-only",
"read-only",
- "pin-to-notifications"
+ "pin-to-notifications",
+ "spell-check"
];
const BOTTOM_BAR_ITEMS: ActionId[] = [
diff --git a/apps/mobile/app/hooks/use-actions.tsx b/apps/mobile/app/hooks/use-actions.tsx
index 31dd73cef..237655388 100644
--- a/apps/mobile/app/hooks/use-actions.tsx
+++ b/apps/mobile/app/hooks/use-actions.tsx
@@ -123,7 +123,8 @@ export type ActionId =
| "default-homepage"
| "default-tag"
| "launcher-shortcut"
- | "expiry-date";
+ | "expiry-date"
+ | "spell-check";
export type Action = {
id: ActionId;
@@ -993,6 +994,28 @@ export const useActions = ({
pro: true,
activeColor: "orange"
},
+ {
+ id: "spell-check",
+ title: strings.spellCheck(),
+ icon: "spellcheck",
+ isToggle: true,
+ checked: item.spellcheck,
+ onPress: async () => {
+ db.notes.spellcheck(!item.spellcheck, item.id);
+ const note = await db.notes.note(item.id);
+ if (note) {
+ setItem(note);
+ const tabs = useTabStore.getState().getTabsForNote(note.id);
+ tabs.forEach((tab) => {
+ useTabStore.getState().updateTab(tab.id, {
+ session: {
+ spellCheckDisabled: !note.spellcheck
+ }
+ });
+ });
+ }
+ }
+ },
{
id: "remove-from-notebook",
title: strings.removeFromNotebook(),
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index de5696e10..1a4778a17 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -285,7 +285,8 @@ export const useEditor = (
locked: undefined,
readonly: undefined,
scrollTop: undefined,
- selection: undefined
+ selection: undefined,
+ spellCheckDisabled: false
}
});
return;
@@ -651,6 +652,7 @@ export const useEditor = (
session.noteLocked = isLockedNote;
session.locked = tabLocked;
session.readonly = item.readonly;
+ session.spellCheckDisabled = !item.spellcheck;
const tab = useTabStore.getState().getTab(tabId!);
diff --git a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts b/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts
index 0d323a31b..4c9413933 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts
@@ -86,6 +86,7 @@ export type TabSessionItem = {
noteLocked?: boolean;
locked?: boolean;
readonly?: boolean;
+ spellCheckDisabled: boolean;
};
const TabSessionStorageKV = new MMKVLoader()
@@ -209,7 +210,8 @@ const DEFAULT_TABS = {
{
id: "679da59a3924d4bd56d16d3f",
session: {
- id: "679da5a5667a16db2353a062"
+ id: "679da5a5667a16db2353a062",
+ spellCheckDisabled: false
}
}
],
diff --git a/apps/mobile/scripts/optimize-fonts.mjs b/apps/mobile/scripts/optimize-fonts.mjs
index 19b77aa9b..c92f55666 100644
--- a/apps/mobile/scripts/optimize-fonts.mjs
+++ b/apps/mobile/scripts/optimize-fonts.mjs
@@ -35,6 +35,7 @@ const EXTRA_ICON_NAMES = [
"star-off",
"star-outline",
"link-variant-remove",
+ "spellcheck",
"link-variant",
"link-variant-off",
"bell",
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index 66893f6cf..7eebabcad 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -464,6 +464,7 @@ const Tiptap = ({
flexDirection: "column",
maxWidth: "100vw"
}}
+ spellCheck={!tab.session?.spellCheckDisabled}
ref={editorRoot}
onDoubleClick={onClickEmptyArea}
>
diff --git a/packages/editor-mobile/src/hooks/useTabStore.ts b/packages/editor-mobile/src/hooks/useTabStore.ts
index 3a961e57d..b170b4f60 100644
--- a/packages/editor-mobile/src/hooks/useTabStore.ts
+++ b/packages/editor-mobile/src/hooks/useTabStore.ts
@@ -35,6 +35,7 @@ export type TabItem = {
noteLocked?: boolean;
scrollTop?: number;
selection?: { to: number; from: number };
+ spellCheckDisabled: boolean;
};
pinned?: boolean;
needsRefresh?: boolean;
@@ -59,7 +60,8 @@ export const useTabStore = create(
{
id: "679da59a3924d4bd56d16d3f",
session: {
- id: "679da5a5667a16db2353a062"
+ id: "679da5a5667a16db2353a062",
+ spellCheckDisabled: false
}
}
],