fix: emoji autocompletion overwriting preceding element (#3064)

* fix getPrevWorldRange to exclude empty text children

this prevents the range from encroaching on the node of elements like emojis and pings to prevent them from being overwritten

* fix typo of "word" as "world"

* trigger pr checks
This commit is contained in:
wjaaaaaaat
2026-08-11 14:23:15 +10:00
committed by GitHub
parent 33f4ba3674
commit c434e0dda3
3 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -241,15 +241,15 @@ export const getPointUntilChar = (
return targetPoint;
};
export const getPrevWorldRange = (editor: Editor): BaseRange | undefined => {
export const getPrevWordRange = (editor: Editor): BaseRange | undefined => {
const { selection } = editor;
if (!selection || !Range.isCollapsed(selection)) return undefined;
const [cursorPoint] = Range.edges(selection);
const worldStartPoint = getPointUntilChar(editor, cursorPoint, {
const wordStartPoint = getPointUntilChar(editor, cursorPoint, {
reverse: true,
match: (char) => char === ' ',
match: (char) => char === ' ' || char === '',
});
return worldStartPoint && Editor.range(editor, worldStartPoint, cursorPoint);
return wordStartPoint && Editor.range(editor, wordStartPoint, cursorPoint);
};
export const isEmptyEditor = (editor: Editor): boolean => {