From c6d8848cbe5a921b4606ae1ba5177dcb603159cd Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 2 Jun 2021 21:39:13 +0530 Subject: [PATCH] Fix #172 --- src/lib/components/actions.svelte | 7 +++++-- src/lib/components/view.svelte | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte index 012dc26b88..a119c4d5a3 100644 --- a/src/lib/components/actions.svelte +++ b/src/lib/components/actions.svelte @@ -115,8 +115,11 @@ let userimagesize = 1080; codeStore.subscribe((state: State) => { - state.mermaid = JSON.parse(state.mermaid); - const b64Code = toBase64(JSON.stringify(state), true); + const stateCopy = JSON.parse(JSON.stringify(state)); + if (typeof stateCopy.mermaid === 'string') { + stateCopy.mermaid = JSON.parse(stateCopy.mermaid); + } + const b64Code = toBase64(JSON.stringify(stateCopy), true); iUrl = `https://mermaid.ink/img/${b64Code}`; svgUrl = `https://mermaid.ink/svg/${b64Code}`; mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}#${window.location.hash})`; diff --git a/src/lib/components/view.svelte b/src/lib/components/view.svelte index 326a6fb81b..adf041607d 100644 --- a/src/lib/components/view.svelte +++ b/src/lib/components/view.svelte @@ -29,6 +29,7 @@ mermaid.init(container); mermaid.render('graph-div', code); container.parentElement.parentElement.parentElement.scrollTop = scroll; + error = false; } else if (manualUpdate) { manualUpdate = false; } else {