From b2b6ad479a56d53d31e74b6a8e73361d830b3eda Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Thu, 10 Jun 2021 10:59:15 +0200 Subject: [PATCH] Revert "Desktop: Make font size consistent between Markdown and Rich Text editors" This reverts commit a058e09183ef9915e5eaffeb152c975b96692aea. Reverts because this change means the settings are directly accessed from the theme, which makes the themes unusable from Joplin Server. --- packages/lib/models/Setting.ts | 2 +- packages/lib/theme.ts | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/lib/models/Setting.ts b/packages/lib/models/Setting.ts index ef45a2e1b8..f3f2a8a951 100644 --- a/packages/lib/models/Setting.ts +++ b/packages/lib/models/Setting.ts @@ -909,7 +909,7 @@ class Setting extends BaseModel { // Deprecated in favour of windowContentZoomFactor 'style.zoom': { value: 100, type: SettingItemType.Int, public: false, storage: SettingStorage.File, appTypes: ['desktop'], section: 'appearance', label: () => '', minimum: 50, maximum: 500, step: 10 }, - 'style.editor.fontSize': { value: 15, type: SettingItemType.Int, public: true, storage: SettingStorage.File, appTypes: ['desktop'], section: 'appearance', label: () => _('Editor font size'), minimum: 4, maximum: 50, step: 1 }, + 'style.editor.fontSize': { value: 13, type: SettingItemType.Int, public: true, storage: SettingStorage.File, appTypes: ['desktop'], section: 'appearance', label: () => _('Editor font size'), minimum: 4, maximum: 50, step: 1 }, 'style.editor.fontFamily': (mobilePlatform) ? ({ diff --git a/packages/lib/theme.ts b/packages/lib/theme.ts index d4a9b97e40..7a814d9ddf 100644 --- a/packages/lib/theme.ts +++ b/packages/lib/theme.ts @@ -52,7 +52,7 @@ const globalStyle: any = { disabledOpacity: 0.3, buttonMinWidth: 50, buttonMinHeight: 30, - // editorFontSize: 12, + editorFontSize: 12, textAreaLineHeight: 17, lineHeight: '1.6em', headerButtonHPadding: 6, @@ -368,22 +368,23 @@ const themeCache_: any = {}; function themeStyle(themeId: number) { if (!themeId) throw new Error('Theme must be specified'); - const cacheKey = `${themeId}_${Setting.value('style.editor.fontSize')}`; + const zoomRatio = 1; + + const cacheKey = themeId; if (themeCache_[cacheKey]) return themeCache_[cacheKey]; // Font size are not theme specific, but they must be referenced // and computed here to allow them to respond to settings changes // without the need to restart const fontSizes: any = { - fontSize: 12, + fontSize: Math.round(12 * zoomRatio), toolbarIconSize: 18, }; - // For consistency, and now that the Markdown editor can use non-monospace - // fonts, we use the same font size everywhere. - fontSizes.noteViewerFontSize = Setting.value('style.editor.fontSize'); // fontSizes.fontSize; //Math.round(fontSizes.fontSize * 1.25); + fontSizes.noteViewerFontSize = Math.round(fontSizes.fontSize * 1.25); let output: any = {}; + output.zoomRatio = zoomRatio; // All theme are based on the light style, and just override the // relevant properties @@ -405,7 +406,7 @@ const cachedStyles_: any = { // the dependencies of the style change. If the style depends only // on the theme, a static string can be provided as a cache key. function buildStyle(cacheKey: any, themeId: number, callback: Function) { - cacheKey = `${Array.isArray(cacheKey) ? cacheKey.join('_') : cacheKey}_${Setting.value('style.editor.fontSize')}`; + cacheKey = Array.isArray(cacheKey) ? cacheKey.join('_') : cacheKey; // We clear the cache whenever switching themes if (cachedStyles_.themeId !== themeId) {