mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-15 02:04:08 +01:00
fix(#4140): Deprecate mermaidAPI.render
This commit is contained in:
@@ -95,7 +95,7 @@ mermaid.initialize(config);
|
|||||||
|
|
||||||
#### Defined in
|
#### Defined in
|
||||||
|
|
||||||
[mermaidAPI.ts:680](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L680)
|
[mermaidAPI.ts:659](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L659)
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|||||||
@@ -337,6 +337,32 @@ const parse = async (text: string, parseOptions?: ParseOptions): Promise<boolean
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that renders an svg with a graph from a chart definition. Usage example below.
|
||||||
|
*
|
||||||
|
* ```javascript
|
||||||
|
* mermaid.initialize({
|
||||||
|
* startOnLoad: true,
|
||||||
|
* });
|
||||||
|
* $(function () {
|
||||||
|
* const graphDefinition = 'graph TB\na-->b';
|
||||||
|
* const cb = function (svgGraph) {
|
||||||
|
* console.log(svgGraph);
|
||||||
|
* };
|
||||||
|
* mermaid.render('id1', graphDefinition, cb);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param id - The id for the SVG element (the element to be rendered)
|
||||||
|
* @param text - The text for the graph definition
|
||||||
|
* @param cb - Callback which is called after rendering is finished with the svg code as in param.
|
||||||
|
* @param svgContainingElement - HTML element where the svg will be inserted. (Is usually element with the .mermaid class)
|
||||||
|
* If no svgContainingElement is provided then the SVG element will be appended to the body.
|
||||||
|
* Selector to element in which a div with the graph temporarily will be
|
||||||
|
* inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
|
||||||
|
* element will be removed when rendering is completed.
|
||||||
|
* @returns Returns the rendered element as a string containing the SVG definition.
|
||||||
|
*/
|
||||||
const render = (id: string, text: string, container?: Element): Promise<RenderResult> => {
|
const render = (id: string, text: string, container?: Element): Promise<RenderResult> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// This promise will resolve when the mermaidAPI.render call is done.
|
// This promise will resolve when the mermaidAPI.render call is done.
|
||||||
|
|||||||
@@ -370,30 +370,9 @@ export const removeExistingElements = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that renders an svg with a graph from a chart definition. Usage example below.
|
* @deprecated - use the `mermaid.render` function instead of `mermaid.mermaidAPI.render`
|
||||||
*
|
*
|
||||||
* ```javascript
|
* Deprecated for external use.
|
||||||
* mermaidAPI.initialize({
|
|
||||||
* startOnLoad: true,
|
|
||||||
* });
|
|
||||||
* $(function () {
|
|
||||||
* const graphDefinition = 'graph TB\na-->b';
|
|
||||||
* const cb = function (svgGraph) {
|
|
||||||
* console.log(svgGraph);
|
|
||||||
* };
|
|
||||||
* mermaidAPI.render('id1', graphDefinition, cb);
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param id - The id for the SVG element (the element to be rendered)
|
|
||||||
* @param text - The text for the graph definition
|
|
||||||
* @param cb - Callback which is called after rendering is finished with the svg code as in param.
|
|
||||||
* @param svgContainingElement - HTML element where the svg will be inserted. (Is usually element with the .mermaid class)
|
|
||||||
* If no svgContainingElement is provided then the SVG element will be appended to the body.
|
|
||||||
* Selector to element in which a div with the graph temporarily will be
|
|
||||||
* inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
|
|
||||||
* element will be removed when rendering is completed.
|
|
||||||
* @returns Returns the rendered element as a string containing the SVG definition.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const render = async function (
|
const render = async function (
|
||||||
|
|||||||
Reference in New Issue
Block a user