Skip to content

Commit

Permalink
New feature: add quick document entry
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwin612 committed Mar 7, 2022
1 parent 9741968 commit 3d3b4b0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/routes/edit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@
code: 'mermaid',
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'
};
let text = '';
let docKey = '';
let language: 'mermaid' | 'json' = 'mermaid';
let errorMarkers: monaco.editor.IMarkerData[] = [];
$: language = languageMap[selectedMode];
Expand All @@ -37,6 +53,9 @@
if (state.updateEditor) {
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;
});
const tabSelectHandler = (message: CustomEvent<Tab>) => {
$codeStore.updateEditor = true;
Expand Down Expand Up @@ -136,7 +155,7 @@
on:click={syncDiagram}><i class="fas fa-sync" /></button>
{/if}

<div class="form-control">
<div class="form-control flex-row items-center">
<label class="cursor-pointer label" for="autoSync">
<input
type="checkbox"
Expand All @@ -145,6 +164,11 @@
bind:checked={$codeStore.autoSync} />
<span> Auto sync</span>
</label>
<a
target="_blank"
class="btn btn-primary btn-xs shadow-lg"
href="https://mermaid-js.github.io/mermaid/{docMap[docKey] || ''}"
><i class="far fa-eye mr-2" /> DOC</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 3d3b4b0

Please sign in to comment.