1 ckeditor5_upgrade_test.module | ckeditor5_upgrade_test_ckeditor5_upgrade_format_alter(&$format, $original_format) |
Implements hook_ckeditor5_upgrade_format_alter().
File
- core/
modules/ ckeditor5/ tests/ ckeditor5_upgrade_test/ ckeditor5_upgrade_test.module, line 18 - Provides assisting code for testing a CKEditor 4 to CKEditor 5 upgrade.
Code
function ckeditor5_upgrade_test_ckeditor5_upgrade_format_alter(&$format, $original_format) {
if (!empty($format->filters['filter_html']->status)) {
$allowed_tags = $format->filters['filter_html']->settings['allowed_html'];
$toolbar = $format->editor_settings['toolbar'];
// Add <test-tag> to the list of allowed tags if the test button is present.
if (in_array('testButton', $toolbar) && strpos($allowed_tags, '<test-tag>') === FALSE) {
$format->filters['filter_html']->settings['allowed_html'] = $allowed_tags . ' <test-tag>';
}
}
}