chore(deps): sync upstream changes (2026-08-26) #5
3 changed files with 8 additions and 8 deletions
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
commit
c434e0dda3
|
|
@ -241,15 +241,15 @@ export const getPointUntilChar = (
|
||||||
return targetPoint;
|
return targetPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPrevWorldRange = (editor: Editor): BaseRange | undefined => {
|
export const getPrevWordRange = (editor: Editor): BaseRange | undefined => {
|
||||||
const { selection } = editor;
|
const { selection } = editor;
|
||||||
if (!selection || !Range.isCollapsed(selection)) return undefined;
|
if (!selection || !Range.isCollapsed(selection)) return undefined;
|
||||||
const [cursorPoint] = Range.edges(selection);
|
const [cursorPoint] = Range.edges(selection);
|
||||||
const worldStartPoint = getPointUntilChar(editor, cursorPoint, {
|
const wordStartPoint = getPointUntilChar(editor, cursorPoint, {
|
||||||
reverse: true,
|
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 => {
|
export const isEmptyEditor = (editor: Editor): boolean => {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import {
|
||||||
AutocompletePrefix,
|
AutocompletePrefix,
|
||||||
AutocompleteQuery,
|
AutocompleteQuery,
|
||||||
getAutocompleteQuery,
|
getAutocompleteQuery,
|
||||||
getPrevWorldRange,
|
getPrevWordRange,
|
||||||
resetEditor,
|
resetEditor,
|
||||||
RoomMentionAutocomplete,
|
RoomMentionAutocomplete,
|
||||||
UserMentionAutocomplete,
|
UserMentionAutocomplete,
|
||||||
|
|
@ -411,7 +411,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||||
sendTypingStatus(!isEmptyEditor(editor));
|
sendTypingStatus(!isEmptyEditor(editor));
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevWordRange = getPrevWorldRange(editor);
|
const prevWordRange = getPrevWordRange(editor);
|
||||||
const query = prevWordRange
|
const query = prevWordRange
|
||||||
? getAutocompleteQuery<AutocompletePrefix>(editor, prevWordRange, AUTOCOMPLETE_PREFIXES)
|
? getAutocompleteQuery<AutocompletePrefix>(editor, prevWordRange, AUTOCOMPLETE_PREFIXES)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import {
|
||||||
createEmoticonElement,
|
createEmoticonElement,
|
||||||
customHtmlEqualsPlainText,
|
customHtmlEqualsPlainText,
|
||||||
getAutocompleteQuery,
|
getAutocompleteQuery,
|
||||||
getPrevWorldRange,
|
getPrevWordRange,
|
||||||
htmlToEditorInput,
|
htmlToEditorInput,
|
||||||
moveCursor,
|
moveCursor,
|
||||||
plainToEditorInput,
|
plainToEditorInput,
|
||||||
|
|
@ -187,7 +187,7 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevWordRange = getPrevWorldRange(editor);
|
const prevWordRange = getPrevWordRange(editor);
|
||||||
const query = prevWordRange
|
const query = prevWordRange
|
||||||
? getAutocompleteQuery<AutocompletePrefix>(editor, prevWordRange, AUTOCOMPLETE_PREFIXES)
|
? getAutocompleteQuery<AutocompletePrefix>(editor, prevWordRange, AUTOCOMPLETE_PREFIXES)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue