Skip to content

Commit

Permalink
fix: add markdown copy modifier (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman authored Jun 11, 2024
1 parent 16f0c6e commit 1069ac1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pages/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<Editor v-on:change="handleChange" v-bind:initialCode="state.code"></Editor>
<Toolbar>
<Menu triggerLabel="Menu">
<MenuItem label="Copy as Markdown" @click="handleCopyAsMD"
modifier="⌘ + ⇧ + c"
/>
<MenuItem label="Copy as HTML" @click="handleCopyAsHTML" />
<MenuItem label="Save File" modifier="⌘ + s" @click="handleSaveFile" />
<MenuItem
Expand Down Expand Up @@ -106,6 +109,11 @@ onUnmounted(() => {
});
function shortcutListener(e) {
if (e.key === "c" && (e.ctrlKey || e.metaKey) && e.shiftKey) {
e.preventDefault();
return handleCopyAsMD();
}
if (e.key === "s" && (e.ctrlKey || e.metaKey) && e.shiftKey) {
e.preventDefault();
return handleSaveAsHTML();
Expand All @@ -122,6 +130,17 @@ function handleChange(code) {
localStorage.setItem(STORAGE_TOKEN, code);
}
async function handleCopyAsMD(){
if (!state.code) {
return;
}
await copy(state.code)
state.copied = true
setTimeout(() => {
state.copied = false;
}, 2500);
}
async function handleCopyAsHTML() {
if (!state.code) {
return;
Expand Down

0 comments on commit 1069ac1

Please sign in to comment.