mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: add shortcuts for switching editor tab
This commit is contained in:
@@ -48,6 +48,7 @@ Edit Table Cell (Popup) | Ctrl/Cmd + Click
|
||||
Copy Heading link | Ctrl/Cmd + Click Heading
|
||||
Switch Editor Tab | Ctrl/Cmd + Alt/Option + Left/Right
|
||||
Close Editor Current Tab | TABS-CLOSE-CURRENT
|
||||
Switch Editor Current Tab | Ctrl + 0-9
|
||||
Toggle Sidebar | Alt/Option + E
|
||||
Toggle Word Wrap | Alt/Option + W
|
||||
Toggle Preview | Alt/Option + V
|
||||
@@ -100,6 +101,7 @@ Switch Repository | Alt/Option + 0-9
|
||||
复制文档标题链接 | Ctrl/Cmd + 单击标题
|
||||
切换编辑器 Tab | Ctrl/Cmd + Alt/Option + Left/Right
|
||||
关闭编辑器当前标签 Tab | TABS-CLOSE-CURRENT
|
||||
切换编辑器当前标签 | Ctrl + 0-9
|
||||
切换侧栏 | Alt/Option + E
|
||||
切换编辑器自动换行 | Alt/Option + W
|
||||
切换文档预览显示 | Alt/Option + V
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import Sortable from 'sortablejs'
|
||||
import { computed, defineComponent, nextTick, onMounted, ref, watch } from 'vue'
|
||||
import { computed, defineComponent, nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useContextMenu } from '@fe/support/ui/context-menu'
|
||||
import { useI18n } from '@fe/services/i18n'
|
||||
import type { Components } from '@fe/types'
|
||||
@@ -131,8 +131,28 @@ export default defineComponent({
|
||||
])
|
||||
}
|
||||
|
||||
function handleKeydown (e: KeyboardEvent) {
|
||||
if (e.ctrlKey && !e.altKey && !e.metaKey && e.code.startsWith('Digit')) {
|
||||
const tabIndex = Number(e.code.substring(5)) - 1
|
||||
|
||||
const tab = props.list[tabIndex === -1 ? props.list.length - 1 : tabIndex]
|
||||
if (tab) {
|
||||
switchTab(tab)
|
||||
}
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initSortable()
|
||||
window.addEventListener('keydown', handleKeydown, true)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('keydown', handleKeydown, true)
|
||||
sortable?.destroy()
|
||||
})
|
||||
|
||||
const tabList = computed(() => sortTabs(props.list))
|
||||
|
||||
Reference in New Issue
Block a user