Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2208b98

Browse files
authored
Merge pull request lowcoder-org#295 from jerry-goodman/develop
0307_pr
2 parents f4d9def + 44041dc commit 2208b98

File tree

200 files changed

+14300
-3019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+14300
-3019
lines changed

client/packages/openblocks-comps/package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"@types/react": "17",
88
"@types/react-dom": "17",
99
"big.js": "^6.2.1",
10-
"mermaid": "^10.0.0",
10+
"mermaid": "^10.0.2",
1111
"openblocks-cli": "workspace:^",
1212
"openblocks-sdk": "workspace:^",
1313
"react": "17",
@@ -32,14 +32,6 @@
3232
"w": 15,
3333
"h": 60
3434
}
35-
},
36-
"mermaid": {
37-
"name": "Mermaid",
38-
"icon": "./icons/icon-chart.svg",
39-
"layoutInfo": {
40-
"w": 15,
41-
"h": 60
42-
}
4335
}
4436
}
4537
},

client/packages/openblocks-comps/src/comps/mermaidComp/index.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
withMethodExposing,
99
} from "openblocks-sdk";
1010

11-
import Mermaid from "./mermaid"
11+
import Mermaid from "./mermaid";
1212

1313
const childrenMap = {
14-
code: stringExposingStateControl("code",
14+
code: stringExposingStateControl(
15+
"code",
1516
`graph LR
1617
Start --> Stop`
1718
),
@@ -26,22 +27,18 @@ const childrenMap = {
2627

2728
const CompBase = new UICompBuilder(childrenMap, (props: any) => {
2829
const code = props.code.value;
29-
return (
30-
<Mermaid code={code}/>
31-
);
32-
}).setPropertyViewFn((children: any) => {
33-
return (
34-
<>
35-
<Section name="Basic">
36-
{children.code.propertyView({ label: "code" })}
37-
</Section>
38-
<Section name="Interaction">{children.onEvent.propertyView()}</Section>
39-
</>
40-
);
41-
}).build();
30+
return <Mermaid code={code} />;
31+
})
32+
.setPropertyViewFn((children: any) => {
33+
return (
34+
<>
35+
<Section name="Basic">{children.code.propertyView({ label: "code" })}</Section>
36+
<Section name="Interaction">{children.onEvent.propertyView()}</Section>
37+
</>
38+
);
39+
})
40+
.build();
4241

4342
const AppViewCompTemp = withMethodExposing(CompBase, []);
4443

45-
export const MermaidComp = withExposingConfigs(AppViewCompTemp, [
46-
new NameConfig("code", ""),
47-
]);
44+
export const MermaidComp = withExposingConfigs(AppViewCompTemp, [new NameConfig("code", "")]);
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import React, { useEffect, useState } from "react"
2-
import mermaid from "mermaid"
1+
import React, { useEffect, useState } from "react";
2+
import mermaid from "mermaid";
33

44
function escape(str: string): string {
5-
const entries: { [index: string]: any } = { lt: "<", gt: ">", nbsp: " ", amp: "&", quot: "\"" }
6-
return str.replace(/&(lt|gt|nbsp|amp|quot);/gi, function (_, t) {
7-
return entries[t]
8-
}).trim()
5+
const entries: { [index: string]: any } = { lt: "<", gt: ">", nbsp: " ", amp: "&", quot: '"' };
6+
return str
7+
.replace(/&(lt|gt|nbsp|amp|quot);/gi, function (_, t) {
8+
return entries[t];
9+
})
10+
.trim();
911
}
1012

1113
export default ({ id = "graphDiv", code = "" }) => {
12-
const [svg, setSvg] = useState('')
14+
const [svg, setSvg] = useState("");
1315

1416
useEffect(() => {
15-
mermaid.initialize({ startOnLoad: false })
16-
}, [])
17+
mermaid.initialize({ startOnLoad: false });
18+
}, []);
1719

1820
useEffect(() => {
19-
if (!code) return
21+
if (!code) return;
2022

21-
mermaid.mermaidAPI.render(id, escape(code)).then(res => {
22-
setSvg(res.svg)
23-
})
24-
}, [code, setSvg])
23+
mermaid.mermaidAPI.render(id, escape(code)).then((res) => {
24+
setSvg(res.svg);
25+
});
26+
}, [code, setSvg]);
2527

26-
return (
27-
<pre className="mermaid" dangerouslySetInnerHTML={{ __html: svg }}></pre>
28-
)
29-
}
28+
return <pre className="mermaid" dangerouslySetInnerHTML={{ __html: svg }}></pre>;
29+
};
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { ChartCompWithDefault } from "./comps/chartComp/chartComp";
22
import { ImageEditorComp } from "./comps/imageEditorComp/index";
3-
import {MermaidComp} from "./comps/mermaidComp";
43

54
export default {
65
chart: ChartCompWithDefault,
76
imageEditor: ImageEditorComp,
8-
mermaid: MermaidComp,
97
};

0 commit comments

Comments
 (0)