@farberg/reveal-template 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/dhbw.css +131 -113
- package/docs/00 - Introduction.md +7 -0
- package/docs/local-dev.html +0 -10
- package/docs/npm.html +10 -3
- package/init-reveal.js +29 -4
- package/package.json +5 -4
- package/plugins/reveal-plugin-show-code-snippets.js +2 -1
- package/plugins/reveal-plugin-mermaid.js +0 -143
package/css/dhbw.css
CHANGED
|
@@ -4,19 +4,19 @@ section.has-dark-background, section.has-dark-background h1, section.has-dark-ba
|
|
|
4
4
|
|
|
5
5
|
/* https://github.com/hakimel/reveal.js/issues/1279 : data-state="dim-background" */
|
|
6
6
|
html.dim-background-light .slide-background {
|
|
7
|
-
|
|
7
|
+
opacity: 0.4 !important;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
html.dim-background .slide-background {
|
|
11
|
-
|
|
11
|
+
opacity: 0.2 !important;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
html.dim-background-medium .slide-background {
|
|
15
|
-
|
|
15
|
+
opacity: 0.1 !important;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
html.dim-background-strong .slide-background {
|
|
19
|
-
|
|
19
|
+
opacity: 0.05 !important;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/*********************************************
|
|
@@ -33,7 +33,8 @@ body {
|
|
|
33
33
|
font-size: 33px;
|
|
34
34
|
font-weight: normal;
|
|
35
35
|
/* color: #222; */
|
|
36
|
-
color: #4e565c;
|
|
36
|
+
color: #4e565c;
|
|
37
|
+
/* was #4e565c */
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
::selection {
|
|
@@ -75,8 +76,8 @@ body {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
.reveal h2 {
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
font-size: 1.5em;
|
|
80
|
+
padding-bottom: 5px;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
.reveal h3 {
|
|
@@ -134,7 +135,8 @@ body {
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
.reveal ol li {
|
|
137
|
-
color: #000000;
|
|
138
|
+
color: #000000;
|
|
139
|
+
/* was #000000 */
|
|
138
140
|
font-size: 90%;
|
|
139
141
|
margin-top: 0em;
|
|
140
142
|
}
|
|
@@ -147,7 +149,8 @@ body {
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
.reveal ul li {
|
|
150
|
-
color: #000000;
|
|
152
|
+
color: #000000;
|
|
153
|
+
/* was #000000 */
|
|
151
154
|
font-size: 90%;
|
|
152
155
|
margin-top: 0em;
|
|
153
156
|
margin-bottom: 0.5em;
|
|
@@ -260,6 +263,18 @@ body {
|
|
|
260
263
|
color: #DCDCDC;
|
|
261
264
|
}
|
|
262
265
|
|
|
266
|
+
.reveal code.language-mermaid,
|
|
267
|
+
.reveal pre code.language-mermaid,
|
|
268
|
+
.reveal code.mermaid,
|
|
269
|
+
.reveal pre code.mermaid {
|
|
270
|
+
background: transparent !important;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.reveal pre.code-wrapper:has(> code.mermaid) {
|
|
274
|
+
background: transparent !important;
|
|
275
|
+
box-shadow: none !important;
|
|
276
|
+
}
|
|
277
|
+
|
|
263
278
|
.reveal table {
|
|
264
279
|
margin: auto;
|
|
265
280
|
border-collapse: collapse;
|
|
@@ -466,11 +481,11 @@ right50transparentbox {
|
|
|
466
481
|
*********************************************/
|
|
467
482
|
|
|
468
483
|
.solution {
|
|
469
|
-
|
|
484
|
+
display: none !important;
|
|
470
485
|
}
|
|
471
486
|
|
|
472
487
|
.solutionvisible {
|
|
473
|
-
|
|
488
|
+
display: unset !important;
|
|
474
489
|
}
|
|
475
490
|
|
|
476
491
|
/*********************************************
|
|
@@ -481,16 +496,16 @@ right50transparentbox {
|
|
|
481
496
|
border-bottom: 0.1px dotted rgb(198, 198, 198) !important;
|
|
482
497
|
}
|
|
483
498
|
|
|
484
|
-
.toc_tr_chapter
|
|
499
|
+
.toc_tr_chapter td {
|
|
485
500
|
border-bottom: 1px solid black !important;
|
|
486
501
|
border-top: 1px solid black !important;
|
|
487
502
|
}
|
|
488
503
|
|
|
489
|
-
.toc_table
|
|
504
|
+
.toc_table tr:last-of-type {
|
|
490
505
|
border-bottom: 1px solid black !important;
|
|
491
506
|
}
|
|
492
507
|
|
|
493
|
-
tr
|
|
508
|
+
tr>tr:first-of-type {
|
|
494
509
|
border-top: 1px solid black !important;
|
|
495
510
|
}
|
|
496
511
|
|
|
@@ -515,36 +530,39 @@ tr > tr:first-of-type {
|
|
|
515
530
|
}
|
|
516
531
|
|
|
517
532
|
credits {
|
|
518
|
-
|
|
533
|
+
visibility: hidden;
|
|
519
534
|
}
|
|
520
535
|
|
|
521
536
|
/* Credits Dennis */
|
|
522
537
|
|
|
523
538
|
attribution {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
539
|
+
position: absolute !important;
|
|
540
|
+
/* display: block; */
|
|
541
|
+
display: table-cell !important;
|
|
542
|
+
vertical-align: middle !important;
|
|
543
|
+
right: 35px;
|
|
544
|
+
bottom: 8px;
|
|
545
|
+
height: 22px;
|
|
546
|
+
z-index: 200;
|
|
547
|
+
font-size: 12px;
|
|
548
|
+
text-align: right;
|
|
534
549
|
color: #4e565c;
|
|
535
550
|
background-color: rgba(0, 0, 0, 0.4);
|
|
536
551
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
552
|
+
|
|
553
|
+
attribution>span {
|
|
554
|
+
padding-left: 5px !important;
|
|
555
|
+
padding-right: 5px !important;
|
|
556
|
+
line-height: 22px !important;
|
|
541
557
|
}
|
|
558
|
+
|
|
542
559
|
attribution a {
|
|
543
|
-
|
|
560
|
+
font-size: 12px;
|
|
544
561
|
color: #4e565c;
|
|
545
562
|
}
|
|
563
|
+
|
|
546
564
|
attribution a:visited {
|
|
547
|
-
|
|
565
|
+
font-size: 12px;
|
|
548
566
|
color: #4e565c;
|
|
549
567
|
}
|
|
550
568
|
|
|
@@ -577,85 +595,85 @@ attribution a:visited {
|
|
|
577
595
|
/** Dirtree plugin */
|
|
578
596
|
|
|
579
597
|
ul.dirtree {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
598
|
+
text-indent: 0;
|
|
599
|
+
margin: 0px 0px 0px 20px;
|
|
600
|
+
padding: 0;
|
|
601
|
+
list-style: none;
|
|
602
|
+
line-height: 1.5em;
|
|
603
|
+
font-family: monospace;
|
|
604
|
+
|
|
605
|
+
list-style-type: none;
|
|
606
|
+
margin-block-start: 0;
|
|
607
|
+
margin-block-end: 0;
|
|
608
|
+
margin-inline-start: 0px;
|
|
609
|
+
margin-inline-end: 0px;
|
|
610
|
+
padding-inline-start: 0;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
ul.dirtree li.dirtree {
|
|
614
|
+
list-style-type: none;
|
|
615
|
+
display: list-item;
|
|
616
|
+
text-indent: 0;
|
|
617
|
+
padding: 0;
|
|
618
|
+
margin-bottom: 0;
|
|
619
|
+
margin-top: 0;
|
|
620
|
+
font-size: 16px;
|
|
621
|
+
position: relative;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
ul.dirtree li.dirtree:before {
|
|
625
|
+
position: absolute;
|
|
626
|
+
left: -15px;
|
|
627
|
+
top: 0px;
|
|
628
|
+
content: "" !important;
|
|
629
|
+
display: block;
|
|
630
|
+
border-left: 1px solid #ddd;
|
|
631
|
+
height: 1em;
|
|
632
|
+
border-bottom: 1px solid #ddd;
|
|
633
|
+
width: 10px;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
ul.dirtree li.dirtree:after {
|
|
637
|
+
position: absolute;
|
|
638
|
+
left: -15px;
|
|
639
|
+
bottom: -7px;
|
|
640
|
+
content: "";
|
|
641
|
+
display: block;
|
|
642
|
+
border-left: 1px solid #ddd;
|
|
643
|
+
height: 100%;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
ul.dirtree li.root {
|
|
647
|
+
margin: 0px 0px 0px -20px;
|
|
648
|
+
padding: 0;
|
|
649
|
+
padding-left: 20px;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
ul.dirtree li.root:before {
|
|
653
|
+
display: none;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
ul.dirtree li.root:after {
|
|
657
|
+
display: none;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
ul.dirtree li.dirtree:last-child:after {
|
|
661
|
+
display: none;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
ul.dirtree ul li {
|
|
665
|
+
margin-left: 0;
|
|
666
|
+
padding: 0;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
ul.dirtree ul ul li {
|
|
670
|
+
margin-left: 0;
|
|
671
|
+
padding: 0;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
ul.dirtree ul ul ul li {
|
|
675
|
+
margin-left: 0;
|
|
676
|
+
padding: 0;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/** Dirtree plugin: end */
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
---
|
|
4
4
|
## Some Heading
|
|
5
5
|
|
|
6
|
+
```mermaid
|
|
7
|
+
graph LR
|
|
8
|
+
A["frontend<br/>0–120ms"] --> B["auth<br/>5–30ms"]
|
|
9
|
+
A --> C["data<br/>35–115ms"]
|
|
10
|
+
C --> D["database<br/>40–110ms"]
|
|
11
|
+
```
|
|
12
|
+
|
|
6
13
|
Some text
|
|
7
14
|
- This is an example presentation
|
|
8
15
|
- This is an example presentation
|
package/docs/local-dev.html
CHANGED
|
@@ -25,16 +25,6 @@
|
|
|
25
25
|
<div class="slides">
|
|
26
26
|
<section data-markdown>
|
|
27
27
|
<textarea data-template>
|
|
28
|
-
## Gateway API
|
|
29
|
-
|
|
30
|
-
```mermaid
|
|
31
|
-
graph LR
|
|
32
|
-
GWC[GatewayClass] -->|implemented by| Ctrl[Controller]
|
|
33
|
-
GW[Gateway] -->|references| GWC
|
|
34
|
-
Route[HTTPRoute] -->|attaches to| GW
|
|
35
|
-
Route -->|routes to| SvcA[Service A]
|
|
36
|
-
Route -->|routes to| SvcB[Service B]
|
|
37
|
-
```
|
|
38
28
|
</textarea>
|
|
39
29
|
</section>
|
|
40
30
|
</div>
|
package/docs/npm.html
CHANGED
|
@@ -4,15 +4,22 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
6
6
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
7
|
-
<meta name="viewport"
|
|
7
|
+
<meta name="viewport"
|
|
8
|
+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes, minimal-ui">
|
|
8
9
|
|
|
9
10
|
<link rel="stylesheet" href="node_modules/reveal.js/dist/reveal.css">
|
|
10
11
|
<link rel="stylesheet" href="node_modules/reveal.js/plugin/highlight/zenburn.css">
|
|
11
12
|
<link rel="stylesheet" href="node_modules/@farberg/reveal-template/css/dhbw.css" id="theme">
|
|
12
13
|
|
|
13
14
|
<script type="module">
|
|
14
|
-
import { initReveal } from '
|
|
15
|
-
initReveal(
|
|
15
|
+
import { initReveal } from '../init-reveal.js'
|
|
16
|
+
initReveal({
|
|
17
|
+
jsPrefixPath: "../",
|
|
18
|
+
cssPrefixPath: "../",
|
|
19
|
+
cssThemePrefixPath: "../",
|
|
20
|
+
revealPath: "../node_modules/reveal.js/",
|
|
21
|
+
verbose: true
|
|
22
|
+
});
|
|
16
23
|
</script>
|
|
17
24
|
</head>
|
|
18
25
|
|
package/init-reveal.js
CHANGED
|
@@ -10,7 +10,6 @@ import ToggleSolutionsPlugin from './plugins/reveal-plugin-toggle-solutions.js';
|
|
|
10
10
|
import DirTreePlugin from './plugins/reveal-plugin-dir-tree.js';
|
|
11
11
|
import PrefixUrlPlugin from './plugins/reveal-plugin-prefix-with-base-url.js';
|
|
12
12
|
import AsciinemaPlugin from './plugins/reveal-plugin-asciinema.js';
|
|
13
|
-
import MermaidPlugin from './plugins/reveal-plugin-mermaid.js';
|
|
14
13
|
|
|
15
14
|
const defaultOptions = {
|
|
16
15
|
revealOptions: {},
|
|
@@ -30,7 +29,8 @@ const externalJsLibs = [
|
|
|
30
29
|
'node_modules/asciinema-player/dist/bundle/asciinema-player.min.js',
|
|
31
30
|
'node_modules/reveal.js-plugins/customcontrols/plugin.js',
|
|
32
31
|
'node_modules/reveal.js-plugins/chalkboard/plugin.js',
|
|
33
|
-
'node_modules/@fortawesome/fontawesome-free/js/all.min.js'
|
|
32
|
+
'node_modules/@fortawesome/fontawesome-free/js/all.min.js',
|
|
33
|
+
'node_modules/reveal.js-mermaid-plugin/plugin/mermaid/mermaid.js'
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
const extraStylesheets = [
|
|
@@ -50,7 +50,7 @@ const extraThemeCssStylesheets = [
|
|
|
50
50
|
const defaultDennisPlugins = [
|
|
51
51
|
ShowCodeSnippets, ShowToc, ShowAttribution, ShowQrCode, ShowTitle,
|
|
52
52
|
ModifyFontSize, ShowHTMLExample, ToggleSolutionsPlugin, DirTreePlugin,
|
|
53
|
-
PrefixUrlPlugin, AsciinemaPlugin
|
|
53
|
+
PrefixUrlPlugin, AsciinemaPlugin
|
|
54
54
|
]
|
|
55
55
|
|
|
56
56
|
const defaultRevealOptions = {
|
|
@@ -73,6 +73,10 @@ const defaultRevealOptions = {
|
|
|
73
73
|
markdown: {
|
|
74
74
|
smartypants: true,
|
|
75
75
|
},
|
|
76
|
+
// Disable automatic hljs; show-code-snippets calls hljs manually per element
|
|
77
|
+
highlight: {
|
|
78
|
+
highlightOnLoad: false
|
|
79
|
+
},
|
|
76
80
|
chalkboard: {
|
|
77
81
|
boardmarkerWidth: 2,
|
|
78
82
|
chalkWidth: 3,
|
|
@@ -99,6 +103,26 @@ const defaultRevealOptions = {
|
|
|
99
103
|
|
|
100
104
|
// Factor of the display size that should remain empty around the content
|
|
101
105
|
margin: 0.05,
|
|
106
|
+
|
|
107
|
+
// reveal.js-mermaid-plugin config (passed to mermaid.initialize)
|
|
108
|
+
mermaid: {
|
|
109
|
+
theme: 'base',
|
|
110
|
+
fontSize: 13,
|
|
111
|
+
themeVariables: {
|
|
112
|
+
textColor: '#000',
|
|
113
|
+
primaryColor: '#e2001a',
|
|
114
|
+
primaryTextColor: '#ffff',
|
|
115
|
+
noteBkgColor: '#ededeb',
|
|
116
|
+
fontFamily: 'arial',
|
|
117
|
+
lineColor: '#5c6971',
|
|
118
|
+
primaryBorderColor: '#5c6971',
|
|
119
|
+
secondaryColor: '#5c6971',
|
|
120
|
+
secondaryTextColor: '#000'
|
|
121
|
+
},
|
|
122
|
+
sequence: { mirrorActors: false, useMaxWidth: true },
|
|
123
|
+
flowchart: { useMaxWidth: true, padding: 6 }
|
|
124
|
+
},
|
|
125
|
+
|
|
102
126
|
// Leave here
|
|
103
127
|
plugins: []
|
|
104
128
|
}
|
|
@@ -208,7 +232,7 @@ export function initReveal(opts) {
|
|
|
208
232
|
addCssDependencies(options, extraStylesheets, extraThemeCssStylesheets),
|
|
209
233
|
addPrintStylesheetIfUrlContainsPrintPdf(),
|
|
210
234
|
windowOnLoadPromise()
|
|
211
|
-
]).then(values => {
|
|
235
|
+
]).then(async values => {
|
|
212
236
|
//Get the first element from the array, this is the Reveal module
|
|
213
237
|
const modules = values[0].map(m => m.default)
|
|
214
238
|
const Reveal = modules.shift();
|
|
@@ -230,6 +254,7 @@ export function initReveal(opts) {
|
|
|
230
254
|
...modules,
|
|
231
255
|
...defaultDennisPlugins,
|
|
232
256
|
...finalOptions.plugins,
|
|
257
|
+
RevealMermaid,
|
|
233
258
|
RevealChalkboard,
|
|
234
259
|
RevealCustomControls
|
|
235
260
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farberg/reveal-template",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"homepage": "https://github.com/pfisterer/reveal-template",
|
|
5
5
|
"description": "Reveal.js template for Dennis' lectures",
|
|
6
6
|
"main": "index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"author": "Dennis Pfisterer, http://dennis-pfisterer.de",
|
|
16
16
|
"license": "Apache License 2.0",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@fortawesome/fontawesome-free": "^7.2.0",
|
|
18
19
|
"asciinema-player": "^3.15.1",
|
|
19
20
|
"connect": "^3.7.0",
|
|
20
21
|
"easyqrcodejs": "^4.6.2",
|
|
@@ -24,8 +25,8 @@
|
|
|
24
25
|
"pdf-merger-js": "^5.1.2",
|
|
25
26
|
"puppeteer": "^24.42.0",
|
|
26
27
|
"reveal.js": "^6.0.1",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"reveal.js-mermaid-plugin": "^11.12.3",
|
|
29
|
+
"reveal.js-plugins": "^4.6.0",
|
|
30
|
+
"serve-static": "^2.2.1"
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -121,7 +121,8 @@ export default () => {
|
|
|
121
121
|
code = outdent(code)
|
|
122
122
|
|
|
123
123
|
const newEl = showCode(el, language, code, showLink ? url : null, outdent)
|
|
124
|
-
|
|
124
|
+
if (language !== 'mermaid')
|
|
125
|
+
highlightPlugin.hljs.highlightElement(newEl)
|
|
125
126
|
} catch (err) {
|
|
126
127
|
console.error(`show-code-snippets: failed to load ${url}:`, err)
|
|
127
128
|
showError(el, `Failed to load ${url}: ${err.message}`)
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// When installed as an npm package the plugin lives at node_modules/@farberg/reveal-template/plugins/
|
|
2
|
-
// and mermaid is 3 levels up. When running from the template root directly it is 1 level up.
|
|
3
|
-
const mermaidUrl = new URL(
|
|
4
|
-
new URL(import.meta.url).pathname.includes('/node_modules/')
|
|
5
|
-
? '../../../mermaid/dist/mermaid.esm.min.mjs'
|
|
6
|
-
: '../node_modules/mermaid/dist/mermaid.esm.min.mjs',
|
|
7
|
-
import.meta.url
|
|
8
|
-
).href;
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
id: 'mermaid',
|
|
12
|
-
init: async (deck) => {
|
|
13
|
-
const { default: mermaid } = await import(mermaidUrl);
|
|
14
|
-
mermaid.initialize({
|
|
15
|
-
'startOnLoad': false,
|
|
16
|
-
'theme': 'base',
|
|
17
|
-
'fontSize': 13,
|
|
18
|
-
'themeVariables': {
|
|
19
|
-
'textColor': '#000',
|
|
20
|
-
'primaryColor': '#e2001a',
|
|
21
|
-
'primaryTextColor': '#ffff',
|
|
22
|
-
'noteBkgColor': '#ededeb',
|
|
23
|
-
'fontFamily': 'arial',
|
|
24
|
-
'lineColor': '#5c6971',
|
|
25
|
-
'primaryBorderColor': '#5c6971',
|
|
26
|
-
'secondaryColor': '#5c6971',
|
|
27
|
-
'secondaryTextColor': '#000'
|
|
28
|
-
},
|
|
29
|
-
'sequence': {
|
|
30
|
-
'mirrorActors': false,
|
|
31
|
-
'useMaxWidth': true
|
|
32
|
-
},
|
|
33
|
-
'flowchart': {
|
|
34
|
-
'useMaxWidth': true,
|
|
35
|
-
'padding': 6
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
function fixSvgScaling(el) {
|
|
40
|
-
el.querySelectorAll('.mermaid svg').forEach(svg => {
|
|
41
|
-
// Ensure viewBox so width:100% scales content proportionally
|
|
42
|
-
if (!svg.getAttribute('viewBox')) {
|
|
43
|
-
const w = parseFloat(svg.getAttribute('width'));
|
|
44
|
-
const h = parseFloat(svg.getAttribute('height'));
|
|
45
|
-
if (w && h) svg.setAttribute('viewBox', `0 0 ${w} ${h}`);
|
|
46
|
-
}
|
|
47
|
-
svg.setAttribute('width', '100%');
|
|
48
|
-
svg.removeAttribute('height');
|
|
49
|
-
svg.style.maxWidth = '100%';
|
|
50
|
-
svg.style.width = '100%';
|
|
51
|
-
svg.style.height = 'auto';
|
|
52
|
-
|
|
53
|
-
// mermaid v11 measures text before the document font is loaded,
|
|
54
|
-
// producing foreignObjects that are too narrow for the actual rendered text.
|
|
55
|
-
// Measure the real content width and expand each foreignObject to fit,
|
|
56
|
-
// then shift the label group by half the difference to keep it centered.
|
|
57
|
-
svg.querySelectorAll('foreignObject').forEach(fo => {
|
|
58
|
-
fo.setAttribute('overflow', 'visible');
|
|
59
|
-
const inner = fo.firstElementChild;
|
|
60
|
-
if (!inner) return;
|
|
61
|
-
const actualWidth = inner.scrollWidth;
|
|
62
|
-
const foWidth = parseFloat(fo.getAttribute('width')) || 0;
|
|
63
|
-
if (actualWidth > foWidth) {
|
|
64
|
-
const extra = actualWidth - foWidth;
|
|
65
|
-
fo.setAttribute('width', actualWidth);
|
|
66
|
-
const labelG = fo.parentElement;
|
|
67
|
-
if (labelG && labelG.hasAttribute('transform')) {
|
|
68
|
-
const m = labelG.getAttribute('transform')
|
|
69
|
-
.match(/translate\((-?[\d.]+),\s*(-?[\d.]+)\)/);
|
|
70
|
-
if (m) {
|
|
71
|
-
labelG.setAttribute('transform',
|
|
72
|
-
`translate(${parseFloat(m[1]) - extra / 2}, ${m[2]})`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async function handle(el) {
|
|
81
|
-
// Convert ```mermaid code blocks to .mermaid elements.
|
|
82
|
-
// highlight.js runs first: adds <span> tags and encodes --> as >.
|
|
83
|
-
// textContent strips spans and decodes HTML entities back to raw mermaid source.
|
|
84
|
-
el.querySelectorAll('code.mermaid').forEach(code => {
|
|
85
|
-
const oldPre = code.parentElement;
|
|
86
|
-
if (oldPre.classList.contains('mermaid')) return;
|
|
87
|
-
const newPre = document.createElement('pre');
|
|
88
|
-
newPre.className = 'mermaid';
|
|
89
|
-
newPre.textContent = code.textContent;
|
|
90
|
-
oldPre.replaceWith(newPre);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Yield so DOM mutations are flushed before mermaid reads them
|
|
94
|
-
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
95
|
-
|
|
96
|
-
// Skip elements already rendered (contain an SVG)
|
|
97
|
-
const unrendered = [...el.querySelectorAll('.mermaid')].filter(
|
|
98
|
-
node => !node.querySelector('svg') && node.textContent.trim().length > 0
|
|
99
|
-
);
|
|
100
|
-
if (unrendered.length === 0) return;
|
|
101
|
-
|
|
102
|
-
await mermaid.run({ nodes: unrendered, suppressErrors: true });
|
|
103
|
-
fixSvgScaling(el);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
deck.on('ready', event => {
|
|
107
|
-
const style = document.createElement("style");
|
|
108
|
-
style.innerHTML = `
|
|
109
|
-
pre.mermaid {
|
|
110
|
-
all: revert;
|
|
111
|
-
padding: 10px;
|
|
112
|
-
border-radius: 10px;
|
|
113
|
-
border: 1px solid #e0e0e0;
|
|
114
|
-
box-shadow: none !important;
|
|
115
|
-
text-align: center;
|
|
116
|
-
overflow: visible;
|
|
117
|
-
}
|
|
118
|
-
.mermaid svg {
|
|
119
|
-
max-width: 100%;
|
|
120
|
-
height: auto;
|
|
121
|
-
}
|
|
122
|
-
.mermaid svg foreignObject {
|
|
123
|
-
overflow: visible;
|
|
124
|
-
}
|
|
125
|
-
.mermaid svg foreignObject * {
|
|
126
|
-
font-size: 13px !important;
|
|
127
|
-
font-family: arial, sans-serif !important;
|
|
128
|
-
line-height: 1.5 !important;
|
|
129
|
-
}
|
|
130
|
-
`;
|
|
131
|
-
document.head.appendChild(style);
|
|
132
|
-
|
|
133
|
-
const print = window.location.search.match(/print-pdf/gi);
|
|
134
|
-
if (print) {
|
|
135
|
-
console.log("print-pdf detected, rendering mermaid diagrams");
|
|
136
|
-
handle(document);
|
|
137
|
-
} else {
|
|
138
|
-
deck.addEventListener('slidechanged', e => handle(e.currentSlide));
|
|
139
|
-
handle(event.currentSlide);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|