Hi, I'm using Wysiwyg with CKeditor and it's removing the "onclick" events in my links whenever I open them in the link editor of CKeditor. If I don't open them (and edit the source directly) it let them stay.
I've tried several things with the "ADVANCED CONTENT FILTER" following instructions in https://ckeditor.com/docs/ckeditor4/latest/guide/dev_allowed_content_rul... and https://stackoverflow.com/questions/49257832/ckeditor-allow-onclick-attr..., but they don't seem to work.
Maybe this is more a question for CKeditor forums, but when I try putting the code suggested in ther docs (https://ckeditor.com/docs/ckeditor4/latest/guide/dev_allowed_content_rul..., for example: allowedContent: 'p(tip)') in the "Content Rules" box it says "Allowed content is not valid JSON.", so I don't know how to apply the official CKeditor advice in this module.
I also don't know if the code of https://stackoverflow.com/questions/49257832/ckeditor-allow-onclick-attr... is the correct one for what I want, but that is more a question for CKeditor I guess.
Any help would be much appreciated.
Comments
Comment #2
twodTry entering just the setting's value. You'll also need to use the "Object Format" (JSON) as it's easier to parse and validate for Wysiwyg module.
So,
"*(*)[onclick]"would get translated to something like this:You probably don't want to allow onclick attributes on every element, so use
"a"instead of"*".Beware that if you have "Custom" mode enabled, you'll have to manually include every other tag/attribute you want to allow. (In this case you would not be able to add the
hrefattribute to links, or any other tags if you change it to"a"instead of"*".)If left in "Automatic" mode CKEditor will look at which buttons/plugins/settings are enabled and build an initial list of allowed tags/attributes based on that, then your config is applied on top of that.
This filtering is applied both when loading existing content and when creating new content using the editor, then Drupal may of ignore some markup when rendering it depending on your format/filter configuration.
Please let me know if something's unclear or this did not work as you expected.
Comment #3
delvalle commentedTwoD, thanks a lot for your detailed and clear response!
I've tried your code in "Automatic" and it saves correctly (it doesn't show a JSON error), but the link editor is still removing the onclick attribute.
I think it's relevant that the editor lets my onclick attribute stay if I don't open the link in the link editor of CKeditor (the button with the anchor, the one that opens with Ctrl+L). I can copy/modify links with onclick via editor's source code and they stay when I save the node. But if I open the link editor, the onclick gets removed immediately.
So I guess the problem could be with the link editor itself (maybe it only allows attributes that are in it's advanced configuration tab and removes all others), not with the ACF configuration or anything else. But I have no idea really...