mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-12 16:54:10 +01:00
Changes after merge
This commit is contained in:
@@ -126,6 +126,17 @@ context('Sequence diagram', () => {
|
|||||||
{ sequence: { noteAlign: 'left' } }
|
{ sequence: { noteAlign: 'left' } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should render multi-line notes aligned to the left when configured', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice->>Bob: I'm short
|
||||||
|
note left of Alice: I am left aligned<br>but also<br>multiline
|
||||||
|
Bob->>Alice: Short as well
|
||||||
|
`,
|
||||||
|
{ sequence: { noteAlign: 'left' } }
|
||||||
|
);
|
||||||
|
});
|
||||||
it('should render notes aligned to the right when configured', () => {
|
it('should render notes aligned to the right when configured', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
@@ -137,6 +148,37 @@ context('Sequence diagram', () => {
|
|||||||
{ sequence: { noteAlign: 'right' } }
|
{ sequence: { noteAlign: 'right' } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('should render multi-line notes aligned to the right when configured', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice->>Bob: I'm short
|
||||||
|
note left of Alice: I am right aligned<br>but also<br>multiline
|
||||||
|
Bob->>Alice: Short as well
|
||||||
|
`,
|
||||||
|
{ sequence: { noteAlign: 'right' } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render multi-line messages aligned to the left when configured', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice->>Bob: I'm short<br>but also<br>multiline
|
||||||
|
Bob->>Alice: Short as well<br>and also<br>multiline
|
||||||
|
`,
|
||||||
|
{ sequence: { messageAlign: 'left' } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should render multi-line messages aligned to the right when configured', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
sequenceDiagram
|
||||||
|
Alice->>Bob: I'm short<br>but also<br>multiline
|
||||||
|
Bob->>Alice: Short as well<br>and also<br>multiline
|
||||||
|
`,
|
||||||
|
{ sequence: { messageAlign: 'right' } }
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
context('auth width scaling', () => {
|
context('auth width scaling', () => {
|
||||||
it('should render long actor descriptions', () => {
|
it('should render long actor descriptions', () => {
|
||||||
|
|||||||
@@ -197,5 +197,24 @@ root((the root))
|
|||||||
expect(mm.children.length).toEqual(1);
|
expect(mm.children.length).toEqual(1);
|
||||||
expect(mm.children[0].descr).toEqual('String containing ()');
|
expect(mm.children[0].descr).toEqual('String containing ()');
|
||||||
});
|
});
|
||||||
|
it('should be possible to have a child after a class assignment', function () {
|
||||||
|
var str = `mindmap
|
||||||
|
root(Root)
|
||||||
|
Child(Child)
|
||||||
|
:::hot
|
||||||
|
a(a)
|
||||||
|
b[New Stuff]`;
|
||||||
|
mindmap.parse(str);
|
||||||
|
const mm = mindmap.yy.getMindmap();
|
||||||
|
expect(mm.nodeId).toEqual('root');
|
||||||
|
expect(mm.descr).toEqual('Root');
|
||||||
|
expect(mm.children.length).toEqual(1);
|
||||||
|
|
||||||
|
const child = mm.children[0];
|
||||||
|
expect(child.nodeId).toEqual('Child');
|
||||||
|
expect(child.children[0].nodeId).toEqual('a');
|
||||||
|
expect(child.children.length).toEqual(2);
|
||||||
|
expect(child.children[1].nodeId).toEqual('b');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ function eachNode(mindmap, callback) {
|
|||||||
}
|
}
|
||||||
/** @param {object} mindmap */
|
/** @param {object} mindmap */
|
||||||
function transpose(mindmap) {
|
function transpose(mindmap) {
|
||||||
console.log('transpose', mindmap);
|
|
||||||
eachNode(mindmap, (node) => {
|
eachNode(mindmap, (node) => {
|
||||||
// node.y = node.y - (node.y - bb.top) * 2 - node.height;
|
|
||||||
const orgWidth = node.width;
|
const orgWidth = node.width;
|
||||||
const orgX = node.x;
|
const orgX = node.x;
|
||||||
node.width = node.height;
|
node.width = node.height;
|
||||||
@@ -91,7 +89,7 @@ function rightToLeft(mindmap) {
|
|||||||
* @param conf
|
* @param conf
|
||||||
*/
|
*/
|
||||||
function layout(mindmap, dir, conf) {
|
function layout(mindmap, dir, conf) {
|
||||||
const bb = new BoundingBox(40, 40);
|
const bb = new BoundingBox(60, 60);
|
||||||
|
|
||||||
const layout = new Layout(bb);
|
const layout = new Layout(bb);
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
\%\%.*\n {console.log('Found comment',yytext);} /* skip comments */
|
||||||
|
// \%\%[^\n]*\n /* skip comments */
|
||||||
"mindmap" return 'MINDMAP';
|
"mindmap" return 'MINDMAP';
|
||||||
":::" { this.begin('CLASS'); }
|
":::" { this.begin('CLASS'); }
|
||||||
<CLASS>.+ { return 'CLASS';this.popState(); }
|
<CLASS>.+ { this.popState();return 'CLASS'; }
|
||||||
<CLASS>\n { this.popState();}
|
<CLASS>\n { this.popState();}
|
||||||
[\n\s]*"::icon(" { this.begin('ICON'); }
|
[\n\s]*"::icon(" { this.begin('ICON'); }
|
||||||
<ICON>[^\)]+ { return 'ICON'; }
|
<ICON>[^\)]+ { return 'ICON'; }
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
start
|
start
|
||||||
// %{ : info document 'EOF' { return yy; } }
|
// %{ : info document 'EOF' { return yy; } }
|
||||||
: MINDMAP document { return yy; }
|
: MINDMAP document { return yy; }
|
||||||
|
| SPACELIST MINDMAP document { return yy; }
|
||||||
;
|
;
|
||||||
|
|
||||||
document
|
document
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ const drawNote = function (elem, noteModel) {
|
|||||||
textObj.fontWeight = conf.noteFontWeight;
|
textObj.fontWeight = conf.noteFontWeight;
|
||||||
textObj.anchor = conf.noteAlign;
|
textObj.anchor = conf.noteAlign;
|
||||||
textObj.textMargin = conf.noteMargin;
|
textObj.textMargin = conf.noteMargin;
|
||||||
textObj.valign = conf.noteAlign;
|
textObj.valign = 'center';
|
||||||
|
|
||||||
let textElem = drawText(g, textObj);
|
let textElem = drawText(g, textObj);
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ const drawMessage = function (diagram, msgModel, lineStarty, diagObj) {
|
|||||||
textObj.fontSize = conf.messageFontSize;
|
textObj.fontSize = conf.messageFontSize;
|
||||||
textObj.fontWeight = conf.messageFontWeight;
|
textObj.fontWeight = conf.messageFontWeight;
|
||||||
textObj.anchor = conf.messageAlign;
|
textObj.anchor = conf.messageAlign;
|
||||||
textObj.valign = conf.messageAlign;
|
textObj.valign = 'center';
|
||||||
textObj.textMargin = conf.wrapPadding;
|
textObj.textMargin = conf.wrapPadding;
|
||||||
textObj.tspan = false;
|
textObj.tspan = false;
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ export const drawText = function (elem, textData) {
|
|||||||
case 'start':
|
case 'start':
|
||||||
textData.x = Math.round(textData.x + textData.textMargin);
|
textData.x = Math.round(textData.x + textData.textMargin);
|
||||||
textData.anchor = 'start';
|
textData.anchor = 'start';
|
||||||
textData.dominantBaseline = 'text-after-edge';
|
textData.dominantBaseline = 'middle';
|
||||||
textData.alignmentBaseline = 'middle';
|
textData.alignmentBaseline = 'middle';
|
||||||
break;
|
break;
|
||||||
case 'middle':
|
case 'middle':
|
||||||
@@ -207,7 +207,7 @@ export const drawText = function (elem, textData) {
|
|||||||
case 'end':
|
case 'end':
|
||||||
textData.x = Math.round(textData.x + textData.width - textData.textMargin);
|
textData.x = Math.round(textData.x + textData.width - textData.textMargin);
|
||||||
textData.anchor = 'end';
|
textData.anchor = 'end';
|
||||||
textData.dominantBaseline = 'text-before-edge';
|
textData.dominantBaseline = 'middle';
|
||||||
textData.alignmentBaseline = 'middle';
|
textData.alignmentBaseline = 'middle';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user