-
Notifications
You must be signed in to change notification settings - Fork 333
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 TinyMCE edit link when link contains html #2993
Conversation
35a7fd0
to
799ebc0
Compare
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.
Thanks for tackling this - unfortunately there's some problems with the approach.
if (linkNode.nodeName !== 'A') { | ||
let count = 0; | ||
while (count < 10 && linkNode.parentNode && linkNode.nodeName !== 'A') { | ||
linkNode = linkNode.parentNode; | ||
count +=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.
Please don't use a while loop - especially with a completely arbitrary number of iterations. If there's a function available to recursively check the ancestors of the element, use that. Otherwise, this might need to go back to the drawing board.
@@ -119,7 +119,17 @@ jQuery.entwine('ss', ($) => { | |||
|
|||
getOriginalAttributes() { | |||
const editor = this.getElement().getEditor(); | |||
const node = $(editor.getSelectedNode()); | |||
|
|||
// Find "a" node, issue https://github.com/silverstripe/silverstripe-cms/issues/2439 |
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.
// Find "a" node, issue https://github.com/silverstripe/silverstripe-cms/issues/2439 | |
// Try to find a parent <a> tag in case the user clicks on some child node inside a link |
No longer needed! The fix in silverstripe/silverstripe-admin#1814 fixes the issue |
Description
If you have a link in tinymce like
<a href=""><span>Title</span></a>
, then you can edit the link. The HTML inside the link tag can be any tag.The issue is that the selected node is the inside HTML tag instead of the link tag.
I'm not 100% keen on the solution using
while
but this is legacy code, so might be ok! Alternative code is welcomed :)This PR is needed for silverstripe/silverstripe-admin#1814
Manual testing steps
Issues
Pull request checklist