Reload index when diagrams change
This commit is contained in:
parent
c5b433ac79
commit
8cf51b3a2a
1 changed files with 10 additions and 1 deletions
11
mod.ts
11
mod.ts
|
@ -23,7 +23,7 @@ const command = new Command()
|
||||||
.description('A server to facilitate editing of Mermaid diagrams')
|
.description('A server to facilitate editing of Mermaid diagrams')
|
||||||
.version('v1.0.0')
|
.version('v1.0.0')
|
||||||
.option(
|
.option(
|
||||||
'-i, --input <input_directory:path>',
|
'-i, --input <input_directory:string>',
|
||||||
'The directory containing .mmd files to compile.',
|
'The directory containing .mmd files to compile.',
|
||||||
{
|
{
|
||||||
default: './',
|
default: './',
|
||||||
|
@ -117,6 +117,10 @@ async function runMermaidFileWatcher(args: Args) {
|
||||||
sockets.forEach((s) =>
|
sockets.forEach((s) =>
|
||||||
s.send(JSON.stringify({ type: 'mermaid', contents }))
|
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?
|
// TODO: handle removals?
|
||||||
}
|
}
|
||||||
|
@ -254,6 +258,11 @@ async function handleMessage({ data }) {
|
||||||
async function handleStructuredMessage(data) {
|
async function handleStructuredMessage(data) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'mermaid': {
|
case 'mermaid': {
|
||||||
|
if (window.location.pathname == '/') {
|
||||||
|
window.location.reload()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (rendering) return
|
if (rendering) return
|
||||||
rendering = true
|
rendering = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue