2022-10-17 23:58:51 -03:00
> **Warning**
>
> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
>
2022-10-29 00:46:25 +05:30
> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/modules/mermaidAPI.md](../../../../packages/mermaid/src/docs/config/setup/modules/mermaidAPI.md).
2022-10-15 00:50:11 -03:00
# Module: mermaidAPI
2023-02-19 13:08:13 +05:30
## Interfaces
2023-02-19 16:10:08 +05:30
- [ParseOptions ](../interfaces/mermaidAPI.ParseOptions.md )
2023-02-19 13:08:13 +05:30
- [RenderResult ](../interfaces/mermaidAPI.RenderResult.md )
2022-10-15 00:50:11 -03:00
## References
2022-10-31 22:15:07 +05:30
### default
2022-10-15 00:50:11 -03:00
Renames and re-exports [mermaidAPI ](mermaidAPI.md#mermaidapi )
2022-11-20 12:27:29 -08:00
## Type Aliases
### D3Element
Ƭ **D3Element** : `any`
#### Defined in
2023-02-19 16:10:08 +05:30
[mermaidAPI.ts:75 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L75 )
2022-11-20 12:27:29 -08:00
2022-10-15 00:50:11 -03:00
## Variables
2022-10-31 22:15:07 +05:30
### mermaidAPI
2022-10-15 00:50:11 -03:00
2023-03-06 14:04:00 +05:30
• `Const` **mermaidAPI** : `Readonly` < { `defaultConfig` : `MermaidConfig` = configApi.defaultConfig; `getConfig` : () => `MermaidConfig` = configApi.getConfig; `getDiagramFromText` : (`text` : `string` ) => `Promise` < `Diagram` > ; `getSiteConfig` : () => `MermaidConfig` = configApi.getSiteConfig; `globalReset` : () => `void` ; `initialize` : (`options` : `MermaidConfig` ) => `void` ; `parse` : (`text` : `string` , `parseOptions?` : [`ParseOptions` ](../interfaces/mermaidAPI.ParseOptions.md )) => `Promise` < `boolean` > ; `parseDirective` : (`p` : `any` , `statement` : `string` , `context` : `string` , `type` : `string` ) => `void` ; `render` : (`id` : `string` , `text` : `string` , `svgContainingElement?` : `Element` ) => `Promise` < [`RenderResult` ](../interfaces/mermaidAPI.RenderResult.md )> ; `reset` : () => `void` ; `setConfig` : (`conf` : `MermaidConfig` ) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig` : (`conf` : `MermaidConfig` ) => `MermaidConfig` = configApi.updateSiteConfig }>
2022-10-15 00:50:11 -03:00
2022-10-31 11:57:50 +05:30
## mermaidAPI configuration defaults
```ts
const config = {
theme: 'default',
logLevel: 'fatal',
securityLevel: 'strict',
startOnLoad: true,
arrowMarkerAbsolute: false,
er: {
diagramPadding: 20,
layoutDirection: 'TB',
minEntityWidth: 100,
minEntityHeight: 75,
entityPadding: 15,
stroke: 'gray',
fill: 'honeydew',
fontSize: 12,
useMaxWidth: true,
},
flowchart: {
diagramPadding: 8,
htmlLabels: true,
curve: 'basis',
},
sequence: {
diagramMarginX: 50,
diagramMarginY: 10,
actorMargin: 50,
width: 150,
height: 65,
boxMargin: 10,
boxTextMargin: 5,
noteMargin: 10,
messageMargin: 35,
messageAlign: 'center',
mirrorActors: true,
bottomMarginAdj: 1,
useMaxWidth: true,
rightAngles: false,
showSequenceNumbers: false,
},
gantt: {
titleTopMargin: 25,
barHeight: 20,
barGap: 4,
topPadding: 50,
leftPadding: 75,
gridLineStartPadding: 35,
fontSize: 11,
fontFamily: '"Open Sans", sans-serif',
numberSectionStyles: 4,
axisFormat: '%Y-%m-%d',
topAxis: false,
2023-03-23 23:45:59 +01:00
compact: false,
2022-10-31 11:57:50 +05:30
},
};
mermaid.initialize(config);
```
2022-10-15 00:50:11 -03:00
#### Defined in
2023-03-23 23:45:59 +01:00
[mermaidAPI.ts:660 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L660 )
2022-10-15 00:50:11 -03:00
## Functions
2022-11-03 10:44:04 -07:00
### appendDivSvgG
▸ **appendDivSvgG** (`parentRoot` , `id` , `enclosingDivId` , `divStyle?` , `svgXlink?` ): `any`
Append an enclosing div, then svg, then g (group) to the d3 parentRoot. Set attributes.
Only set the style attribute on the enclosing div if divStyle is given.
Only set the xmlns:xlink attribute on svg if svgXlink is given.
Return the last node appended
#### Parameters
| Name | Type | Description |
| :--------------- | :------- | :----------------------------------------------- |
| `parentRoot` | `any` | the d3 node to append things to |
| `id` | `string` | the value to set the id attr to |
| `enclosingDivId` | `string` | the id to set the enclosing div to |
| `divStyle?` | `string` | if given, the style to set the enclosing div to |
| `svgXlink?` | `string` | if given, the link to set the new svg element to |
#### Returns
`any`
- returns the parentRoot that had nodes appended
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:305 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L305 )
2022-11-03 10:44:04 -07:00
---
### cleanUpSvgCode
▸ **cleanUpSvgCode** (`svgCode?` , `inSandboxMode` , `useArrowMarkerUrls` ): `string`
Clean up svgCode. Do replacements needed
#### Parameters
| Name | Type | Default value | Description |
| :------------------- | :-------- | :------------ | :---------------------------------------------------------- |
| `svgCode` | `string` | `''` | the code to clean up |
| `inSandboxMode` | `boolean` | `undefined` | security level |
| `useArrowMarkerUrls` | `boolean` | `undefined` | should arrow marker's use full urls? (vs. just the anchors) |
#### Returns
`string`
the cleaned up svgCode
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:256 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L256 )
2022-11-03 10:44:04 -07:00
---
### createCssStyles
▸ **createCssStyles** (`config` , `graphType` , `classDefs?` ): `string`
Create the user styles
#### Parameters
2022-12-31 20:59:18 +00:00
| Name | Type | Description |
| :---------- | :------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------ |
| `config` | `MermaidConfig` | configuration that has style and theme settings to use |
| `graphType` | `string` | used for checking if classDefs should be applied |
| `classDefs` | `undefined` \| `null` \| `Record` < `string` , `DiagramStyleClassDef` > | the classDefs in the diagram text. Might be null if none were defined. Usually is the result of a call to getClasses(...) |
2022-11-03 10:44:04 -07:00
#### Returns
`string`
the string with all the user styles
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:185 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L185 )
2022-11-03 10:44:04 -07:00
---
### createUserStyles
▸ **createUserStyles** (`config` , `graphType` , `classDefs` , `svgId` ): `string`
#### Parameters
| Name | Type |
| :---------- | :----------------------------------------- |
| `config` | `MermaidConfig` |
| `graphType` | `string` |
| `classDefs` | `Record` < `string` , `DiagramStyleClassDef` > |
| `svgId` | `string` |
#### Returns
`string`
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:233 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L233 )
2022-11-03 10:44:04 -07:00
---
### cssImportantStyles
▸ **cssImportantStyles** (`cssClass` , `element` , `cssClasses?` ): `string`
Create a CSS style that starts with the given class name, then the element,
with an enclosing block that has each of the cssClasses followed by !important;
#### Parameters
| Name | Type | Default value | Description |
| :----------- | :---------- | :------------ | :--------------------------------------------- |
| `cssClass` | `string` | `undefined` | CSS class name |
| `element` | `string` | `undefined` | CSS element |
| `cssClasses` | `string` \[] | `[]` | list of CSS styles to append after the element |
#### Returns
`string`
- the constructed string
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:169 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L169 )
2022-11-03 10:44:04 -07:00
---
2022-10-31 22:15:07 +05:30
### decodeEntities
2022-10-15 00:50:11 -03:00
▸ **decodeEntities** (`text` ): `string`
#### Parameters
2022-11-03 10:44:04 -07:00
| Name | Type | Description |
| :----- | :------- | :----------------- |
| `text` | `string` | text to be decoded |
2022-10-15 00:50:11 -03:00
#### Returns
`string`
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:149 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L149 )
2022-10-15 00:50:11 -03:00
---
2022-10-31 22:15:07 +05:30
### encodeEntities
2022-10-15 00:50:11 -03:00
▸ **encodeEntities** (`text` ): `string`
#### Parameters
2022-11-03 10:44:04 -07:00
| Name | Type | Description |
| :----- | :------- | :----------------- |
| `text` | `string` | text to be encoded |
2022-10-15 00:50:11 -03:00
#### Returns
`string`
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:120 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L120 )
2022-11-14 14:51:23 +05:30
---
### putIntoIFrame
▸ **putIntoIFrame** (`svgCode?` , `svgElement?` ): `string`
Put the svgCode into an iFrame. Return the iFrame code
#### Parameters
| Name | Type | Default value | Description |
| :------------ | :------- | :------------ | :--------------------------------------------------------------------------- |
| `svgCode` | `string` | `''` | the svg code to put inside the iFrame |
| `svgElement?` | `any` | `undefined` | the d3 node that has the current svgElement so we can get the height from it |
#### Returns
`string`
- the code with the iFrame that now contains the svgCode
TODO replace btoa(). Replace with buf.toString('base64')?
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:284 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L284 )
2022-11-14 14:51:23 +05:30
---
### removeExistingElements
2022-12-13 13:42:07 +05:30
▸ **removeExistingElements** (`doc` , `id` , `divId` , `iFrameId` ): `void`
2022-11-14 14:51:23 +05:30
Remove any existing elements from the given document
#### Parameters
2022-12-13 13:42:07 +05:30
| Name | Type | Description |
| :--------- | :--------- | :------------------------------------ |
| `doc` | `Document` | the document to removed elements from |
| `id` | `string` | id for any existing SVG element |
| `divId` | `string` | - |
| `iFrameId` | `string` | - |
2022-11-14 14:51:23 +05:30
#### Returns
`void`
#### Defined in
2023-03-05 00:22:02 +05:30
[mermaidAPI.ts:355 ](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L355 )