mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Fix classDef issue
This commit is contained in:
parent
a8e49a0d2d
commit
23dfe1e8a9
2
dist/index.html
vendored
2
dist/index.html
vendored
@ -16,6 +16,8 @@ C -->|Two| E[iPhone]
|
||||
C -->|Three| F[Car]
|
||||
click A "index.html#link-clicked" "link test"
|
||||
click B testClick "click test"
|
||||
classDef someclass fill:#f96;
|
||||
class A someclass;
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
@ -215,18 +215,7 @@ export const getClasses = function (text) {
|
||||
|
||||
// Parse the graph definition
|
||||
parser.parse(text)
|
||||
|
||||
const classes = flowDb.getClasses()
|
||||
|
||||
// Add default class if undefined
|
||||
if (typeof (classes.default) === 'undefined') {
|
||||
classes.default = { id: 'default' }
|
||||
classes.default.styles = []
|
||||
classes.default.clusterStyles = ['rx:4px', 'fill: rgb(255, 255, 222)', 'rx: 4px', 'stroke: rgb(170, 170, 51)', 'stroke-width: 1px']
|
||||
classes.default.nodeLabelStyles = ['fill:#000', 'stroke:none', 'font-weight:300', 'font-family:"Helvetica Neue",Helvetica,Arial,sans-serf', 'font-size:14px']
|
||||
classes.default.edgeLabelStyles = ['fill:#000', 'stroke:none', 'font-weight:300', 'font-family:"Helvetica Neue",Helvetica,Arial,sans-serf', 'font-size:14px']
|
||||
}
|
||||
return classes
|
||||
return flowDb.getClasses()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -380,8 +380,17 @@ const render = function (id, txt, cb, container) {
|
||||
const svg = element.firstChild
|
||||
const firstChild = svg.firstChild
|
||||
|
||||
// classDef
|
||||
let style = themes[config.theme] || themes.default
|
||||
if (graphType === 'flowchart') {
|
||||
const classes = flowRenderer.getClasses(txt)
|
||||
for (const className in classes) {
|
||||
style += `\n.${className} rect,.${className} polygon,.${className} circle,.${className} ellipse{${classes[className].styles.join(' !important;')} !important;}`
|
||||
}
|
||||
}
|
||||
|
||||
const style1 = document.createElement('style')
|
||||
style1.innerHTML = scope(themes[config.theme] || themes.default, `#${id}`)
|
||||
style1.innerHTML = scope(style, `#${id}`)
|
||||
svg.insertBefore(style1, firstChild)
|
||||
|
||||
const style2 = document.createElement('style')
|
||||
|
Loading…
x
Reference in New Issue
Block a user