Skip to content

Commit

Permalink
优化VS Code内编辑体验
Browse files Browse the repository at this point in the history
  • Loading branch information
cweijan committed Jul 10, 2024
1 parent d11078a commit ae1b9f1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions resource/vditor/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function getToolbar(resPath) {
{ name: 'upload', tipPosition: 'e' },
"|",
{
name:'selectTheme',
name: 'selectTheme',
tipPosition: 's', tip: 'Select Theme',
icon: 'Theme:',
click() {
Expand Down Expand Up @@ -291,11 +291,13 @@ export const autoSymbol = (handler, editor) => {
}
}
const isMac = navigator.userAgent.includes('Mac OS');
window.onkeydown = (e) => {
window.addEventListener('keydown', e => {
if (isMac && isCompose(e) && e.altKey) {
e.preventDefault()
}
if (matchShortcut('^⌘e', e) || matchShortcut('^!e', e)) {
e.stopPropagation();
e.preventDefault();
return handler.emit("editInVSCode", true);
}
if (e.code == 'F12') return handler.emit('developerTool')
Expand Down Expand Up @@ -331,7 +333,7 @@ export const autoSymbol = (handler, editor) => {
document.execCommand('insertText', false, e.key);
document.getSelection().modify('move', 'left', 'character')
}
}
}, true)

window.onresize = () => {
document.getElementById('vditor').style.height = `${document.documentElement.clientHeight}px`
Expand Down

0 comments on commit ae1b9f1

Please sign in to comment.