Skip to content

Commit

Permalink
Merge pull request #9 from AlexMikhalev/main
Browse files Browse the repository at this point in the history
Added mermaid shortcut
  • Loading branch information
Reocin authored Mar 4, 2021
2 parents daa8861 + 9c14822 commit 6eee591
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ To delete a saved or last used color just click it with the right mouse button.

## Changelog

- Version 0.2.2
- added /mermaid snipplet to generate mermaid code block - allows drawing diagrams ![](assets/Mermaid.png)
- Version 0.2.1
⁻ Some Bug Fixes
- No input preview mode
- Highlighting of the html buttons when hover
- Replace selection when insert colors.
- No input preview mode
- Highlighting of the html buttons when hover
- Replace selection when insert colors.
- Saved Colors can be added and edited in the settings.
- New HTML Tags `<details></details>` and `<summary></summary>`
- Vesion 0.2.0
Expand Down
Binary file added assets/Mermaid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/SidePanelControlView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,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');
Expand Down
29 changes: 19 additions & 10 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const icons: Record<string, string> = {
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),
Expand Down

0 comments on commit 6eee591

Please sign in to comment.