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