From 7cba061d187236913aae0ae47cc76625b2bc8a44 Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Fri, 29 Apr 2022 10:01:25 -0700 Subject: [PATCH 1/2] add missing quotes to example theme default --- docs/8.6.0_docs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/8.6.0_docs.md b/docs/8.6.0_docs.md index 68da8f868..f5ebfc1ab 100644 --- a/docs/8.6.0_docs.md +++ b/docs/8.6.0_docs.md @@ -7,7 +7,7 @@ With version 8.6.0 comes the release of directives for mermaid, a new system for modifying configurations, with the aim of establishing centralized, sane defaults and simple implementation. `directives` allow for a single-use overwriting of `config`, as it has been discussed in [Configurations](./Setup.md). -This allows site Diagram Authors to instantiate temporary modifications to `config` through the use of [Directives](), which are parsed before rendering diagram definitions. This allows the Diagram Authors to alter the appearance of the diagrams. +This allows site Diagram Authors to instantiate temporary modifications to `config` through the use of [Directives](), which are parsed before rendering diagram definitions. This allows the Diagram Authors to alter the appearance of the diagrams. **A likely application for this is in the creation of diagrams/charts inside company/organizational webpages, that rely on mermaid for diagram and chart rendering.** @@ -65,7 +65,7 @@ init would be an argument-directive: `%%{init: { **insert argument here**}}%%` The json object that is passed as {**argument** } must be valid, quoted json or it will be ignored. **for example**: -`%%{init: {"theme": default, "logLevel": 1 }}%%` +`%%{init: {"theme": "default", "logLevel": 1 }}%%` Configurations that are passed through init cannot change the parameters in secure arrays of higher levels. In the event of a conflict, mermaid will give priority to secure arrays and parse the request, without changing the values of the parameters in conflict. From 01272386451cbd193bf9d2153b8d014078cec431 Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Fri, 29 Apr 2022 17:46:19 -0700 Subject: [PATCH 2/2] protect config.js from attempting to use invalid theme name --- src/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.js b/src/config.js index a9fca15e8..7ae58cc32 100644 --- a/src/config.js +++ b/src/config.js @@ -27,7 +27,7 @@ export const updateCurrentConfig = (siteCfg, _directives) => { cfg = assignWithDepth(cfg, sumOfDirectives); - if (sumOfDirectives.theme) { + if (sumOfDirectives.theme && theme[sumOfDirectives.theme]) { const tmpConfigFromInitialize = assignWithDepth({}, configFromInitialize); const themeVariables = assignWithDepth( tmpConfigFromInitialize.themeVariables || {}, @@ -59,7 +59,7 @@ export const setSiteConfig = (conf) => { siteConfig = assignWithDepth({}, defaultConfig); siteConfig = assignWithDepth(siteConfig, conf); - if (conf.theme) { + if (conf.theme && theme[conf.theme]) { siteConfig.themeVariables = theme[conf.theme].getThemeVariables(conf.themeVariables); }