Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 0adf1f9

Browse files
committed
fix(mermaid): fix styles and escape html
fixes: #389 fixes: #391
1 parent dd4a940 commit 0adf1f9

File tree

8 files changed

+1358
-35
lines changed

8 files changed

+1358
-35
lines changed

packages/client/assets/style/customize.css

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
max-width: var(--base-max-width);
3939
min-width: 320px;
4040
z-index: 2;
41+
width: 100vw; /* for mermaid */
4142
}
4243

4344
.slide-background {
@@ -67,3 +68,7 @@
6768
height: var(--qr-code-image-size);
6869
margin: 0 auto;
6970
}
71+
72+
.mermaid {
73+
width: 100%;
74+
}

packages/client/src/setup/Mermaid.js

+13-16
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@ export class Mermaid {
44
constructor() {
55
mermaid.initialize({
66
startOnLoad: false,
7+
er: {
8+
useMaxWidth: false,
9+
},
10+
flowchart: {
11+
useMaxWidth: false,
12+
},
13+
sequence: {
14+
useMaxWidth: false,
15+
},
16+
gantt: {
17+
useMaxWidth: false,
18+
},
719
});
820
}
921

1022
getElms() {
1123
return document.querySelectorAll('.mermaid');
1224
}
1325

14-
encode(elm) {
15-
const encodedString = `data:image/svg+xml;base64,${btoa(elm.innerHTML)}`;
16-
17-
elm.innerHTML = ''; // delete svg
18-
Object.assign(elm.style, {
19-
visibility: 'initial',
20-
background: `url(${encodedString})`,
21-
backgroundRepeat: 'no-repeat',
22-
backgroundPosition: 'center',
23-
margin: '0 auto',
24-
});
25-
}
26-
2726
init() {
2827
const elms = this.getElms();
2928

@@ -33,7 +32,6 @@ export class Mermaid {
3332
});
3433

3534
mermaid.init();
36-
// this.encode(elm);
3735
});
3836
}
3937

@@ -57,12 +55,11 @@ export class Mermaid {
5755

5856
elm.removeAttribute('data-processed');
5957

60-
mermaid.init();
6158
Object.assign(elm.style, {
6259
visibility: 'initial',
6360
});
6461

65-
// this.encode(elm);
62+
mermaid.init();
6663
}
6764
}
6865
}

0 commit comments

Comments
 (0)