fix prompt input ctrl + z

This commit is contained in:
Qing 2022-09-22 22:37:41 +08:00
parent 5be91edf9d
commit 5429bf2e87
3 changed files with 17 additions and 3 deletions

View File

@ -640,6 +640,10 @@ export default function Editor(props: EditorProps) {
// Handle Cmd+Z // Handle Cmd+Z
const undoPredicate = (event: KeyboardEvent) => { const undoPredicate = (event: KeyboardEvent) => {
// TODO: fix prompt input ctrl+z
if (isSD) {
return false
}
const isCmdZ = const isCmdZ =
(event.metaKey || event.ctrlKey) && !event.shiftKey && event.key === 'z' (event.metaKey || event.ctrlKey) && !event.shiftKey && event.key === 'z'
// Handle tab switch // Handle tab switch
@ -654,7 +658,7 @@ export default function Editor(props: EditorProps) {
return false return false
} }
useKey(undoPredicate, undo, undefined, [undoStroke, undoRender]) useKey(undoPredicate, undo, undefined, [undoStroke, undoRender, isSD])
const disableUndo = () => { const disableUndo = () => {
if (isInpainting) { if (isInpainting) {
@ -714,6 +718,9 @@ export default function Editor(props: EditorProps) {
// Handle Cmd+shift+Z // Handle Cmd+shift+Z
const redoPredicate = (event: KeyboardEvent) => { const redoPredicate = (event: KeyboardEvent) => {
if (isSD) {
return false
}
const isCmdZ = const isCmdZ =
(event.metaKey || event.ctrlKey) && (event.metaKey || event.ctrlKey) &&
event.shiftKey && event.shiftKey &&
@ -730,7 +737,7 @@ export default function Editor(props: EditorProps) {
return false return false
} }
useKey(redoPredicate, redo, undefined, [redoStroke, redoRender]) useKey(redoPredicate, redo, undefined, [redoStroke, redoRender, isSD])
const disableRedo = () => { const disableRedo = () => {
if (isInpainting) { if (isInpainting) {

View File

@ -32,12 +32,19 @@ const PromptInput = () => {
} }
}) })
const onKeyUp = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
handleRepaintClick()
}
}
return ( return (
<div className="prompt-wrapper"> <div className="prompt-wrapper">
<TextInput <TextInput
ref={ref} ref={ref}
value={prompt} value={prompt}
onInput={handleOnInput} onInput={handleOnInput}
onKeyUp={onKeyUp}
placeholder="I want to repaint of..." placeholder="I want to repaint of..."
/> />
<Button <Button

View File

@ -12,7 +12,7 @@ const INPUT_WIDTH = 30
// TODO: 添加收起来的按钮 // TODO: 添加收起来的按钮
const SidePanel = () => { const SidePanel = () => {
const [open, toggleOpen] = useToggle(false) const [open, toggleOpen] = useToggle(true)
const [setting, setSettingState] = useRecoilState(settingState) const [setting, setSettingState] = useRecoilState(settingState)
return ( return (