Skip to content

Commit

Permalink
Added image shortcut
Browse files Browse the repository at this point in the history
Added config options for title bar icons
  • Loading branch information
mdickin committed Mar 11, 2017
1 parent 73356b5 commit 13d47bc
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**v0.7.0**
* Added image shortcut (ctrl+shift+L). Thanks to [@ngtrian](https://github.com/ngtrian) for the recommendation!
* Added configuration settings to show/hide icons in the title bar.

**v0.6.0**
* Added icon. Thanks to [@LaChRiZ](https://github.com/LaChRiZ) for the contribution!
* Modified link shortcut (ctrl+L) to surround URLs with angle brackets. Thanks to [@StephD](https://github.com/StephD)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
Handy shortcuts for editing Markdown (`.md`, `.markdown`) files. Now with title and context menu integration!

**Quickly toggle bullet points**

![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/bullets.gif)

**Easily generate URLs**

![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/urls.gif)

**Convert tabular data to tables**
![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/table_with_header.gif)

![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/table_with_header.gif)

**Context and title menu integration**

![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/shortcut_menu.png)

**Note**: extension will override a few default VS Code key bindings (ctrl+B, ctrl+I, ctrl+L), but only when editing Markdown files.
You can show and hide icons in the title bar with the `markdownShortcuts.icons.*` config settings.

## Exposed Commands

Expand All @@ -25,6 +28,7 @@ Handy shortcuts for editing Markdown (`.md`, `.markdown`) files. Now with title
| md-shortcut.toggleItalic | Make \_italic\_ | ctrl+I |
| md-shortcut.toggleStrikethrough | Make \~\~strikethrough\~\~ | |
| md-shortcut.toggleHyperlink | Make [a hyperlink]\(www.example.org) | ctrl+L |
| md-shortcut.toggleImage | Make an image ![]\(image_url.png) | ctrl+shift+L |
| md-shortcut.toggleCodeBlock | Make \`\`\`a code block\`\`\` | ctrl+M ctrl+C |
| md-shortcut.toggleInlineCode | Make \`inline code\` | ctrl+M ctrl+I |
| md-shortcut.toggleBullets | Make * bullet point | ctrl+M ctrl+B |
Expand Down
19 changes: 19 additions & 0 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var _commands = [
new Command('toggleCodeBlock', toggleCodeBlock, 'Toggle code block', '```Code block```', true),
new Command('toggleInlineCode', toggleInlineCode, 'Toggle inline code', '`Inline code`', true),
new Command('toggleLink', toggleLink, 'Toggle hyperlink', '[Link text](link_url)', true),
new Command('toggleImage', toggleImage, 'Toggle image', '![](image_url)', true),
new Command('toggleBullets', toggleBullets, 'Toggle bullet points', '* Bullet point', true),
new Command('toggleNumbers', toggleNumberList, 'Toggle number list', '1 Numbered list item', true),
new Command('toggleTitleH1', toggleTitleH1, 'Toggle title H1', '# Title', true),
Expand Down Expand Up @@ -199,6 +200,24 @@ function toggleLink() {
}
}

function toggleImage() {
if (editorHelpers.isAnythingSelected()) {
editorHelpers.surroundSelection('![](', ')')
}
else {
return vscode.window.showInputBox({
prompt: "Image URL"
})
.then((url) => {
if (!url == null) return;

editorHelpers.surroundSelection("![](" + url, ")");
})
}
}



function Command(command, callback, label, description, showInCommandPalette) {
this.command = command;
this.callback = callback;
Expand Down
4 changes: 4 additions & 0 deletions media/icons/image_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions media/icons/image_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 72 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Markdown Shortcuts",
"description": "Shortcuts for Markdown editing",
"icon": "media/images/markdown-shortcuts-512x512.png",
"version": "0.6.1",
"version": "0.7.0",
"publisher": "mdickin",
"engines": {
"vscode": "^0.10.10"
Expand All @@ -20,8 +20,43 @@
"*"
],
"contributes": {
"configuration": {
"type": "object",
"title": "Markdown Shortcuts",
"properties": {
"markdownShortcuts.icons.bold": {
"type": "boolean",
"default": true,
"description": "Show bold icon in title bar"
},
"markdownShortcuts.icons.italic": {
"type": "boolean",
"default": true,
"description": "Show italic icon in title bar"
},
"markdownShortcuts.icons.strikethrough": {
"type": "boolean",
"default": true,
"description": "Show strikethrough icon in title bar"
},
"markdownShortcuts.icons.bullets": {
"type": "boolean",
"default": true,
"description": "Show bullets icon in title bar"
},
"markdownShortcuts.icons.link": {
"type": "boolean",
"default": false,
"description": "Show link icon in title bar"
},
"markdownShortcuts.icons.image": {
"type": "boolean",
"default": false,
"description": "Show image icon in title bar"
}
}
},
"commands": [

{
"command": "md-shortcut.toggleBold",
"title": "Toggle bold",
Expand Down Expand Up @@ -72,6 +107,15 @@
},
"category": "Markdown Shortcuts"
},
{
"command": "md-shortcut.toggleImage",
"title": "Toggle image",
"icon": {
"dark": "./media/icons/image_white.svg",
"light": "./media/icons/image_black.svg"
},
"category": "Markdown Shortcuts"
},
{
"command": "md-shortcut.toggleBullets",
"title": "Toggle bullet points",
Expand Down Expand Up @@ -139,6 +183,11 @@
"key": "ctrl+l",
"when": "editorTextFocus && editorLangId == 'markdown'"
},
{
"command": "md-shortcut.toggleImage",
"key": "ctrl+shift+l",
"when": "editorTextFocus && editorLangId == 'markdown'"
},
{
"command": "md-shortcut.toggleCodeBlock",
"key": "ctrl+m ctrl+c",
Expand Down Expand Up @@ -188,15 +237,20 @@
"group": "2_markdown_1@4"
},
{
"command": "md-shortcut.toggleCodeBlock",
"command": "md-shortcut.toggleImage",
"when": "editorLangId == 'markdown'",
"group": "2_markdown_1@5"
},
{
"command": "md-shortcut.toggleInlineCode",
"command": "md-shortcut.toggleCodeBlock",
"when": "editorLangId == 'markdown'",
"group": "2_markdown_1@6"
},
{
"command": "md-shortcut.toggleInlineCode",
"when": "editorLangId == 'markdown'",
"group": "2_markdown_1@7"
},
{
"command": "md-shortcut.toggleBullets",
"when": "editorLangId == 'markdown'",
Expand Down Expand Up @@ -226,23 +280,33 @@
"editor/title": [
{
"command": "md-shortcut.toggleBold",
"when": "editorLangId == 'markdown'",
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.bold",
"group": "navigation@1"
},
{
"command": "md-shortcut.toggleItalic",
"when": "editorLangId == 'markdown'",
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.italic",
"group": "navigation@2"
},
{
"command": "md-shortcut.toggleStrikethrough",
"when": "editorLangId == 'markdown'",
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.strikethrough",
"group": "navigation@3"
},
{
"command": "md-shortcut.toggleBullets",
"when": "editorLangId == 'markdown'",
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.bullets",
"group": "navigation@4"
},
{
"command": "md-shortcut.toggleLink",
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.link",
"group": "navigation@5"
},
{
"command": "md-shortcut.toggleImage",
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.image",
"group": "navigation@6"
}
]
}
Expand Down

0 comments on commit 13d47bc

Please sign in to comment.