mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
feat: configurable line spacing
This commit is contained in:
@@ -26,6 +26,7 @@ export type Settings = {
|
||||
noToolbar?: boolean;
|
||||
noHeader?: boolean;
|
||||
keyboardShown?: boolean;
|
||||
doubleSpacedLines?: boolean;
|
||||
};
|
||||
|
||||
export type EditorProps = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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.'
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user