feat: add some keyboard shortcuts for markdown
This commit is contained in:
1 parent
7003badaa5
commit
5b4cf4de08
1 file changed
+20
@@ -82,6 +82,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let previewing = false
|
let previewing = false
|
||||||
|
|
||||||
|
const shortcuts = {
|
||||||
|
KeyB: () => wrapSelection('**', '**'),
|
||||||
|
KeyI: () => wrapSelection('*', '*'),
|
||||||
|
KeyS: () => wrapSelection('~~', '~~'),
|
||||||
|
KeyH: () => wrapSelection('\n# ', ''),
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if uploadingImage && images}
|
{#if uploadingImage && images}
|
||||||
@@ -96,6 +103,19 @@
|
|||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<svelte:body
|
||||||
|
on:keydown={(e) => {
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
// @ts-ignore
|
||||||
|
let shortcut = shortcuts[e.code]
|
||||||
|
if (shortcut) {
|
||||||
|
e.preventDefault()
|
||||||
|
shortcut?.()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{#if label}
|
{#if label}
|
||||||
<div class="block my-1 font-bold text-sm">{label}</div>
|
<div class="block my-1 font-bold text-sm">{label}</div>
|
||||||
|
|||||||
Reference in new issue
Block a user