mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Merge branch 'knsv/new-shapes' of https://github.com/mermaid-js/mermaid into knsv/new-shapes
This commit is contained in:
commit
98cb8b998e
@ -58,6 +58,7 @@ rehype
|
||||
roughjs
|
||||
rscratch
|
||||
shiki
|
||||
Slidev
|
||||
sparkline
|
||||
sphinxcontrib
|
||||
ssim
|
||||
|
@ -12,7 +12,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -30,7 +30,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: true },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -47,7 +47,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[Car]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -62,7 +62,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -->|Two| E[\\iPhone\\]
|
||||
C -->|Three| F[Car]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -78,7 +78,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
classDef processHead fill:#888888,color:white,font-weight:bold,stroke-width:3px,stroke:#001f3f
|
||||
class 1A,1B,D,E processHead
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -107,7 +107,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
35(SAM.CommonFA.PopulationFME)-->39(SAM.CommonFA.ChargeDetails)
|
||||
36(SAM.CommonFA.PremetricCost)-->39(SAM.CommonFA.ChargeDetails)
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -178,7 +178,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
9a072290_1ec3_e711_8c5a_005056ad0002-->d6072290_1ec3_e711_8c5a_005056ad0002
|
||||
9a072290_1ec3_e711_8c5a_005056ad0002-->71082290_1ec3_e711_8c5a_005056ad0002
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -187,7 +187,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`
|
||||
graph TB;subgraph "number as labels";1;end;
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -199,7 +199,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
a1-->a2
|
||||
end
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -211,7 +211,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
a1-->a2
|
||||
end
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -246,7 +246,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
style foo fill:#F99,stroke-width:2px,stroke:#F0F,color:darkred
|
||||
style bar fill:#999,stroke-width:10px,stroke:#0F0,color:blue
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -348,7 +348,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
sid-7CE72B24-E0C1-46D3-8132-8BA66BE05AA7-->sid-4DA958A0-26D9-4D47-93A7-70F39FD7D51A;
|
||||
sid-7CE72B24-E0C1-46D3-8132-8BA66BE05AA7-->sid-4FC27B48-A6F9-460A-A675-021F5854FE22;
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -364,7 +364,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
listUrl: false,
|
||||
listId: 'color styling',
|
||||
fontFamily: 'courier',
|
||||
@ -390,7 +390,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
listUrl: false,
|
||||
listId: 'color styling',
|
||||
fontFamily: 'courier',
|
||||
@ -411,7 +411,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -435,7 +435,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -457,7 +457,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -471,7 +471,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -485,7 +485,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -500,7 +500,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -527,7 +527,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
class A someclass;`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -544,7 +544,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[fa:fa-car Car]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, flowchart: { nodeSpacing: 50 }, fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, flowchart: { nodeSpacing: 50 }, fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -560,7 +560,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { rankSpacing: '100' },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -578,7 +578,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -603,7 +603,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
click E "notes://do-your-thing/id" "other protocol test"
|
||||
click F "javascript:alert('test')" "script test"
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, securityLevel: 'loose', fontFamily: 'courier' }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, securityLevel: 'loose', fontFamily: 'courier' }
|
||||
);
|
||||
});
|
||||
|
||||
@ -623,7 +623,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
click B "index.html#link-clicked" "link test"
|
||||
click D testClick "click test"
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, flowchart: { htmlLabels: true } }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, flowchart: { htmlLabels: true } }
|
||||
);
|
||||
});
|
||||
|
||||
@ -645,7 +645,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -664,7 +664,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
class A myClass1
|
||||
class D myClass2
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, flowchart: { htmlLabels: true } }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, flowchart: { htmlLabels: true } }
|
||||
);
|
||||
});
|
||||
|
||||
@ -682,7 +682,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -711,7 +711,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -728,7 +728,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -752,7 +752,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: false },
|
||||
fontFamily: 'courier',
|
||||
}
|
||||
@ -769,7 +769,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[fa:fa-car Car]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, flowchart: { diagramPadding: 0 } }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, flowchart: { diagramPadding: 0 } }
|
||||
);
|
||||
});
|
||||
|
||||
@ -778,7 +778,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`graph TD
|
||||
A[Christmas]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0 }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1 }
|
||||
);
|
||||
});
|
||||
|
||||
@ -796,7 +796,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -----> E4
|
||||
C ======> E5
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0 }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1 }
|
||||
);
|
||||
});
|
||||
it('FDH36: should render escaped without html labels', () => {
|
||||
@ -804,7 +804,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`graph TD
|
||||
a["<strong>Haiya</strong>"]-->b
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, htmlLabels: false, flowchart: { htmlLabels: false } }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, htmlLabels: false, flowchart: { htmlLabels: false } }
|
||||
);
|
||||
});
|
||||
it('FDH37: should render non-escaped with html labels', () => {
|
||||
@ -814,7 +814,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -830,7 +830,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[fa:fa-car Car]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, flowchart: { useMaxWidth: true } }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, flowchart: { useMaxWidth: true } }
|
||||
);
|
||||
cy.get('svg').should((svg) => {
|
||||
expect(svg).to.have.attr('width', '100%');
|
||||
@ -853,7 +853,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[fa:fa-car Car]
|
||||
`,
|
||||
{ look: 'handDrawn', handDrawnSeed: 0, flowchart: { useMaxWidth: false } }
|
||||
{ look: 'handDrawn', handDrawnSeed: 1, flowchart: { useMaxWidth: false } }
|
||||
);
|
||||
cy.get('svg').should((svg) => {
|
||||
// const height = parseFloat(svg.attr('height'));
|
||||
@ -874,7 +874,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -904,7 +904,7 @@ describe('Flowchart HandDrawn', () => {
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -919,7 +919,7 @@ graph TD
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -937,7 +937,7 @@ graph TD
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -977,7 +977,7 @@ graph TD
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -999,7 +999,7 @@ graph TD
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -1016,7 +1016,7 @@ graph TD
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -1027,12 +1027,12 @@ graph TD
|
||||
imgSnapshotTest(
|
||||
`
|
||||
graph TD
|
||||
classDef default fill:#a34,stroke:#000,stroke-width:4px,color:#fff
|
||||
classDef default fill:#a34,stroke:#000,stroke-width:4px,color:#fff
|
||||
hello --> default
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
htmlLabels: true,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
@ -1051,7 +1051,7 @@ graph TD
|
||||
`,
|
||||
{
|
||||
look: 'handDrawn',
|
||||
handDrawnSeed: 0,
|
||||
handDrawnSeed: 1,
|
||||
flowchart: { htmlLabels: true },
|
||||
securityLevel: 'loose',
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ const newShapesSet5 = [
|
||||
'card',
|
||||
'shadedProcess',
|
||||
] as const;
|
||||
const newShapesSet6 = ['curlyBraces'];
|
||||
|
||||
// Aggregate all shape sets into a single array
|
||||
const newShapesSets = [
|
||||
@ -48,6 +49,7 @@ const newShapesSets = [
|
||||
newShapesSet3,
|
||||
newShapesSet4,
|
||||
newShapesSet5,
|
||||
newShapesSet6,
|
||||
] as const;
|
||||
|
||||
looks.forEach((look) => {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/rendering-util/render.ts:25](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L25)
|
||||
[packages/mermaid/src/rendering-util/render.ts:24](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L24)
|
||||
|
||||
---
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/rendering-util/render.ts:24](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L24)
|
||||
[packages/mermaid/src/rendering-util/render.ts:23](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L23)
|
||||
|
||||
---
|
||||
|
||||
@ -36,4 +36,4 @@
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/rendering-util/render.ts:23](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L23)
|
||||
[packages/mermaid/src/rendering-util/render.ts:22](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L22)
|
||||
|
@ -19,4 +19,4 @@ The `parseError` function will not be called.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/types.ts:43](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L43)
|
||||
[packages/mermaid/src/types.ts:47](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L47)
|
||||
|
@ -18,4 +18,4 @@ The diagram type, e.g. 'flowchart', 'sequence', etc.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/types.ts:50](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L50)
|
||||
[packages/mermaid/src/types.ts:54](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L54)
|
||||
|
@ -39,7 +39,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/types.ts:73](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L73)
|
||||
[packages/mermaid/src/types.ts:77](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L77)
|
||||
|
||||
---
|
||||
|
||||
@ -51,7 +51,7 @@ The diagram type, e.g. 'flowchart', 'sequence', etc.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/types.ts:63](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L63)
|
||||
[packages/mermaid/src/types.ts:67](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L67)
|
||||
|
||||
---
|
||||
|
||||
@ -63,4 +63,4 @@ The svg code for the rendered graph.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/types.ts:59](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L59)
|
||||
[packages/mermaid/src/types.ts:63](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L63)
|
||||
|
@ -59,6 +59,7 @@ To add an integration to this list, see the [Integrations - create page](./integ
|
||||
- [MonsterWriter](https://www.monsterwriter.com/) ✅
|
||||
- [Joplin](https://joplinapp.org) ✅
|
||||
- [LiveBook](https://livebook.dev) ✅
|
||||
- [Slidev](https://sli.dev) ✅
|
||||
- [Tuleap](https://docs.tuleap.org/user-guide/writing-in-tuleap.html#graphs) ✅
|
||||
- [Mermaid Flow Visual Editor](https://www.mermaidflow.app) ✅
|
||||
- [Mermerd](https://github.com/KarnerTh/mermerd)
|
||||
|
@ -12,7 +12,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
|
||||
|
||||
<br />
|
||||
|
||||
<a href="https://www.producthunt.com/posts/mermaid-chart?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-mermaid-chart" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=416671&theme=light" alt="Mermaid Chart - A smarter way to create diagrams | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
<a href="https://www.producthunt.com/products/mermaid-chart?utm_source=badge-follow&utm_medium=badge&utm_souce=badge-mermaid-chart" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/follow.svg?product_id=552855&theme=light" alt="Mermaid Chart - A smarter way to create diagrams | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
|
||||
## About
|
||||
|
||||
|
@ -6,6 +6,30 @@
|
||||
|
||||
# Blog
|
||||
|
||||
## [Mermaid AI Is Here to Change the Game For Diagram Creation](https://www.mermaidchart.com/blog/posts/mermaid-ai-is-here-to-change-the-game-for-diagram-creation/)
|
||||
|
||||
22 July 2024 · 5 mins
|
||||
|
||||
The Mermaid AI chat interface
|
||||
|
||||
## [How to Make a Sequence Diagram with Mermaid Chart](https://www.mermaidchart.com/blog/posts/how-to-make-a-sequence-diagram-in-mermaid-chart-step-by-step-guide/)
|
||||
|
||||
8 July 2024 · 6 mins
|
||||
|
||||
Sequence diagrams are important for communicating complex systems in a clear and concise manner.
|
||||
|
||||
## [How to Use the New “Comments” Feature in Mermaid Chart](https://www.mermaidchart.com/blog/posts/how-to-use-the-new-comments-feature-in-mermaid-chart/)
|
||||
|
||||
2 July 2024 · 3 mins
|
||||
|
||||
How to Use the New Comments Feature in Mermaid Chart
|
||||
|
||||
## [How to Use the official Mermaid Chart for Confluence app](https://www.mermaidchart.com/blog/posts/how-to-use-the-official-mermaid-chart-for-confluence-app/)
|
||||
|
||||
21 May 2024 · 4 mins
|
||||
|
||||
It doesn’t matter if you’re a data enthusiast, software engineer, or visual storyteller; our Confluence app can allow you to embed Mermaid Chart diagrams — and dynamically edit them — within your Confluence pages.
|
||||
|
||||
## [How to Choose the Right Documentation Software](https://www.mermaidchart.com/blog/posts/how-to-choose-the-right-documentation-software/)
|
||||
|
||||
7 May 2024 · 5 mins
|
||||
|
@ -172,7 +172,7 @@ The `title` is an _optional_ string to be displayed at the top of the Gantt char
|
||||
The `excludes` is an _optional_ attribute that accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".
|
||||
These date will be marked on the graph, and be excluded from the duration calculation of tasks. Meaning that if there are excluded dates during a task interval, the number of 'skipped' days will be added to the end of the task to ensure the duration is as specified in the code.
|
||||
|
||||
#### Weekend (v\<MERMAID_RELEASE_VERSION>+)
|
||||
#### Weekend (v\11.0.0+)
|
||||
|
||||
When excluding weekends, it is possible to configure the weekends to be either Friday and Saturday or Saturday and Sunday. By default weekends are Saturday and Sunday.
|
||||
To define the weekend start day, there is an _optional_ attribute `weekend` that can be added in a new line followed by either `friday` or `saturday`.
|
||||
|
@ -918,7 +918,7 @@ Usage example:
|
||||
commit
|
||||
```
|
||||
|
||||
### Bottom to Top (`BT:`) (v\<MERMAID_RELEASE_VERSION>+)
|
||||
### Bottom to Top (`BT:`) (v11.0.0+)
|
||||
|
||||
In `BT` (**Bottom-to-Top**) orientation, the commits run from bottom to top of the graph and branches are arranged side-by-side.
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
>
|
||||
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/packet.md](../../packages/mermaid/src/docs/syntax/packet.md).
|
||||
|
||||
# Packet Diagram (v\<MERMAID_RELEASE_VERSION>+)
|
||||
# Packet Diagram (v11.0.0+)
|
||||
|
||||
## Introduction
|
||||
|
||||
|
@ -208,18 +208,18 @@ Messages can be of two displayed either solid or with a dotted line.
|
||||
|
||||
There are ten types of arrows currently supported:
|
||||
|
||||
| Type | Description |
|
||||
| -------- | ------------------------------------------------------------------------ |
|
||||
| `->` | Solid line without arrow |
|
||||
| `-->` | Dotted line without arrow |
|
||||
| `->>` | Solid line with arrowhead |
|
||||
| `-->>` | Dotted line with arrowhead |
|
||||
| `<<->>` | Solid line with bidirectional arrowheads (v\<MERMAID_RELEASE_VERSION>+) |
|
||||
| `<<-->>` | Dotted line with bidirectional arrowheads (v\<MERMAID_RELEASE_VERSION>+) |
|
||||
| `-x` | Solid line with a cross at the end |
|
||||
| `--x` | Dotted line with a cross at the end. |
|
||||
| `-)` | Solid line with an open arrow at the end (async) |
|
||||
| `--)` | Dotted line with a open arrow at the end (async) |
|
||||
| Type | Description |
|
||||
| -------- | ---------------------------------------------------- |
|
||||
| `->` | Solid line without arrow |
|
||||
| `-->` | Dotted line without arrow |
|
||||
| `->>` | Solid line with arrowhead |
|
||||
| `-->>` | Dotted line with arrowhead |
|
||||
| `<<->>` | Solid line with bidirectional arrowheads (v11.0.0+) |
|
||||
| `<<-->>` | Dotted line with bidirectional arrowheads (v11.0.0+) |
|
||||
| `-x` | Solid line with a cross at the end |
|
||||
| `--x` | Dotted line with a cross at the end. |
|
||||
| `-)` | Solid line with an open arrow at the end (async) |
|
||||
| `--)` | Dotted line with a open arrow at the end (async) |
|
||||
|
||||
## Activations
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
<template>
|
||||
<div class="-mt-6 mb-8">
|
||||
<a
|
||||
href="https://www.producthunt.com/posts/mermaid-ai-2?embed=true&utm_source=badge-featured&utm_medium=badge&utm_souce=badge-mermaid-ai-2"
|
||||
target="_blank"
|
||||
><img
|
||||
src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=465568&theme=light"
|
||||
alt="Mermaid AI - Maximize your diagramming efficiency with Mermaid AI | Product Hunt"
|
||||
style="width: 250px; height: 54px"
|
||||
width="250"
|
||||
height="54"
|
||||
/></a>
|
||||
</div>
|
||||
</template>
|
@ -1,26 +1,65 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue';
|
||||
|
||||
interface Taglines {
|
||||
label: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
const taglines: Taglines[] = [
|
||||
{
|
||||
label: 'Use the Visual Editor in Mermaid Chart to design and build diagrams',
|
||||
url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=visual_editor',
|
||||
},
|
||||
{
|
||||
label: 'Diagram live with teammates in Mermaid Chart',
|
||||
url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=teams',
|
||||
},
|
||||
{
|
||||
label: 'Skip the rough draft with Mermaid AI in Mermaid Chart',
|
||||
url: 'https://www.mermaidchart.com/play?utm_source=mermaid_live_editor&utm_medium=banner_ad&utm_campaign=mermaid_ai',
|
||||
},
|
||||
];
|
||||
|
||||
let index = ref(Math.floor(Math.random() * taglines.length));
|
||||
onMounted(() => {
|
||||
setInterval(() => {
|
||||
index.value = (index.value + 1) % taglines.length;
|
||||
}, 60_000);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="w-full top-bar bg-gradient-to-r from-[#bd34fe] to-[#ff3670] flex items-center text-center justify-center p-1 text-white"
|
||||
>
|
||||
<p class="flex-grow text-center tracking-wide text-text">
|
||||
<a
|
||||
href="https://www.mermaidchart.com/landing"
|
||||
target="_blank"
|
||||
class="unstyled flex-grow tracking-wide plausible-event-name=bannerClick"
|
||||
>
|
||||
<span class="text-primary-50 font-semibold">{{
|
||||
[
|
||||
'Try diagramming with ChatGPT at Mermaid Chart',
|
||||
'Try Mermaid’s Visual Editor at Mermaid Chart',
|
||||
'Enjoy live collaboration with teammates at Mermaid Chart',
|
||||
][Math.floor(Math.random() * 3)]
|
||||
}}</span>
|
||||
<button
|
||||
class="ml-4 rounded bg-[#111113] p-1 px-2 text-sm font-semibold tracking-wide text-white"
|
||||
<div class="mb-4 w-full top-bar bg-gradient-to-r from-[#bd34fe] to-[#ff3670] flex p-1">
|
||||
<p class="w-full tracking-wide fade-text">
|
||||
<transition name="fade" mode="out-in">
|
||||
<a
|
||||
:key="index"
|
||||
:href="taglines[index].url"
|
||||
target="_blank"
|
||||
class="unstyled flex justify-center items-center gap-4 text-white tracking-wide plausible-event-name=bannerClick"
|
||||
>
|
||||
Try it now
|
||||
</button>
|
||||
</a>
|
||||
<span class="font-semibold">{{ taglines[index].label }}</span>
|
||||
<button class="rounded bg-[#111113] p-1 px-2 text-sm font-semibold tracking-wide">
|
||||
Try it now
|
||||
</button>
|
||||
</a>
|
||||
</transition>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 1s;
|
||||
}
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
.fade-enter-to,
|
||||
.fade-leave-from {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
|
@ -11,11 +11,11 @@ import HomePage from '../components/HomePage.vue';
|
||||
import TopBar from '../components/TopBar.vue';
|
||||
import { getRedirect } from './redirect.js';
|
||||
// @ts-ignore Type not available
|
||||
import { h } from 'vue';
|
||||
import Theme from 'vitepress/theme';
|
||||
import '../style/main.css';
|
||||
import 'uno.css';
|
||||
import type { EnhanceAppContext } from 'vitepress';
|
||||
import Theme from 'vitepress/theme';
|
||||
import { h } from 'vue';
|
||||
import '../style/main.css';
|
||||
|
||||
export default {
|
||||
...DefaultTheme,
|
||||
@ -24,6 +24,7 @@ export default {
|
||||
// Keeping this as comment as it took a lot of time to figure out how to add a component to the top bar.
|
||||
'home-hero-before': () => h(TopBar),
|
||||
'home-features-after': () => h(HomePage),
|
||||
'doc-before': () => h(TopBar),
|
||||
});
|
||||
},
|
||||
enhanceApp({ app, router }: EnhanceAppContext) {
|
||||
|
@ -54,6 +54,7 @@ To add an integration to this list, see the [Integrations - create page](./integ
|
||||
- [MonsterWriter](https://www.monsterwriter.com/) ✅
|
||||
- [Joplin](https://joplinapp.org) ✅
|
||||
- [LiveBook](https://livebook.dev) ✅
|
||||
- [Slidev](https://sli.dev) ✅
|
||||
- [Tuleap](https://docs.tuleap.org/user-guide/writing-in-tuleap.html#graphs) ✅
|
||||
- [Mermaid Flow Visual Editor](https://www.mermaidflow.app) ✅
|
||||
- [Mermerd](https://github.com/KarnerTh/mermerd)
|
||||
|
@ -6,7 +6,7 @@ Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an accoun
|
||||
|
||||
<br />
|
||||
|
||||
<a href="https://www.producthunt.com/posts/mermaid-chart?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-mermaid-chart" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=416671&theme=light" alt="Mermaid Chart - A smarter way to create diagrams | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
<a href="https://www.producthunt.com/products/mermaid-chart?utm_source=badge-follow&utm_medium=badge&utm_souce=badge-mermaid-chart" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/follow.svg?product_id=552855&theme=light" alt="Mermaid Chart - A smarter way to create diagrams | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
|
||||
## About
|
||||
|
||||
|
@ -1,5 +1,29 @@
|
||||
# Blog
|
||||
|
||||
## [Mermaid AI Is Here to Change the Game For Diagram Creation](https://www.mermaidchart.com/blog/posts/mermaid-ai-is-here-to-change-the-game-for-diagram-creation/)
|
||||
|
||||
22 July 2024 · 5 mins
|
||||
|
||||
The Mermaid AI chat interface
|
||||
|
||||
## [How to Make a Sequence Diagram with Mermaid Chart](https://www.mermaidchart.com/blog/posts/how-to-make-a-sequence-diagram-in-mermaid-chart-step-by-step-guide/)
|
||||
|
||||
8 July 2024 · 6 mins
|
||||
|
||||
Sequence diagrams are important for communicating complex systems in a clear and concise manner.
|
||||
|
||||
## [How to Use the New “Comments” Feature in Mermaid Chart](https://www.mermaidchart.com/blog/posts/how-to-use-the-new-comments-feature-in-mermaid-chart/)
|
||||
|
||||
2 July 2024 · 3 mins
|
||||
|
||||
How to Use the New Comments Feature in Mermaid Chart
|
||||
|
||||
## [How to Use the official Mermaid Chart for Confluence app](https://www.mermaidchart.com/blog/posts/how-to-use-the-official-mermaid-chart-for-confluence-app/)
|
||||
|
||||
21 May 2024 · 4 mins
|
||||
|
||||
It doesn’t matter if you’re a data enthusiast, software engineer, or visual storyteller; our Confluence app can allow you to embed Mermaid Chart diagrams — and dynamically edit them — within your Confluence pages.
|
||||
|
||||
## [How to Choose the Right Documentation Software](https://www.mermaidchart.com/blog/posts/how-to-choose-the-right-documentation-software/)
|
||||
|
||||
7 May 2024 · 5 mins
|
||||
|
@ -114,7 +114,7 @@ The `title` is an _optional_ string to be displayed at the top of the Gantt char
|
||||
The `excludes` is an _optional_ attribute that accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".
|
||||
These date will be marked on the graph, and be excluded from the duration calculation of tasks. Meaning that if there are excluded dates during a task interval, the number of 'skipped' days will be added to the end of the task to ensure the duration is as specified in the code.
|
||||
|
||||
#### Weekend (v\<MERMAID_RELEASE_VERSION>+)
|
||||
#### Weekend (v\11.0.0+)
|
||||
|
||||
When excluding weekends, it is possible to configure the weekends to be either Friday and Saturday or Saturday and Sunday. By default weekends are Saturday and Sunday.
|
||||
To define the weekend start day, there is an _optional_ attribute `weekend` that can be added in a new line followed by either `friday` or `saturday`.
|
||||
|
@ -571,7 +571,7 @@ Usage example:
|
||||
commit
|
||||
```
|
||||
|
||||
### Bottom to Top (`BT:`) (v<MERMAID_RELEASE_VERSION>+)
|
||||
### Bottom to Top (`BT:`) (v11.0.0+)
|
||||
|
||||
In `BT` (**Bottom-to-Top**) orientation, the commits run from bottom to top of the graph and branches are arranged side-by-side.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Packet Diagram (v<MERMAID_RELEASE_VERSION>+)
|
||||
# Packet Diagram (v11.0.0+)
|
||||
|
||||
## Introduction
|
||||
|
||||
|
@ -143,18 +143,18 @@ Messages can be of two displayed either solid or with a dotted line.
|
||||
|
||||
There are ten types of arrows currently supported:
|
||||
|
||||
| Type | Description |
|
||||
| -------- | ----------------------------------------------------------------------- |
|
||||
| `->` | Solid line without arrow |
|
||||
| `-->` | Dotted line without arrow |
|
||||
| `->>` | Solid line with arrowhead |
|
||||
| `-->>` | Dotted line with arrowhead |
|
||||
| `<<->>` | Solid line with bidirectional arrowheads (v<MERMAID_RELEASE_VERSION>+) |
|
||||
| `<<-->>` | Dotted line with bidirectional arrowheads (v<MERMAID_RELEASE_VERSION>+) |
|
||||
| `-x` | Solid line with a cross at the end |
|
||||
| `--x` | Dotted line with a cross at the end. |
|
||||
| `-)` | Solid line with an open arrow at the end (async) |
|
||||
| `--)` | Dotted line with a open arrow at the end (async) |
|
||||
| Type | Description |
|
||||
| -------- | ---------------------------------------------------- |
|
||||
| `->` | Solid line without arrow |
|
||||
| `-->` | Dotted line without arrow |
|
||||
| `->>` | Solid line with arrowhead |
|
||||
| `-->>` | Dotted line with arrowhead |
|
||||
| `<<->>` | Solid line with bidirectional arrowheads (v11.0.0+) |
|
||||
| `<<-->>` | Dotted line with bidirectional arrowheads (v11.0.0+) |
|
||||
| `-x` | Solid line with a cross at the end |
|
||||
| `--x` | Dotted line with a cross at the end. |
|
||||
| `-)` | Solid line with an open arrow at the end (async) |
|
||||
| `--)` | Dotted line with a open arrow at the end (async) |
|
||||
|
||||
## Activations
|
||||
|
||||
|
@ -48,6 +48,7 @@ import { multiWaveEdgedRectangle } from './shapes/multiWaveEdgedRectangle.js';
|
||||
import { windowPane } from './shapes/windowPane.js';
|
||||
import { linedWaveEdgedRect } from './shapes/linedWaveEdgedRect.js';
|
||||
import { taggedWaveEdgedRectangle } from './shapes/taggedWaveEdgedRectangle.js';
|
||||
import { curlyBraces } from './shapes/curlyBraces.js';
|
||||
|
||||
//Use these names as the left side to render shapes.
|
||||
const shapes = {
|
||||
@ -212,6 +213,9 @@ const shapes = {
|
||||
lightningBolt,
|
||||
bolt: lightningBolt,
|
||||
'com-link': lightningBolt,
|
||||
curlyBraces,
|
||||
brace: curlyBraces,
|
||||
comment: curlyBraces,
|
||||
hourglass,
|
||||
odd: rect_left_inv_arrow,
|
||||
labelRect,
|
||||
|
@ -17,6 +17,7 @@ export const anchor = (parent: SVGAElement, node: Node): Promise<SVGAElement> =>
|
||||
cssClasses = 'anchor';
|
||||
}
|
||||
const shapeSvg = parent
|
||||
// @ts-ignore - SVGElement is not typed
|
||||
.insert('g')
|
||||
.attr('class', cssClasses)
|
||||
.attr('id', node.domId || node.id);
|
||||
|
@ -0,0 +1,114 @@
|
||||
import { labelHelper, updateNodeBounds, getNodeClasses, createPathFromPoints } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
import {
|
||||
styles2String,
|
||||
userNodeOverrides,
|
||||
} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js';
|
||||
import rough from 'roughjs';
|
||||
|
||||
function generateCirclePoints(
|
||||
centerX: number,
|
||||
centerY: number,
|
||||
radius: number,
|
||||
numPoints = 100,
|
||||
startAngle = 0,
|
||||
endAngle = 180
|
||||
) {
|
||||
const points = [];
|
||||
|
||||
// Convert angles to radians
|
||||
const startAngleRad = (startAngle * Math.PI) / 180;
|
||||
const endAngleRad = (endAngle * Math.PI) / 180;
|
||||
|
||||
// Calculate the angle range in radians
|
||||
const angleRange = endAngleRad - startAngleRad;
|
||||
|
||||
// Calculate the angle step
|
||||
const angleStep = angleRange / (numPoints - 1);
|
||||
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
const angle = startAngleRad + i * angleStep;
|
||||
const x = centerX + radius * Math.cos(angle);
|
||||
const y = centerY + radius * Math.sin(angle);
|
||||
points.push({ x, y });
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
export const curlyBraces = async (parent: SVGAElement, node: Node) => {
|
||||
const { labelStyles, nodeStyles } = styles2String(node);
|
||||
node.labelStyle = labelStyles;
|
||||
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
const w = bbox.width + (node.padding ?? 0);
|
||||
const h = bbox.height + (node.padding ?? 0);
|
||||
const radius = w * 0.05;
|
||||
|
||||
const { cssStyles } = node;
|
||||
|
||||
const points = [
|
||||
...generateCirclePoints(w / 2, -h / 2, radius, 20, -90, 0),
|
||||
{ x: w / 2 + radius, y: -radius },
|
||||
...generateCirclePoints(w / 2 + w * 0.1, -radius, radius, 20, -180, -270),
|
||||
...generateCirclePoints(w / 2 + w * 0.1, radius, radius, 20, -90, -180),
|
||||
{ x: w / 2 + radius, y: h / 2 },
|
||||
...generateCirclePoints(w / 2, h / 2, radius, 20, 0, 90),
|
||||
];
|
||||
|
||||
const rectPoints = [
|
||||
{ x: -w / 2, y: -h / 2 - radius },
|
||||
{ x: w / 2, y: -h / 2 - radius },
|
||||
...generateCirclePoints(w / 2, -h / 2, radius, 20, -90, 0),
|
||||
{ x: w / 2 + radius, y: -radius },
|
||||
...generateCirclePoints(w / 2 + w * 0.1, -radius, radius, 20, -180, -270),
|
||||
...generateCirclePoints(w / 2 + w * 0.1, radius, radius, 20, -90, -180),
|
||||
{ x: w / 2 + radius, y: h / 2 },
|
||||
...generateCirclePoints(w / 2, h / 2, radius, 20, 0, 90),
|
||||
{ x: w / 2, y: h / 2 + radius },
|
||||
{ x: -w / 2, y: h / 2 + radius },
|
||||
];
|
||||
|
||||
// @ts-ignore - rough is not typed
|
||||
const rc = rough.svg(shapeSvg);
|
||||
const options = userNodeOverrides(node, { fill: 'none' });
|
||||
|
||||
if (node.look !== 'handDrawn') {
|
||||
options.roughness = 0;
|
||||
options.fillStyle = 'solid';
|
||||
}
|
||||
const bowTieRectPath = createPathFromPoints(points);
|
||||
const newCurlyBracePath = bowTieRectPath.replace('Z', '');
|
||||
const curlyBracePath = rc.path(newCurlyBracePath, options);
|
||||
const rectPath = createPathFromPoints(rectPoints);
|
||||
const rectShape = rc.path(rectPath, { ...options });
|
||||
const bowTieRectShape = shapeSvg.insert('g', ':first-child');
|
||||
bowTieRectShape.insert(() => rectShape, ':first-child').attr('stroke-opacity', 0);
|
||||
bowTieRectShape.insert(() => curlyBracePath, ':first-child');
|
||||
bowTieRectShape.attr('class', 'text');
|
||||
|
||||
if (cssStyles && node.look !== 'handDrawn') {
|
||||
bowTieRectShape.selectAll('path').attr('style', cssStyles);
|
||||
}
|
||||
|
||||
if (nodeStyles && node.look !== 'handDrawn') {
|
||||
bowTieRectShape.selectAll('path').attr('style', nodeStyles);
|
||||
}
|
||||
|
||||
bowTieRectShape.attr('transform', `translate(${-radius}, 0)`);
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-w / 2 - (bbox.x - (bbox.left ?? 0))},${-h / 2 + (node.padding ?? 0) / 2 - (bbox.y - (bbox.top ?? 0))})`
|
||||
);
|
||||
|
||||
updateNodeBounds(node, bowTieRectShape);
|
||||
|
||||
node.intersect = function (point) {
|
||||
const pos = intersect.polygon(node, rectPoints, point);
|
||||
|
||||
return pos;
|
||||
};
|
||||
|
||||
return shapeSvg;
|
||||
};
|
@ -4,25 +4,33 @@ import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
import rough from 'roughjs';
|
||||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js';
|
||||
|
||||
export const createCylinderPathWithInnerArcD = (
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
export const createCylinderPathWithoutInnerArcD = (
|
||||
w: number,
|
||||
h: number,
|
||||
rx: number,
|
||||
ry: number
|
||||
) => {
|
||||
return `M ${-w / 2} ${-h / 2}
|
||||
L ${-w / 2} ${h / 2}
|
||||
A ${rx} ${ry} 0 0 0 ${w / 2},${h / 2}
|
||||
L ${w / 2} ${-h / 2}
|
||||
A ${rx} ${ry} 0 0 0 ${-w / 2},${-h / 2}`;
|
||||
};
|
||||
|
||||
export const createCylinderUpperArcPathD = (w: number, h: number, rx: number, ry: number) => {
|
||||
return `M ${-w / 2} ${-h / 2}
|
||||
A ${rx} ${ry} 0 0 0 ${w / 2} ${-h / 2}`;
|
||||
};
|
||||
|
||||
export const createCylinderLowerArcPathD = (
|
||||
w: number,
|
||||
h: number,
|
||||
rx: number,
|
||||
ry: number,
|
||||
outerOffset: number
|
||||
): string => {
|
||||
return [
|
||||
`M${x},${y + ry}`,
|
||||
`a${rx},${ry} 0,0,0 ${width},0`,
|
||||
`a${rx},${ry} 0,0,0 ${-width},0`,
|
||||
`l0,${height}`,
|
||||
`a${rx},${ry} 0,0,0 ${width},0`,
|
||||
`l0,${-height}`,
|
||||
`M${x},${y + ry + outerOffset}`, // Move to the start of the offset top arc
|
||||
`a${rx},${ry} 0,0,0 ${width},0`, // Draw the duplicated top ellipse
|
||||
].join(' ');
|
||||
) => {
|
||||
return `M ${w / 2} ${-h / 2 + outerOffset}
|
||||
A ${rx} ${ry} 0 0 1 ${-w / 2} ${-h / 2 + outerOffset}`;
|
||||
};
|
||||
|
||||
export const linedCylinder = async (parent: SVGAElement, node: Node) => {
|
||||
@ -35,39 +43,47 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
|
||||
const h = bbox.height + ry + node.padding;
|
||||
const outerOffset = h * 0.1; // 10% of height
|
||||
|
||||
let cylinder: d3.Selection<SVGPathElement | SVGGElement, unknown, null, undefined>;
|
||||
const { cssStyles } = node;
|
||||
|
||||
if (node.look === 'handDrawn') {
|
||||
// @ts-ignore - rough is not typed
|
||||
const rc = rough.svg(shapeSvg);
|
||||
const options = userNodeOverrides(node, {});
|
||||
const pathData = createCylinderPathWithInnerArcD(0, 0, w, h, rx, ry, outerOffset);
|
||||
const innerLine = rc.path(pathData, options);
|
||||
// @ts-ignore - rough is not typed
|
||||
const rc = rough.svg(shapeSvg);
|
||||
const options = userNodeOverrides(node, {});
|
||||
|
||||
cylinder = shapeSvg.insert(() => innerLine, ':first-child');
|
||||
cylinder.attr('class', 'basic label-container');
|
||||
if (cssStyles) {
|
||||
cylinder.attr('style', cssStyles);
|
||||
}
|
||||
} else {
|
||||
const pathData = createCylinderPathWithInnerArcD(0, 0, w, h, rx, ry, outerOffset);
|
||||
cylinder = shapeSvg
|
||||
.insert('path', ':first-child')
|
||||
.attr('d', pathData)
|
||||
.attr('class', 'basic label-container')
|
||||
.attr('style', cssStyles)
|
||||
.attr('style', nodeStyles);
|
||||
if (node.look !== 'handDrawn') {
|
||||
options.roughness = 0;
|
||||
options.fillStyle = 'solid';
|
||||
}
|
||||
|
||||
cylinder.attr('label-offset-y', ry);
|
||||
cylinder.attr('transform', `translate(${-w / 2}, ${-(h / 2 + ry)})`);
|
||||
const cylinderPath = createCylinderPathWithoutInnerArcD(w, h, rx, ry);
|
||||
const cylinderNode = rc.path(cylinderPath, options);
|
||||
|
||||
updateNodeBounds(node, cylinder);
|
||||
const UpperArcPath = createCylinderUpperArcPathD(w, h, rx, ry);
|
||||
const UpperArcPathNode = rc.path(UpperArcPath, { ...options, fill: 'none' });
|
||||
|
||||
const lowerArcPath = createCylinderLowerArcPathD(w, h, rx, ry, outerOffset);
|
||||
const lowerArcPathNode = rc.path(lowerArcPath, { ...options, fill: 'none' });
|
||||
|
||||
const linedCylinder = shapeSvg.insert(() => cylinderNode, ':first-child');
|
||||
linedCylinder.insert(() => lowerArcPathNode);
|
||||
linedCylinder.insert(() => UpperArcPathNode);
|
||||
|
||||
linedCylinder.attr('class', 'basic label-container');
|
||||
|
||||
if (cssStyles && node.look !== 'handDrawn') {
|
||||
linedCylinder.selectAll('path').attr('style', cssStyles);
|
||||
}
|
||||
|
||||
if (nodeStyles && node.look !== 'handDrawn') {
|
||||
linedCylinder.selectAll('path').attr('style', nodeStyles);
|
||||
}
|
||||
|
||||
linedCylinder.attr('label-offset-y', ry);
|
||||
|
||||
updateNodeBounds(node, linedCylinder);
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height + outerOffset - (bbox.y - (bbox.top ?? 0))})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height})`
|
||||
);
|
||||
|
||||
node.intersect = function (point) {
|
||||
|
@ -55,7 +55,7 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
||||
|
||||
label.attr(
|
||||
'transform',
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height - (bbox.y - (bbox.top ?? 0))})`
|
||||
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - (bbox.height + (node.padding ?? 0) / 2 - (bbox.y - (bbox.top ?? 0)))})`
|
||||
);
|
||||
|
||||
node.intersect = function (point) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user