fix: restore local edit prompt input handling
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-05-23 13:47:04 +08:00
parent 50890de38d
commit 862c0f2937

View File

@ -291,16 +291,6 @@ const stopLocalEditPromptTextEvent = (
event: React.SyntheticEvent<HTMLElement>
) => {
event.stopPropagation();
stopLocalEditPromptNativeEvent(event);
};
const stopLocalEditPromptNativeEvent = (
event: React.SyntheticEvent<HTMLElement>
) => {
const nativeEvent = event.nativeEvent as Event & {
stopImmediatePropagation?: () => void;
};
nativeEvent.stopPropagation?.();
nativeEvent.stopImmediatePropagation?.();
};
const FLOATING_TOOLBAR_SCALE = 0.8;
const IMAGE_EDIT_PANEL_SCALE = 0.5;
@ -2449,14 +2439,17 @@ export function ImageNode({
? top - promptStackHeight - 8
: top + height + 8;
const promptWidth = Math.min(Math.max(width, 236), 360);
const isEditing =
editingLocalEditRegionId === region.id || !region.prompt.trim();
return {
region,
isEditing: editingLocalEditRegionId === region.id || !region.prompt.trim(),
isEditing,
style: {
left,
top: Math.max(4, promptTop),
width: promptWidth,
zIndex: isEditing ? 190 : 170,
} satisfies React.CSSProperties,
};
});
@ -8010,7 +8003,6 @@ export function ImageNode({
autoComplete="off"
enterKeyHint="done"
lang="zh-CN"
onBeforeInputCapture={stopLocalEditPromptNativeEvent}
onBlur={(event) => {
const nextPrompt = event.currentTarget.value;
localEditPromptDraftRefs.current[region.id] =
@ -8037,7 +8029,6 @@ export function ImageNode({
event.stopPropagation();
event.currentTarget.focus({ preventScroll: true });
}}
onCompositionEndCapture={stopLocalEditPromptNativeEvent}
onCompositionEnd={(event) => {
stopLocalEditPromptTextEvent(event);
localEditPromptComposingRefs.current[region.id] =
@ -8045,13 +8036,11 @@ export function ImageNode({
localEditPromptDraftRefs.current[region.id] =
event.currentTarget.value;
}}
onCompositionStartCapture={stopLocalEditPromptNativeEvent}
onCompositionStart={(event) => {
stopLocalEditPromptTextEvent(event);
localEditPromptComposingRefs.current[region.id] =
true;
}}
onCompositionUpdateCapture={stopLocalEditPromptNativeEvent}
onCompositionUpdate={(event) => {
stopLocalEditPromptTextEvent(event);
}}
@ -8061,7 +8050,6 @@ export function ImageNode({
current === region.id ? current : region.id
);
}}
onInputCapture={stopLocalEditPromptNativeEvent}
onInput={(event) => {
stopLocalEditPromptTextEvent(event);
localEditPromptDraftRefs.current[region.id] =
@ -8072,7 +8060,6 @@ export function ImageNode({
localEditPromptDraftRefs.current[region.id] =
event.currentTarget.value;
}}
onKeyDownCapture={stopLocalEditPromptNativeEvent}
onKeyDown={(event) => {
stopLocalEditPromptTextEvent(event);
const isComposing =
@ -8102,7 +8089,6 @@ export function ImageNode({
setEditingLocalEditRegionId(null);
}
}}
onKeyUpCapture={stopLocalEditPromptNativeEvent}
onKeyUp={(event) => {
stopLocalEditPromptTextEvent(event);
}}
@ -8120,7 +8106,6 @@ export function ImageNode({
event.stopPropagation();
event.currentTarget.focus({ preventScroll: true });
}}
onPasteCapture={stopLocalEditPromptNativeEvent}
placeholder={`区域 ${region.index} 提示词`}
ref={(input) => {
localEditPromptInputRefs.current[region.id] = input;