mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: paste as mermaid if applicable (#8116)
This commit is contained in:
parent
63dee03ef0
commit
22b39277f5
5 changed files with 179 additions and 27 deletions
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());
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue