1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-07 21:47:02 +09:00

fix: replace misspelled word with correct spelling at correct position in spellcheck context menu

This commit is contained in:
Andrew Simachev 2025-06-05 14:14:39 +02:00
parent 4dd52a38f2
commit d6555dac7d
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF

View file

@ -596,10 +596,20 @@ class App extends React.Component<object, State> {
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 = '';