Description: The error is thrown when I add a custom link into a slate editor at current cursor position and use tab or space after the inserted link.
This is the code I am using to add my custom link DOM element into slate editor at current cursor position.
window.addEventListener("message", (event) => {
var linkDOMElement = document.getElementById('insertLink');
if (!linkDOMElement) {
var range;
if (event.data && (typeof event.data === 'string' || event.data instanceof String) && event.data.includes("atProspectId") && window.getSelection) {
var range = window.getSelection().getRangeAt(0);
var html = event.data;
// create a span dom element
var newElement = document.createElement('span');
newElement.id = 'insertLink';
newElement.innerHTML = html;
// insert created dom element named newElement at current cursor position
range.insertNode(newElement);
}
}
}, false);
Scenario: We have a script which attaches our custom icon to the outreach email editor and apparently outreach email editor uses slate editor. After clicking upon this icon, it opens our extension application in a new tab[for now]. If user clicks on "INSERT LINK" button, link should be inserted at current cursor position which is happening as expected. But, I am unable to click the link and write any texts further after the insertion. If I use space or tab after the link insertion, this error shows up. You could see this clearly in the attached video.
Environment:
Slate Version: No idea as this is happening in third party website Operating System: Windows Browser: Chrome
To see how the above error is thrown, you could click on the following link and watch 43 secs video.