diff --git a/docs/config/usage.md b/docs/config/usage.md
index 190ef2197..1069ffa5f 100644
--- a/docs/config/usage.md
+++ b/docs/config/usage.md
@@ -247,6 +247,23 @@ The example below show an outline of how this could be used. The example just lo
```
+To determine the type of diagram present in a given text, you can utilize the `mermaid.detectType` function, as demonstrated in the example below.
+
+```html
+
+```
+
### Binding events
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
diff --git a/packages/mermaid/src/docs/config/usage.md b/packages/mermaid/src/docs/config/usage.md
index c74023952..211a06af7 100644
--- a/packages/mermaid/src/docs/config/usage.md
+++ b/packages/mermaid/src/docs/config/usage.md
@@ -244,6 +244,23 @@ The example below show an outline of how this could be used. The example just lo
```
+To determine the type of diagram present in a given text, you can utilize the `mermaid.detectType` function, as demonstrated in the example below.
+
+```html
+
+```
+
### Binding events
Sometimes the generated graph also has defined interactions like tooltip and click events. When using the API one must
diff --git a/packages/mermaid/src/mermaid.ts b/packages/mermaid/src/mermaid.ts
index 52727d30b..bd99877b6 100644
--- a/packages/mermaid/src/mermaid.ts
+++ b/packages/mermaid/src/mermaid.ts
@@ -7,7 +7,11 @@ import { MermaidConfig } from './config.type';
import { log } from './logger';
import utils from './utils';
import { mermaidAPI, ParseOptions, RenderResult } from './mermaidAPI';
-import { registerLazyLoadedDiagrams, loadRegisteredDiagrams } from './diagram-api/detectType';
+import {
+ registerLazyLoadedDiagrams,
+ loadRegisteredDiagrams,
+ detectType,
+} from './diagram-api/detectType';
import type { ParseErrorFunction } from './Diagram';
import { isDetailedError } from './utils';
import type { DetailedError } from './utils';
@@ -400,6 +404,7 @@ const mermaid: {
initialize: typeof initialize;
contentLoaded: typeof contentLoaded;
setParseErrorHandler: typeof setParseErrorHandler;
+ detectType: typeof detectType;
} = {
startOnLoad: true,
mermaidAPI,
@@ -412,6 +417,7 @@ const mermaid: {
parseError: undefined,
contentLoaded,
setParseErrorHandler,
+ detectType,
};
export default mermaid;