In the Experience Editor, clicking the default button "Insert an external link into the text field" on the ribbon of a Rich Text field might fail with an unhandled exception.
The following error can be found in the log records:
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: html
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.ExperienceEditor.Web.LinkConverter.LinkConverter.ConvertHtmlToXmlLink(String html)
at Sitecore.Shell.Applications.WebEdit.Commands.InsertExternalLink.Run(ClientPipelineArgs args)
Note: the same issue occurs when trying to add an external link in the message Edit Body dialog in Email Experience Manager (EXM).
To resolve the issue, consider upgrading the Sitecore XP instance to Sitecore XP 9.3 or later.
Alternatively, consider the following solution:
Sitecore.PageModes.PageEditor.postRequest(
message +
'(itemid=' +
itemid +
',language=' +
language +
',version=' +
version +
',fieldid=' +
fieldid +
',controlid=' +
controlid +
(message === "webedit:insertexternallink" ? ',selection=' + this.getSelectedHtml() : "") +
',webeditparams=' +
parameters +
')',