mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-24 01:40:41 +02:00
feat: paste as mermaid if applicable (#8116)
This commit is contained in:
32
packages/excalidraw/mermaid.ts
Normal file
32
packages/excalidraw/mermaid.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/** heuristically checks whether the text may be a mermaid diagram definition */
|
||||
export const isMaybeMermaidDefinition = (text: string) => {
|
||||
const chartTypes = [
|
||||
"flowchart",
|
||||
"sequenceDiagram",
|
||||
"classDiagram",
|
||||
"stateDiagram",
|
||||
"stateDiagram-v2",
|
||||
"erDiagram",
|
||||
"journey",
|
||||
"gantt",
|
||||
"pie",
|
||||
"quadrantChart",
|
||||
"requirementDiagram",
|
||||
"gitGraph",
|
||||
"C4Context",
|
||||
"mindmap",
|
||||
"timeline",
|
||||
"zenuml",
|
||||
"sankey",
|
||||
"xychart",
|
||||
"block",
|
||||
];
|
||||
|
||||
const re = new RegExp(
|
||||
`^(?:%%{.*?}%%[\\s\\n]*)?\\b${chartTypes
|
||||
.map((x) => `${x}(-beta)?`)
|
||||
.join("|")}\\b`,
|
||||
);
|
||||
|
||||
return re.test(text.trim());
|
||||
};
|
Reference in New Issue
Block a user