Text Formatter: Fix unexpected appearance and emoji wrapping (#1911)
This commit is contained in:
parent
8569c8a1fb
commit
fc4c529e8e
@ -204,9 +204,14 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
openTextFormatter();
|
openTextFormatter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processSelectionWithTimeout() {
|
||||||
|
// Small delay to allow browser properly recalculate selection
|
||||||
|
setTimeout(processSelection, 1);
|
||||||
|
}
|
||||||
|
|
||||||
function handleMouseDown(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
function handleMouseDown(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||||
if (e.button !== 2) {
|
if (e.button !== 2) {
|
||||||
e.target.addEventListener('mouseup', processSelection, { once: true });
|
e.target.addEventListener('mouseup', processSelectionWithTimeout, { once: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +266,7 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
editLastMessage();
|
editLastMessage();
|
||||||
} else {
|
} else {
|
||||||
e.target.addEventListener('keyup', processSelection, { once: true });
|
e.target.addEventListener('keyup', processSelectionWithTimeout, { once: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +388,7 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
onContextMenu={IS_ANDROID ? stopEvent : undefined}
|
onContextMenu={IS_ANDROID ? stopEvent : undefined}
|
||||||
onTouchCancel={IS_ANDROID ? processSelection : undefined}
|
onTouchCancel={IS_ANDROID ? processSelectionWithTimeout : undefined}
|
||||||
aria-label={placeholder}
|
aria-label={placeholder}
|
||||||
/>
|
/>
|
||||||
<div ref={cloneRef} className={buildClassName(className, 'clone')} dir="auto" />
|
<div ref={cloneRef} className={buildClassName(className, 'clone')} dir="auto" />
|
||||||
|
|||||||
@ -133,8 +133,7 @@ const TextFormatter: FC<OwnProps> = ({
|
|||||||
if (!selectedRange) {
|
if (!selectedRange) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
fragmentEl.innerText = selectedRange.toString();
|
fragmentEl.replaceChildren(selectedRange.cloneContents());
|
||||||
|
|
||||||
return fragmentEl.innerHTML;
|
return fragmentEl.innerHTML;
|
||||||
}, [selectedRange]);
|
}, [selectedRange]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user