Skip to content

Commit 34b4d8a

Browse files
committed
web: add editor line height setting
Signed-off-by: 01zulfi <[email protected]>
1 parent 33c3bf0 commit 34b4d8a

File tree

7 files changed

+56
-6
lines changed

7 files changed

+56
-6
lines changed

apps/web/src/components/editor/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ export const EDITOR_ZOOM = {
2323
MIN: 30,
2424
STEP: 10
2525
};
26+
27+
export const EDITOR_LINE_HEIGHT = {
28+
DEFAULT: 1.2,
29+
MAX: 10,
30+
MIN: 1
31+
};

apps/web/src/components/editor/manager.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ import BaseStore from "../../stores";
2424
import type { TOCItem, ToolbarDefinition } from "@notesnook/editor";
2525
import Config from "../../utils/config";
2626
import { getCurrentPreset } from "../../common/toolbar-config";
27-
import { EDITOR_ZOOM } from "./common";
27+
import { EDITOR_LINE_HEIGHT, EDITOR_ZOOM } from "./common";
28+
29+
type EditorConfig = {
30+
fontFamily: string;
31+
fontSize: number;
32+
zoom: number;
33+
lineHeight: number;
34+
};
2835

29-
type EditorConfig = { fontFamily: string; fontSize: number; zoom: number };
3036
type EditorContext = {
3137
editor?: IEditor;
3238
canUndo?: boolean;
@@ -41,7 +47,8 @@ class EditorManager extends BaseStore<EditorManager> {
4147
editorConfig: EditorConfig = Config.get("editorConfig", {
4248
fontFamily: "sans-serif",
4349
fontSize: 14,
44-
zoom: EDITOR_ZOOM.DEFAULT
50+
zoom: EDITOR_ZOOM.DEFAULT,
51+
lineHeight: EDITOR_LINE_HEIGHT.DEFAULT
4552
});
4653
editors: Record<string, EditorContext> = {};
4754

apps/web/src/components/editor/tiptap.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ function TiptapWrapper(
623623
".tiptap.ProseMirror": { pb: 150 },
624624
".editor-container": {
625625
opacity: isHydrating ? 0 : 1,
626-
zoom: editorConfig.zoom + "%"
626+
zoom: editorConfig.zoom + "%",
627+
lineHeight: editorConfig.lineHeight
627628
},
628629
".editor-loading-container.hidden": { display: "none" }
629630
}}

apps/web/src/dialogs/settings/editor-settings.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import { useStore as useSettingStore } from "../../stores/setting-store";
2727
import { getFonts } from "@notesnook/editor";
2828
import { useSpellChecker } from "../../hooks/use-spell-checker";
2929
import { SpellCheckerLanguages } from "./components/spell-checker-languages";
30-
3130
import { CustomizeToolbar } from "./components/customize-toolbar";
3231
import { DictionaryWords } from "./components/dictionary-words";
3332
import { strings } from "@notesnook/intl";
3433
import { isMac } from "../../utils/platform";
34+
import { EDITOR_LINE_HEIGHT } from "../../components/editor/common";
3535

3636
export const EditorSettings: SettingsGroup[] = [
3737
{
@@ -94,6 +94,24 @@ export const EditorSettings: SettingsGroup[] = [
9494
}
9595
]
9696
},
97+
{
98+
key: "line-height",
99+
title: strings.lineHeight(),
100+
description: strings.lineHeightDesc(),
101+
onStateChange: (listener) =>
102+
onEditorConfigChange((c) => c.lineHeight, listener),
103+
components: [
104+
{
105+
type: "input",
106+
inputType: "number",
107+
max: EDITOR_LINE_HEIGHT.MAX,
108+
min: EDITOR_LINE_HEIGHT.MIN,
109+
defaultValue: () => editorConfig().lineHeight,
110+
onChange: (value) =>
111+
useEditorManager.getState().setEditorConfig({ lineHeight: value })
112+
}
113+
]
114+
},
97115
{
98116
key: "double-spacing",
99117
title: strings.doubleSpacedLines(),

packages/intl/locale/en.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ msgstr "Add your first note"
747747
msgid "Add your first notebook"
748748
msgstr "Add your first notebook"
749749

750+
#: src/strings.ts:2614
751+
msgid "Adjust the line height of the editor"
752+
msgstr "Adjust the line height of the editor"
753+
750754
#: src/strings.ts:2170
751755
msgid "Advanced"
752756
msgstr "Advanced"
@@ -3534,6 +3538,10 @@ msgstr "Light"
35343538
msgid "Line {line}, Column {column}"
35353539
msgstr "Line {line}, Column {column}"
35363540

3541+
#: src/strings.ts:2613
3542+
msgid "Line height"
3543+
msgstr "Line height"
3544+
35373545
#: src/strings.ts:1151
35383546
msgid "Line spacing changed"
35393547
msgstr "Line spacing changed"

packages/intl/locale/pseudo-LOCALE.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ msgstr ""
747747
msgid "Add your first notebook"
748748
msgstr ""
749749

750+
#: src/strings.ts:2614
751+
msgid "Adjust the line height of the editor"
752+
msgstr ""
753+
750754
#: src/strings.ts:2170
751755
msgid "Advanced"
752756
msgstr ""
@@ -3514,6 +3518,10 @@ msgstr ""
35143518
msgid "Line {line}, Column {column}"
35153519
msgstr ""
35163520

3521+
#: src/strings.ts:2613
3522+
msgid "Line height"
3523+
msgstr ""
3524+
35173525
#: src/strings.ts:1151
35183526
msgid "Line spacing changed"
35193527
msgstr ""

packages/intl/src/strings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2609,5 +2609,7 @@ Use this if changes from other devices are not appearing on this device. This wi
26092609
views: () => t`Views`,
26102610
clickToUpdate: () => t`Click to update`,
26112611
noPassword: () => t`No password`,
2612-
publishToTheWeb: () => t`Publish to the web`
2612+
publishToTheWeb: () => t`Publish to the web`,
2613+
lineHeight: () => t`Line height`,
2614+
lineHeightDesc: () => t`Adjust the line height of the editor`
26132615
};

0 commit comments

Comments
 (0)