UNPKG

docsify-mermaid

Version:

A plugin to render mermaid diagrams in docsify

1 lines 2.56 kB
{"version":3,"sources":["plugin.js","index.js"],"names":["plugin","mermaidConf","hook","afterEach","html","next","htmlElement","document","createElement","innerHTML","querySelectorAll","forEach","element","replacement","textContent","classList","add","parentNode","replaceChild","doneEach","mermaid","run","window","$docsify","props","mermaidConfig","querySelector","plugins","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,SAAS,SAATA,MAAS,CAACC,WAAD;AAAA,WAAiB,UAACC,IAAD,EAAU;;AAEtCA,aAAKC,SAAL,CAAe,UAACC,IAAD,EAAOC,IAAP,EAAgB;AAC3B;AACA,gBAAMC,cAAcC,SAASC,aAAT,CAAuB,KAAvB,CAApB;AACAF,wBAAYG,SAAZ,GAAwBL,IAAxB;;AAEAE,wBAAYI,gBAAZ,CAA6B,wBAA7B,EAAuDC,OAAvD,CAA+D,UAACC,OAAD,EAAa;AACxE;AACA,oBAAMC,cAAcN,SAASC,aAAT,CAAuB,KAAvB,CAApB;AACAK,4BAAYC,WAAZ,GAA0BF,QAAQE,WAAlC;AACAD,4BAAYE,SAAZ,CAAsBC,GAAtB,CAA0B,SAA1B;;AAEA;AACAJ,wBAAQK,UAAR,CAAmBC,YAAnB,CAAgCL,WAAhC,EAA6CD,OAA7C;AACH,aARD;;AAUAP,iBAAKC,YAAYG,SAAjB;AACH,SAhBD;;AAkBAP,aAAKiB,QAAL,CAAc;AAAA,mBAAMC,QAAQC,GAAR,CAAYpB,WAAZ,CAAN;AAAA,SAAd;AAEH,KAtBc;AAAA,CAAf;;kBAwBeD;;;;ACxBf;;;;;;AAEA,IAAI,CAACsB,OAAOC,QAAZ,EAAsB;AAClBD,WAAOC,QAAP,GAAkB,EAAlB;AACH;;AAED,IAAMC,QAAQF,OAAOC,QAAP,CAAgBE,aAAhB,IAAiC,EAAEC,eAAe,UAAjB,EAA/C;;AAEAJ,OAAOC,QAAP,CAAgBI,OAAhB,GAA0B,CAACL,OAAOC,QAAP,CAAgBI,OAAhB,IAA2B,EAA5B,EAAgCC,MAAhC,CAAuC,sBAAOJ,KAAP,CAAvC,CAA1B","file":"docsify-mermaid.map","sourceRoot":"../src","sourcesContent":["const plugin = (mermaidConf) => (hook) => {\n\n hook.afterEach((html, next) => {\n // We load the HTML inside a DOM node to allow for manipulation\n const htmlElement = document.createElement('div');\n htmlElement.innerHTML = html;\n\n htmlElement.querySelectorAll('pre[data-lang=mermaid]').forEach((element) => {\n // Create a <div class=\"mermaid\"> to replace the <pre> \n const replacement = document.createElement('div');\n replacement.textContent = element.textContent;\n replacement.classList.add('mermaid');\n\n // Replace\n element.parentNode.replaceChild(replacement, element);\n });\n\n next(htmlElement.innerHTML);\n });\n\n hook.doneEach(() => mermaid.run(mermaidConf));\n\n};\n\nexport default plugin;","import plugin from './plugin';\n\nif (!window.$docsify) {\n window.$docsify = {}\n}\n\nconst props = window.$docsify.mermaidConfig || { querySelector: \".mermaid\" };\n\nwindow.$docsify.plugins = (window.$docsify.plugins || []).concat(plugin(props));"]}