mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 08:15:52 +01:00
allow overriding theme fonts
This commit is contained in:
33
src/routes/api/fonts.js
Normal file
33
src/routes/api/fonts.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const optionService = require('../../services/options');
|
||||
|
||||
function getFontCss(req, res) {
|
||||
res.setHeader('Content-Type', 'text/css');
|
||||
|
||||
if (!optionService.getOptionBool('overrideThemeFonts')) {
|
||||
res.send('');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const optionsMap = optionService.getOptionsMap();
|
||||
|
||||
// using body to be more specific than themes' :root
|
||||
res.send(`
|
||||
body {
|
||||
--main-font-family: ${optionsMap.mainFontFamily};
|
||||
--main-font-size: ${optionsMap.mainFontSize}%;
|
||||
|
||||
--tree-font-family: ${optionsMap.treeFontFamily};
|
||||
--tree-font-size: ${optionsMap.treeFontSize}%;
|
||||
|
||||
--detail-font-family: ${optionsMap.detailFontFamily};
|
||||
--detail-font-size: ${optionsMap.detailFontSize}%;
|
||||
|
||||
--monospace-font-family: ${optionsMap.monospaceFontFamily};
|
||||
--monospace-font-size: ${optionsMap.monospaceFontSize};
|
||||
}`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getFontCss
|
||||
};
|
||||
@@ -17,8 +17,13 @@ const ALLOWED_OPTIONS = new Set([
|
||||
'syncProxy',
|
||||
'hoistedNoteId',
|
||||
'mainFontSize',
|
||||
'mainFontFamily',
|
||||
'treeFontSize',
|
||||
'treeFontFamily',
|
||||
'detailFontSize',
|
||||
'detailFontFamily',
|
||||
'monospaceFontSize',
|
||||
'monospaceFontFamily',
|
||||
'openTabs',
|
||||
'noteInfoWidget',
|
||||
'attributesWidget',
|
||||
@@ -44,7 +49,8 @@ const ALLOWED_OPTIONS = new Set([
|
||||
'headingStyle',
|
||||
'autoCollapseNoteTree',
|
||||
'autoReadonlySizeText',
|
||||
'autoReadonlySizeCode'
|
||||
'autoReadonlySizeCode',
|
||||
'overrideThemeFonts'
|
||||
]);
|
||||
|
||||
function getOptions() {
|
||||
|
||||
@@ -38,6 +38,7 @@ const similarNotesRoute = require('./api/similar_notes');
|
||||
const keysRoute = require('./api/keys');
|
||||
const backendLogRoute = require('./api/backend_log');
|
||||
const statsRoute = require('./api/stats');
|
||||
const fontsRoute = require('./api/fonts');
|
||||
|
||||
const log = require('../services/log');
|
||||
const express = require('express');
|
||||
@@ -326,6 +327,8 @@ function register(app) {
|
||||
|
||||
apiRoute(POST, '/api/delete-notes-preview', notesApiRoute.getDeleteNotesPreview);
|
||||
|
||||
route(GET, '/api/fonts', [auth.checkApiAuthOrElectron], fontsRoute.getFontCss);
|
||||
|
||||
app.use('', router);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user