When I have an image surrounded by a link (<a ...><img ... /></a>), clicking on the image only selects the image. I have certain circumstances where I need to include the link in the selection, so I have tried to use this javascript. It works fine in Firefox (and not at all in IE because IE selection is lost when there is no text selected, see this old thread), but in Chrome the selection is not changed to include the <a> link.
console.log(editor.getSelectedElement().tagName);
// "IMG"
var
element = editor.getSelectedElement();
if
(element.tagName ==
"IMG"
&& element.parentNode && element.parentNode.tagName ==
"A"
) {
console.log(element.parentNode.tagName);
// "A"
editor.selectElement(element.parentNode.parentNode); // does nothing
}
console.log(editor.getSelectedElement().tagName);
// "IMG"