From 650ceb439f48cca789c6d0fd51ef3ec2321107d4 Mon Sep 17 00:00:00 2001 From: Yang Libin Date: Thu, 25 Nov 2021 21:14:47 +0800 Subject: [PATCH] feat: support some keyboard shortcuts (#100) - `Ctrl-B` - `Ctrl-D` - `Ctrl-I` --- src/store/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index c10b9b3..4c79991 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -100,6 +100,18 @@ const mutations = { editor.setValue(doc); }, "Ctrl-S": function save(editor) {}, + "Ctrl-B": function bold(editor) { + const selected = editor.getSelection(); + editor.replaceSelection(`**${selected}**`); + }, + "Ctrl-D": function del(editor) { + const selected = editor.getSelection(); + editor.replaceSelection(`~~${selected}~~`); + }, + "Ctrl-I": function italic(editor) { + const selected = editor.getSelection(); + editor.replaceSelection(`*${selected}*`); + } }, }); },