-
-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1374 from mermaid-js/release-promotion
Release live editor
- Loading branch information
Showing
18 changed files
with
688 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"types": ["cypress", "cypress-localstorage-commands", "cy-verify-downloads", "node"] | ||
"types": ["cypress", "cypress-localstorage-commands", "node"] | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import debounce from 'lodash-es/debounce'; | ||
import { get } from 'svelte/store'; | ||
import { stateStore } from './state'; | ||
|
||
let shouldSync = true; | ||
let updater: () => void; | ||
let renderPromise: Promise<void> | undefined; | ||
let resolveRenderPromise: (() => void) | undefined; | ||
const renderDelay = 1000; | ||
const slowRenderThreshold = 150; | ||
|
||
const debouncedRender = debounce(() => { | ||
shouldSync = true; | ||
updater(); | ||
}, renderDelay); | ||
|
||
export const recordRenderTime = (renderTimeMs: number, updaterFunction: () => void): void => { | ||
resolveRenderPromise?.(); | ||
const { autoSync } = get(stateStore); | ||
if (!autoSync) { | ||
return; | ||
} | ||
updater = updaterFunction; | ||
const isSlow = renderTimeMs > slowRenderThreshold; | ||
if (!shouldSync) { | ||
debouncedRender(); | ||
} | ||
shouldSync = !isSlow; | ||
}; | ||
|
||
export const shouldRefreshView = (): boolean => { | ||
if (!renderPromise) { | ||
renderPromise = new Promise((resolve) => { | ||
resolveRenderPromise = () => { | ||
renderPromise = undefined; | ||
resolve(); | ||
}; | ||
}); | ||
} | ||
|
||
if (!shouldSync) { | ||
debouncedRender(); | ||
} | ||
return shouldSync; | ||
}; | ||
|
||
export const waitForRender = (): Promise<void> => { | ||
return renderPromise ?? Promise.resolve(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
<script lang="ts"> | ||
const taglines = [ | ||
'Try diagramming with ChatGPT at Mermaid Chart', | ||
"Try Mermaid's Visual Editor at Mermaid Chart", | ||
'Enjoy live collaboration with teammates at Mermaid Chart' | ||
]; | ||
const taglines = { | ||
announcement_bar_ai_diagramming: 'Try diagramming with ChatGPT at Mermaid Chart', | ||
announcement_bar_visual_editor: "Try Mermaid's Visual Editor at Mermaid Chart", | ||
announcement_bar_live_collaboration: 'Enjoy live collaboration with teammates at Mermaid Chart' | ||
}; | ||
const taglineKeys = Object.keys(taglines); | ||
const taglineKey = taglineKeys[Math.floor(Math.random() * taglineKeys.length)]; | ||
const tagline = taglines[taglineKey]; | ||
const url = | ||
'https://www.mermaidchart.com/?' + | ||
new URLSearchParams({ | ||
utm_source: 'mermaid_live_editor', | ||
utm_medium: taglineKey, | ||
utm_campaign: 'promo_2024' | ||
}).toString(); | ||
</script> | ||
|
||
<a | ||
href="https://www.mermaidchart.com/" | ||
href={url} | ||
target="_blank" | ||
class="flex flex-grow justify-center gap-6 align-middle tracking-wide"> | ||
{taglines[Math.floor(Math.random() * taglines.length)]} | ||
{tagline} | ||
<button class="rounded bg-gray-800 p-1 px-4 text-sm font-light">Try it now</button> | ||
</a> |
Oops, something went wrong.