-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwowchemy-slides.js
73 lines (72 loc) · 2.37 KB
/
wowchemy-slides.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(() => {
// ns-params:@params
var slides = { highlight_style: "dracula", theme: "black" };
// <stdin>
var enabledPlugins = [RevealMarkdown, RevealSearch, RevealNotes, RevealMath.KaTeX, RevealZoom];
var isObject = function(o) {
return o === Object(o) && !isArray(o) && typeof o !== "function";
};
var isArray = function(a) {
return Array.isArray(a);
};
var toCamelCase = function(s) {
return s.replace(/([-_][a-z])/gi, function(term) {
return term.toUpperCase().replace("-", "").replace("_", "");
});
};
var keysToCamelCase = function(o) {
if (isObject(o)) {
const n = {};
Object.keys(o).forEach(function(k) {
n[toCamelCase(k)] = keysToCamelCase(o[k]);
});
return n;
} else if (isArray(o)) {
return o.map(function(i) {
return keysToCamelCase(i);
});
}
return o;
};
var pluginOptions = {};
if (typeof slides.reveal_options !== "undefined") {
pluginOptions = slides.reveal_options;
}
pluginOptions = keysToCamelCase(pluginOptions);
if (typeof pluginOptions.menu_enabled === "undefined") {
pluginOptions.menu_enabled = true;
}
if (pluginOptions.menu_enabled) {
enabledPlugins.push(RevealMenu);
}
pluginOptions["plugins"] = enabledPlugins;
Reveal.initialize(pluginOptions);
if (typeof slides.diagram === "undefined") {
slides.diagram = false;
}
if (slides.diagram) {
mermaidOptions = {};
if (typeof slides.diagram_options !== "undefined") {
mermaidOptions = slides.diagram_options;
}
mermaidOptions["startOnLoad"] = false;
mermaid.initialize(mermaidOptions);
let renderMermaidDiagrams = function renderMermaidDiagrams2(event) {
let mermaidDivs = event.currentSlide.querySelectorAll(".mermaid:not(.done)");
let indices = Reveal.getIndices();
let pageno = `${indices.h}-${indices.v}`;
mermaidDivs.forEach(function(mermaidDiv, i) {
let insertSvg = function(svgCode) {
mermaidDiv.innerHTML = svgCode;
mermaidDiv.classList.add("done");
};
let graphDefinition = mermaidDiv.textContent;
mermaid.mermaidAPI.render(`mermaid${pageno}-${i}`, graphDefinition, insertSvg);
});
Reveal.layout();
};
Reveal.on("ready", (event) => renderMermaidDiagrams(event));
Reveal.on("slidechanged", (event) => renderMermaidDiagrams(event));
}
var mermaidOptions;
})();