mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 17:29:54 +02:00
Merge branch 'release/11.4.0' of github.com:mermaid-js/mermaid into release/11.4.0
This commit is contained in:
@@ -130,7 +130,8 @@ const addNode = (level: number, id: string, descr: string, type: number, shapeDa
|
|||||||
throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`);
|
throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc?.shape) {
|
// if shape is defined in the yaml data, use it if it is a valid shape kanbanItem
|
||||||
|
if (doc?.shape && doc.shape === 'kanbanItem') {
|
||||||
node.shape = doc?.shape;
|
node.shape = doc?.shape;
|
||||||
}
|
}
|
||||||
if (doc?.label) {
|
if (doc?.label) {
|
||||||
|
@@ -6,25 +6,26 @@ import { userNodeOverrides, styles2String } from './handDrawnShapeStyles.js';
|
|||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
import type { D3Selection } from '../../../types.js';
|
import type { D3Selection } from '../../../types.js';
|
||||||
|
|
||||||
const colorFromPriority = (priority: KanbanNode['priority']) => {
|
const colorFromPriority = (priority: NonNullable<KanbanNode['priority']>) => {
|
||||||
switch (priority) {
|
switch (priority) {
|
||||||
case 'Very High':
|
case 'Very High':
|
||||||
return 'red';
|
return 'red';
|
||||||
case 'High':
|
case 'High':
|
||||||
return 'orange';
|
return 'orange';
|
||||||
|
case 'Medium':
|
||||||
|
return null; // no stroke
|
||||||
case 'Low':
|
case 'Low':
|
||||||
return 'blue';
|
return 'blue';
|
||||||
case 'Very Low':
|
case 'Very Low':
|
||||||
return 'lightblue';
|
return 'lightblue';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const kanbanItem = async <T extends SVGGraphicsElement>(
|
export async function kanbanItem<T extends SVGGraphicsElement>(
|
||||||
parent: D3Selection<T>,
|
parent: D3Selection<T>,
|
||||||
node: Node,
|
// Omit the 'shape' prop since otherwise, it causes a TypeScript circular dependency error
|
||||||
|
kanbanNode: Omit<Node, 'shape'> | Omit<KanbanNode, 'level' | 'shape'>,
|
||||||
{ config }: ShapeRenderOptions
|
{ config }: ShapeRenderOptions
|
||||||
) => {
|
) {
|
||||||
const unknownNode = node as unknown;
|
|
||||||
const kanbanNode = unknownNode as KanbanNode;
|
|
||||||
const { labelStyles, nodeStyles } = styles2String(kanbanNode);
|
const { labelStyles, nodeStyles } = styles2String(kanbanNode);
|
||||||
kanbanNode.labelStyle = labelStyles;
|
kanbanNode.labelStyle = labelStyles;
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ export const kanbanItem = async <T extends SVGGraphicsElement>(
|
|||||||
let ticketUrl = '';
|
let ticketUrl = '';
|
||||||
let link;
|
let link;
|
||||||
|
|
||||||
if (kanbanNode.ticket && config?.kanban?.ticketBaseUrl) {
|
if ('ticket' in kanbanNode && kanbanNode.ticket && config?.kanban?.ticketBaseUrl) {
|
||||||
ticketUrl = config?.kanban?.ticketBaseUrl.replace('#TICKET#', kanbanNode.ticket);
|
ticketUrl = config?.kanban?.ticketBaseUrl.replace('#TICKET#', kanbanNode.ticket);
|
||||||
link = shapeSvg
|
link = shapeSvg
|
||||||
.insert<SVGAElement>('svg:a', ':first-child')
|
.insert<SVGAElement>('svg:a', ':first-child')
|
||||||
@@ -62,17 +63,21 @@ export const kanbanItem = async <T extends SVGGraphicsElement>(
|
|||||||
};
|
};
|
||||||
let labelEl, bbox2;
|
let labelEl, bbox2;
|
||||||
if (link) {
|
if (link) {
|
||||||
({ label: labelEl, bbox: bbox2 } = await insertLabel(link, kanbanNode.ticket || '', options));
|
({ label: labelEl, bbox: bbox2 } = await insertLabel(
|
||||||
|
link,
|
||||||
|
('ticket' in kanbanNode && kanbanNode.ticket) || '',
|
||||||
|
options
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
({ label: labelEl, bbox: bbox2 } = await insertLabel(
|
({ label: labelEl, bbox: bbox2 } = await insertLabel(
|
||||||
shapeSvg,
|
shapeSvg,
|
||||||
kanbanNode.ticket || '',
|
('ticket' in kanbanNode && kanbanNode.ticket) || '',
|
||||||
options
|
options
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
const { label: labelElAssigned, bbox: bboxAssigned } = await insertLabel(
|
const { label: labelElAssigned, bbox: bboxAssigned } = await insertLabel(
|
||||||
shapeSvg,
|
shapeSvg,
|
||||||
kanbanNode.assigned || '',
|
('assigned' in kanbanNode && kanbanNode.assigned) || '',
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
kanbanNode.width = orgWidth;
|
kanbanNode.width = orgWidth;
|
||||||
@@ -129,7 +134,9 @@ export const kanbanItem = async <T extends SVGGraphicsElement>(
|
|||||||
.attr('y', y)
|
.attr('y', y)
|
||||||
.attr('width', totalWidth)
|
.attr('width', totalWidth)
|
||||||
.attr('height', totalHeight);
|
.attr('height', totalHeight);
|
||||||
if (kanbanNode.priority) {
|
|
||||||
|
const priority = 'priority' in kanbanNode && kanbanNode.priority;
|
||||||
|
if (priority) {
|
||||||
const line = shapeSvg.append('line', ':first-child');
|
const line = shapeSvg.append('line', ':first-child');
|
||||||
const lineX = x + 2;
|
const lineX = x + 2;
|
||||||
|
|
||||||
@@ -142,7 +149,7 @@ export const kanbanItem = async <T extends SVGGraphicsElement>(
|
|||||||
.attr('y2', y2)
|
.attr('y2', y2)
|
||||||
|
|
||||||
.attr('stroke-width', '4')
|
.attr('stroke-width', '4')
|
||||||
.attr('stroke', colorFromPriority(kanbanNode.priority));
|
.attr('stroke', colorFromPriority(priority));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,4 +161,4 @@ export const kanbanItem = async <T extends SVGGraphicsElement>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
return shapeSvg;
|
return shapeSvg;
|
||||||
};
|
}
|
||||||
|
Reference in New Issue
Block a user