mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 00:09:51 +02:00
Merge branch 'develop' into edge-flicker-fix
This commit is contained in:
@@ -317,6 +317,32 @@ describe('when parsing directions', function () {
|
||||
expect(data4Layout.nodes[3].label).toEqual('for E');
|
||||
expect(data4Layout.nodes[4].label).toEqual('for D');
|
||||
});
|
||||
|
||||
it('should be possible to use @ syntax in labels', function () {
|
||||
const res = flow.parser.parse(`flowchart TD
|
||||
A["@A@"] --> B["@for@ B@"] & C@{ label: "@for@ c@"} & E{"\`@for@ E@\`"} & D(("@for@ D@"))
|
||||
H1{{"@for@ H@"}}
|
||||
H2{{"\`@for@ H@\`"}}
|
||||
Q1{"@for@ Q@"}
|
||||
Q2{"\`@for@ Q@\`"}
|
||||
AS1>"@for@ AS@"]
|
||||
AS2>"\`@for@ AS@\`"]
|
||||
`);
|
||||
|
||||
const data4Layout = flow.parser.yy.getData();
|
||||
expect(data4Layout.nodes.length).toBe(11);
|
||||
expect(data4Layout.nodes[0].label).toEqual('@A@');
|
||||
expect(data4Layout.nodes[1].label).toEqual('@for@ B@');
|
||||
expect(data4Layout.nodes[2].label).toEqual('@for@ c@');
|
||||
expect(data4Layout.nodes[3].label).toEqual('@for@ E@');
|
||||
expect(data4Layout.nodes[4].label).toEqual('@for@ D@');
|
||||
expect(data4Layout.nodes[5].label).toEqual('@for@ H@');
|
||||
expect(data4Layout.nodes[6].label).toEqual('@for@ H@');
|
||||
expect(data4Layout.nodes[7].label).toEqual('@for@ Q@');
|
||||
expect(data4Layout.nodes[8].label).toEqual('@for@ Q@');
|
||||
expect(data4Layout.nodes[9].label).toEqual('@for@ AS@');
|
||||
expect(data4Layout.nodes[10].label).toEqual('@for@ AS@');
|
||||
});
|
||||
it.skip(' should be possible to use @ syntax to add labels with trail spaces', function () {
|
||||
const res = flow.parser.parse(
|
||||
`flowchart TB
|
||||
|
@@ -141,7 +141,7 @@ that id.
|
||||
.*direction\s+RL[^\n]* return 'direction_rl';
|
||||
.*direction\s+LR[^\n]* return 'direction_lr';
|
||||
|
||||
[^\s]+\@(?=[^\{]) { return 'LINK_ID'; }
|
||||
[^\s\"]+\@(?=[^\{\"]) { return 'LINK_ID'; }
|
||||
[0-9]+ return 'NUM';
|
||||
\# return 'BRKT';
|
||||
":::" return 'STYLE_SEPARATOR';
|
||||
|
@@ -1,7 +1,7 @@
|
||||
const getStyles = (options) =>
|
||||
`
|
||||
.mermaid-main-font {
|
||||
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
|
||||
font-family: ${options.fontFamily};
|
||||
}
|
||||
|
||||
.exclude-range {
|
||||
@@ -45,7 +45,7 @@ const getStyles = (options) =>
|
||||
|
||||
.sectionTitle {
|
||||
text-anchor: start;
|
||||
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
|
||||
font-family: ${options.fontFamily};
|
||||
}
|
||||
|
||||
|
||||
@@ -86,13 +86,13 @@ const getStyles = (options) =>
|
||||
|
||||
.taskText {
|
||||
text-anchor: middle;
|
||||
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
|
||||
font-family: ${options.fontFamily};
|
||||
}
|
||||
|
||||
.taskTextOutsideRight {
|
||||
fill: ${options.taskTextDarkColor};
|
||||
text-anchor: start;
|
||||
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
|
||||
font-family: ${options.fontFamily};
|
||||
}
|
||||
|
||||
.taskTextOutsideLeft {
|
||||
@@ -248,7 +248,7 @@ const getStyles = (options) =>
|
||||
text-anchor: middle;
|
||||
font-size: 18px;
|
||||
fill: ${options.titleColor || options.textColor};
|
||||
font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif);
|
||||
font-family: ${options.fontFamily};
|
||||
}
|
||||
`;
|
||||
|
||||
|
@@ -4,11 +4,13 @@ import parser from './parser/sankey.jison';
|
||||
import db from './sankeyDB.js';
|
||||
import renderer from './sankeyRenderer.js';
|
||||
import { prepareTextForParsing } from './sankeyUtils.js';
|
||||
import sankeyStyles from './styles.js';
|
||||
|
||||
const originalParse = parser.parse.bind(parser);
|
||||
parser.parse = (text: string) => originalParse(prepareTextForParsing(text));
|
||||
|
||||
export const diagram: DiagramDefinition = {
|
||||
styles: sankeyStyles,
|
||||
parser,
|
||||
db,
|
||||
renderer,
|
||||
|
@@ -136,7 +136,6 @@ export const draw = function (text: string, id: string, _version: string, diagOb
|
||||
svg
|
||||
.append('g')
|
||||
.attr('class', 'node-labels')
|
||||
.attr('font-family', 'sans-serif')
|
||||
.attr('font-size', 14)
|
||||
.selectAll('text')
|
||||
.data(graph.nodes)
|
||||
|
6
packages/mermaid/src/diagrams/sankey/styles.js
Normal file
6
packages/mermaid/src/diagrams/sankey/styles.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const getStyles = (options) =>
|
||||
`.label {
|
||||
font-family: ${options.fontFamily};
|
||||
}`;
|
||||
|
||||
export default getStyles;
|
@@ -1,7 +1,6 @@
|
||||
const getStyles = (options) =>
|
||||
`.label {
|
||||
font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
||||
font-family: var(--mermaid-font-family);
|
||||
font-family: ${options.fontFamily};
|
||||
color: ${options.textColor};
|
||||
}
|
||||
.mouth {
|
||||
@@ -79,8 +78,7 @@ const getStyles = (options) =>
|
||||
text-align: center;
|
||||
max-width: 200px;
|
||||
padding: 2px;
|
||||
font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
||||
font-family: var(--mermaid-font-family);
|
||||
font-family: ${options.fontFamily};
|
||||
font-size: 12px;
|
||||
background: ${options.tertiaryColor};
|
||||
border: 1px solid ${options.border2};
|
||||
|
Reference in New Issue
Block a user