diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 45847c44..98e24866 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -19,6 +19,11 @@ jobs:
node-version: 18
cache: yarn
+ - name: Setup Pages
+ uses: actions/configure-pages@v5
+ with:
+ static_site_generator: sveltekit
+
- name: Build & Deploy
env:
MERMAID_DOMAIN: 'mermaid.live'
@@ -32,13 +37,24 @@ jobs:
yarn install
version=$(yarn version --patch --no-git-tag-version | grep "New version" | cut -d':' -f 2)
yarn build
- yarn run lint
- cd ..
- - name: Deploy
- uses: peaceiris/actions-gh-pages@v3
- if: ${{ github.ref == 'refs/heads/master' }}
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: ./docs
- keep_files: true
+ path: ./docs
+
+ deploy:
+ if: ${{ github.ref == 'refs/heads/master' }}
+ needs: build
+ runs-on: ubuntu-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
+ permissions:
+ pages: write # to deploy to Pages
+ id-token: write # to verify the deployment originates from an appropriate source
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.gitignore b/.gitignore
index 93a49ede..51e6c4d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,15 @@
-node_modules/
-coverage/
-.cache/
-build/
-yarn-error.log
-.npmrc
.DS_Store
+.cache/
+.env.local
+.npmrc
/.svelte-kit
/build
-/functions
-/snapshots.js
+/coverage
/cypress/downloads
-/cypress/videos
/cypress/screenshots
-.env.local
+/cypress/videos
+/docs
+/functions
+/node_modules
+/snapshots.js
+yarn-error.log
diff --git a/CNAME b/CNAME
new file mode 100644
index 00000000..f2f75b9a
--- /dev/null
+++ b/CNAME
@@ -0,0 +1 @@
+mermaid.live
diff --git a/package.json b/package.json
index 511bc4a8..2fe43e8d 100644
--- a/package.json
+++ b/package.json
@@ -31,12 +31,12 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/svelte": "^5.2.4",
- "@types/dompurify": "^3.0.5",
"@types/lodash-es": "^4.17.12",
"@types/pako": "2.0.3",
"@types/uuid": "9.0.8",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
+ "@vitest/coverage-v8": "2.1.9",
"@vitest/ui": "^2.1.4",
"autoprefixer": "^10.4.14",
"bits-ui": "^1.3.12",
@@ -88,7 +88,6 @@
"@mermaid-js/layout-elk": "^0.1.4",
"@mermaid-js/mermaid-zenuml": "^0.2.0",
"dayjs": "^1.11.7",
- "dompurify": "^3.1.6",
"js-base64": "3.7.7",
"lodash-es": "^4.17.21",
"mermaid": "^11.3.0",
diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte
index de439711..acf75658 100644
--- a/src/lib/components/Editor.svelte
+++ b/src/lib/components/Editor.svelte
@@ -13,7 +13,6 @@
import { env } from '$/util/env';
import type { EditorMode } from '$lib/types';
import { initEditor } from '$lib/util/monacoExtra';
- import { sanitizeText } from '$lib/util/sanitize';
import { stateStore, updateCode, updateConfig, urlsStore } from '$lib/util/state';
import { logEvent } from '$lib/util/stats';
import { errorDebug, syncDiagram } from '$lib/util/util';
@@ -140,7 +139,7 @@
-
+
Syntax error
{#if env.isEnabledMermaidChartLinks}
@@ -157,10 +156,9 @@
{/if}
-
-
- {@html sanitizeText($stateStore.error?.toString().replaceAll('\n', '
'))}
-
+
{/if}
diff --git a/src/lib/util/sanitize.ts b/src/lib/util/sanitize.ts
deleted file mode 100644
index aa5d1c55..00000000
--- a/src/lib/util/sanitize.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import DOMPurify from 'dompurify';
-
-export const sanitizeText = (text?: string): string => {
- return DOMPurify.sanitize(text ?? '', {
- ALLOWED_TAGS: [
- 'b',
- 'i',
- 'u',
- 'a',
- 'p',
- 's',
- 'br',
- 'span',
- 'strong',
- 'em',
- 'code',
- 'pre',
- 'ul',
- 'ol',
- 'li'
- ]
- });
-};
diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte
new file mode 100644
index 00000000..adf4b6bd
--- /dev/null
+++ b/src/routes/+error.svelte
@@ -0,0 +1,20 @@
+
+
+{#if $page.status !== 404}
+
+
Error {$page.status}
+
{$page.error?.message || 'An unexpected error occurred'}
+
Return to Home
+
+{/if}
diff --git a/svelte.config.js b/svelte.config.js
index 53a66551..7d17fce0 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -1,12 +1,12 @@
import adapter from '@sveltejs/adapter-static';
-import preprocess from 'svelte-preprocess';
+import { sveltePreprocess } from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: [
- preprocess({
+ sveltePreprocess({
postcss: true
})
],
@@ -15,13 +15,8 @@ const config = {
'$/*': './src/lib/*'
},
adapter: adapter({
- pages: `docs`
- }),
- paths: process.env['DEPLOY']
- ? {
- base: `/mermaid-live-editor`
- }
- : {}
+ pages: 'docs'
+ })
}
};
diff --git a/yarn.lock b/yarn.lock
index 3ce77ac0..2c0b3b66 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -68,6 +68,11 @@
js-tokens "^4.0.0"
picocolors "^1.0.0"
+"@babel/helper-string-parser@^7.25.9":
+ version "7.25.9"
+ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz#1aabb72ee72ed35789b4bbcad3ca2862ce614e8c"
+ integrity sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==
+
"@babel/helper-validator-identifier@^7.22.20":
version "7.22.20"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0"
@@ -93,6 +98,13 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.7.tgz#9a5226f92f0c5c8ead550b750f5608e766c8ce85"
integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==
+"@babel/parser@^7.25.4":
+ version "7.26.10"
+ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.26.10.tgz#e9bdb82f14b97df6569b0b038edd436839c57749"
+ integrity sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==
+ dependencies:
+ "@babel/types" "^7.26.10"
+
"@babel/runtime@^7.12.5":
version "7.26.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.9.tgz#aa4c6facc65b9cb3f87d75125ffd47781b475433"
@@ -100,6 +112,14 @@
dependencies:
regenerator-runtime "^0.14.0"
+"@babel/types@^7.25.4", "@babel/types@^7.26.10":
+ version "7.26.10"
+ resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.10.tgz#396382f6335bd4feb65741eacfc808218f859259"
+ integrity sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==
+ dependencies:
+ "@babel/helper-string-parser" "^7.25.9"
+ "@babel/helper-validator-identifier" "^7.25.9"
+
"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
@@ -574,7 +594,7 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"
-"@jridgewell/trace-mapping@^0.3.24":
+"@jridgewell/trace-mapping@^0.3.23", "@jridgewell/trace-mapping@^0.3.24":
version "0.3.25"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0"
integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==
@@ -1059,13 +1079,6 @@
"@types/d3-transition" "*"
"@types/d3-zoom" "*"
-"@types/dompurify@^3.0.5":
- version "3.2.0"
- resolved "https://registry.yarnpkg.com/@types/dompurify/-/dompurify-3.2.0.tgz#56610bf3e4250df57744d61fbd95422e07dfb840"
- integrity sha512-Fgg31wv9QbLDA0SpTOXO3MaxySc4DKGLi8sna4/Utjo4r3ZRPdCt4UQee8BWr+Q5z21yifghREPJGYaEOEIACg==
- dependencies:
- dompurify "*"
-
"@types/estree@1.0.6", "@types/estree@^1.0.0", "@types/estree@^1.0.5", "@types/estree@^1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
@@ -1298,6 +1311,24 @@
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==
+"@vitest/coverage-v8@2.1.9":
+ version "2.1.9"
+ resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-2.1.9.tgz#060bebfe3705c1023bdc220e17fdea4bd9e2b24d"
+ integrity sha512-Z2cOr0ksM00MpEfyVE8KXIYPEcBFxdbLSs56L8PO0QQMxt/6bDj45uQfxoc96v05KW3clk7vvgP0qfDit9DmfQ==
+ dependencies:
+ "@ampproject/remapping" "^2.3.0"
+ "@bcoe/v8-coverage" "^0.2.3"
+ debug "^4.3.7"
+ istanbul-lib-coverage "^3.2.2"
+ istanbul-lib-report "^3.0.1"
+ istanbul-lib-source-maps "^5.0.6"
+ istanbul-reports "^3.1.7"
+ magic-string "^0.30.12"
+ magicast "^0.3.5"
+ std-env "^3.8.0"
+ test-exclude "^7.0.1"
+ tinyrainbow "^1.2.0"
+
"@vitest/expect@2.1.9":
version "2.1.9"
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-2.1.9.tgz#b566ea20d58ea6578d8dc37040d6c1a47ebe5ff8"
@@ -1951,12 +1982,7 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
-caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001565, caniuse-lite@^1.0.30001587, caniuse-lite@^1.0.30001646:
- version "1.0.30001701"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001701.tgz"
- integrity sha512-faRs/AW3jA9nTwmJBSO1PQ6L/EOgsB5HMQQq4iCu5zhPgVVgO/pZRHlmatwijZKetFw8/Pr4q6dEN8sJuq8qTw==
-
-caniuse-lite@^1.0.30001688, caniuse-lite@^1.0.30001702:
+caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001565, caniuse-lite@^1.0.30001587, caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001688, caniuse-lite@^1.0.30001702:
version "1.0.30001704"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001704.tgz#6644fe909d924ac3a7125e8a0ab6af95b1f32990"
integrity sha512-+L2IgBbV6gXB4ETf0keSvLr7JUrRVbIaB/lrQ1+z8mRcQiisG5k+lG6O4n6Y5q6f5EuNfaYXKgymucphlEXQew==
@@ -2982,18 +3008,18 @@ domhandler@^5.0.2, domhandler@^5.0.3:
dependencies:
domelementtype "^2.3.0"
-dompurify@*, dompurify@^3.1.6, dompurify@^3.2.1:
+dompurify@^3.1.5:
+ version "3.1.5"
+ resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.5.tgz#2c6a113fc728682a0f55684b1388c58ddb79dc38"
+ integrity sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA==
+
+dompurify@^3.2.1:
version "3.2.4"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.2.4.tgz#af5a5a11407524431456cf18836c55d13441cd8e"
integrity sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==
optionalDependencies:
"@types/trusted-types" "^2.0.7"
-dompurify@^3.1.5:
- version "3.1.5"
- resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.5.tgz#2c6a113fc728682a0f55684b1388c58ddb79dc38"
- integrity sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA==
-
domutils@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.1.0.tgz#c47f551278d3dc4b0b1ab8cbb42d751a6f0d824e"
@@ -3755,7 +3781,7 @@ glob-parent@^6.0.2:
dependencies:
is-glob "^4.0.3"
-glob@^10.3.10:
+glob@^10.3.10, glob@^10.4.1:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
@@ -4166,7 +4192,12 @@ istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0:
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz#189e7909d0a39fa5a3dfad5b03f71947770191d3"
integrity sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==
-istanbul-lib-report@^3.0.0:
+istanbul-lib-coverage@^3.2.2:
+ version "3.2.2"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756"
+ integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==
+
+istanbul-lib-report@^3.0.0, istanbul-lib-report@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d"
integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==
@@ -4175,6 +4206,15 @@ istanbul-lib-report@^3.0.0:
make-dir "^4.0.0"
supports-color "^7.1.0"
+istanbul-lib-source-maps@^5.0.6:
+ version "5.0.6"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz#acaef948df7747c8eb5fbf1265cb980f6353a441"
+ integrity sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==
+ dependencies:
+ "@jridgewell/trace-mapping" "^0.3.23"
+ debug "^4.1.1"
+ istanbul-lib-coverage "^3.0.0"
+
istanbul-reports@^3.1.4:
version "3.1.6"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.6.tgz#2544bcab4768154281a2f0870471902704ccaa1a"
@@ -4183,6 +4223,14 @@ istanbul-reports@^3.1.4:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"
+istanbul-reports@^3.1.7:
+ version "3.1.7"
+ resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.7.tgz#daed12b9e1dca518e15c056e1e537e741280fa0b"
+ integrity sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==
+ dependencies:
+ html-escaper "^2.0.0"
+ istanbul-lib-report "^3.0.0"
+
its-name@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/its-name/-/its-name-1.0.0.tgz#2065f1883ecb568c65f7112ddbf123401fae4af0"
@@ -4597,6 +4645,15 @@ magic-string@^0.30.5:
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.15"
+magicast@^0.3.5:
+ version "0.3.5"
+ resolved "https://registry.yarnpkg.com/magicast/-/magicast-0.3.5.tgz#8301c3c7d66704a0771eb1bad74274f0ec036739"
+ integrity sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==
+ dependencies:
+ "@babel/parser" "^7.25.4"
+ "@babel/types" "^7.25.4"
+ source-map-js "^1.2.0"
+
make-dir@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e"
@@ -6520,6 +6577,15 @@ test-exclude@^6.0.0:
glob "^7.1.4"
minimatch "^3.0.4"
+test-exclude@^7.0.1:
+ version "7.0.1"
+ resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-7.0.1.tgz#20b3ba4906ac20994e275bbcafd68d510264c2a2"
+ integrity sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==
+ dependencies:
+ "@istanbuljs/schema" "^0.1.2"
+ glob "^10.4.1"
+ minimatch "^9.0.4"
+
text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"