Bug #83136
closedCKeditor: RteLinkBrowser ignores HTML tags in links --> they are removed
0%
Description
Using CKEditor in backend:
- Add "Hello World" to RTE
- Select "World" and make it bold: "*World*"
- Now select "Hello World" and make a link to a page.
Result: Bold styling of "World" is lost.
Another scenario:After creating the link for "Hello World" without bold:
- Select "World" again and make it bold again: "*World*"
- No modify the link using the link browser to another page
Result: Bold styling of "World" is gone again.
That is the case for all HTML content inside links, so it e.g. also happens if I add an SVG icon inside the link or similar stuff.
The problem is this code in "typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js"
var selection = RteLinkBrowser.CKEditor.getSelection();
if (selection && selection.getSelectedText() === '') {
selection.selectElement(selection.getStartElement());
}
if (selection && selection.getSelectedText()) {
linkElement.setText(selection.getSelectedText());
} else {
linkElement.setText(linkElement.getAttribute('href'));
}
RteLinkBrowser.CKEditor.insertElement(linkElement);
It only selects the text and ignores any HTML content.
It could be solved by doing it like this instead (not perfect, e.g. it doesn't take into account more than one range and what happens in case of e.g. a td/tr/li element was selected and also no checks if a range exists at all):
var selection = RteLinkBrowser.CKEditor.getSelection();
var range = selection.getRanges()[selection.getRanges().length - 1];
var content = range.cloneContents().getHtml();
linkElement.setHtml(content);
Probably a better way would be to do it in the same way as CKEditor does it in their own link plugin, I think these are the relevant sections:
https://github.com/ckeditor/ckeditor-dev/blob/major/plugins/link/dialogs/link.js#L38
https://github.com/ckeditor/ckeditor-dev/blob/major/plugins/link/dialogs/link.js#L56
It is especially annoying that those things are lost when changing updating the link.
I have tested the above steps with their link plugin and it works fine. It even takes care to e.g. add the links per table cell if selecting multiple:
https://sdk.ckeditor.com/samples/fullpreset.html
Updated by Gerrit Code Review almost 7 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54832
Updated by Gerrit Code Review almost 7 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54832
Updated by Gerrit Code Review almost 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54832
Updated by Gerrit Code Review almost 7 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54832
Updated by Gerrit Code Review almost 7 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54832
Updated by Christian Kuhn about 6 years ago
- Status changed from Under Review to Needs Feedback
patch has been abandoned due to the lack of work. i'm unsure if the issue still exists and thus set the state to 'needs feedback' for now.
Updated by Riccardo De Contardi over 5 years ago
- Status changed from Needs Feedback to Closed
I am not able to reproduce this issue with TYPO3 8.7.24, 9.5.4 and 10.0.0-dev (latest master), using Chrome, FIrefox and Safari on MAC (all updated to the latest versions)
I think it is safe to close this one for now.
If you think that this is the wrong decision or experience the issue again, and have more detailed information about how to reproduce it, please reopen it or open a new issue with a reference to this one. Thank you!