diff --git a/src/routes/edit.svelte b/src/routes/edit.svelte index 63e943c1..ea639409 100644 --- a/src/routes/edit.svelte +++ b/src/routes/edit.svelte @@ -22,22 +22,38 @@ config: 'json' }; const docMap = { - graph: '/#/flowchart', - graph_config: '/#/flowchart?id=configuration', - sequenceDiagram: '/#/sequenceDiagram', - sequenceDiagram_config: '/#/sequenceDiagram?id=configuration', - classDiagram: '/#/classDiagram', - classDiagram_config: '/#/classDiagram?id=configuration', - 'stateDiagram-v2': '/#/stateDiagram', - gantt: '/#/gantt', - gantt_config: '/#/gantt?id=configuration', - pie: '/#/pie', - erDiagram: '/#/entityRelationshipDiagram', - erDiagram_config: '/#/entityRelationshipDiagram?id=styling', - journey: '/#/user-journey' + graph: { + code: '/#/flowchart', + config: '/#/flowchart?id=configuration' + }, + sequenceDiagram: { + code: '/#/sequenceDiagram', + config: '/#/sequenceDiagram?id=configuration' + }, + classDiagram: { + code: '/#/classDiagram', + config: '/#/classDiagram?id=configuration' + }, + 'stateDiagram-v2': { + code: '/#/stateDiagram' + }, + gantt: { + code: '/#/gantt', + config: '/#/gantt?id=configuration' + }, + pie: { + code: '/#/pie' + }, + erDiagram: { + code: '/#/entityRelationshipDiagram', + config: '/#/entityRelationshipDiagram?id=styling' + }, + journey: { + code: '/#/user-journey' + } }; let text = ''; - let docKey = ''; + let docURL = ''; let language: 'mermaid' | 'json' = 'mermaid'; let errorMarkers: monaco.editor.IMarkerData[] = []; $: language = languageMap[selectedMode]; @@ -54,8 +70,11 @@ text = selectedMode === 'code' ? state.code : state.mermaid; } let codeTypeMatch = /([\S]+)[\s\n]/.exec(state.code); - docKey = codeTypeMatch && codeTypeMatch.length > 1 ? codeTypeMatch[1] : null; - docKey = docKey ? docKey + (selectedMode !== 'code' ? '_config' : '') : null; + let docKey = codeTypeMatch && codeTypeMatch.length > 1 ? codeTypeMatch[1] : null; + docURL = + ((docKey && docMap[docKey]) || {})[selectedMode] || + ((docKey && docMap[docKey]) || {})['code'] || + ''; }); const tabSelectHandler = (message: CustomEvent) => { $codeStore.updateEditor = true; @@ -147,29 +166,29 @@
+
+ +
+ {#if !$codeStore.autoSync} {/if} -
- - DOC -
+
@@ -187,9 +206,9 @@ + on:click|stopPropagation={() => viewDiagram()}>View