From 65d85a2bcacabaf64ae5efbff868d296d6103aa7 Mon Sep 17 00:00:00 2001 From: Jihchi Lee Date: Wed, 8 Apr 2020 21:41:23 +0800 Subject: [PATCH] Add "Link to SVG" Which is served by mermaid.ink. --- src/components/Links.svelte | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/Links.svelte b/src/components/Links.svelte index 9abc4bc8..63351bbd 100644 --- a/src/components/Links.svelte +++ b/src/components/Links.svelte @@ -55,12 +55,17 @@ export const onCopyMarkdown = event => { } let url = '/mermaid-live-editor/#/view'; +let b64Code; let iUrl; +let svgUrl; let mdCode; -const unsubscribe = codeStore.subscribe( state => { -url = '/mermaid-live-editor/#/view/' + Base64.encodeURI(JSON.stringify(state)); -iUrl = `https://mermaid.ink/img/${Base64.encodeURI(JSON.stringify(state))}`; - mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}#/edit/${Base64.encodeURI(JSON.stringify(state))})`; + +const unsubscribe = codeStore.subscribe(state => { + b64Code = Base64.encodeURI(JSON.stringify(state)); + url = `/mermaid-live-editor/#/view/${b64Code}`; + iUrl = `https://mermaid.ink/img/${b64Code}`; + svgUrl = `https://mermaid.ink/svg/${b64Code}`; + mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}#/edit/${b64Code})`; }); @@ -86,6 +91,7 @@ label[for="markdown"] { Download SVG Link to Image + Link to SVG Download PNG