If pasting a url atop another url, don't wrap one in the other (#8642)

This commit is contained in:
Michael Telatynski 2022-05-18 10:08:24 +01:00 committed by GitHub
parent f427f09b8b
commit 65e27cd6be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -354,7 +354,8 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
this.modifiedFlag = true;
const range = getRangeForSelection(this.editorRef.current, model, document.getSelection());
if (plainText && range.length > 0 && linkify.test(plainText)) {
// If the user is pasting a link, and has a range selected which is not a link, wrap the range with the link
if (plainText && range.length > 0 && linkify.test(plainText) && !linkify.test(range.text)) {
formatRangeAsLink(range, plainText);
} else {
replaceRangeAndMoveCaret(range, parts);