Skip to content

Commit b540e7c

Browse files
committed
Add hotkey for code block
1 parent 1f58670 commit b540e7c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ class MarkdownCodeButtonElement extends MarkdownButtonElement {
181181
super()
182182
styles.set(this, {prefix: '`', suffix: '`', blockPrefix: '```', blockSuffix: '```'})
183183
}
184+
185+
connectedCallback() {
186+
super.connectedCallback()
187+
this.setAttribute('hotkey', 'C')
188+
}
184189
}
185190

186191
if (!window.customElements.get('md-code')) {

test/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,13 @@ describe('markdown-toolbar-element', function () {
614614
assert.equal("`|puts 'Hello, world!'|`", visualValue())
615615
})
616616

617+
it('surrounds a line with backticks via hotkey', function () {
618+
focus()
619+
setVisualValue("|puts 'Hello, world!'|")
620+
pressHotkey('C')
621+
assert.equal("`|puts 'Hello, world!'|`", visualValue())
622+
})
623+
617624
it('surrounds multiple lines with triple backticks if you click the code icon', function () {
618625
setVisualValue('|class Greeter\n def hello_world\n "Hello World!"\n end\nend|')
619626
clickToolbar('md-code')

0 commit comments

Comments
 (0)