From 2fcb7e9867abc194c8b528a41d9f84d99fb78e40 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Tue, 29 Nov 2022 20:46:22 +0530 Subject: [PATCH] fix: Make super note styling consistent with plaintext notes on mobile --- .../blocks-editor/src/Editor/BlocksEditor.tsx | 4 --- .../NoteView/SuperEditor/SuperEditor.tsx | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/blocks-editor/src/Editor/BlocksEditor.tsx b/packages/blocks-editor/src/Editor/BlocksEditor.tsx index 5a96b6615e4..d90891b15c1 100644 --- a/packages/blocks-editor/src/Editor/BlocksEditor.tsx +++ b/packages/blocks-editor/src/Editor/BlocksEditor.tsx @@ -24,7 +24,6 @@ import FloatingLinkEditorPlugin from '../Lexical/Plugins/FloatingLinkEditorPlugi import {truncateString} from './Utils'; import {SuperEditorContentId} from './Constants'; import {classNames} from '@standardnotes/utils'; -import {EditorLineHeight} from '@standardnotes/snjs'; import {MarkdownTransformers} from './MarkdownTransformers'; type BlocksEditorProps = { @@ -34,7 +33,6 @@ type BlocksEditorProps = { previewLength?: number; spellcheck?: boolean; ignoreFirstChange?: boolean; - lineHeight?: EditorLineHeight; readonly?: boolean; }; @@ -45,7 +43,6 @@ export const BlocksEditor: FunctionComponent = ({ previewLength, spellcheck, ignoreFirstChange = false, - lineHeight, readonly, }) => { const [didIgnoreFirstChange, setDidIgnoreFirstChange] = useState(false); @@ -103,7 +100,6 @@ export const BlocksEditor: FunctionComponent = ({ id={SuperEditorContentId} className={classNames( 'ContentEditable__root overflow-y-auto', - lineHeight && `leading-${lineHeight.toLowerCase()}`, className, )} spellCheck={spellcheck} diff --git a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx index 3f3f4c950e4..717c29cbce2 100644 --- a/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx +++ b/packages/web/src/javascripts/Components/NoteView/SuperEditor/SuperEditor.tsx @@ -1,5 +1,12 @@ import { WebApplication } from '@/Application/Application' -import { ApplicationEvent, EditorLineHeight, isPayloadSourceRetrieved, PrefKey } from '@standardnotes/snjs' +import { + ApplicationEvent, + classNames, + EditorFontSize, + EditorLineHeight, + isPayloadSourceRetrieved, + PrefKey, +} from '@standardnotes/snjs' import { FunctionComponent, useCallback, useEffect, useRef, useState } from 'react' import { BlocksEditor, BlocksEditorComposer } from '@standardnotes/blocks-editor' import { ItemSelectionPlugin } from './Plugins/ItemSelectionPlugin/ItemSelectionPlugin' @@ -29,6 +36,7 @@ import { SuperNoteMarkdownPreview } from './SuperNoteMarkdownPreview' import { ExportPlugin } from './Plugins/ExportPlugin/ExportPlugin' import GetMarkdownPlugin, { GetMarkdownPluginInterface } from './Plugins/GetMarkdownPlugin/GetMarkdownPlugin' import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin' +import { getPlaintextFontSize } from '@/Utils/getPlaintextFontSize' const NotePreviewCharLimit = 160 @@ -81,8 +89,6 @@ export const SuperEditor: FunctionComponent = ({ }) }, [application]) - const [lineHeight, setLineHeight] = useState(PrefDefaults[PrefKey.EditorLineHeight]) - const handleChange = useCallback( async (value: string, preview: string) => { if (ignoreNextChange.current === true) { @@ -129,10 +135,15 @@ export const SuperEditor: FunctionComponent = ({ return disposer }, [controller, controller.item.uuid]) + const [lineHeight, setLineHeight] = useState(PrefDefaults[PrefKey.EditorLineHeight]) + const [fontSize, setFontSize] = useState() + const reloadPreferences = useCallback(() => { const lineHeight = application.getPreference(PrefKey.EditorLineHeight, PrefDefaults[PrefKey.EditorLineHeight]) + const fontSize = application.getPreference(PrefKey.EditorFontSize, PrefDefaults[PrefKey.EditorFontSize]) setLineHeight(lineHeight) + setFontSize(fontSize) }, [application]) useEffect(() => { @@ -144,7 +155,7 @@ export const SuperEditor: FunctionComponent = ({ }, [reloadPreferences, application]) return ( -
+
<> @@ -157,10 +168,13 @@ export const SuperEditor: FunctionComponent = ({