Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code syntax improvment (initialize func) #3277

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/mermaidAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,23 +491,20 @@ function updateRendererConfigs(conf) {
/** @param {any} options */
function initialize(options) {
// Handle legacy location of font-family configuration
if (options && options.fontFamily) {
if (!options.themeVariables) {
if (options?.fontFamily) {
if (!options.themeVariables?.fontFamily) {
options.themeVariables = { fontFamily: options.fontFamily };
} else {
if (!options.themeVariables.fontFamily) {
options.themeVariables = { fontFamily: options.fontFamily };
}
}
}

// Set default options
configApi.saveConfigFromInitialize(options);

if (options && options.theme && theme[options.theme]) {
if (options?.theme && theme[options.theme]) {
// Todo merge with user options
options.themeVariables = theme[options.theme].getThemeVariables(options.themeVariables);
} else {
if (options) options.themeVariables = theme.default.getThemeVariables(options.themeVariables);
} else if (options) {
options.themeVariables = theme.default.getThemeVariables(options.themeVariables);
}

const config =
Expand Down