Skip to content

Commit

Permalink
Merge pull request #87 from aleevas/DS-1508
Browse files Browse the repository at this point in the history
feat: [DS-1508] - Add a 'highlighted' element to the Ckeditor5 Style plugin
  • Loading branch information
podarok authored Aug 29, 2024
2 parents 3c10395 + 921c940 commit 36043ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openy_editor/config/install/editor.editor.full_html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ settings:
- outdent
- indent
- heading
- style
- '|'
- link
- '|'
Expand All @@ -43,6 +44,11 @@ settings:
- heading4
- heading5
- heading6
ckeditor5_style:
styles:
-
label: Highlighted
element: '<span class="highlighted">'
ckeditor5_sourceEditing:
allowed_tags: { }
ckeditor5_list:
Expand Down
31 changes: 31 additions & 0 deletions openy_editor/openy_editor.install
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,34 @@ function openy_editor_update_91001() {
$active_config->set('settings.plugins', $enabled_plugins);
$active_config->save(TRUE);
}

/**
* Update editor settings to add Style button with a 'highlighted' style.
*/
function openy_editor_update_91002() {
$active_config = \Drupal::configFactory()->getEditable('editor.editor.full_html');
$settings = $active_config->get('settings');
if (empty($settings['toolbar']['items'])) {
return;
}
// Put the Style button to the toolbar.
foreach ($settings['toolbar']['items'] as $id => $plugin_name) {
if ($plugin_name === 'heading') {
$position = $id + 1;
array_splice( $settings['toolbar']['items'] , $position, 0, 'style');
}
}
// Add the "Highlighted" style.
$default_plugin_settings = [
'styles' => [
[
'label' => 'Highlighted',
'element' => '<span class="highlighted">',
]
],
];

$settings['plugins']['ckeditor5_style'] = $default_plugin_settings;
$active_config->set('settings', $settings);
$active_config->save(TRUE);
}

0 comments on commit 36043ea

Please sign in to comment.