feat: support some keyboard shortcuts (#100)

- `Ctrl-B`
- `Ctrl-D`
- `Ctrl-I`
This commit is contained in:
Yang Libin 2021-11-25 21:14:47 +08:00 committed by GitHub
parent c4235ad505
commit 650ceb439f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}*`);
}
},
});
},