Skip to content

Commit 13d47bc

Browse files
committed
Added image shortcut
Added config options for title bar icons
1 parent 73356b5 commit 13d47bc

File tree

6 files changed

+109
-10
lines changed

6 files changed

+109
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**v0.7.0**
2+
* Added image shortcut (ctrl+shift+L). Thanks to [@ngtrian](https://github.com/ngtrian) for the recommendation!
3+
* Added configuration settings to show/hide icons in the title bar.
4+
15
**v0.6.0**
26
* Added icon. Thanks to [@LaChRiZ](https://github.com/LaChRiZ) for the contribution!
37
* Modified link shortcut (ctrl+L) to surround URLs with angle brackets. Thanks to [@StephD](https://github.com/StephD)

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
Handy shortcuts for editing Markdown (`.md`, `.markdown`) files. Now with title and context menu integration!
33

44
**Quickly toggle bullet points**
5+
56
![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/bullets.gif)
67

78
**Easily generate URLs**
9+
810
![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/urls.gif)
911

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

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

1416
**Context and title menu integration**
17+
1518
![](https://raw.githubusercontent.com/mdickin/vscode-markdown-shortcuts/master/media/demo/shortcut_menu.png)
1619

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

1922
## Exposed Commands
2023

@@ -25,6 +28,7 @@ Handy shortcuts for editing Markdown (`.md`, `.markdown`) files. Now with title
2528
| md-shortcut.toggleItalic | Make \_italic\_ | ctrl+I |
2629
| md-shortcut.toggleStrikethrough | Make \~\~strikethrough\~\~ | |
2730
| md-shortcut.toggleHyperlink | Make [a hyperlink]\(www.example.org) | ctrl+L |
31+
| md-shortcut.toggleImage | Make an image ![]\(image_url.png) | ctrl+shift+L |
2832
| md-shortcut.toggleCodeBlock | Make \`\`\`a code block\`\`\` | ctrl+M ctrl+C |
2933
| md-shortcut.toggleInlineCode | Make \`inline code\` | ctrl+M ctrl+I |
3034
| md-shortcut.toggleBullets | Make * bullet point | ctrl+M ctrl+B |

lib/commands.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var _commands = [
1414
new Command('toggleCodeBlock', toggleCodeBlock, 'Toggle code block', '```Code block```', true),
1515
new Command('toggleInlineCode', toggleInlineCode, 'Toggle inline code', '`Inline code`', true),
1616
new Command('toggleLink', toggleLink, 'Toggle hyperlink', '[Link text](link_url)', true),
17+
new Command('toggleImage', toggleImage, 'Toggle image', '![](image_url)', true),
1718
new Command('toggleBullets', toggleBullets, 'Toggle bullet points', '* Bullet point', true),
1819
new Command('toggleNumbers', toggleNumberList, 'Toggle number list', '1 Numbered list item', true),
1920
new Command('toggleTitleH1', toggleTitleH1, 'Toggle title H1', '# Title', true),
@@ -199,6 +200,24 @@ function toggleLink() {
199200
}
200201
}
201202

203+
function toggleImage() {
204+
if (editorHelpers.isAnythingSelected()) {
205+
editorHelpers.surroundSelection('![](', ')')
206+
}
207+
else {
208+
return vscode.window.showInputBox({
209+
prompt: "Image URL"
210+
})
211+
.then((url) => {
212+
if (!url == null) return;
213+
214+
editorHelpers.surroundSelection("![](" + url, ")");
215+
})
216+
}
217+
}
218+
219+
220+
202221
function Command(command, callback, label, description, showInCommandPalette) {
203222
this.command = command;
204223
this.callback = callback;

media/icons/image_black.svg

Lines changed: 4 additions & 0 deletions
Loading

media/icons/image_white.svg

Lines changed: 4 additions & 0 deletions
Loading

package.json

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Markdown Shortcuts",
44
"description": "Shortcuts for Markdown editing",
55
"icon": "media/images/markdown-shortcuts-512x512.png",
6-
"version": "0.6.1",
6+
"version": "0.7.0",
77
"publisher": "mdickin",
88
"engines": {
99
"vscode": "^0.10.10"
@@ -20,8 +20,43 @@
2020
"*"
2121
],
2222
"contributes": {
23+
"configuration": {
24+
"type": "object",
25+
"title": "Markdown Shortcuts",
26+
"properties": {
27+
"markdownShortcuts.icons.bold": {
28+
"type": "boolean",
29+
"default": true,
30+
"description": "Show bold icon in title bar"
31+
},
32+
"markdownShortcuts.icons.italic": {
33+
"type": "boolean",
34+
"default": true,
35+
"description": "Show italic icon in title bar"
36+
},
37+
"markdownShortcuts.icons.strikethrough": {
38+
"type": "boolean",
39+
"default": true,
40+
"description": "Show strikethrough icon in title bar"
41+
},
42+
"markdownShortcuts.icons.bullets": {
43+
"type": "boolean",
44+
"default": true,
45+
"description": "Show bullets icon in title bar"
46+
},
47+
"markdownShortcuts.icons.link": {
48+
"type": "boolean",
49+
"default": false,
50+
"description": "Show link icon in title bar"
51+
},
52+
"markdownShortcuts.icons.image": {
53+
"type": "boolean",
54+
"default": false,
55+
"description": "Show image icon in title bar"
56+
}
57+
}
58+
},
2359
"commands": [
24-
2560
{
2661
"command": "md-shortcut.toggleBold",
2762
"title": "Toggle bold",
@@ -72,6 +107,15 @@
72107
},
73108
"category": "Markdown Shortcuts"
74109
},
110+
{
111+
"command": "md-shortcut.toggleImage",
112+
"title": "Toggle image",
113+
"icon": {
114+
"dark": "./media/icons/image_white.svg",
115+
"light": "./media/icons/image_black.svg"
116+
},
117+
"category": "Markdown Shortcuts"
118+
},
75119
{
76120
"command": "md-shortcut.toggleBullets",
77121
"title": "Toggle bullet points",
@@ -139,6 +183,11 @@
139183
"key": "ctrl+l",
140184
"when": "editorTextFocus && editorLangId == 'markdown'"
141185
},
186+
{
187+
"command": "md-shortcut.toggleImage",
188+
"key": "ctrl+shift+l",
189+
"when": "editorTextFocus && editorLangId == 'markdown'"
190+
},
142191
{
143192
"command": "md-shortcut.toggleCodeBlock",
144193
"key": "ctrl+m ctrl+c",
@@ -188,15 +237,20 @@
188237
"group": "2_markdown_1@4"
189238
},
190239
{
191-
"command": "md-shortcut.toggleCodeBlock",
240+
"command": "md-shortcut.toggleImage",
192241
"when": "editorLangId == 'markdown'",
193242
"group": "2_markdown_1@5"
194243
},
195244
{
196-
"command": "md-shortcut.toggleInlineCode",
245+
"command": "md-shortcut.toggleCodeBlock",
197246
"when": "editorLangId == 'markdown'",
198247
"group": "2_markdown_1@6"
199248
},
249+
{
250+
"command": "md-shortcut.toggleInlineCode",
251+
"when": "editorLangId == 'markdown'",
252+
"group": "2_markdown_1@7"
253+
},
200254
{
201255
"command": "md-shortcut.toggleBullets",
202256
"when": "editorLangId == 'markdown'",
@@ -226,23 +280,33 @@
226280
"editor/title": [
227281
{
228282
"command": "md-shortcut.toggleBold",
229-
"when": "editorLangId == 'markdown'",
283+
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.bold",
230284
"group": "navigation@1"
231285
},
232286
{
233287
"command": "md-shortcut.toggleItalic",
234-
"when": "editorLangId == 'markdown'",
288+
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.italic",
235289
"group": "navigation@2"
236290
},
237291
{
238292
"command": "md-shortcut.toggleStrikethrough",
239-
"when": "editorLangId == 'markdown'",
293+
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.strikethrough",
240294
"group": "navigation@3"
241295
},
242296
{
243297
"command": "md-shortcut.toggleBullets",
244-
"when": "editorLangId == 'markdown'",
298+
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.bullets",
245299
"group": "navigation@4"
300+
},
301+
{
302+
"command": "md-shortcut.toggleLink",
303+
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.link",
304+
"group": "navigation@5"
305+
},
306+
{
307+
"command": "md-shortcut.toggleImage",
308+
"when": "editorLangId == 'markdown' && config.markdownShortcuts.icons.image",
309+
"group": "navigation@6"
246310
}
247311
]
248312
}

0 commit comments

Comments
 (0)