docs: small fixes

This commit is contained in:
Emerson Bottero 2022-10-20 00:13:46 -03:00
parent 4cd1e9a462
commit 4b64775fde
4 changed files with 35 additions and 5 deletions

View File

@ -11,7 +11,7 @@ export default defineConfig({
themeConfig: {
nav: nav(),
editLink: {
pattern: 'https://github.com/mermaid-js/mermaid/edit/develop/docs/:path',
pattern: 'https://github.com/mermaid-js/mermaid/edit/develop/packages/mermaid/src/docs/:path',
text: 'Edit this page on GitHub',
},

View File

@ -1,6 +1,23 @@
import { MermaidMarkdown } from 'vitepress-plugin-mermaid';
// import { deflate } from 'pako';
// import { fromUint8Array } from 'js-base64';
import shiki from 'shiki';
// const serializeState = (state: State, serde: SerdeType = 'pako'): string => {
// if (serdes[serde] === undefined) {
// throw new Error(`Unknown serde type: ${serde}`);
// }
// const json = JSON.stringify(state);
// const serialized = serdes[serde].serialize(json);
// return `${serde}:${serialized}`;
// };
// const serialize = (state: string): string => {
// const data = new TextEncoder().encode(state);
// const compressed = deflate(data, { level: 9 });
// return fromUint8Array(compressed, true);
// };
export default {
config: async (md) => {
MermaidMarkdown(md);
@ -15,9 +32,16 @@ export default {
let code = highlighter.codeToHtml(token.content, { lang: 'mermaid' });
code = code.replace('#2e3440ff', 'transparent');
code = code.replace('#292D3E', 'transparent');
console.log(token.content);
code =
'<h5>Code:</h5>' +
'<div class="language-mermaid"><button class="copy"></button><span class="lang">mermaid</span>' +
`<div class="language-mermaid">` +
// tODO: compute edit link!
// `<a class="edit" href="https://mermaid.live/edit#pako:${serialize(
// token.content
// )}" target=”_blank”>✒️</a>` +
`<button class="copy"></button><span class="lang">mermaid</span>` +
code +
'</div>';

View File

@ -19,3 +19,9 @@
.vp-doc > div {
width: 100%;
}
a.edit {
margin: 12px;
position: relative;
top: 10px;
}

View File

@ -502,10 +502,10 @@ Beginner's tip—a full example using interactive links in a html context:
</pre>
<script>
var callback = function () {
const callback = function () {
alert('A callback was triggered');
};
var config = {
const config = {
startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
securityLevel: 'loose',
@ -594,7 +594,7 @@ A shorter form of adding a class is to attach the classname to the node using th
```mermaid-example
flowchart LR
A:::someclass --> B
classDef someclass fill:#f96;
classDef someclass fill:#f96
```
### Css classes