client,server: Enforce min value of max content width (closes #593)

This commit is contained in:
Elian Doran 2024-11-15 22:29:59 +02:00
parent 40c9ef69e7
commit 2260dcefe5
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View File

@ -2,6 +2,8 @@ import OptionsWidget from "../options_widget.js";
import utils from "../../../../services/utils.js"; import utils from "../../../../services/utils.js";
import { t } from "../../../../services/i18n.js"; import { t } from "../../../../services/i18n.js";
const MIN_VALUE = 640;
const TPL = ` const TPL = `
<div class="options-section"> <div class="options-section">
<h4>${t("max_content_width.title")}</h4> <h4>${t("max_content_width.title")}</h4>
@ -11,7 +13,7 @@ const TPL = `
<div class="form-group row"> <div class="form-group row">
<div class="col-6"> <div class="col-6">
<label>${t("max_content_width.max_width_label")}</label> <label>${t("max_content_width.max_width_label")}</label>
<input type="number" min="200" step="10" class="max-content-width form-control options-number-input"> <input type="number" min="${MIN_VALUE}" step="10" class="max-content-width form-control options-number-input">
</div> </div>
</div> </div>
@ -34,6 +36,6 @@ export default class MaxContentWidthOptions extends OptionsWidget {
} }
async optionsLoaded(options) { async optionsLoaded(options) {
this.$maxContentWidth.val(options.maxContentWidth); this.$maxContentWidth.val(Math.max(MIN_VALUE, options.maxContentWidth));
} }
} }

View File

@ -42,7 +42,7 @@ function index(req: Request, res: Response) {
isDev: env.isDev(), isDev: env.isDev(),
isMainWindow: !req.query.extraWindow, isMainWindow: !req.query.extraWindow,
isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(), isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),
maxContentWidth: parseInt(options.maxContentWidth), maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),
triliumVersion: packageJson.version, triliumVersion: packageJson.version,
assetPath: assetPath, assetPath: assetPath,
appPath: appPath appPath: appPath