mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-05 16:46:43 +02:00
Add no-var
rule.
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"no-prototype-builtins": "off",
|
"no-prototype-builtins": "off",
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
|
"no-var": "error",
|
||||||
"jsdoc/check-indentation": "off",
|
"jsdoc/check-indentation": "off",
|
||||||
"jsdoc/check-alignment": "off",
|
"jsdoc/check-alignment": "off",
|
||||||
"jsdoc/check-line-alignment": "off",
|
"jsdoc/check-line-alignment": "off",
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const { defineConfig } = require('cypress');
|
const { defineConfig } = require('cypress');
|
||||||
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');
|
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');
|
||||||
require('@applitools/eyes-cypress')(module);
|
require('@applitools/eyes-cypress')(module);
|
||||||
|
@@ -17,9 +17,9 @@
|
|||||||
rerender('XMas');
|
rerender('XMas');
|
||||||
|
|
||||||
function rerender(text) {
|
function rerender(text) {
|
||||||
var graphText = `graph TD
|
let graphText = `graph TD
|
||||||
A[${text}] -->|Get money| B(Go shopping)`;
|
A[${text}] -->|Get money| B(Go shopping)`;
|
||||||
var graph = mermaid.mermaidAPI.render('id', graphText);
|
let graph = mermaid.mermaidAPI.render('id', graphText);
|
||||||
console.log('\x1b[35m%s\x1b[0m', '>> graph', graph);
|
console.log('\x1b[35m%s\x1b[0m', '>> graph', graph);
|
||||||
document.getElementById('graph').innerHTML = graph;
|
document.getElementById('graph').innerHTML = graph;
|
||||||
}
|
}
|
||||||
|
@@ -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';
|
||||||
|
@@ -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()>";
|
||||||
|
|
||||||
|
@@ -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()>";
|
||||||
|
|
||||||
|
@@ -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()>";
|
||||||
|
|
||||||
|
@@ -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`)</';
|
||||||
|
@@ -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')"}`;
|
||||||
|
@@ -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')" }`;
|
||||||
|
|
||||||
|
@@ -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")`;
|
||||||
|
|
||||||
|
@@ -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";
|
||||||
|
@@ -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'/`;
|
||||||
|
|
||||||
|
@@ -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(() => {
|
let handler = setInterval(() => {
|
||||||
cnt++;
|
cnt++;
|
||||||
a = {};
|
a = {};
|
||||||
if (typeof a.polluted !== 'undefined') {
|
if (typeof a.polluted !== 'undefined') {
|
||||||
|
@@ -96,7 +96,7 @@
|
|||||||
// var diagram = ` graph TD
|
// var 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>"]`;
|
||||||
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 />"]';
|
||||||
|
@@ -96,7 +96,7 @@
|
|||||||
// var diagram = ` graph TD
|
// var 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>"]`;
|
||||||
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 />"]';
|
||||||
|
@@ -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(() => {
|
let handler = setInterval(() => {
|
||||||
cnt++;
|
cnt++;
|
||||||
a = {};
|
a = {};
|
||||||
if (typeof a.polluted !== 'undefined') {
|
if (typeof a.polluted !== 'undefined') {
|
||||||
|
@@ -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";
|
||||||
|
@@ -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';
|
||||||
|
@@ -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);
|
||||||
|
@@ -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)";
|
||||||
|
@@ -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);
|
||||||
|
@@ -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);
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
// This example plugins/index.js can be used to load plugins
|
// This example plugins/index.js can be used to load plugins
|
||||||
//
|
//
|
||||||
|
@@ -42,7 +42,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;
|
||||||
|
@@ -1101,7 +1101,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;
|
||||||
|
@@ -1073,7 +1073,7 @@ Enterprise_Boundary(b0, "BankBoundary0") {
|
|||||||
}
|
}
|
||||||
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;
|
||||||
|
@@ -1553,7 +1553,7 @@ Returns **void**
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var config = {
|
let config = {
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
logLevel: 'fatal',
|
logLevel: 'fatal',
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@@ -558,7 +558,7 @@ click Shape2 call callbackFunction() "This is a tooltip for a callback"
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var callbackFunction = function () {
|
let callbackFunction = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -622,10 +622,10 @@ Beginner's tip—a full example using interactive links in an HTML page:
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var callback = function () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
securityLevel: 'loose',
|
securityLevel: 'loose',
|
||||||
};
|
};
|
||||||
|
@@ -641,7 +641,7 @@ A node can have click events bound that lead to either a JavaScript callback or
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var callback = function (nodeId) {
|
let callback = function (nodeId) {
|
||||||
alert('A callback was triggered on ' + nodeId);
|
alert('A callback was triggered on ' + nodeId);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -719,10 +719,10 @@ Beginner's tip—here's a full example of using interactive links in HTML:
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var callback = function () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
flowchart: {
|
flowchart: {
|
||||||
useMaxWidth: true,
|
useMaxWidth: true,
|
||||||
|
@@ -685,7 +685,7 @@ Examples of tooltip usage below:
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var callback = function () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -761,10 +761,10 @@ Beginner's tip—a full example using interactive links in a html context:
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var callback = function () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
|
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
|
||||||
securityLevel: 'loose',
|
securityLevel: 'loose',
|
||||||
|
@@ -377,13 +377,13 @@ Beginner's tip—a full example using interactive links in an html context:
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var printArguments = function (arg1, arg2, arg3) {
|
let 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) {
|
let printTask = function (taskId) {
|
||||||
alert('taskId: ' + taskId);
|
alert('taskId: ' + taskId);
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
securityLevel: 'loose',
|
securityLevel: 'loose',
|
||||||
};
|
};
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var require = {
|
let 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>
|
||||||
@@ -60,16 +60,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')
|
||||||
@@ -126,7 +126,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;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
var num = 0;
|
let num = 0;
|
||||||
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
|
||||||
const conf = {
|
const conf = {
|
||||||
|
@@ -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) {
|
let insertSvg = function (svgCode, bindFunctions) {
|
||||||
element.innerHTML = svgCode;
|
element.innerHTML = svgCode;
|
||||||
};
|
};
|
||||||
var graphDefinition = 'graph TB\na-->b';
|
let graphDefinition = 'graph TB\na-->b';
|
||||||
var graph = mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg);
|
let 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>
|
||||||
```
|
```
|
||||||
|
@@ -348,7 +348,7 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph
|
|||||||
let points = edge.points;
|
let points = edge.points;
|
||||||
let pointsHasChanged = false;
|
let pointsHasChanged = false;
|
||||||
const tail = graph.node(e.v);
|
const tail = graph.node(e.v);
|
||||||
var head = graph.node(e.w);
|
let head = graph.node(e.w);
|
||||||
|
|
||||||
log.info('abc88 InsertEdge: ', edge);
|
log.info('abc88 InsertEdge: ', edge);
|
||||||
if (head.intersect && tail.intersect) {
|
if (head.intersect && tail.intersect) {
|
||||||
|
@@ -7,19 +7,19 @@
|
|||||||
function intersectEllipse(node, rx, ry, point) {
|
function intersectEllipse(node, rx, ry, point) {
|
||||||
// Formulae from: https://mathworld.wolfram.com/Ellipse-LineIntersection.html
|
// Formulae from: https://mathworld.wolfram.com/Ellipse-LineIntersection.html
|
||||||
|
|
||||||
var cx = node.x;
|
let cx = node.x;
|
||||||
var cy = node.y;
|
let cy = node.y;
|
||||||
|
|
||||||
var px = cx - point.x;
|
let px = cx - point.x;
|
||||||
var py = cy - point.y;
|
let py = cy - point.y;
|
||||||
|
|
||||||
var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px);
|
let det = Math.sqrt(rx * rx * py * py + ry * ry * px * px);
|
||||||
|
|
||||||
var dx = Math.abs((rx * ry * px) / det);
|
let dx = Math.abs((rx * ry * px) / det);
|
||||||
if (point.x < cx) {
|
if (point.x < cx) {
|
||||||
dx = -dx;
|
dx = -dx;
|
||||||
}
|
}
|
||||||
var dy = Math.abs((rx * ry * py) / det);
|
let dy = Math.abs((rx * ry * py) / det);
|
||||||
if (point.y < cy) {
|
if (point.y < cy) {
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
}
|
}
|
||||||
|
@@ -10,10 +10,10 @@ function intersectLine(p1, p2, q1, q2) {
|
|||||||
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
|
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
|
||||||
// p7 and p473.
|
// p7 and p473.
|
||||||
|
|
||||||
var a1, a2, b1, b2, c1, c2;
|
let a1, a2, b1, b2, c1, c2;
|
||||||
var r1, r2, r3, r4;
|
let r1, r2, r3, r4;
|
||||||
var denom, offset, num;
|
let denom, offset, num;
|
||||||
var x, y;
|
let x, y;
|
||||||
|
|
||||||
// Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x +
|
// Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x +
|
||||||
// b1 y + c1 = 0.
|
// b1 y + c1 = 0.
|
||||||
|
@@ -13,13 +13,13 @@ export default intersectPolygon;
|
|||||||
* @param point
|
* @param point
|
||||||
*/
|
*/
|
||||||
function intersectPolygon(node, polyPoints, point) {
|
function intersectPolygon(node, polyPoints, point) {
|
||||||
var x1 = node.x;
|
let x1 = node.x;
|
||||||
var y1 = node.y;
|
let y1 = node.y;
|
||||||
|
|
||||||
var intersections = [];
|
let intersections = [];
|
||||||
|
|
||||||
var minX = Number.POSITIVE_INFINITY;
|
let minX = Number.POSITIVE_INFINITY;
|
||||||
var minY = Number.POSITIVE_INFINITY;
|
let minY = Number.POSITIVE_INFINITY;
|
||||||
if (typeof polyPoints.forEach === 'function') {
|
if (typeof polyPoints.forEach === 'function') {
|
||||||
polyPoints.forEach(function (entry) {
|
polyPoints.forEach(function (entry) {
|
||||||
minX = Math.min(minX, entry.x);
|
minX = Math.min(minX, entry.x);
|
||||||
@@ -30,13 +30,13 @@ function intersectPolygon(node, polyPoints, point) {
|
|||||||
minY = Math.min(minY, polyPoints.y);
|
minY = Math.min(minY, polyPoints.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
var left = x1 - node.width / 2 - minX;
|
let left = x1 - node.width / 2 - minX;
|
||||||
var top = y1 - node.height / 2 - minY;
|
let top = y1 - node.height / 2 - minY;
|
||||||
|
|
||||||
for (var i = 0; i < polyPoints.length; i++) {
|
for (let i = 0; i < polyPoints.length; i++) {
|
||||||
var p1 = polyPoints[i];
|
let p1 = polyPoints[i];
|
||||||
var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0];
|
let p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0];
|
||||||
var intersect = intersectLine(
|
let intersect = intersectLine(
|
||||||
node,
|
node,
|
||||||
point,
|
point,
|
||||||
{ x: left + p1.x, y: top + p1.y },
|
{ x: left + p1.x, y: top + p1.y },
|
||||||
@@ -55,13 +55,13 @@ function intersectPolygon(node, polyPoints, point) {
|
|||||||
if (intersections.length > 1) {
|
if (intersections.length > 1) {
|
||||||
// More intersections, find the one nearest to edge end point
|
// More intersections, find the one nearest to edge end point
|
||||||
intersections.sort(function (p, q) {
|
intersections.sort(function (p, q) {
|
||||||
var pdx = p.x - point.x;
|
let pdx = p.x - point.x;
|
||||||
var pdy = p.y - point.y;
|
let pdy = p.y - point.y;
|
||||||
var distp = Math.sqrt(pdx * pdx + pdy * pdy);
|
let distp = Math.sqrt(pdx * pdx + pdy * pdy);
|
||||||
|
|
||||||
var qdx = q.x - point.x;
|
let qdx = q.x - point.x;
|
||||||
var qdy = q.y - point.y;
|
let qdy = q.y - point.y;
|
||||||
var distq = Math.sqrt(qdx * qdx + qdy * qdy);
|
let distq = Math.sqrt(qdx * qdx + qdy * qdy);
|
||||||
|
|
||||||
return distp < distq ? -1 : distp === distq ? 0 : 1;
|
return distp < distq ? -1 : distp === distq ? 0 : 1;
|
||||||
});
|
});
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
const intersectRect = (node, point) => {
|
const intersectRect = (node, point) => {
|
||||||
var x = node.x;
|
let x = node.x;
|
||||||
var y = node.y;
|
let y = node.y;
|
||||||
|
|
||||||
// Rectangle intersection algorithm from:
|
// Rectangle intersection algorithm from:
|
||||||
// https://math.stackexchange.com/questions/108113/find-edge-between-two-boxes
|
// https://math.stackexchange.com/questions/108113/find-edge-between-two-boxes
|
||||||
var dx = point.x - x;
|
let dx = point.x - x;
|
||||||
var dy = point.y - y;
|
let dy = point.y - y;
|
||||||
var w = node.width / 2;
|
let w = node.width / 2;
|
||||||
var h = node.height / 2;
|
let h = node.height / 2;
|
||||||
|
|
||||||
var sx, sy;
|
let sx, sy;
|
||||||
if (Math.abs(dy) * w > Math.abs(dx) * h) {
|
if (Math.abs(dy) * w > Math.abs(dx) * h) {
|
||||||
// Intersection is top or bottom of rect.
|
// Intersection is top or bottom of rect.
|
||||||
if (dy < 0) {
|
if (dy < 0) {
|
||||||
|
@@ -24,7 +24,7 @@ let wrapEnabled = false;
|
|||||||
let description = '';
|
let description = '';
|
||||||
let c4ShapeInRow = 4;
|
let c4ShapeInRow = 4;
|
||||||
let c4BoundaryInRow = 2;
|
let c4BoundaryInRow = 2;
|
||||||
var c4Type;
|
let c4Type;
|
||||||
|
|
||||||
export const getC4Type = function () {
|
export const getC4Type = function () {
|
||||||
return c4Type;
|
return c4Type;
|
||||||
|
@@ -38,7 +38,7 @@ export const drawEmbeddedImage = function (elem, x, y, link) {
|
|||||||
const imageElem = elem.append('use');
|
const imageElem = elem.append('use');
|
||||||
imageElem.attr('x', x);
|
imageElem.attr('x', x);
|
||||||
imageElem.attr('y', y);
|
imageElem.attr('y', y);
|
||||||
var sanitizedLink = sanitizeUrl(link);
|
let sanitizedLink = sanitizeUrl(link);
|
||||||
imageElem.attr('xlink:href', '#' + sanitizedLink);
|
imageElem.attr('xlink:href', '#' + sanitizedLink);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -249,7 +249,7 @@ export const drawClass = function (elem, classDef, conf, diagObj) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const classBox = g.node().getBBox();
|
const classBox = g.node().getBBox();
|
||||||
var cssClassStr = ' ';
|
let cssClassStr = ' ';
|
||||||
|
|
||||||
if (classDef.cssClasses.length > 0) {
|
if (classDef.cssClasses.length > 0) {
|
||||||
cssClassStr = cssClassStr + classDef.cssClasses.join(' ');
|
cssClassStr = cssClassStr + classDef.cssClasses.join(' ');
|
||||||
|
@@ -206,7 +206,7 @@ export const addEdges = function (edges, g, diagObj) {
|
|||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
// Identify Link
|
// Identify Link
|
||||||
var linkIdBase = 'L-' + edge.start + '-' + edge.end;
|
let linkIdBase = 'L-' + edge.start + '-' + edge.end;
|
||||||
// count the links from+to the same node to give unique id
|
// count the links from+to the same node to give unique id
|
||||||
if (typeof linkIdCnt[linkIdBase] === 'undefined') {
|
if (typeof linkIdCnt[linkIdBase] === 'undefined') {
|
||||||
linkIdCnt[linkIdBase] = 0;
|
linkIdCnt[linkIdBase] = 0;
|
||||||
@@ -217,8 +217,8 @@ export const addEdges = function (edges, g, diagObj) {
|
|||||||
}
|
}
|
||||||
let linkId = linkIdBase + '-' + linkIdCnt[linkIdBase];
|
let linkId = linkIdBase + '-' + linkIdCnt[linkIdBase];
|
||||||
log.info('abc78 new link id to be used is', linkIdBase, linkId, linkIdCnt[linkIdBase]);
|
log.info('abc78 new link id to be used is', linkIdBase, linkId, linkIdCnt[linkIdBase]);
|
||||||
var linkNameStart = 'LS-' + edge.start;
|
let linkNameStart = 'LS-' + edge.start;
|
||||||
var linkNameEnd = 'LE-' + edge.end;
|
let linkNameEnd = 'LE-' + edge.end;
|
||||||
|
|
||||||
const edgeData = { style: '', labelStyle: '' };
|
const edgeData = { style: '', labelStyle: '' };
|
||||||
edgeData.minlen = edge.length || 1;
|
edgeData.minlen = edge.length || 1;
|
||||||
|
@@ -178,9 +178,9 @@ export const addEdges = function (edges, g, diagObj) {
|
|||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
// Identify Link
|
// Identify Link
|
||||||
var linkId = 'L-' + edge.start + '-' + edge.end;
|
let linkId = 'L-' + edge.start + '-' + edge.end;
|
||||||
var linkNameStart = 'LS-' + edge.start;
|
let linkNameStart = 'LS-' + edge.start;
|
||||||
var linkNameEnd = 'LE-' + edge.end;
|
let linkNameEnd = 'LE-' + edge.end;
|
||||||
|
|
||||||
const edgeData = {};
|
const edgeData = {};
|
||||||
|
|
||||||
|
@@ -399,10 +399,10 @@ export const draw = function (text, id, version, diagObj) {
|
|||||||
return typeof links[d.id] !== 'undefined';
|
return typeof links[d.id] !== 'undefined';
|
||||||
})
|
})
|
||||||
.each(function (o) {
|
.each(function (o) {
|
||||||
var taskRect = doc.querySelector('#' + o.id);
|
let taskRect = doc.querySelector('#' + o.id);
|
||||||
var taskText = doc.querySelector('#' + o.id + '-text');
|
let taskText = doc.querySelector('#' + o.id + '-text');
|
||||||
const oldParent = taskRect.parentNode;
|
const oldParent = taskRect.parentNode;
|
||||||
var Link = doc.createElement('a');
|
let Link = doc.createElement('a');
|
||||||
Link.setAttribute('xlink:href', links[o.id]);
|
Link.setAttribute('xlink:href', links[o.id]);
|
||||||
Link.setAttribute('target', '_top');
|
Link.setAttribute('target', '_top');
|
||||||
oldParent.appendChild(Link);
|
oldParent.appendChild(Link);
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/** Created by knut on 15-01-14. */
|
/** Created by knut on 15-01-14. */
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger';
|
||||||
|
|
||||||
var message = '';
|
let message = '';
|
||||||
var info = false;
|
let info = false;
|
||||||
|
|
||||||
export const setMessage = (txt) => {
|
export const setMessage = (txt) => {
|
||||||
log.debug('Setting message to: ' + txt);
|
log.debug('Setting message to: ' + txt);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
describe('when parsing an info graph it', function () {
|
describe('when parsing an info graph it', function () {
|
||||||
var ex;
|
let ex;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
ex = require('./parser/info').parser;
|
ex = require('./parser/info').parser;
|
||||||
@@ -7,7 +7,7 @@ describe('when parsing an info graph it', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle an info definition', function () {
|
it('should handle an info definition', function () {
|
||||||
var str = `info
|
let str = `info
|
||||||
showInfo`;
|
showInfo`;
|
||||||
|
|
||||||
ex.parse(str);
|
ex.parse(str);
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/** Created by knut on 15-01-14. */
|
/** Created by knut on 15-01-14. */
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger';
|
||||||
|
|
||||||
var message = '';
|
let message = '';
|
||||||
var info = false;
|
let info = false;
|
||||||
|
|
||||||
export const setMessage = (txt) => {
|
export const setMessage = (txt) => {
|
||||||
log.debug('Setting message to: ' + txt);
|
log.debug('Setting message to: ' + txt);
|
||||||
|
@@ -58,24 +58,24 @@ export const draw = (txt, id, _version, diagObj) => {
|
|||||||
elem.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
|
elem.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
|
||||||
|
|
||||||
// Fetch the default direction, use TD if none was found
|
// Fetch the default direction, use TD if none was found
|
||||||
var margin = 40;
|
let margin = 40;
|
||||||
var legendRectSize = 18;
|
let legendRectSize = 18;
|
||||||
var legendSpacing = 4;
|
let legendSpacing = 4;
|
||||||
|
|
||||||
var radius = Math.min(width, height) / 2 - margin;
|
let radius = Math.min(width, height) / 2 - margin;
|
||||||
|
|
||||||
var svg = diagram
|
let svg = diagram
|
||||||
.append('g')
|
.append('g')
|
||||||
.attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')');
|
.attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')');
|
||||||
|
|
||||||
var data = diagObj.db.getSections();
|
let data = diagObj.db.getSections();
|
||||||
var sum = 0;
|
let sum = 0;
|
||||||
Object.keys(data).forEach(function (key) {
|
Object.keys(data).forEach(function (key) {
|
||||||
sum += data[key];
|
sum += data[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
const themeVariables = conf.themeVariables;
|
const themeVariables = conf.themeVariables;
|
||||||
var myGeneratedColors = [
|
let myGeneratedColors = [
|
||||||
themeVariables.pie1,
|
themeVariables.pie1,
|
||||||
themeVariables.pie2,
|
themeVariables.pie2,
|
||||||
themeVariables.pie3,
|
themeVariables.pie3,
|
||||||
@@ -91,16 +91,16 @@ export const draw = (txt, id, _version, diagObj) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Set the color scale
|
// Set the color scale
|
||||||
var color = scaleOrdinal().range(myGeneratedColors);
|
let color = scaleOrdinal().range(myGeneratedColors);
|
||||||
|
|
||||||
// Compute the position of each group on the pie:
|
// Compute the position of each group on the pie:
|
||||||
var pie = d3pie().value(function (d) {
|
let pie = d3pie().value(function (d) {
|
||||||
return d[1];
|
return d[1];
|
||||||
});
|
});
|
||||||
var dataReady = pie(Object.entries(data));
|
let dataReady = pie(Object.entries(data));
|
||||||
|
|
||||||
// Shape helper to build arcs:
|
// Shape helper to build arcs:
|
||||||
var arcGenerator = arc().innerRadius(0).outerRadius(radius);
|
let arcGenerator = arc().innerRadius(0).outerRadius(radius);
|
||||||
|
|
||||||
// Build the pie chart: each part of the pie is a path that we build using the arc function.
|
// Build the pie chart: each part of the pie is a path that we build using the arc function.
|
||||||
svg
|
svg
|
||||||
@@ -138,17 +138,17 @@ export const draw = (txt, id, _version, diagObj) => {
|
|||||||
.attr('class', 'pieTitleText');
|
.attr('class', 'pieTitleText');
|
||||||
|
|
||||||
// Add the legends/annotations for each section
|
// Add the legends/annotations for each section
|
||||||
var legend = svg
|
let legend = svg
|
||||||
.selectAll('.legend')
|
.selectAll('.legend')
|
||||||
.data(color.domain())
|
.data(color.domain())
|
||||||
.enter()
|
.enter()
|
||||||
.append('g')
|
.append('g')
|
||||||
.attr('class', 'legend')
|
.attr('class', 'legend')
|
||||||
.attr('transform', function (d, i) {
|
.attr('transform', function (d, i) {
|
||||||
var height = legendRectSize + legendSpacing;
|
let height = legendRectSize + legendSpacing;
|
||||||
var offset = (height * color.domain().length) / 2;
|
let offset = (height * color.domain().length) / 2;
|
||||||
var horz = 12 * legendRectSize;
|
let horz = 12 * legendRectSize;
|
||||||
var vert = i * height - offset;
|
let vert = i * height - offset;
|
||||||
return 'translate(' + horz + ',' + vert + ')';
|
return 'translate(' + horz + ',' + vert + ')';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -259,11 +259,11 @@ export const addALink = function (actorId, text) {
|
|||||||
try {
|
try {
|
||||||
const links = {};
|
const links = {};
|
||||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||||
var sep = sanitizedText.indexOf('@');
|
let sep = sanitizedText.indexOf('@');
|
||||||
sanitizedText = sanitizedText.replace(/&/g, '&');
|
sanitizedText = sanitizedText.replace(/&/g, '&');
|
||||||
sanitizedText = sanitizedText.replace(/=/g, '=');
|
sanitizedText = sanitizedText.replace(/=/g, '=');
|
||||||
var label = sanitizedText.slice(0, sep - 1).trim();
|
let label = sanitizedText.slice(0, sep - 1).trim();
|
||||||
var link = sanitizedText.slice(sep + 1).trim();
|
let link = sanitizedText.slice(sep + 1).trim();
|
||||||
|
|
||||||
links[label] = link;
|
links[label] = link;
|
||||||
// add the deserialized text to the actor's links field.
|
// add the deserialized text to the actor's links field.
|
||||||
|
@@ -494,12 +494,12 @@ export const drawActors = function (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const drawActorsPopup = function (diagram, actors, actorKeys, doc) {
|
export const drawActorsPopup = function (diagram, actors, actorKeys, doc) {
|
||||||
var maxHeight = 0;
|
let maxHeight = 0;
|
||||||
var maxWidth = 0;
|
let maxWidth = 0;
|
||||||
for (let i = 0; i < actorKeys.length; i++) {
|
for (let i = 0; i < actorKeys.length; i++) {
|
||||||
const actor = actors[actorKeys[i]];
|
const actor = actors[actorKeys[i]];
|
||||||
const minMenuWidth = getRequiredPopupWidth(actor);
|
const minMenuWidth = getRequiredPopupWidth(actor);
|
||||||
var menuDimensions = svgDraw.drawPopup(
|
let menuDimensions = svgDraw.drawPopup(
|
||||||
diagram,
|
diagram,
|
||||||
actor,
|
actor,
|
||||||
minMenuWidth,
|
minMenuWidth,
|
||||||
@@ -846,7 +846,7 @@ export const draw = function (_text, id, _version, diagObj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// only draw popups for the top row of actors.
|
// only draw popups for the top row of actors.
|
||||||
var requiredBoxSize = drawActorsPopup(diagram, actors, actorKeys, doc);
|
let requiredBoxSize = drawActorsPopup(diagram, actors, actorKeys, doc);
|
||||||
|
|
||||||
const { bounds: box } = bounds.getBounds();
|
const { bounds: box } = bounds.getBounds();
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMe
|
|||||||
const actorCnt = actor.actorCnt;
|
const actorCnt = actor.actorCnt;
|
||||||
const rectData = actor.rectData;
|
const rectData = actor.rectData;
|
||||||
|
|
||||||
var displayValue = 'none';
|
let displayValue = 'none';
|
||||||
if (forceMenus) {
|
if (forceMenus) {
|
||||||
displayValue = 'block !important';
|
displayValue = 'block !important';
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMe
|
|||||||
g.attr('class', 'actorPopupMenu');
|
g.attr('class', 'actorPopupMenu');
|
||||||
g.attr('display', displayValue);
|
g.attr('display', displayValue);
|
||||||
addPopupInteraction('#actor' + actorCnt + '_popup', actorCnt);
|
addPopupInteraction('#actor' + actorCnt + '_popup', actorCnt);
|
||||||
var actorClass = '';
|
let actorClass = '';
|
||||||
if (typeof rectData.class !== 'undefined') {
|
if (typeof rectData.class !== 'undefined') {
|
||||||
actorClass = ' ' + rectData.class;
|
actorClass = ' ' + rectData.class;
|
||||||
}
|
}
|
||||||
@@ -76,11 +76,11 @@ export const drawPopup = function (elem, actor, minMenuWidth, textAttrs, forceMe
|
|||||||
rectElem.attr('height', rectData.height);
|
rectElem.attr('height', rectData.height);
|
||||||
rectElem.attr('rx', rectData.rx);
|
rectElem.attr('rx', rectData.rx);
|
||||||
rectElem.attr('ry', rectData.ry);
|
rectElem.attr('ry', rectData.ry);
|
||||||
|
let linkY = 20;
|
||||||
if (links != null) {
|
if (links != null) {
|
||||||
var linkY = 20;
|
|
||||||
for (let key in links) {
|
for (let key in links) {
|
||||||
var linkElem = g.append('a');
|
let linkElem = g.append('a');
|
||||||
var sanitizedLink = sanitizeUrl(links[key]);
|
let sanitizedLink = sanitizeUrl(links[key]);
|
||||||
linkElem.attr('xlink:href', sanitizedLink);
|
linkElem.attr('xlink:href', sanitizedLink);
|
||||||
linkElem.attr('target', '_blank');
|
linkElem.attr('target', '_blank');
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ export const drawImage = function (elem, x, y, link) {
|
|||||||
const imageElem = elem.append('image');
|
const imageElem = elem.append('image');
|
||||||
imageElem.attr('x', x);
|
imageElem.attr('x', x);
|
||||||
imageElem.attr('y', y);
|
imageElem.attr('y', y);
|
||||||
var sanitizedLink = sanitizeUrl(link);
|
let sanitizedLink = sanitizeUrl(link);
|
||||||
imageElem.attr('xlink:href', sanitizedLink);
|
imageElem.attr('xlink:href', sanitizedLink);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ export const drawEmbeddedImage = function (elem, x, y, link) {
|
|||||||
const imageElem = elem.append('use');
|
const imageElem = elem.append('use');
|
||||||
imageElem.attr('x', x);
|
imageElem.attr('x', x);
|
||||||
imageElem.attr('y', y);
|
imageElem.attr('y', y);
|
||||||
var sanitizedLink = sanitizeUrl(link);
|
let sanitizedLink = sanitizeUrl(link);
|
||||||
imageElem.attr('xlink:href', '#' + sanitizedLink);
|
imageElem.attr('xlink:href', '#' + sanitizedLink);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,14 +137,14 @@ export const popdownMenu = function (popid) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const popupMenuUpFunc = function (popupId) {
|
const popupMenuUpFunc = function (popupId) {
|
||||||
var pu = document.getElementById(popupId);
|
let pu = document.getElementById(popupId);
|
||||||
if (pu != null) {
|
if (pu != null) {
|
||||||
pu.style.display = 'block';
|
pu.style.display = 'block';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const popupMenuDownFunc = function (popupId) {
|
const popupMenuDownFunc = function (popupId) {
|
||||||
var pu = document.getElementById(popupId);
|
let pu = document.getElementById(popupId);
|
||||||
if (pu != null) {
|
if (pu != null) {
|
||||||
pu.style.display = 'none';
|
pu.style.display = 'none';
|
||||||
}
|
}
|
||||||
@@ -340,7 +340,7 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
|
|||||||
const center = actor.x + actor.width / 2;
|
const center = actor.x + actor.width / 2;
|
||||||
|
|
||||||
const boxpluslineGroup = elem.append('g');
|
const boxpluslineGroup = elem.append('g');
|
||||||
var g = boxpluslineGroup;
|
let g = boxpluslineGroup;
|
||||||
|
|
||||||
if (actor.y === 0) {
|
if (actor.y === 0) {
|
||||||
actorCnt++;
|
actorCnt++;
|
||||||
@@ -364,7 +364,7 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rect = getNoteRect();
|
const rect = getNoteRect();
|
||||||
var cssclass = 'actor';
|
let cssclass = 'actor';
|
||||||
if (actor.properties != null && actor.properties['class']) {
|
if (actor.properties != null && actor.properties['class']) {
|
||||||
cssclass = actor.properties['class'];
|
cssclass = actor.properties['class'];
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { remark } from 'remark';
|
import { remark } from 'remark';
|
||||||
import type { Code, Root } from 'mdast';
|
import type { Code, Root } from 'mdast';
|
||||||
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
||||||
// @ts-ignore
|
// @ts-ignore: no types for this package
|
||||||
import flatmap from 'unist-util-flatmap';
|
import flatmap from 'unist-util-flatmap';
|
||||||
import { globby } from 'globby';
|
import { globby } from 'globby';
|
||||||
import { join, dirname } from 'path';
|
import { join, dirname } from 'path';
|
||||||
|
@@ -1551,7 +1551,7 @@ Returns **void**
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var config = {
|
let config = {
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
logLevel: 'fatal',
|
logLevel: 'fatal',
|
||||||
securityLevel: 'strict',
|
securityLevel: 'strict',
|
||||||
|
@@ -399,7 +399,7 @@ click Shape2 call callbackFunction() "This is a tooltip for a callback"
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var callbackFunction = function () {
|
let 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 () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
securityLevel: 'loose',
|
securityLevel: 'loose',
|
||||||
};
|
};
|
||||||
|
@@ -416,7 +416,7 @@ click nodeId call callback()
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var callback = function (nodeId) {
|
let 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 () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
flowchart: {
|
flowchart: {
|
||||||
useMaxWidth: true,
|
useMaxWidth: true,
|
||||||
|
@@ -440,7 +440,7 @@ Examples of tooltip usage below:
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var callback = function () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -493,10 +493,10 @@ Beginner's tip—a full example using interactive links in a html context:
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var callback = function () {
|
let callback = function () {
|
||||||
alert('A callback was triggered');
|
alert('A callback was triggered');
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
|
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
|
||||||
securityLevel: 'loose',
|
securityLevel: 'loose',
|
||||||
|
@@ -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) {
|
let 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) {
|
let printTask = function (taskId) {
|
||||||
alert('taskId: ' + taskId);
|
alert('taskId: ' + taskId);
|
||||||
};
|
};
|
||||||
var config = {
|
let config = {
|
||||||
startOnLoad: true,
|
startOnLoad: true,
|
||||||
securityLevel: 'loose',
|
securityLevel: 'loose',
|
||||||
};
|
};
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var require = {
|
let 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>
|
||||||
@@ -60,16 +60,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')
|
||||||
@@ -126,7 +126,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;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
var num = 0;
|
let num = 0;
|
||||||
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
|
||||||
const conf = {
|
const conf = {
|
||||||
|
@@ -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) {
|
let insertSvg = function (svgCode, bindFunctions) {
|
||||||
element.innerHTML = svgCode;
|
element.innerHTML = svgCode;
|
||||||
};
|
};
|
||||||
var graphDefinition = 'graph TB\na-->b';
|
let graphDefinition = 'graph TB\na-->b';
|
||||||
var graph = mermaid.mermaidAPI.render('graphDiv', graphDefinition, insertSvg);
|
let 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>
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user