Skip to content

Commit

Permalink
web: rename to markdown shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Mar 5, 2024
1 parent 3d1726c commit 3465a81
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
15 changes: 12 additions & 3 deletions apps/web/src/components/editor/tiptap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ function TipTap(props: TipTapProps) {
);
const dateFormat = useSettingsStore((store) => store.dateFormat);
const timeFormat = useSettingsStore((store) => store.timeFormat);
const inputRules = useSettingsStore((store) => store.inputRules);
const markdownShortcuts = useSettingsStore(
(store) => store.markdownShortcuts
);
const { toolbarConfig } = useToolbarConfig();
const { isSearching, toggleSearch } = useSearch();

Expand Down Expand Up @@ -181,7 +183,7 @@ function TipTap(props: TipTapProps) {
}
}
},
enableInputRules: inputRules,
enableInputRules: markdownShortcuts,
downloadOptions,
doubleSpacedLines,
dateFormat,
Expand Down Expand Up @@ -292,7 +294,14 @@ function TipTap(props: TipTapProps) {
},
getAttachmentData: onGetAttachmentData
};
}, [readonly, nonce, doubleSpacedLines, dateFormat, timeFormat, inputRules]);
}, [
readonly,
nonce,
doubleSpacedLines,
dateFormat,
timeFormat,
markdownShortcuts
]);

const editor = useTiptap(
tiptapOptions,
Expand Down
17 changes: 8 additions & 9 deletions apps/web/src/dialogs/settings/editor-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,23 @@ symbols (e.g. 202305261253)`,
]
},
{
key: "input-rules",
title: "Input rules",
description: `Input rules are triggered whenever you input a specific character combination.
key: "markdown-shortcuts",
title: "Markdown shortcuts",
description: `Markdown shortcuts are triggered whenever you input a specific character combination.
A few examples of this:
For example:
1. Typing '/date' adds the current Date
2. Wrapping something in '**' turns it into bold text
3. Typing '1.' automatically creates a numbered list.
This behavior can be disabled via this setting.`,
4. etc.`,
onStateChange: (listener) =>
useSettingStore.subscribe((c) => c.inputRules, listener),
useSettingStore.subscribe((c) => c.markdownShortcuts, listener),
components: [
{
type: "toggle",
isToggled: () => useSettingStore.getState().inputRules,
toggle: () => useSettingStore.getState().toggleInputRules()
isToggled: () => useSettingStore.getState().markdownShortcuts,
toggle: () => useSettingStore.getState().toggleMarkdownShortcuts()
}
]
}
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/stores/setting-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SettingStore extends BaseStore {
PATHS.backupsDirectory
);
doubleSpacedParagraphs = Config.get("doubleSpacedLines", true);
inputRules = Config.get("inputRules", true);
markdownShortcuts = Config.get("markdownShortcuts", true);
notificationsSettings = Config.get("notifications", { reminder: true });

zoomFactor = 1.0;
Expand Down Expand Up @@ -167,11 +167,11 @@ class SettingStore extends BaseStore {
Config.set("doubleSpacedLines", !doubleSpacedParagraphs);
};

toggleInputRules = (toggleState) => {
toggleMarkdownShortcuts = (toggleState) => {
this.set((state) => {
state.inputRules =
toggleState !== undefined ? toggleState : !state.inputRules;
Config.set("inputRules", state.inputRules);
state.markdownShortcuts =
toggleState !== undefined ? toggleState : !state.markdownShortcuts;
Config.set("markdownShortcuts", state.markdownShortcuts);
});
};

Expand Down

0 comments on commit 3465a81

Please sign in to comment.