From 5d23df462f89a94f61f4070cfc861fadc1e8d745 Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Thu, 24 Aug 2023 18:19:02 +0300 Subject: [PATCH] work for #6673 import font settings for article elements --- themes-import.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/themes-import.js b/themes-import.js index a6d1b9850f..7ca6b1f9de 100644 --- a/themes-import.js +++ b/themes-import.js @@ -1,6 +1,7 @@ const fs = require("fs"); const MikeThemes = require("./themes.json"); var themes = {}; +var articleFontSettings = {}; const _dirPath = "./src/themes/"; const displayNameMap = { @@ -58,7 +59,19 @@ function getShadowSettings(shadowGroup) { return createBoxShadow(result); } -Object.keys(MikeThemes).forEach(function (themeName) { +if(!!MikeThemes["article"] && Object.keys(MikeThemes["article"]).length > 0) { + const allowedSettings = ["fontSize", "textDecoration", "fontFamily", "fontWeight", "fontStyle", "fontStretch", "letterSpacing", "lineHeight", "paragraphIndent", "paragraphSpacing", "textCase"]; + Object.keys(MikeThemes["article"]).forEach(fontSettingsName => { + const fontSettings = MikeThemes["article"][fontSettingsName]; + if(!!fontSettings && Object.keys(fontSettings).length > 0) { + Object.keys(fontSettings).filter(key => allowedSettings.indexOf(key) !== -1).forEach(key => { + articleFontSettings["--sjs-article-font-" + fontSettingsName + "-" + key] = fontSettings[key] ? fontSettings[key]["value"] : undefined; + }); + } + }); +} + +Object.keys(MikeThemes).filter(key => ["light", "dark", "ui", "article"].indexOf(key) === -1).forEach(function (themeName) { console.log(themeName); const generalGroup = MikeThemes[themeName]["general"]; @@ -128,6 +141,7 @@ Object.keys(MikeThemes).forEach(function (themeName) { themes[displayThemeName]["--sjs-special-yellow-light"] = specialGroup["yellow-light"] ? specialGroup["yellow-light"]["value"] : undefined; themes[displayThemeName]["--sjs-special-yellow-forecolor"] = specialGroup["yellow-forecolor"] ? specialGroup["yellow-forecolor"]["value"] : undefined; } + themes[displayThemeName] = Object.assign(themes[displayThemeName], articleFontSettings); }); const predefinedThemesContent = JSON.stringify(themes, null, 4);