Skip to content

Commit

Permalink
hook update to restrict text alaignments control WYSIWYG
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Jan 13, 2025
1 parent f17c7b8 commit 8185078
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/tide_ckeditor/tide_ckeditor.install
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,26 @@ function tide_ckeditor_update_10002() {
$filter->save();
}
}

/**
* Restrict user to only use left and right text alignment control in WYSIWYG.
*/
function tide_ckeditor_update_10003() {
$editor_types = ['rich_text', 'summary', 'admin'];

// Loop through each editor type to update its configuration.
foreach ($editor_types as $editor_type) {
// Get the editable configuration for the current editor type.
$editor_config = \Drupal::configFactory()->getEditable("editor.editor.$editor_type");

// Get the current configuration data.
$editor_config_data = $editor_config->get();

// Check if the 'enabled_alignments' key exists and update it.
if (isset($editor_config_data['plugins']['ckeditor5_alignment']['enabled_alignments'])) {
$editor_config_data['plugins']['ckeditor5_alignment']['enabled_alignments'] = ['left', 'right'];
}

$editor_config->setData($editor_config_data)->save();
}
}

0 comments on commit 8185078

Please sign in to comment.