-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Allow wrapping an image in a link #1577
FIX Allow wrapping an image in a link #1577
Conversation
|
||
// If the selected node type can contain text, and we didn't find selected text above, | ||
// then you haven't got a selection we can wrap in a link. | ||
const x = document.createElement(node.nodeName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of this? Seems like it will will always return false since we're just testing an element we're creating ourselves? Or is there some sort of difference between browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're essentially getting the browser to check for us if this node can have text. If it can have text, and we didn't have any text selected, then this selection isn't valid for wrapping a link, since we'd want the link to wrap the text.
If this element cannot have text, then we go into the next set of conditional statements to see if this is an element that can be wrapped inside a link (like img), or if it's something that cannot (like iframe or another link)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK sorry I totally missed the bit where node
is variable :)
// Check if there is a single selected node which can be wrapped in a link. | ||
if (node === selection.getSel().focusNode && node === selection.getSel().anchorNode) { | ||
const parsed = tinymce.activeEditor.dom.createFragment(`<a>${node.outerHTML}</a>`); | ||
if (parsed.childNodes.length === 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again this seems really odd because we're testing the length of something that we're creating ourselves that seems like it will always return the same result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, except for this one we need tinymce to check if for us instead since tinymce may have its own parsing rules and allowed combinations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, works good
Supercedes #1571
Make sure you check the installer CI run linked in the issue to see behat passing happily
Required for
Issue