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:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user