mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
feat: sequence diagram background rect
This commit is contained in:
@@ -138,6 +138,13 @@ export const bounds = {
|
||||
const loop = this.sequenceItems.pop()
|
||||
return loop
|
||||
},
|
||||
newRect: function (color) {
|
||||
this.sequenceItems.push({ startx: undefined, starty: this.verticalPos, stopx: undefined, stopy: undefined, color: color })
|
||||
},
|
||||
endRect: function () {
|
||||
const rect = this.sequenceItems.pop()
|
||||
return rect
|
||||
},
|
||||
addSectionToLoop: function (message) {
|
||||
const loop = this.sequenceItems.pop()
|
||||
loop.sections = loop.sections || []
|
||||
@@ -410,6 +417,25 @@ export const draw = function (text, id) {
|
||||
svgDraw.drawLoop(diagram, loopData, 'loop', conf)
|
||||
bounds.bumpVerticalPos(conf.boxMargin)
|
||||
break
|
||||
case parser.yy.LINETYPE.RECT_START:
|
||||
bounds.bumpVerticalPos(conf.boxMargin)
|
||||
bounds.newRect(msg.message)
|
||||
bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
|
||||
break
|
||||
case parser.yy.LINETYPE.RECT_END:
|
||||
const rectData = bounds.endRect()
|
||||
svgDraw.drawRect(diagram, {
|
||||
x: rectData.startx,
|
||||
y: rectData.starty,
|
||||
width: rectData.stopx - rectData.startx,
|
||||
height: rectData.stopy - rectData.starty,
|
||||
fill: rectData.color,
|
||||
class: 'rect',
|
||||
rx: 0,
|
||||
ry: 0
|
||||
}, true)
|
||||
bounds.bumpVerticalPos(conf.boxMargin)
|
||||
break
|
||||
case parser.yy.LINETYPE.OPT_START:
|
||||
bounds.bumpVerticalPos(conf.boxMargin)
|
||||
bounds.newLoop(msg.message)
|
||||
|
Reference in New Issue
Block a user