@ktrysmt/beautiful-mermaid 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -3854,6 +3854,30 @@ function renderSequenceAscii(text, config, colorMode, theme) {
|
|
|
3854
3854
|
const divYMap = /* @__PURE__ */ new Map();
|
|
3855
3855
|
const notePositions = [];
|
|
3856
3856
|
let curY = actorBoxH;
|
|
3857
|
+
for (const note of diagram.notes) {
|
|
3858
|
+
if (note.afterIndex !== -1) continue;
|
|
3859
|
+
curY += 1;
|
|
3860
|
+
const nLines = splitLines(note.text);
|
|
3861
|
+
const nWidth = Math.max(...nLines.map((l) => l.length)) + 4;
|
|
3862
|
+
const nHeight = nLines.length + 2;
|
|
3863
|
+
const aIdx = actorIdx.get(note.actorIds[0]) ?? 0;
|
|
3864
|
+
let nx;
|
|
3865
|
+
if (note.position === "left") {
|
|
3866
|
+
nx = llX[aIdx] - nWidth - 1;
|
|
3867
|
+
} else if (note.position === "right") {
|
|
3868
|
+
nx = llX[aIdx] + 2;
|
|
3869
|
+
} else {
|
|
3870
|
+
if (note.actorIds.length >= 2) {
|
|
3871
|
+
const aIdx2 = actorIdx.get(note.actorIds[1]) ?? aIdx;
|
|
3872
|
+
nx = Math.floor((llX[aIdx] + llX[aIdx2]) / 2) - Math.floor(nWidth / 2);
|
|
3873
|
+
} else {
|
|
3874
|
+
nx = llX[aIdx] - Math.floor(nWidth / 2);
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
nx = Math.max(0, nx);
|
|
3878
|
+
notePositions.push({ x: nx, y: curY, width: nWidth, height: nHeight, lines: nLines });
|
|
3879
|
+
curY += nHeight;
|
|
3880
|
+
}
|
|
3857
3881
|
for (let m = 0; m < diagram.messages.length; m++) {
|
|
3858
3882
|
for (let b = 0; b < diagram.blocks.length; b++) {
|
|
3859
3883
|
if (diagram.blocks[b].startIndex === m) {
|
|
@@ -7397,6 +7421,42 @@ function layoutSequenceDiagram(diagram, _options = {}) {
|
|
|
7397
7421
|
const activationStacks = /* @__PURE__ */ new Map();
|
|
7398
7422
|
const activations = [];
|
|
7399
7423
|
const nestingOffset = 4;
|
|
7424
|
+
const notesBeforeFirstMsg = notesByAfterIndex.get(-1);
|
|
7425
|
+
if (notesBeforeFirstMsg && notesBeforeFirstMsg.length > 0) {
|
|
7426
|
+
let noteY = messageY;
|
|
7427
|
+
for (const note of notesBeforeFirstMsg) {
|
|
7428
|
+
const noteW = Math.max(
|
|
7429
|
+
SEQ.noteWidth,
|
|
7430
|
+
estimateTextWidth(note.text, FONT_SIZES.edgeLabel, FONT_WEIGHTS.edgeLabel) + SEQ.notePadX * 2
|
|
7431
|
+
);
|
|
7432
|
+
const noteH = FONT_SIZES.edgeLabel + SEQ.notePadY * 2;
|
|
7433
|
+
const firstActorIdx = actorIndex.get(note.actorIds[0] ?? "") ?? 0;
|
|
7434
|
+
let noteX;
|
|
7435
|
+
if (note.position === "left") {
|
|
7436
|
+
noteX = actorCenterX[firstActorIdx] - actorWidths[firstActorIdx] / 2 - noteW - SEQ.noteGap;
|
|
7437
|
+
} else if (note.position === "right") {
|
|
7438
|
+
noteX = actorCenterX[firstActorIdx] + actorWidths[firstActorIdx] / 2 + SEQ.noteGap;
|
|
7439
|
+
} else {
|
|
7440
|
+
if (note.actorIds.length > 1) {
|
|
7441
|
+
const lastActorIdx = actorIndex.get(note.actorIds[note.actorIds.length - 1] ?? "") ?? firstActorIdx;
|
|
7442
|
+
noteX = (actorCenterX[firstActorIdx] + actorCenterX[lastActorIdx]) / 2 - noteW / 2;
|
|
7443
|
+
} else {
|
|
7444
|
+
noteX = actorCenterX[firstActorIdx] - noteW / 2;
|
|
7445
|
+
}
|
|
7446
|
+
}
|
|
7447
|
+
positionedNotes.push({
|
|
7448
|
+
text: note.text,
|
|
7449
|
+
x: noteX,
|
|
7450
|
+
y: noteY,
|
|
7451
|
+
width: noteW,
|
|
7452
|
+
height: noteH,
|
|
7453
|
+
position: note.position,
|
|
7454
|
+
actors: note.actorIds
|
|
7455
|
+
});
|
|
7456
|
+
noteY += noteH + 4;
|
|
7457
|
+
}
|
|
7458
|
+
messageY = Math.max(messageY, noteY + SEQ.messageRowHeight / 2);
|
|
7459
|
+
}
|
|
7400
7460
|
for (let msgIdx = 0; msgIdx < diagram.messages.length; msgIdx++) {
|
|
7401
7461
|
const msg = diagram.messages[msgIdx];
|
|
7402
7462
|
const fromIdx = actorIndex.get(msg.from) ?? 0;
|