From b466e8430e88ef113471d8e91c9a099493a755f7 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 16 Mar 2026 23:29:13 +0900 Subject: [PATCH] feat: Show mermaid.live privacy policy only on mermaid.live As the OSS project only controls the mermaid.live domain, we're adding an env variable to let anyone who is self hosting live editor to set their own privacy policy, or to hide the button if they want to. --- Dockerfile | 2 + src/env.d.ts | 2 + src/lib/components/Privacy.svelte | 95 +++++++++++-------- .../components/VersionSecurityToolbar.svelte | 11 ++- src/lib/util/env.ts | 2 + src/lib/util/migration/domainMigration.ts | 10 ++ src/routes/edit/+page.svelte | 2 +- 7 files changed, 82 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index 153e4cbd..b22325f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,8 @@ ARG MERMAID_KROKI_RENDERER_URL ARG MERMAID_ANALYTICS_URL ARG MERMAID_DOMAIN ARG MERMAID_IS_ENABLED_MERMAID_CHART_LINKS +ARG MERMAID_PRIVACY_POLICY_URL +ARG MERMAID_HIDE_PRIVACY_POLICY COPY . ./ diff --git a/src/env.d.ts b/src/env.d.ts index bfbceaa0..acd808db 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -7,6 +7,8 @@ interface ImportMetaEnv { readonly MERMAID_DOCS_URL?: string; readonly MERMAID_DOMAIN?: string; readonly MERMAID_IS_ENABLED_MERMAID_CHART_LINKS?: string; + readonly MERMAID_PRIVACY_POLICY_URL?: string; + readonly MERMAID_HIDE_PRIVACY_POLICY?: string; // more env variables... } diff --git a/src/lib/components/Privacy.svelte b/src/lib/components/Privacy.svelte index 38563b62..07e5444a 100644 --- a/src/lib/components/Privacy.svelte +++ b/src/lib/components/Privacy.svelte @@ -1,45 +1,66 @@ - - +{#if env.privacyPolicyUrl} + - - - - - - Data security - - + +{:else} + + + + + + + + + Data security + + -

Your diagrams never leave your browser.

-

They're only stored in the URL and your browser's local storage.

-

- This is a fully open source, client-side app deployed on GitHub Pages - that works offline as a - Progressive Web App. -

-

- We use self hosted, privacy-friendly Plausible Analytics to collect anonymous usage metadata - (diagram types, feature usage, etc.). All data is publicly available. -

- -

- External services (PNG/SVG/Kroki exports, "Save to Mermaid Chart", "Repair with AI", etc) - will share your diagram with those 3rd parties, and are highlighted in the UI on hover. -

-
-
-
+ {#if isOnMermaidLive()} +

Your diagrams never leave your browser.

+

They're only stored in the URL and your browser's local storage.

+

+ This is a fully open source, client-side app deployed on GitHub Pages + that works offline as a + Progressive Web App. +

+

+ We use self hosted, privacy-friendly Plausible Analytics to collect anonymous usage + metadata (diagram types, feature usage, etc.). All data is publicly available. +

+ +

+ External services (PNG/SVG/Kroki exports, "Save to Mermaid Chart", "Repair with AI", + etc) will share your diagram with those 3rd parties, and are highlighted in the UI on + hover. +

+
+ {:else} +

No privacy policy has been configured for this deployment.

+

+ If you are self-hosting the Mermaid Live Editor, set the + MERMAID_PRIVACY_POLICY_URL + environment variable at build time to link to your privacy policy, or set + MERMAID_HIDE_PRIVACY_POLICY + to true to hide this button. +

+ {/if} + +
+{/if} diff --git a/src/lib/components/VersionSecurityToolbar.svelte b/src/lib/components/VersionSecurityToolbar.svelte index 14b319bf..73abdd80 100644 --- a/src/lib/components/VersionSecurityToolbar.svelte +++ b/src/lib/components/VersionSecurityToolbar.svelte @@ -4,6 +4,7 @@ import { Button } from '$/components/ui/button'; import { Separator } from '$/components/ui/separator'; import { TID } from '$/constants'; + import { env } from '$/util/env'; import { version } from 'mermaid/package.json'; import { mode, setMode } from 'mode-watcher'; import ThemeIcon from './ThemeIcon.svelte'; @@ -11,11 +12,13 @@ v{version} - + {#if !env.hidePrivacyPolicy} + - + + {/if}