123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import * as params from '@params';
- import {fixMermaid} from './wowchemy-utils';
- var enabledPlugins = [RevealMarkdown, RevealHighlight, RevealSearch, RevealNotes, RevealMath.MathJax3, RevealZoom];
- const isObject = function (o) {
- return o === Object(o) && !isArray(o) && typeof o !== 'function';
- };
- const isArray = function (a) {
- return Array.isArray(a);
- };
- const toCamelCase = function (s) {
- return s.replace(/([-_][a-z])/gi, function (term) {
- return term.toUpperCase().replace('-', '').replace('_', '');
- });
- };
- const 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 params.slides.reveal_options !== 'undefined') {
- pluginOptions = params.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);
- function mermaidSlidesReadyToRender(mslide) {
- var diag = mslide.querySelector('.mermaid');
- if (diag) {
- var background = mslide.slideBackgroundElement;
-
-
- var currentHorizontalIndex = Reveal.getState()['indexh'];
-
- var diagramSlideIndex = Reveal.getIndices(mslide)['h'];
- if (
-
-
- !diag.hasAttribute('data-processed') &&
-
-
-
- background.hasAttribute('data-loaded') &&
-
- background.style.display === 'block' &&
-
- diagramSlideIndex - currentHorizontalIndex <= 1
- )
- return mslide;
- }
- return null;
- }
- function renderMermaidSlides() {
-
- var diagramSlides = Reveal.getSlides().filter(mermaidSlidesReadyToRender);
-
- diagramSlides.forEach(function (item) {
- mermaid.init(item.querySelector('.mermaid'));
- });
- }
- Reveal.on('slidechanged', function () {
- renderMermaidSlides();
- });
- Reveal.on('Ready', function () {
- if (Reveal.isReady()) {
- renderMermaidSlides();
- }
- });
- if (typeof params.slides.diagram === 'undefined') {
- params.slides.diagram = false;
- }
- if (params.slides.diagram) {
-
-
-
- var mermaidOptions = {};
- if (typeof params.slides.diagram_options !== 'undefined') {
- mermaidOptions = params.slides.diagram_options;
- }
-
- mermaidOptions['startOnLoad'] = false;
- mermaid.initialize(mermaidOptions);
-
- document.addEventListener('DOMContentLoaded', function () {
- fixMermaid(false);
- });
- }
|