mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-22 09:46:42 +02:00
feat(arch): added aws icons
This commit is contained in:
@@ -226,6 +226,17 @@
|
|||||||
</pre>
|
</pre>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<h2>AWS Icon Demo</h2>
|
||||||
|
<pre class="mermaid">
|
||||||
|
architecture
|
||||||
|
service s3(s3)[Cloud Store]
|
||||||
|
service ec2(ec2)[Server]
|
||||||
|
service wave(wavelength)[Wave]
|
||||||
|
|
||||||
|
s3 L--R ec2
|
||||||
|
s3 T--B wave
|
||||||
|
</pre>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import mermaid from './mermaid.esm.mjs';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
|
||||||
@@ -284,6 +295,7 @@
|
|||||||
iconSize: 80,
|
iconSize: 80,
|
||||||
},
|
},
|
||||||
useMaxWidth: false,
|
useMaxWidth: false,
|
||||||
|
iconLibraries: ['aws:full']
|
||||||
});
|
});
|
||||||
function callback() {
|
function callback() {
|
||||||
alert('It worked');
|
alert('It worked');
|
||||||
|
@@ -120,6 +120,12 @@ export interface MermaidConfig {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
legacyMathML?: boolean;
|
legacyMathML?: boolean;
|
||||||
|
/**
|
||||||
|
* This option specifies an object contianing a mappig of SVG icon names to a resolver that returns the svg code.
|
||||||
|
* For supported diagrams (i.e., Architecture), their syntax allows refering to key names in this object to display the corresponding SVG icon in the rendered diagram.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
iconLibraries?: Array<import('./rendering-util/svgRegister.js').IconLibrary | 'aws:full'>;
|
||||||
/**
|
/**
|
||||||
* This option forces Mermaid to rely on KaTeX's own stylesheet for rendering MathML. Due to differences between OS
|
* This option forces Mermaid to rely on KaTeX's own stylesheet for rendering MathML. Due to differences between OS
|
||||||
* fonts and browser's MathML implementation, this option is recommended if consistent rendering is important.
|
* fonts and browser's MathML implementation, this option is recommended if consistent rendering is important.
|
||||||
@@ -127,12 +133,6 @@ export interface MermaidConfig {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
forceLegacyMathML?: boolean;
|
forceLegacyMathML?: boolean;
|
||||||
/**
|
|
||||||
* This option specifies an object contianing a mappig of SVG icon names to a resolver that returns the svg code.
|
|
||||||
* For supported diagrams (i.e., Architecture), their syntax allows refering to key names in this object to display the corresponding SVG icon in the rendered diagram.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
iconLibraries?: Array<import('./rendering-util/svgRegister.js').IconLibrary>;
|
|
||||||
/**
|
/**
|
||||||
* This option controls if the generated ids of nodes in the SVG are
|
* This option controls if the generated ids of nodes in the SVG are
|
||||||
* generated randomly or based on a seed.
|
* generated randomly or based on a seed.
|
||||||
|
@@ -533,8 +533,15 @@ function initialize(options: MermaidConfig = {}) {
|
|||||||
|
|
||||||
registerIcons(defaultIconLibrary);
|
registerIcons(defaultIconLibrary);
|
||||||
if (options?.iconLibraries) {
|
if (options?.iconLibraries) {
|
||||||
options.iconLibraries.forEach((library) => {
|
options.iconLibraries.forEach(async (library) => {
|
||||||
|
if (typeof (library) === 'string') {
|
||||||
|
if (library === 'aws:full') {
|
||||||
|
const { default: awsFull } = await import('./rendering-util/svg/aws/aws_full.js');
|
||||||
|
registerIcons(awsFull);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
registerIcons(library);
|
registerIcons(library);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
237
packages/mermaid/src/rendering-util/svg/aws/aws_common.ts
Normal file
237
packages/mermaid/src/rendering-util/svg/aws/aws_common.ts
Normal file
File diff suppressed because one or more lines are too long
2816
packages/mermaid/src/rendering-util/svg/aws/aws_full.ts
Normal file
2816
packages/mermaid/src/rendering-util/svg/aws/aws_full.ts
Normal file
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Designer: Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -2,7 +2,7 @@
|
|||||||
* Designer: Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
* @see https://github.com/NicolasNewman/IconLibrary
|
* @see https://github.com/NicolasNewman/IconLibrary
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -2,7 +2,7 @@
|
|||||||
* Designer: Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
* @see https://github.com/NicolasNewman/IconLibrary
|
* @see https://github.com/NicolasNewman/IconLibrary
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -2,7 +2,7 @@
|
|||||||
* Designer: Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
* @see https://github.com/NicolasNewman/IconLibrary
|
* @see https://github.com/NicolasNewman/IconLibrary
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -2,7 +2,7 @@
|
|||||||
* Designer: Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
* @see https://github.com/NicolasNewman/IconLibrary
|
* @see https://github.com/NicolasNewman/IconLibrary
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -2,7 +2,7 @@
|
|||||||
* Designer: Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
* @see https://github.com/NicolasNewman/IconLibrary
|
* @see https://github.com/NicolasNewman/IconLibrary
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* @author Nicolas Newman
|
* Designer: Nicolas Newman
|
||||||
* @see https://github.com/NicolasNewman/IconLibrary
|
* @see https://github.com/NicolasNewman/IconLibrary
|
||||||
*/
|
*/
|
||||||
import { createIcon } from '../svgRegister.js';
|
import { createIcon } from '../../svgRegister.js';
|
||||||
|
|
||||||
export default createIcon(
|
export default createIcon(
|
||||||
`<g>
|
`<g>
|
@@ -1,11 +1,12 @@
|
|||||||
import type { IconLibrary } from '../svgRegister.js';
|
import type { IconLibrary } from '../svgRegister.js';
|
||||||
import database from './database.js';
|
import database from './default/database.js';
|
||||||
import server from './server.js';
|
import server from './default/server.js';
|
||||||
import disk from './disk.js';
|
import disk from './default/disk.js';
|
||||||
import internet from './internet.js';
|
import internet from './default/internet.js';
|
||||||
import cloud from './cloud.js';
|
import cloud from './default/cloud.js';
|
||||||
import unknown from './unknown.js';
|
import unknown from './default/unknown.js';
|
||||||
import blank from './blank.js';
|
import blank from './default/blank.js';
|
||||||
|
import awsCommon from './aws/aws_common.js';
|
||||||
|
|
||||||
const defaultIconLibrary: IconLibrary = {
|
const defaultIconLibrary: IconLibrary = {
|
||||||
database: database,
|
database: database,
|
||||||
@@ -15,6 +16,7 @@ const defaultIconLibrary: IconLibrary = {
|
|||||||
cloud: cloud,
|
cloud: cloud,
|
||||||
unknown: unknown,
|
unknown: unknown,
|
||||||
blank: blank,
|
blank: blank,
|
||||||
|
...awsCommon,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultIconLibrary;
|
export default defaultIconLibrary;
|
||||||
|
@@ -6,7 +6,7 @@ type IconResolver = (
|
|||||||
) => Selection<SVGGElement, unknown, Element | null, unknown>;
|
) => Selection<SVGGElement, unknown, Element | null, unknown>;
|
||||||
type IconLibrary = Record<string, IconResolver>;
|
type IconLibrary = Record<string, IconResolver>;
|
||||||
|
|
||||||
const createIcon = (icon: string, originalSize: number): IconResolver => {
|
const createIcon: (icon: string, originalSize: number) => IconResolver = (icon, originalSize) => {
|
||||||
return (
|
return (
|
||||||
parent: Selection<SVGGElement, unknown, Element | null, unknown>,
|
parent: Selection<SVGGElement, unknown, Element | null, unknown>,
|
||||||
size: number = originalSize
|
size: number = originalSize
|
||||||
|
@@ -185,7 +185,7 @@ properties:
|
|||||||
description: |
|
description: |
|
||||||
This option specifies an object contianing a mappig of SVG icon names to a resolver that returns the svg code.
|
This option specifies an object contianing a mappig of SVG icon names to a resolver that returns the svg code.
|
||||||
For supported diagrams (i.e., Architecture), their syntax allows refering to key names in this object to display the corresponding SVG icon in the rendered diagram.
|
For supported diagrams (i.e., Architecture), their syntax allows refering to key names in this object to display the corresponding SVG icon in the rendered diagram.
|
||||||
tsType: Array<import('./rendering-util/svgRegister.js').IconLibrary>
|
tsType: Array<import('./rendering-util/svgRegister.js').IconLibrary | 'aws:full'>
|
||||||
forceLegacyMathML:
|
forceLegacyMathML:
|
||||||
description: |
|
description: |
|
||||||
This option forces Mermaid to rely on KaTeX's own stylesheet for rendering MathML. Due to differences between OS
|
This option forces Mermaid to rely on KaTeX's own stylesheet for rendering MathML. Due to differences between OS
|
||||||
|
Reference in New Issue
Block a user