mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-19 07:20:21 +02:00
feat: improve mermaid detection on paste (#8287)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
export const isMaybeMermaidDefinition = (text: string) => {
|
||||
const chartTypes = [
|
||||
"flowchart",
|
||||
"graph",
|
||||
"sequenceDiagram",
|
||||
"classDiagram",
|
||||
"stateDiagram",
|
||||
@@ -23,9 +24,9 @@ export const isMaybeMermaidDefinition = (text: string) => {
|
||||
];
|
||||
|
||||
const re = new RegExp(
|
||||
`^(?:%%{.*?}%%[\\s\\n]*)?\\b${chartTypes
|
||||
.map((x) => `${x}(-beta)?`)
|
||||
.join("|")}\\b`,
|
||||
`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${chartTypes
|
||||
.map((x) => `\\s*${x}(-beta)?`)
|
||||
.join("|")})\\b`,
|
||||
);
|
||||
|
||||
return re.test(text.trim());
|
||||
|
Reference in New Issue
Block a user