Skip to content

Commit

Permalink
Merge pull request #5284 from ad1992/aakansha/actor-name
Browse files Browse the repository at this point in the history
feat: add name field to the actors
  • Loading branch information
sidharthv96 authored Feb 27, 2024
2 parents a5a2ea1 + 23dd7b2 commit 3093afe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions demos/sequence.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ <h1>Sequence diagram demos</h1>
Note left of Bob: Alice/Bob Note
end
</pre>
<pre class="mermaid">
sequenceDiagram
actor Alice
actor John
Alice-xJohn: Hello John, how are you?
John--xAlice: Great!
</pre>

<hr />

Expand Down
1 change: 1 addition & 0 deletions packages/mermaid/src/diagrams/common/commonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface RectData {
ry?: number;
attrs?: Record<string, string | number>;
anchor?: string;
name?: string;
}

export interface Bound {
Expand Down
3 changes: 3 additions & 0 deletions packages/mermaid/src/diagrams/common/svgDrawCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const drawRect = (element: SVG | Group, rectData: RectData): D3RectElemen
rectElement.attr('stroke', rectData.stroke);
rectElement.attr('width', rectData.width);
rectElement.attr('height', rectData.height);
if (rectData.name) {
rectElement.attr('name', rectData.name);
}
rectData.rx !== undefined && rectElement.attr('rx', rectData.rx);
rectData.ry !== undefined && rectElement.attr('ry', rectData.ry);

Expand Down
2 changes: 2 additions & 0 deletions packages/mermaid/src/diagrams/sequence/svgDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ const drawActorTypeParticipant = async function (elem, actor, conf, isFooter) {
rect.class = cssclass;
rect.rx = 3;
rect.ry = 3;
rect.name = actor.name;
const rectElem = drawRect(g, rect);
actor.rectData = rect;

Expand Down Expand Up @@ -439,6 +440,7 @@ const drawActorTypeActor = async function (elem, actor, conf, isFooter) {
cssClass += ` ${TOP_ACTOR_CLASS}`;
}
actElem.attr('class', cssClass);
actElem.attr('name', actor.name);

const rect = svgDrawCommon.getNoteRect();
rect.x = actor.x;
Expand Down

0 comments on commit 3093afe

Please sign in to comment.