diff --git a/src/components/InlineWikilinkInput.tsx b/src/components/InlineWikilinkInput.tsx
index 04b5ff07..174ddc10 100644
--- a/src/components/InlineWikilinkInput.tsx
+++ b/src/components/InlineWikilinkInput.tsx
@@ -201,11 +201,6 @@ export function InlineWikilinkInput({
onSelectionIndexChange: (nextSelectionIndex) => setSelectionRange(collapseSelectionRange(nextSelectionIndex)),
focusSelectionAt: (nextSelectionIndex) => focusSelectionRange(collapseSelectionRange(nextSelectionIndex)),
})
- const insertText = (text: string) => {
- const nextState = replaceInlineSelection(value, selectionRange, text)
- onChange(nextState.value)
- setSelectionRange(nextState.selection)
- }
const insertTransferText = (text: string) => {
const currentSelectionRange = editorRef.current
? readSelectionRange(editorRef.current)
@@ -363,7 +358,6 @@ export function InlineWikilinkInput({
onCycleSuggestions: cycleSuggestions,
onSelectSuggestion: () => selectSuggestion(selectedSuggestionIndex),
onDeleteContent: deleteContent,
- onInsertText: insertText,
canSubmit: onSubmit !== undefined,
onSubmit: submitValue,
})
diff --git a/src/components/WikilinkChatInput.test.tsx b/src/components/WikilinkChatInput.test.tsx
index f6d28009..305d58d5 100644
--- a/src/components/WikilinkChatInput.test.tsx
+++ b/src/components/WikilinkChatInput.test.tsx
@@ -299,6 +299,32 @@ describe('WikilinkChatInput', () => {
removeAllRanges.mockRestore()
})
+ it('lets committed composed characters reach the native input pipeline once', () => {
+ const onDraftChange = vi.fn()
+ render()
+ const editor = screen.getByTestId('agent-input')
+ editor.focus()
+
+ const portugueseText = 'á é í ç ã õ'
+ const accentedKey = createEvent.keyDown(editor, { key: 'á' })
+ fireEvent(editor, accentedKey)
+ expect(accentedKey.defaultPrevented).toBe(false)
+
+ editor.textContent = portugueseText
+ setSelection(editor, portugueseText.length)
+ fireEvent.input(editor)
+ expect(onDraftChange).toHaveBeenLastCalledWith(portugueseText)
+
+ const cjkKey = createEvent.keyDown(editor, { key: '你' })
+ fireEvent(editor, cjkKey)
+ expect(cjkKey.defaultPrevented).toBe(false)
+
+ editor.textContent = `${portugueseText}你`
+ setSelection(editor, portugueseText.length + 1)
+ fireEvent.input(editor)
+ expect(onDraftChange).toHaveBeenLastCalledWith(`${portugueseText}你`)
+ })
+
it('deletes an inline chip with a single Backspace', () => {
render()
updateEditorText('edit my [[alp')
diff --git a/src/components/inlineWikilinkKeydown.ts b/src/components/inlineWikilinkKeydown.ts
index ee500120..5bf64a1c 100644
--- a/src/components/inlineWikilinkKeydown.ts
+++ b/src/components/inlineWikilinkKeydown.ts
@@ -77,26 +77,6 @@ function handleDeleteKeys({
return false
}
-interface HandleInsertTextArgs {
- event: React.KeyboardEvent
- isComposing: boolean
- onInsertText: (text: string) => void
-}
-
-function handleInsertText({
- event,
- isComposing,
- onInsertText,
-}: HandleInsertTextArgs): boolean {
- if (event.metaKey || event.ctrlKey || event.altKey) return false
- if (isInlineWikilinkCompositionEvent(event, isComposing)) return false
- if (event.key.length !== 1) return false
-
- event.preventDefault()
- onInsertText(event.key)
- return true
-}
-
interface HandleSubmitKeyArgs {
event: React.KeyboardEvent
isComposing: boolean
@@ -127,7 +107,6 @@ interface HandleInlineWikilinkKeyDownArgs {
onCycleSuggestions: (direction: 1 | -1) => void
onSelectSuggestion: () => void
onDeleteContent: (direction: 'backward' | 'forward') => void
- onInsertText: (text: string) => void
canSubmit: boolean
onSubmit: () => void
}
@@ -140,7 +119,6 @@ export function handleInlineWikilinkKeyDown({
onCycleSuggestions,
onSelectSuggestion,
onDeleteContent,
- onInsertText,
canSubmit,
onSubmit,
}: HandleInlineWikilinkKeyDownArgs) {
@@ -160,9 +138,5 @@ export function handleInlineWikilinkKeyDown({
return
}
- if (handleInsertText({ event, isComposing, onInsertText })) {
- return
- }
-
handleSubmitKey({ event, isComposing, canSubmit, onSubmit })
}