-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ braintree | |
catmull | ||
compositTitleSize | ||
curv | ||
deephistory | ||
doublecircle | ||
elems | ||
gantt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/mermaid/src/rendering-util/rendering-elements/shapes/history.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; | ||
import intersect from '../intersect/index.js'; | ||
import type { Node } from '../../types.js'; | ||
import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; | ||
import rough from 'roughjs'; | ||
import type { D3Selection } from '../../../types.js'; | ||
import { handleUndefinedAttr } from '../../../utils.js'; | ||
|
||
export async function historyBase<T extends SVGGraphicsElement>( | ||
parent: D3Selection<T>, | ||
node: Node | ||
) { | ||
const { labelStyles, nodeStyles } = styles2String(node); | ||
node.labelStyle = labelStyles; | ||
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node)); | ||
|
||
const radius = 16; | ||
let circleElem; | ||
const { cssStyles } = node; | ||
|
||
if (node.look === 'handDrawn') { | ||
// @ts-expect-error -- Passing a D3.Selection seems to work for some reason | ||
const rc = rough.svg(shapeSvg); | ||
const options = userNodeOverrides(node, {}); | ||
const roughNode = rc.circle(0, 0, radius * 2, options); | ||
|
||
circleElem = shapeSvg.insert(() => roughNode, ':first-child'); | ||
circleElem | ||
.attr('class', 'basic label-container history') | ||
.attr('style', handleUndefinedAttr(cssStyles)); | ||
} else { | ||
circleElem = shapeSvg | ||
.insert('circle', ':first-child') | ||
.attr('class', 'basic label-container history') | ||
.attr('style', nodeStyles) | ||
.attr('r', radius) | ||
.attr('cx', 0) | ||
.attr('cy', 0); | ||
} | ||
|
||
updateNodeBounds(node, circleElem); | ||
|
||
node.intersect = function (point) { | ||
return intersect.circle(node, radius, point); | ||
}; | ||
|
||
return shapeSvg; | ||
} | ||
|
||
export async function history<T extends SVGGraphicsElement>(parent: D3Selection<T>, node: Node) { | ||
node.label = 'H'; | ||
return await historyBase(parent, node); | ||
} | ||
|
||
export async function deephistory<T extends SVGGraphicsElement>( | ||
parent: D3Selection<T>, | ||
node: Node | ||
) { | ||
node.label = 'H*'; | ||
return await historyBase(parent, node); | ||
} |