From 344f9f5943038da368c6f067c4ee625678f985b9 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sun, 21 Feb 2021 21:53:56 +0000 Subject: [PATCH 1/2] Added mermaid shortcut --- README.md | 1 + src/SidePanelControlView.ts | 3 +++ src/formatter.ts | 29 +++++++++++++++++++---------- src/icons.ts | 1 + 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 66451de..6a3604a 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ To delete a saved or last used color just click it with the right mouse button. - Defines the side of the side pane. By default the side pane will open on the right side/leaf. ## Changelog +- added /mermaid snipplet to generate mermaid code block - allows drawing diagrams ![](assets/Mermaid.png) - Vesion 0.2.0 - Added support for HTML snippets in command language and in side pane. - Added a color picker diff --git a/src/SidePanelControlView.ts b/src/SidePanelControlView.ts index daf6619..c361f07 100644 --- a/src/SidePanelControlView.ts +++ b/src/SidePanelControlView.ts @@ -206,6 +206,9 @@ export class SidePanelControlView extends ItemView { button = row.createDiv({ cls: 'nav-action-button' }); addClickEvent(button, 'link'); button.appendChild(svgToElement('link')); + button = row.createDiv({ cls: 'nav-action-button' }); + addClickEvent(button, 'mermaidBlock'); + button.appendChild(svgToElement('mermaidBlock')); button = row.createDiv({ cls: 'nav-action-button' }); addClickEvent(button, 'internalLink'); diff --git a/src/formatter.ts b/src/formatter.ts index 26bde32..e428932 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -90,15 +90,6 @@ export const formatSettings = { newLine: false, enclose: false, }, - codeInline: { - des: 'code_inline', - icon: 'codeInline', - symbol: '``', - shift: 1, - selectionInput: 1, - newLine: false, - enclose: false, - }, codeBlock: { des: 'code_block', icon: 'codeBlock', @@ -108,6 +99,24 @@ export const formatSettings = { newLine: true, enclose: true, }, + mermaidBlock: { + des: 'mermaid_block', + icon: 'mermaidBlock', + symbol: '```mermaid \n```', + shift: 4, + selectionInput: 4, + newLine: true, + enclose: true, + }, + codeInline: { + des: 'code_inline', + icon: 'codeInline', + symbol: '``', + shift: 1, + selectionInput: 1, + newLine: false, + enclose: false, + }, link: { des: 'link', icon: 'link', @@ -235,7 +244,7 @@ export function iconFormatter( editor.replaceRange(item.symbol, curserStart); editor.setCursor(curserStart.line, curserStart.ch + item.shift); } - } else if (['code_block'].contains(item.des)) { + } else if (['code_block'].contains(item.des)||['mermaid_block'].contains(item.des)) { if (isSelection) { const re = new RegExp('^(```).*(```)$', 'gs'); const match = selection.trim().match(re); diff --git a/src/icons.ts b/src/icons.ts index 8a3c70a..a0dba91 100644 --- a/src/icons.ts +++ b/src/icons.ts @@ -20,6 +20,7 @@ export const icons: Record = { codeInline: pathToSvg(mdiIcons.mdiCodeTags), codeBlock: pathToSvg(mdiIcons.mdiXml), link: pathToSvg(mdiIcons.mdiLinkVariant), + mermaidBlock: pathToSvg(mdiIcons.mdiGraph), fileLink: pathToSvg(mdiIcons.mdiFileLink), image: pathToSvg(mdiIcons.mdiImage), quote: pathToSvg(mdiIcons.mdiFormatIndentIncrease), From 5e1cfc1892a7c7ac3e27777def1be12709c41167 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sun, 21 Feb 2021 21:54:31 +0000 Subject: [PATCH 2/2] Missing screenshot --- assets/Mermaid.png | Bin 0 -> 6097 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/Mermaid.png diff --git a/assets/Mermaid.png b/assets/Mermaid.png new file mode 100644 index 0000000000000000000000000000000000000000..c9d4752c3b686b924ea4ebd8af9fcdc266bda31a GIT binary patch literal 6097 zcmd5gcTkgGwkQY+D#{NKkYYn6GzFvyC@3XFsz4}0fJm2~&>;#c(tmUby@Wt00VF{P zO+gS4kP>>89-8zT*pGd0XLe_HX7|1Q)Rr$9q<1rC0ysOOckJc`ne+j-Nx#w-89`R4}PZNE3xYi*xKIg3z6B}!C2GEz| z2I4aVFw$%?oMHlo>`Nym-edgt0QG^#d?gr+azGuds7P+&gh36{xpUF&*0J9#7kZ9p zxk}zVehkdAhbdpbex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