chore: add shortcut keys and hints for the shortcuts (#6779)

This commit is contained in:
非法操作 2024-07-30 16:18:58 +08:00 committed by GitHub
parent 72963d1f13
commit 0675c5f716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -30,7 +30,7 @@ const UndoRedo: FC<UndoRedoProps> = ({ handleUndo, handleRedo }) => {
return (
<div className='flex items-center p-0.5 rounded-lg border-[0.5px] border-gray-100 bg-white shadow-lg text-gray-500'>
<TipPopup title={t('workflow.common.undo')!} >
<TipPopup title={t('workflow.common.undo')!} shortcuts={['ctrl', 'z']}>
<div
data-tooltip-id='workflow.undo'
className={`
@ -43,7 +43,7 @@ const UndoRedo: FC<UndoRedoProps> = ({ handleUndo, handleRedo }) => {
<RiArrowGoBackLine className='h-4 w-4' />
</div>
</TipPopup>
<TipPopup title={t('workflow.common.redo')!} >
<TipPopup title={t('workflow.common.redo')!} shortcuts={['ctrl', 'y']}>
<div
data-tooltip-id='workflow.redo'
className={`

View File

@ -16,7 +16,7 @@ import {
useSelectionInteractions,
useWorkflow,
} from '../hooks'
import { isEventTargetInputArea } from '../utils'
import { getKeyboardKeyCodeBySystem, isEventTargetInputArea } from '../utils'
import { useStore } from '../store'
import AddBlock from './add-block'
import TipPopup from './tip-popup'
@ -78,6 +78,11 @@ const Control = () => {
handleLayout()
}
useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.o`, (e) => {
e.preventDefault()
goLayout()
}, { exactMatch: true, useCapture: true })
const addNote = (e: MouseEvent<HTMLDivElement>) => {
if (getNodesReadOnly())
return
@ -101,7 +106,7 @@ const Control = () => {
</div>
</TipPopup>
<div className='mx-[3px] w-[1px] h-3.5 bg-gray-200'></div>
<TipPopup title={t('workflow.common.pointerMode')}>
<TipPopup title={t('workflow.common.pointerMode')} shortcuts={['v']}>
<div
className={cn(
'flex items-center justify-center mr-[1px] w-8 h-8 rounded-lg cursor-pointer',
@ -113,7 +118,7 @@ const Control = () => {
<RiCursorLine className='w-4 h-4' />
</div>
</TipPopup>
<TipPopup title={t('workflow.common.handMode')}>
<TipPopup title={t('workflow.common.handMode')} shortcuts={['h']}>
<div
className={cn(
'flex items-center justify-center w-8 h-8 rounded-lg cursor-pointer',
@ -126,7 +131,7 @@ const Control = () => {
</div>
</TipPopup>
<div className='mx-[3px] w-[1px] h-3.5 bg-gray-200'></div>
<TipPopup title={t('workflow.panel.organizeBlocks')}>
<TipPopup title={t('workflow.panel.organizeBlocks')} shortcuts={['ctrl', 'o']}>
<div
className={cn(
'flex items-center justify-center w-8 h-8 rounded-lg hover:bg-black/5 hover:text-gray-700 cursor-pointer',