From 2260dcefe5958064ea5079268f1bee3093b77007 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 15 Nov 2024 22:29:59 +0200 Subject: [PATCH] client,server: Enforce min value of max content width (closes #593) --- .../type_widgets/options/appearance/max_content_width.js | 6 ++++-- src/routes/index.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/public/app/widgets/type_widgets/options/appearance/max_content_width.js b/src/public/app/widgets/type_widgets/options/appearance/max_content_width.js index a874dff3f..bb5a9d85c 100644 --- a/src/public/app/widgets/type_widgets/options/appearance/max_content_width.js +++ b/src/public/app/widgets/type_widgets/options/appearance/max_content_width.js @@ -2,6 +2,8 @@ import OptionsWidget from "../options_widget.js"; import utils from "../../../../services/utils.js"; import { t } from "../../../../services/i18n.js"; +const MIN_VALUE = 640; + const TPL = `

${t("max_content_width.title")}

@@ -11,7 +13,7 @@ const TPL = `
- +
@@ -34,6 +36,6 @@ export default class MaxContentWidthOptions extends OptionsWidget { } async optionsLoaded(options) { - this.$maxContentWidth.val(options.maxContentWidth); + this.$maxContentWidth.val(Math.max(MIN_VALUE, options.maxContentWidth)); } } diff --git a/src/routes/index.ts b/src/routes/index.ts index 7cc0a5014..ca204e868 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -42,7 +42,7 @@ function index(req: Request, res: Response) { isDev: env.isDev(), isMainWindow: !req.query.extraWindow, isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(), - maxContentWidth: parseInt(options.maxContentWidth), + maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)), triliumVersion: packageJson.version, assetPath: assetPath, appPath: appPath