fix: Fix eslint warnings

This commit is contained in:
Sidharth Vinod 2022-10-09 22:08:32 +08:00
parent 1255c0064b
commit 6e2deb1fa7
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
45 changed files with 104 additions and 107 deletions

View File

@ -52,24 +52,25 @@
}, },
"overrides": [ "overrides": [
{ {
"files": "./**/*.html", "files": ["cypress/**", "demos/**"],
"rules": {
"no-undef": "off",
"jsdoc/require-jsdoc": "off"
}
},
{
"files": ["./cypress/**", "./demos/**"],
"rules": { "rules": {
"no-console": "off" "no-console": "off"
} }
}, },
{ {
"files": ["./**/*.spec.{ts,js}", "./cypress/**", "./demos/**", "./**/docs/**"], "files": ["*.spec.{ts,js}", "cypress/**", "demos/**", "**/docs/**"],
"rules": { "rules": {
"jsdoc/require-jsdoc": "off", "jsdoc/require-jsdoc": "off",
"@typescript-eslint/no-unused-vars": "off" "@typescript-eslint/no-unused-vars": "off"
} }
},
{
"files": ["*.html", "*.md", "**/*.md/*"],
"rules": {
"no-var": "error",
"no-undef": "off",
"@typescript-eslint/no-unused-vars": "off"
}
} }
] ]
} }

View File

@ -1,3 +1 @@
import { vi } from 'vitest'; // DO NOT delete this file. It is used by vitest to mock the dagre-d3 module.
// export const render = vi.fn();

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'classDiagram\n'; let diagram = 'classDiagram\n';
diagram += 'class Square~<img/src'; diagram += 'class Square~<img/src';
diagram += "='1'/onerror=xssAttack()>~{\n"; diagram += "='1'/onerror=xssAttack()>~{\n";
diagram += 'id A\n'; diagram += 'id A\n';

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'stateDiagram-v2\n'; let diagram = 'stateDiagram-v2\n';
diagram += 's2 : This is a state description<img/src'; diagram += 's2 : This is a state description<img/src';
diagram += "='1'/onerror=xssAttack()>"; diagram += "='1'/onerror=xssAttack()>";

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'stateDiagram-v2\n'; let diagram = 'stateDiagram-v2\n';
diagram += 's2 : A<img/src'; diagram += 's2 : A<img/src';
diagram += "='1'/onerror=xssAttack()>"; diagram += "='1'/onerror=xssAttack()>";

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'stateDiagram-v2\n'; let diagram = 'stateDiagram-v2\n';
diagram += 'if_state --> False: if n < 0<img/src'; diagram += 'if_state --> False: if n < 0<img/src';
diagram += "='1'/onerror=xssAttack()>"; diagram += "='1'/onerror=xssAttack()>";

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'classDiagram\n'; let diagram = 'classDiagram\n';
diagram += 'classA <-- classB : <ifr'; diagram += 'classA <-- classB : <ifr';
diagram += "ame/srcdoc='<scr"; diagram += "ame/srcdoc='<scr";
diagram += 'ipt>parent.xssAttack(`XSS`)</'; diagram += 'ipt>parent.xssAttack(`XSS`)</';

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = `sequenceDiagram let diagram = `sequenceDiagram
participant John participant John
links John: {"XSS": "javas`; links John: {"XSS": "javas`;
diagram += `cript:alert('AudioParam')"}`; diagram += `cript:alert('AudioParam')"}`;

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = `sequenceDiagram let diagram = `sequenceDiagram
participant Alice participant Alice
links Alice: { "Click me!" : "javasjavascript:cript:alert('goose')" }`; links Alice: { "Click me!" : "javasjavascript:cript:alert('goose')" }`;

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = `sequenceDiagram let diagram = `sequenceDiagram
participant Alice participant Alice
link Alice: Click Me!@javasjavascript:cript:alert("goose")`; link Alice: Click Me!@javasjavascript:cript:alert("goose")`;

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = `classDiagram let diagram = `classDiagram
Class "<img/src='x'/onerror=xssAttack(1)>" <--> "<img/src='x'/onerror=xssAttack(2)>" C2: Cool label`; Class "<img/src='x'/onerror=xssAttack(1)>" <--> "<img/src='x'/onerror=xssAttack(2)>" C2: Cool label`;
// // var diagram = "stateDiagram-v2\n"; // // var diagram = "stateDiagram-v2\n";

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = `classDiagram let diagram = `classDiagram
class Shape{ class Shape{
<<<img/src='1'/`; <<<img/src='1'/`;

View File

@ -54,9 +54,9 @@
startOnLoad: true, startOnLoad: true,
useMaxWidth: true, useMaxWidth: true,
}); });
var cnt = 0; let cnt = 0;
var a; let a;
var handler = setInterval(() => { const handler = setInterval(() => {
cnt++; cnt++;
a = {}; a = {};
if (typeof a.polluted !== 'undefined') { if (typeof a.polluted !== 'undefined') {

View File

@ -96,7 +96,7 @@
// var diagram = ` graph TD // var diagram = ` graph TD
// A --> B["&lt;a href='javasc`; // A --> B["&lt;a href='javasc`;
// diagram += `ript#colon;xssAttack()'&gt;AAA&lt;/a&gt;"]`; // diagram += `ript#colon;xssAttack()'&gt;AAA&lt;/a&gt;"]`;
var diagram = ` graph TD let diagram = ` graph TD
A --> B["<a href='javasc`; A --> B["<a href='javasc`;
diagram += `ript#colon;xssAttack()'>AAA</a>"]`; diagram += `ript#colon;xssAttack()'>AAA</a>"]`;
// diagram += '//via.placeholder.com/64\' width=64 />"]'; // diagram += '//via.placeholder.com/64\' width=64 />"]';

View File

@ -96,7 +96,7 @@
// var diagram = ` graph TD // var diagram = ` graph TD
// A --> B["&lt;a href='javasc`; // A --> B["&lt;a href='javasc`;
// diagram += `ript#colon;xssAttack()'&gt;AAA&lt;/a&gt;"]`; // diagram += `ript#colon;xssAttack()'&gt;AAA&lt;/a&gt;"]`;
var diagram = ` graph TD let diagram = ` graph TD
A --> B["<a href='javasc`; A --> B["<a href='javasc`;
diagram += `ript#9;t#colon;xssAttack()'>AAA</a>"]`; diagram += `ript#9;t#colon;xssAttack()'>AAA</a>"]`;
// diagram += '//via.placeholder.com/64\' width=64 />"]'; // diagram += '//via.placeholder.com/64\' width=64 />"]';

View File

@ -42,9 +42,9 @@
startOnLoad: true, startOnLoad: true,
useMaxWidth: true, useMaxWidth: true,
}); });
var cnt = 0; let cnt = 0;
var a; let a;
var handler = setInterval(() => { const handler = setInterval(() => {
cnt++; cnt++;
a = {}; a = {};
if (typeof a.polluted !== 'undefined') { if (typeof a.polluted !== 'undefined') {

View File

@ -85,7 +85,7 @@
alert('It worked'); alert('It worked');
} }
var diagram = '%%{init: {"flowchart": {"htmlLabels": "true"}} }%%\n'; let diagram = '%%{init: {"flowchart": {"htmlLabels": "true"}} }%%\n';
diagram += 'flowchart\n'; diagram += 'flowchart\n';
diagram += 'A["<ifra'; diagram += 'A["<ifra';
diagram += "me srcdoc='<scrip"; diagram += "me srcdoc='<scrip";

View File

@ -92,7 +92,7 @@
document.getElementsByTagName('body')[0].appendChild(div); document.getElementsByTagName('body')[0].appendChild(div);
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'graph LR\n'; let diagram = 'graph LR\n';
diagram += 'B-->D("<img onerror=location=`java'; diagram += 'B-->D("<img onerror=location=`java';
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
diagram += 'script\x3a;xssAttack\u0028\u0029` src=x>");\n'; diagram += 'script\x3a;xssAttack\u0028\u0029` src=x>");\n';

View File

@ -92,7 +92,7 @@
document.getElementsByTagName('body')[0].appendChild(div); document.getElementsByTagName('body')[0].appendChild(div);
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'graph LR\n'; let diagram = 'graph LR\n';
diagram += 'A(<img/src/onerror=xssAttack`1`>)'; diagram += 'A(<img/src/onerror=xssAttack`1`>)';
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram); console.log(diagram);

View File

@ -92,7 +92,7 @@
document.getElementsByTagName('body')[0].appendChild(div); document.getElementsByTagName('body')[0].appendChild(div);
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'graph LR\n'; let diagram = 'graph LR\n';
diagram += " B(<a href='<"; diagram += " B(<a href='<";
diagram += 'script></'; diagram += 'script></';
diagram += "script>Javascript:xssAttack`1`'>Click)"; diagram += "script>Javascript:xssAttack`1`'>Click)";

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'stateDiagram-v2\n'; let diagram = 'stateDiagram-v2\n';
diagram += "<img/src='1'/onerror=xssAttack()> --> B"; diagram += "<img/src='1'/onerror=xssAttack()> --> B";
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram); console.log(diagram);

View File

@ -93,7 +93,7 @@
throw new Error('XSS Succeeded'); throw new Error('XSS Succeeded');
} }
var diagram = 'stateDiagram-v2\n'; let diagram = 'stateDiagram-v2\n';
diagram += "<img/src='1'/onerror=xssAttack()> --> B"; diagram += "<img/src='1'/onerror=xssAttack()> --> B";
// diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n"; // diagram += "script\u003aalert\u0028document.domain\u0029\` src=x>\"\);\n";
console.log(diagram); console.log(diagram);

View File

@ -277,7 +277,7 @@
<script> <script>
function testClick(nodeId) { function testClick(nodeId) {
console.log('clicked', nodeId); console.log('clicked', nodeId);
var originalBgColor = document.querySelector('body').style.backgroundColor; let originalBgColor = document.querySelector('body').style.backgroundColor;
document.querySelector('body').style.backgroundColor = 'yellow'; document.querySelector('body').style.backgroundColor = 'yellow';
setTimeout(function () { setTimeout(function () {
document.querySelector('body').style.backgroundColor = originalBgColor; document.querySelector('body').style.backgroundColor = originalBgColor;

View File

@ -46,7 +46,7 @@
<script> <script>
function testClick(nodeId) { function testClick(nodeId) {
console.log('clicked', nodeId); console.log('clicked', nodeId);
var originalBgColor = document.querySelector('body').style.backgroundColor; let originalBgColor = document.querySelector('body').style.backgroundColor;
document.querySelector('body').style.backgroundColor = 'yellow'; document.querySelector('body').style.backgroundColor = 'yellow';
setTimeout(function () { setTimeout(function () {
document.querySelector('body').style.backgroundColor = originalBgColor; document.querySelector('body').style.backgroundColor = originalBgColor;

View File

@ -1513,7 +1513,7 @@
<script> <script>
function testClick(nodeId) { function testClick(nodeId) {
console.log('clicked', nodeId); console.log('clicked', nodeId);
var originalBgColor = document.querySelector('body').style.backgroundColor; let originalBgColor = document.querySelector('body').style.backgroundColor;
document.querySelector('body').style.backgroundColor = 'yellow'; document.querySelector('body').style.backgroundColor = 'yellow';
setTimeout(function () { setTimeout(function () {
document.querySelector('body').style.backgroundColor = originalBgColor; document.querySelector('body').style.backgroundColor = originalBgColor;

View File

@ -174,7 +174,7 @@
} }
function testClick(nodeId) { function testClick(nodeId) {
console.log('clicked', nodeId); console.log('clicked', nodeId);
var originalBgColor = document.querySelector('body').style.backgroundColor; let originalBgColor = document.querySelector('body').style.backgroundColor;
document.querySelector('body').style.backgroundColor = 'yellow'; document.querySelector('body').style.backgroundColor = 'yellow';
setTimeout(function () { setTimeout(function () {
document.querySelector('body').style.backgroundColor = originalBgColor; document.querySelector('body').style.backgroundColor = originalBgColor;

View File

@ -1561,7 +1561,7 @@ Returns **void**
```html ```html
<script> <script>
var config = { const config = {
theme: 'default', theme: 'default',
logLevel: 'fatal', logLevel: 'fatal',
securityLevel: 'strict', securityLevel: 'strict',

View File

@ -589,7 +589,7 @@ click Shape2 call callbackFunction() "This is a tooltip for a callback"
```html ```html
<script> <script>
var callbackFunction = function () { const callbackFunction = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
</script> </script>
@ -653,10 +653,10 @@ Beginner's tip—a full example using interactive links in an HTML page:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
securityLevel: 'loose', securityLevel: 'loose',
}; };

View File

@ -649,7 +649,7 @@ A node can have click events bound that lead to either a JavaScript callback or
```html ```html
<script> <script>
var callback = function (nodeId) { const callback = function (nodeId) {
alert('A callback was triggered on ' + nodeId); alert('A callback was triggered on ' + nodeId);
}; };
</script> </script>
@ -727,10 +727,10 @@ Beginner's tip—here's a full example of using interactive links in HTML:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
flowchart: { flowchart: {
useMaxWidth: true, useMaxWidth: true,

View File

@ -695,7 +695,7 @@ Examples of tooltip usage below:
```html ```html
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
</script> </script>
@ -771,10 +771,10 @@ Beginner's tip—a full example using interactive links in a html context:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' }, flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
securityLevel: 'loose', securityLevel: 'loose',

View File

@ -391,13 +391,13 @@ Beginner's tip—a full example using interactive links in an html context:
</pre> </pre>
<script> <script>
var printArguments = function (arg1, arg2, arg3) { const printArguments = function (arg1, arg2, arg3) {
alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3); alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3);
}; };
var printTask = function (taskId) { const printTask = function (taskId) {
alert('taskId: ' + taskId); alert('taskId: ' + taskId);
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
securityLevel: 'loose', securityLevel: 'loose',
}; };

View File

@ -29,7 +29,7 @@
src="https://plausible.io/js/plausible.js" src="https://plausible.io/js/plausible.js"
></script> ></script>
<script> <script>
var require = { const require = {
paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.29.1/min/vs' }, paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.29.1/min/vs' },
}; };
</script> </script>
@ -51,16 +51,16 @@
<body> <body>
<div id="app"></div> <div id="app"></div>
<script> <script>
var initEditor = exports.default; let initEditor = exports.default;
var parser = new DOMParser(); let parser = new DOMParser();
var currentCodeExample = 0; let currentCodeExample = 0;
var colorize = []; let colorize = [];
function colorizeEverything(html) { function colorizeEverything(html) {
initEditor(monaco); initEditor(monaco);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
monaco.editor.setTheme('mermaid'); monaco.editor.setTheme('mermaid');
var parsed = parser.parseFromString(html, 'text/html').body; let parsed = parser.parseFromString(html, 'text/html').body;
Promise.all( Promise.all(
[...parsed.querySelectorAll('pre[id*="code"]')].map((codeBlock) => [...parsed.querySelectorAll('pre[id*="code"]')].map((codeBlock) =>
monaco.editor.colorize(codeBlock.innerText, 'mermaid') monaco.editor.colorize(codeBlock.innerText, 'mermaid')
@ -117,7 +117,7 @@
function (hook, vm) { function (hook, vm) {
hook.beforeEach(function (html) { hook.beforeEach(function (html) {
url = 'https://github.com/mermaid-js/mermaid/blob/develop/src/docs/' + vm.route.file; url = 'https://github.com/mermaid-js/mermaid/blob/develop/src/docs/' + vm.route.file;
var editHtml = '[:memo: Edit this Page](' + url + ')\n'; let editHtml = '[:memo: Edit this Page](' + url + ')\n';
return editHtml + html; return editHtml + html;
}); });
@ -136,7 +136,6 @@
], ],
}; };
var num = 0;
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
const conf = { const conf = {

View File

@ -208,14 +208,14 @@ The example below show an outline of how this could be used. The example just lo
<script> <script>
mermaid.mermaidAPI.initialize({ startOnLoad: false }); mermaid.mermaidAPI.initialize({ startOnLoad: false });
$(function () { $(async function () {
// Example of using the API var // Example of using the API var
element = document.querySelector('#graphDiv'); element = document.querySelector('#graphDiv');
var insertSvg = function (svgCode, bindFunctions) { const insertSvg = function (svgCode, bindFunctions) {
element.innerHTML = svgCode; element.innerHTML = svgCode;
}; };
var graphDefinition = 'graph TB\na-->b'; const graphDefinition = 'graph TB\na-->b';
var graph = mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg); const graph = await mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg);
}); });
</script> </script>
``` ```
@ -339,7 +339,7 @@ on what kind of integration you use.
```html ```html
<script src="../dist/mermaid.js"></script> <script src="../dist/mermaid.js"></script>
<script> <script>
var config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } }; let config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } };
mermaid.initialize(config); mermaid.initialize(config);
</script> </script>
``` ```

View File

@ -1559,7 +1559,7 @@ Returns **void**
```html ```html
<script> <script>
var config = { const config = {
theme: 'default', theme: 'default',
logLevel: 'fatal', logLevel: 'fatal',
securityLevel: 'strict', securityLevel: 'strict',

View File

@ -399,7 +399,7 @@ click Shape2 call callbackFunction() "This is a tooltip for a callback"
```html ```html
<script> <script>
var callbackFunction = function () { const callbackFunction = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
</script> </script>
@ -451,10 +451,10 @@ Beginner's tip—a full example using interactive links in an HTML page:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
securityLevel: 'loose', securityLevel: 'loose',
}; };

View File

@ -416,7 +416,7 @@ click nodeId call callback()
```html ```html
<script> <script>
var callback = function (nodeId) { const callback = function (nodeId) {
alert('A callback was triggered on ' + nodeId); alert('A callback was triggered on ' + nodeId);
}; };
</script> </script>
@ -471,10 +471,10 @@ Beginner's tip—here's a full example of using interactive links in HTML:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
flowchart: { flowchart: {
useMaxWidth: true, useMaxWidth: true,

View File

@ -442,7 +442,7 @@ Examples of tooltip usage below:
```html ```html
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
</script> </script>
@ -495,10 +495,10 @@ Beginner's tip—a full example using interactive links in a html context:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' }, flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
securityLevel: 'loose', securityLevel: 'loose',

View File

@ -327,13 +327,13 @@ Beginner's tip—a full example using interactive links in an html context:
</pre> </pre>
<script> <script>
var printArguments = function (arg1, arg2, arg3) { const printArguments = function (arg1, arg2, arg3) {
alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3); alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3);
}; };
var printTask = function (taskId) { const printTask = function (taskId) {
alert('taskId: ' + taskId); alert('taskId: ' + taskId);
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
securityLevel: 'loose', securityLevel: 'loose',
}; };

View File

@ -29,7 +29,7 @@
src="https://plausible.io/js/plausible.js" src="https://plausible.io/js/plausible.js"
></script> ></script>
<script> <script>
var require = { const require = {
paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.29.1/min/vs' }, paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.29.1/min/vs' },
}; };
</script> </script>
@ -51,16 +51,16 @@
<body> <body>
<div id="app"></div> <div id="app"></div>
<script> <script>
var initEditor = exports.default; let initEditor = exports.default;
var parser = new DOMParser(); let parser = new DOMParser();
var currentCodeExample = 0; let currentCodeExample = 0;
var colorize = []; let colorize = [];
function colorizeEverything(html) { function colorizeEverything(html) {
initEditor(monaco); initEditor(monaco);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
monaco.editor.setTheme('mermaid'); monaco.editor.setTheme('mermaid');
var parsed = parser.parseFromString(html, 'text/html').body; let parsed = parser.parseFromString(html, 'text/html').body;
Promise.all( Promise.all(
[...parsed.querySelectorAll('pre[id*="code"]')].map((codeBlock) => [...parsed.querySelectorAll('pre[id*="code"]')].map((codeBlock) =>
monaco.editor.colorize(codeBlock.innerText, 'mermaid') monaco.editor.colorize(codeBlock.innerText, 'mermaid')
@ -117,7 +117,7 @@
function (hook, vm) { function (hook, vm) {
hook.beforeEach(function (html) { hook.beforeEach(function (html) {
url = 'https://github.com/mermaid-js/mermaid/blob/develop/src/docs/' + vm.route.file; url = 'https://github.com/mermaid-js/mermaid/blob/develop/src/docs/' + vm.route.file;
var editHtml = '[:memo: Edit this Page](' + url + ')\n'; let editHtml = '[:memo: Edit this Page](' + url + ')\n';
return editHtml + html; return editHtml + html;
}); });
@ -136,7 +136,6 @@
], ],
}; };
var num = 0;
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
const conf = { const conf = {

View File

@ -208,14 +208,14 @@ The example below show an outline of how this could be used. The example just lo
<script> <script>
mermaid.mermaidAPI.initialize({ startOnLoad: false }); mermaid.mermaidAPI.initialize({ startOnLoad: false });
$(function () { $(async function () {
// Example of using the API var // Example of using the API var
element = document.querySelector('#graphDiv'); element = document.querySelector('#graphDiv');
var insertSvg = function (svgCode, bindFunctions) { const insertSvg = function (svgCode, bindFunctions) {
element.innerHTML = svgCode; element.innerHTML = svgCode;
}; };
var graphDefinition = 'graph TB\na-->b'; const graphDefinition = 'graph TB\na-->b';
var graph = mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg); const graph = await mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg);
}); });
</script> </script>
``` ```
@ -339,7 +339,7 @@ on what kind of integration you use.
```html ```html
<script src="../dist/mermaid.js"></script> <script src="../dist/mermaid.js"></script>
<script> <script>
var config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } }; let config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } };
mermaid.initialize(config); mermaid.initialize(config);
</script> </script>
``` ```

View File

@ -29,7 +29,7 @@ mermaid.initialize({ flowchart: { htmlLabels: false } });
**Example 2:** **Example 2:**
```js ```js
var config = { const config = {
startOnLoad: true, startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' }, flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
@ -1560,7 +1560,7 @@ Returns **void**
```html ```html
<script> <script>
var config = { const config = {
theme: 'default', theme: 'default',
logLevel: 'fatal', logLevel: 'fatal',
securityLevel: 'strict', securityLevel: 'strict',

View File

@ -211,11 +211,11 @@ The example below show an outline of how this could be used. The example just lo
$(function () { $(function () {
// Example of using the API var // Example of using the API var
element = document.querySelector('#graphDiv'); element = document.querySelector('#graphDiv');
var insertSvg = function (svgCode, bindFunctions) { const insertSvg = function (svgCode, bindFunctions) {
element.innerHTML = svgCode; element.innerHTML = svgCode;
}; };
var graphDefinition = 'graph TB\na-->b'; const graphDefinition = 'graph TB\na-->b';
var graph = mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg); const graph = mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg);
}); });
</script> </script>
``` ```
@ -339,7 +339,7 @@ on what kind of integration you use.
```html ```html
<script src="../dist/mermaid.js"></script> <script src="../dist/mermaid.js"></script>
<script> <script>
var config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } }; let config = { startOnLoad: true, flowchart: { useMaxWidth: false, htmlLabels: true } };
mermaid.initialize(config); mermaid.initialize(config);
</script> </script>
``` ```

View File

@ -399,7 +399,7 @@ click Shape2 call callbackFunction() "This is a tooltip for a callback"
```html ```html
<script> <script>
var callbackFunction = function () { const callbackFunction = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
</script> </script>
@ -451,10 +451,10 @@ Beginner's tip—a full example using interactive links in an HTML page:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
securityLevel: 'loose', securityLevel: 'loose',
}; };

View File

@ -449,7 +449,7 @@ Examples of tooltip usage below:
```html ```html
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
</script> </script>
@ -502,10 +502,10 @@ Beginner's tip—a full example using interactive links in a html context:
</pre> </pre>
<script> <script>
var callback = function () { const callback = function () {
alert('A callback was triggered'); alert('A callback was triggered');
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' }, flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
securityLevel: 'loose', securityLevel: 'loose',

View File

@ -327,13 +327,13 @@ Beginner's tip—a full example using interactive links in an html context:
</pre> </pre>
<script> <script>
var printArguments = function (arg1, arg2, arg3) { const printArguments = function (arg1, arg2, arg3) {
alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3); alert('printArguments called with arguments: ' + arg1 + ', ' + arg2 + ', ' + arg3);
}; };
var printTask = function (taskId) { const printTask = function (taskId) {
alert('taskId: ' + taskId); alert('taskId: ' + taskId);
}; };
var config = { const config = {
startOnLoad: true, startOnLoad: true,
securityLevel: 'loose', securityLevel: 'loose',
}; };