feat: configurable line spacing

This commit is contained in:
ammarahm-ed
2022-08-06 23:37:33 +05:00
parent e8887ff42a
commit 6ed4adf9b4
6 changed files with 29 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ export type Settings = {
noToolbar?: boolean;
noHeader?: boolean;
keyboardShown?: boolean;
doubleSpacedLines?: boolean;
};
export type EditorProps = {

View File

@@ -123,6 +123,7 @@ export const useEditorEvents = (
const handleBack = useRef<NativeEventSubscription>();
const readonly = useEditorStore(state => state.readonly);
const isPremium = useUserStore(state => state.premium);
const doubleSpacedLines = useSettingStore(state => state.settings?.doubleSpacedLines);
const tools = useDragState(state => state.data);
const { keyboardShown } = useKeyboard();
if (!editor) return null;
@@ -137,7 +138,8 @@ export const useEditorEvents = (
tools: tools || getDefaultPresets().default,
noHeader: noHeader,
noToolbar: readonly || editorPropReadonly || noToolbar,
keyboardShown: keyboardShown || false
keyboardShown: keyboardShown || false,
doubleSpacedLines: doubleSpacedLines
});
}, [
fullscreen,
@@ -148,7 +150,8 @@ export const useEditorEvents = (
deviceMode,
tools,
editor.commands,
keyboardShown
keyboardShown,
doubleSpacedLines
]);
const onBackPress = useCallback(async () => {
@@ -298,7 +301,7 @@ export const useEditorEvents = (
break;
case EventTypes.filepicker:
const { pick } = require('./picker.js').default;
pick({ type: 'image' });
pick({ type: editorMessage.value });
break;
case EventTypes.download:
console.log('download attachment request', editorMessage.value);

View File

@@ -31,6 +31,8 @@ export const SectionItem = React.memo(
//@ts-ignore
[item.property]: !settings[item.property]
});
//@ts-ignore
item.onChange?.(!settings[item.property]);
};
const styles =

View File

@@ -736,6 +736,22 @@ export const settingsGroups: SettingSection[] = [
modifer: () => {
useDragState.getState().setPreset('default');
}
},
{
id: 'double-spaced-lines',
name: 'Use double spaced lines',
description: `New lines will be double spaced (old ones won't be affected).`,
type: 'switch',
property: 'doubleSpacedLines',
icon: 'format-line-spacing',
onChange: property => {
ToastEvent.show({
heading: 'Line spacing changed',
type: 'success',
message:
'Close and reopen the current opened note or restart the app for changes to take affect.'
});
}
}
]
},

View File

@@ -13,6 +13,7 @@ export type SettingSection = {
getter?: (...args: any[]) => any;
useHook?: (...args: any[]) => unknown;
hidden?: (current: any) => boolean;
onChange?: (property: boolean) => void;
};
export type SettingsGroup = {

View File

@@ -42,6 +42,7 @@ export type Settings = {
lastVerificationEmailTime?: number;
sessionExpired: boolean;
version: number | null;
doubleSpacedLines?: boolean;
};
type Dimensions = {
@@ -103,7 +104,8 @@ export const useSettingStore = create<SettingStore>((set, get) => ({
},
showBackupCompleteSheet: true,
sessionExpired: false,
version: null
version: null,
doubleSpacedLines: true
},
sheetKeyboardHandler: true,
fullscreen: false,