mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
Move UID to separate file, refine run sh
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
sankeyJustify as d3SankeyJustify,
|
||||
} from 'd3-sankey';
|
||||
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||
import { Uid } from './sankeyUtils.js';
|
||||
import { Uid } from '../../rendering-util/uid.js';
|
||||
import { SankeyLinkColor, SankeyNodeAlignment } from '../../config.type.js';
|
||||
|
||||
/**
|
||||
@@ -66,14 +66,16 @@ export const draw = function (text: string, id: string, _version: string, diagOb
|
||||
// }
|
||||
//
|
||||
const graph = diagObj.db.getGraph();
|
||||
|
||||
const alignmentsMap: Record<SankeyNodeAlignment, (node: SankeyNode<{}, {}>, n: number) => number> = new Map([
|
||||
const alignmentsMap: Map<
|
||||
SankeyNodeAlignment,
|
||||
(node: SankeyNode<{}, {}>, n: number) => number
|
||||
> = new Map([
|
||||
[SankeyNodeAlignment.left, d3SankeyLeft],
|
||||
[SankeyNodeAlignment.right, d3SankeyRight],
|
||||
[SankeyNodeAlignment.center, d3SankeyCenter],
|
||||
[SankeyNodeAlignment.justify, d3SankeyJustify],
|
||||
]);
|
||||
const nodeAlignment = alignmentsMap[conf?.nodeAlignment];
|
||||
const nodeAlignment = alignmentsMap.get(conf?.nodeAlignment || SankeyNodeAlignment.justify);
|
||||
|
||||
// Construct and configure a Sankey generator
|
||||
// That will be a function that calculates nodes and links dimensions
|
||||
|
@@ -6,22 +6,3 @@ export const prepareTextForParsing = (text: string): string => {
|
||||
|
||||
return textToParse;
|
||||
};
|
||||
|
||||
export class Uid {
|
||||
private static count = 0;
|
||||
id: string;
|
||||
href: string;
|
||||
|
||||
public static next(name: string): Uid {
|
||||
return new Uid(name + ++Uid.count);
|
||||
}
|
||||
|
||||
constructor(id: string) {
|
||||
this.id = id;
|
||||
this.href = `#${id}`;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return 'url(' + this.href + ')';
|
||||
}
|
||||
}
|
||||
|
18
packages/mermaid/src/rendering-util/uid.ts
Normal file
18
packages/mermaid/src/rendering-util/uid.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export class Uid {
|
||||
private static count = 0;
|
||||
id: string;
|
||||
href: string;
|
||||
|
||||
public static next(name: string): Uid {
|
||||
return new Uid(name + ++Uid.count);
|
||||
}
|
||||
|
||||
constructor(id: string) {
|
||||
this.id = id;
|
||||
this.href = `#${id}`;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return 'url(' + this.href + ')';
|
||||
}
|
||||
}
|
27
run
27
run
@@ -30,27 +30,28 @@ Run commands within docker containers.
|
||||
|
||||
Development quick start guide:
|
||||
|
||||
\033[1m$name pnpm install\033[0m # Install packages
|
||||
\033[1m$name dev\033[0m # Run dev server with examples, open http://localhost:9000
|
||||
\033[1m$name docs:dev\033[0m # For docs contributions, open http://localhost:3333
|
||||
\033[1m$name pnpm install\033[0m # Install packages
|
||||
\033[1m$name dev\033[0m # Run dev server with examples, open http://localhost:9000
|
||||
\033[1m$name docs:dev\033[0m # For docs contributions, open http://localhost:3333
|
||||
|
||||
Commands:
|
||||
|
||||
$name pnpm # Run any 'pnpm' command
|
||||
$name dev # Run dev server with examples, open http://localhost:9000
|
||||
$name docs:dev # For docs contributions, open http://localhost:3333
|
||||
$name pnpm # Run any 'pnpm' command
|
||||
$name dev # Run dev server with examples, open http://localhost:9000
|
||||
$name docs:dev # For docs contributions, open http://localhost:3333
|
||||
|
||||
$name sh # Open 'sh' inside docker container for development
|
||||
$name sh # Open 'sh' inside docker container for development
|
||||
|
||||
$name help # Show this help
|
||||
$name help # Show this help
|
||||
|
||||
Examples of frequiently used commands:
|
||||
|
||||
$name pnpm add # Add package, 'run add d3-sankey'
|
||||
$name pnpm prettier # Prettify a file 'run prettier <path-to-file>'
|
||||
$name pnpm test # Run unit tests
|
||||
$name pnpm vitest # Run watcher for unit tests
|
||||
$name pnpm e2e # Run integration tests
|
||||
$name pnpm add # Add package, 'run add d3-sankey'
|
||||
$name pnpm prettier --write # Prettify a file 'run prettier <path-to-file>'
|
||||
# git diff --name-only develop | xargs run pnpm prettier --write
|
||||
$name pnpm test # Run unit tests
|
||||
$name pnpm vitest # Run watcher for unit tests
|
||||
$name pnpm e2e # Run integration tests
|
||||
$name pnpm -w run lint:fix
|
||||
EOF
|
||||
)
|
||||
|
Reference in New Issue
Block a user