move useHotkey for undo/redo into App
This commit is contained in:
11
src/App.tsx
11
src/App.tsx
@ -29,6 +29,7 @@ import {
|
|||||||
codeManager,
|
codeManager,
|
||||||
kclManager,
|
kclManager,
|
||||||
settingsActor,
|
settingsActor,
|
||||||
|
editorManager,
|
||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { maybeWriteToDisk } from '@src/lib/telemetry'
|
import { maybeWriteToDisk } from '@src/lib/telemetry'
|
||||||
import type { IndexLoaderData } from '@src/lib/types'
|
import type { IndexLoaderData } from '@src/lib/types'
|
||||||
@ -94,6 +95,16 @@ export function App() {
|
|||||||
useHotkeys('backspace', (e) => {
|
useHotkeys('backspace', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
// Since these already exist in the editor, we don't need to define them
|
||||||
|
// with the wrapper.
|
||||||
|
useHotkeys('mod+z', (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
editorManager.undo()
|
||||||
|
})
|
||||||
|
useHotkeys('mod+shift+z', (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
editorManager.redo()
|
||||||
|
})
|
||||||
useHotkeyWrapper(
|
useHotkeyWrapper(
|
||||||
[isDesktop() ? 'mod + ,' : 'shift + mod + ,'],
|
[isDesktop() ? 'mod + ,' : 'shift + mod + ,'],
|
||||||
() => navigate(filePath + PATHS.SETTINGS),
|
() => navigate(filePath + PATHS.SETTINGS),
|
||||||
|
@ -75,17 +75,6 @@ export const KclEditorPane = () => {
|
|||||||
: context.app.theme.current
|
: context.app.theme.current
|
||||||
const { copilotLSP, kclLSP } = useLspContext()
|
const { copilotLSP, kclLSP } = useLspContext()
|
||||||
|
|
||||||
// Since these already exist in the editor, we don't need to define them
|
|
||||||
// with the wrapper.
|
|
||||||
useHotkeys('mod+z', (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
editorManager.undo()
|
|
||||||
})
|
|
||||||
useHotkeys('mod+shift+z', (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
editorManager.redo()
|
|
||||||
})
|
|
||||||
|
|
||||||
// When this component unmounts, we need to tell the machine that the editor
|
// When this component unmounts, we need to tell the machine that the editor
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
Reference in New Issue
Block a user