mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Merge branch 'develop' into feature/2776_katex_math
This commit is contained in:
commit
0b087b71dc
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@ -12,23 +12,23 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
node-version: 18.x
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-mermaid:
|
build-mermaid:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [18.x]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
# uses version from "packageManager" field in package.json
|
# uses version from "packageManager" field in package.json
|
||||||
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ env.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ env.node-version }}
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
|
6
.github/workflows/e2e.yml
vendored
6
.github/workflows/e2e.yml
vendored
@ -17,6 +17,7 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
node-version: 18.x
|
||||||
# For PRs and MergeQueues, the target commit is used, and for push events, github.event.previous is used.
|
# For PRs and MergeQueues, the target commit is used, and for push events, github.event.previous is used.
|
||||||
targetHash: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || (github.event.before == '0000000000000000000000000000000000000000' && 'develop' || github.event.before) }}
|
targetHash: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || (github.event.before == '0000000000000000000000000000000000000000' && 'develop' || github.event.before) }}
|
||||||
|
|
||||||
@ -60,7 +61,6 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [18.x]
|
|
||||||
containers: [1, 2, 3, 4]
|
containers: [1, 2, 3, 4]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -68,10 +68,10 @@ jobs:
|
|||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
# uses version from "packageManager" field in package.json
|
# uses version from "packageManager" field in package.json
|
||||||
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ env.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ env.node-version }}
|
||||||
|
|
||||||
# These cached snapshots are downloaded, providing the reference snapshots.
|
# These cached snapshots are downloaded, providing the reference snapshots.
|
||||||
- name: Cache snapshots
|
- name: Cache snapshots
|
||||||
|
10
.github/workflows/lint.yml
vendored
10
.github/workflows/lint.yml
vendored
@ -13,23 +13,23 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
node-version: 18.x
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [18.x]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
# uses version from "packageManager" field in package.json
|
# uses version from "packageManager" field in package.json
|
||||||
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ env.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ env.node-version }}
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
|
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@ -5,23 +5,23 @@ on: [push, pull_request, merge_group]
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
node-version: 18.x
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
unit-test:
|
unit-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [18.x]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
# uses version from "packageManager" field in package.json
|
# uses version from "packageManager" field in package.json
|
||||||
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ env.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ env.node-version }}
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Pie chart demos</h1>
|
<h1>Pie chart demos</h1>
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
pie title Pets adopted by volunteers
|
pie title Default text position: Animal adoption
|
||||||
accTitle: simple pie char demo
|
accTitle: simple pie char demo
|
||||||
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
|
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
|
||||||
"Dogs": 386
|
"Dogs": 386
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
%%{init: {"pie": {"textPosition": 0.9}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
|
%%{init: {"pie": {"textPosition": 0.9}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
|
||||||
pie
|
pie
|
||||||
title Key elements in Product X
|
title Offset labels close to border: Product X
|
||||||
accTitle: Key elements in Product X
|
accTitle: Key elements in Product X
|
||||||
accDescr: This is a pie chart showing the key elements in Product X.
|
accDescr: This is a pie chart showing the key elements in Product X.
|
||||||
"Calcium": 42.96
|
"Calcium": 42.96
|
||||||
@ -36,6 +36,19 @@
|
|||||||
"Iron": 5
|
"Iron": 5
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
%%{init: {"pie": {"textPosition": 0.45}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
|
||||||
|
pie
|
||||||
|
title Centralized labels: Languages
|
||||||
|
accTitle: Key elements in Product X
|
||||||
|
accDescr: This is a pie chart showing the key elements in Product X.
|
||||||
|
"JavaScript": 30
|
||||||
|
"Python": 25
|
||||||
|
"Java": 20
|
||||||
|
"C#": 15
|
||||||
|
"Others": 10
|
||||||
|
</pre>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import mermaid from './mermaid.esm.mjs';
|
import mermaid from './mermaid.esm.mjs';
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
|
@ -163,11 +163,11 @@ timeline
|
|||||||
timeline
|
timeline
|
||||||
title MermaidChart 2023 Timeline
|
title MermaidChart 2023 Timeline
|
||||||
section 2023 Q1 <br> Release Personal Tier
|
section 2023 Q1 <br> Release Personal Tier
|
||||||
Buttet 1 : sub-point 1a : sub-point 1b
|
Bullet 1 : sub-point 1a : sub-point 1b
|
||||||
: sub-point 1c
|
: sub-point 1c
|
||||||
Bullet 2 : sub-point 2a : sub-point 2b
|
Bullet 2 : sub-point 2a : sub-point 2b
|
||||||
section 2023 Q2 <br> Release XYZ Tier
|
section 2023 Q2 <br> Release XYZ Tier
|
||||||
Buttet 3 : sub-point <br> 3a : sub-point 3b
|
Bullet 3 : sub-point <br> 3a : sub-point 3b
|
||||||
: sub-point 3c
|
: sub-point 3c
|
||||||
Bullet 4 : sub-point 4a : sub-point 4b
|
Bullet 4 : sub-point 4a : sub-point 4b
|
||||||
```
|
```
|
||||||
@ -176,11 +176,11 @@ timeline
|
|||||||
timeline
|
timeline
|
||||||
title MermaidChart 2023 Timeline
|
title MermaidChart 2023 Timeline
|
||||||
section 2023 Q1 <br> Release Personal Tier
|
section 2023 Q1 <br> Release Personal Tier
|
||||||
Buttet 1 : sub-point 1a : sub-point 1b
|
Bullet 1 : sub-point 1a : sub-point 1b
|
||||||
: sub-point 1c
|
: sub-point 1c
|
||||||
Bullet 2 : sub-point 2a : sub-point 2b
|
Bullet 2 : sub-point 2a : sub-point 2b
|
||||||
section 2023 Q2 <br> Release XYZ Tier
|
section 2023 Q2 <br> Release XYZ Tier
|
||||||
Buttet 3 : sub-point <br> 3a : sub-point 3b
|
Bullet 3 : sub-point <br> 3a : sub-point 3b
|
||||||
: sub-point 3c
|
: sub-point 3c
|
||||||
Bullet 4 : sub-point 4a : sub-point 4b
|
Bullet 4 : sub-point 4a : sub-point 4b
|
||||||
```
|
```
|
||||||
|
@ -18,13 +18,18 @@ export const getRows = (s?: string): string[] => {
|
|||||||
return str.split('#br#');
|
return str.split('#br#');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
const setupDompurifyHooksIfNotSetup = (() => {
|
||||||
* Removes script tags from a text
|
let setup = false;
|
||||||
*
|
|
||||||
* @param txt - The text to sanitize
|
return () => {
|
||||||
* @returns The safer text
|
if (!setup) {
|
||||||
*/
|
setupDompurifyHooks();
|
||||||
export const removeScript = (txt: string): string => {
|
setup = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
function setupDompurifyHooks() {
|
||||||
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';
|
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';
|
||||||
|
|
||||||
DOMPurify.addHook('beforeSanitizeAttributes', (node: Element) => {
|
DOMPurify.addHook('beforeSanitizeAttributes', (node: Element) => {
|
||||||
@ -33,8 +38,6 @@ export const removeScript = (txt: string): string => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const sanitizedText = DOMPurify.sanitize(txt);
|
|
||||||
|
|
||||||
DOMPurify.addHook('afterSanitizeAttributes', (node: Element) => {
|
DOMPurify.addHook('afterSanitizeAttributes', (node: Element) => {
|
||||||
if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
|
if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
|
||||||
node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) || '');
|
node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) || '');
|
||||||
@ -44,6 +47,18 @@ export const removeScript = (txt: string): string => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes script tags from a text
|
||||||
|
*
|
||||||
|
* @param txt - The text to sanitize
|
||||||
|
* @returns The safer text
|
||||||
|
*/
|
||||||
|
export const removeScript = (txt: string): string => {
|
||||||
|
setupDompurifyHooksIfNotSetup();
|
||||||
|
|
||||||
|
const sanitizedText = DOMPurify.sanitize(txt);
|
||||||
|
|
||||||
return sanitizedText;
|
return sanitizedText;
|
||||||
};
|
};
|
||||||
|
@ -112,11 +112,11 @@ timeline
|
|||||||
timeline
|
timeline
|
||||||
title MermaidChart 2023 Timeline
|
title MermaidChart 2023 Timeline
|
||||||
section 2023 Q1 <br> Release Personal Tier
|
section 2023 Q1 <br> Release Personal Tier
|
||||||
Buttet 1 : sub-point 1a : sub-point 1b
|
Bullet 1 : sub-point 1a : sub-point 1b
|
||||||
: sub-point 1c
|
: sub-point 1c
|
||||||
Bullet 2 : sub-point 2a : sub-point 2b
|
Bullet 2 : sub-point 2a : sub-point 2b
|
||||||
section 2023 Q2 <br> Release XYZ Tier
|
section 2023 Q2 <br> Release XYZ Tier
|
||||||
Buttet 3 : sub-point <br> 3a : sub-point 3b
|
Bullet 3 : sub-point <br> 3a : sub-point 3b
|
||||||
: sub-point 3c
|
: sub-point 3c
|
||||||
Bullet 4 : sub-point 4a : sub-point 4b
|
Bullet 4 : sub-point 4a : sub-point 4b
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user