From a61a69e4775c794099fa9b7b7f339c6fae3e0d21 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 22 Apr 2026 18:58:31 +0530 Subject: [PATCH] fix: Show picker on netlify --- src/lib/util/migration/domainMigration.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/util/migration/domainMigration.ts b/src/lib/util/migration/domainMigration.ts index 3e0ce105..c4b5159e 100644 --- a/src/lib/util/migration/domainMigration.ts +++ b/src/lib/util/migration/domainMigration.ts @@ -4,6 +4,7 @@ import { editorChooserVariants, type EditorChooserVariant } from '$/util/experim const mermaidAiDomain = 'mermaid.ai'; const mermaidLiveDomain = 'mermaid.live'; +const netlifyPreviewDomain = 'netlify.app'; /** * Check if we're on mermaid.ai @@ -21,6 +22,13 @@ export const isOnMermaidLive = (): boolean => { return domain === mermaidLiveDomain || domain.endsWith(`.${mermaidLiveDomain}`); }; +/** + * Check if we're on a Netlify preview/staging deploy (*.netlify.app). + */ +const isOnNetlifyPreview = (): boolean => { + return window.location.hostname.endsWith(`.${netlifyPreviewDomain}`); +}; + /** * Check if the current URL has pako data (diagram content from a shared link). */ @@ -64,7 +72,7 @@ export const shouldShowEditorChooser = (): boolean => { if (window.innerWidth < 640) return false; const forced = new URLSearchParams(window.location.search).get('editorChooser') === '1'; if (forced) return true; - if (!isOnMermaidAI() && !isOnMermaidLive()) return false; + if (!isOnMermaidAI() && !isOnMermaidLive() && !isOnNetlifyPreview()) return false; if (window.localStorage.getItem(C.editorChooserDismissedKey) === 'true') return false; if (hasPakoData()) return false; if (isReferredFromMermaid()) return false;