From 8cf51b3a2a5941956922d92c4ec83b8657514556 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 7 Jun 2024 15:30:29 -0500 Subject: [PATCH] Reload index when diagrams change --- mod.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mod.ts b/mod.ts index 7efb206..aa7a03c 100755 --- a/mod.ts +++ b/mod.ts @@ -23,7 +23,7 @@ const command = new Command() .description('A server to facilitate editing of Mermaid diagrams') .version('v1.0.0') .option( - '-i, --input ', + '-i, --input ', 'The directory containing .mmd files to compile.', { default: './', @@ -117,6 +117,10 @@ async function runMermaidFileWatcher(args: Args) { sockets.forEach((s) => s.send(JSON.stringify({ type: 'mermaid', contents })) ) + } else if (p.endsWith('.mmd') && kind == 'remove') { + sockets.forEach((s) => + s.send(JSON.stringify({ type: 'mermaid', contents: '' })) + ) } // TODO: handle removals? } @@ -254,6 +258,11 @@ async function handleMessage({ data }) { async function handleStructuredMessage(data) { switch (data.type) { case 'mermaid': { + if (window.location.pathname == '/') { + window.location.reload() + return + } + if (rendering) return rendering = true