Skip to content
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

FR: MODIFY_PURIFIER_CONFIG #204

Closed
ishetnogferre opened this issue Apr 4, 2024 · 3 comments
Closed

FR: MODIFY_PURIFIER_CONFIG #204

ishetnogferre opened this issue Apr 4, 2024 · 3 comments
Labels

Comments

@ishetnogferre
Copy link

ishetnogferre commented Apr 4, 2024

Description

For the Redactor field, we had the option to modify the purifier config via the MODIFY_PURIFIER_CONFIG event. I was wondering if we could have the same for CKEditor or is there another way to modify this?

We like to migrate a Redactor field to CKEditor but are losing, in this case, some data-attributes, we've added via this event.

Some context on what we're doing:

Event::on(
                RedactorField::class,
                RedactorField::EVENT_MODIFY_PURIFIER_CONFIG,
                function (Event $event) {
                    if( $event->config ) {
                        if( $def = $event->config->getDefinition('HTML', true) ) {
                            // http://htmlpurifier.org/docs/enduser-customize.html#addAttribute
                            $def->addAttribute('a', 'data-track-name', 'Text');
                            $def->addAttribute('a', 'data-track-id', 'Text');
                            $def->addAttribute('a', 'data-track-follow', 'Text');
                        }
                    }
                }
            );

Thanks!

@i-just
Copy link
Contributor

i-just commented Apr 4, 2024

Hi, thanks for reaching out. The same event exists for the CKEditor: https://github.com/craftcms/ckeditor?tab=readme-ov-file#html-purifier-configs.

Hope this helps!

@i-just i-just closed this as completed Apr 4, 2024
@ishetnogferre
Copy link
Author

ishetnogferre commented Apr 5, 2024

Oh, apologies, looked over that!

Although the event is there and the Purifier config is extended in the same way as the Redactor one, the config still doesn't seem to be applied (in this case) 🤔 Gonna debug a little more to see if I can pinpoint where it's different in this case.

@ishetnogferre
Copy link
Author

In this case we also had to edit the General HTML Support setting in the config of the CKEditor field: https://ckeditor.com/docs/ckeditor5/latest/features/html/general-html-support.html#enabling-all-html-features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants