-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat: Add getConfigValue
#5251
feat: Add getConfigValue
#5251
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import type { D3Element } from '../../mermaidAPI.js'; | |
import { sanitizeText } from '../../diagrams/common/common.js'; | ||
import { log } from '../../logger.js'; | ||
import type { MindmapNode } from './mindmapTypes.js'; | ||
import { defaultConfig } from '../../config.js'; | ||
import { getConfigValue } from '../../config.js'; | ||
|
||
let nodes: MindmapNode[] = []; | ||
let cnt = 0; | ||
|
@@ -32,7 +32,7 @@ const getMindmap = () => { | |
const addNode = (level: number, id: string, descr: string, type: number) => { | ||
log.info('addNode', level, id, descr, type); | ||
const conf = getConfig(); | ||
let padding: number = conf.mindmap?.padding ?? defaultConfig.mindmap.padding; | ||
let padding: number = getConfigValue(conf, 'mindmap.padding'); | ||
switch (type) { | ||
case nodeType.ROUNDED_RECT: | ||
case nodeType.RECT: | ||
|
@@ -47,7 +47,7 @@ const addNode = (level: number, id: string, descr: string, type: number) => { | |
descr: sanitizeText(descr, conf), | ||
type, | ||
children: [], | ||
width: conf.mindmap?.maxNodeWidth ?? defaultConfig.mindmap.maxNodeWidth, | ||
width: getConfigValue(conf, 'mindmap.maxNodeWidth'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also not a big fan of this syntax, since it makes things more complicated. Ideally, we'd instead change The only reason I haven't yet is that some of the config values don't have default values, because Then we could just do: |
||
padding, | ||
} satisfies MindmapNode; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for values that valid but falsy,
false
,0
, or""
.