diff --git a/src/ts/app.tsx b/src/ts/app.tsx index aae9c30eb7..c6d28483d1 100644 --- a/src/ts/app.tsx +++ b/src/ts/app.tsx @@ -596,10 +596,20 @@ class App extends React.Component { const value = String(obj.get(0).innerText || ''); S.Block.updateContent(rootId, focused, { text: value }); - U.Data.blockInsertText(rootId, focused, item.id, range.from, range.to); - focus.set(focused, { from: range.from, to: range.from + item.id.length }); - focus.apply(); + // Find the first occurrence of the misspelled word in the value + const wordIndex = value.indexOf(misspelledWord); + if (wordIndex !== -1) { + U.Data.blockInsertText( + rootId, + focused, + item.id, + wordIndex, + wordIndex + misspelledWord.length + ); + focus.set(focused, { from: wordIndex, to: wordIndex + item.id.length }); + focus.apply(); + } } else if (isInput || isTextarea || isEditable) { let value = '';