mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-11 19:28:33 +00:00
fix(app): skip editor reconcile during IME composition (#17041)
This commit is contained in:
@@ -490,6 +490,18 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
setComposing(false)
|
setComposing(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleCompositionStart = () => {
|
||||||
|
setComposing(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCompositionEnd = () => {
|
||||||
|
setComposing(false)
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (composing()) return
|
||||||
|
reconcile(prompt.current().filter((part) => part.type !== "image"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const agentList = createMemo(() =>
|
const agentList = createMemo(() =>
|
||||||
sync.data.agent
|
sync.data.agent
|
||||||
.filter((agent) => !agent.hidden && agent.mode !== "primary")
|
.filter((agent) => !agent.hidden && agent.mode !== "primary")
|
||||||
@@ -680,24 +692,27 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const reconcile = (input: Prompt) => {
|
||||||
|
if (mirror.input) {
|
||||||
|
mirror.input = false
|
||||||
|
if (isNormalizedEditor()) return
|
||||||
|
|
||||||
|
renderEditorWithCursor(input)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const dom = parseFromDOM()
|
||||||
|
if (isNormalizedEditor() && isPromptEqual(input, dom)) return
|
||||||
|
|
||||||
|
renderEditorWithCursor(input)
|
||||||
|
}
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
() => prompt.current(),
|
() => prompt.current(),
|
||||||
(currentParts) => {
|
(parts) => {
|
||||||
const inputParts = currentParts.filter((part) => part.type !== "image")
|
if (composing()) return
|
||||||
|
reconcile(parts.filter((part) => part.type !== "image"))
|
||||||
if (mirror.input) {
|
|
||||||
mirror.input = false
|
|
||||||
if (isNormalizedEditor()) return
|
|
||||||
|
|
||||||
renderEditorWithCursor(inputParts)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const domParts = parseFromDOM()
|
|
||||||
if (isNormalizedEditor() && isPromptEqual(inputParts, domParts)) return
|
|
||||||
|
|
||||||
renderEditorWithCursor(inputParts)
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -1208,8 +1223,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
spellcheck={store.mode === "normal"}
|
spellcheck={store.mode === "normal"}
|
||||||
onInput={handleInput}
|
onInput={handleInput}
|
||||||
onPaste={handlePaste}
|
onPaste={handlePaste}
|
||||||
onCompositionStart={() => setComposing(true)}
|
onCompositionStart={handleCompositionStart}
|
||||||
onCompositionEnd={() => setComposing(false)}
|
onCompositionEnd={handleCompositionEnd}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
classList={{
|
classList={{
|
||||||
|
|||||||
Reference in New Issue
Block a user