Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao committed Nov 25, 2024
1 parent ec6b1df commit 7653705
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use Drupal\ckeditor5\Plugin\CKEditor5PluginManagerInterface;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\CurrentRouteMatch;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Psr\Container\ContainerInterface;
Expand All @@ -24,6 +22,11 @@
*/
class FilterResizeTableColumns extends FilterBase implements ContainerFactoryPluginInterface {

/**
* The CKEditor5 plugin manager.
*
* @var \Drupal\ckeditor5\Plugin\CKEditor5PluginManagerInterface
*/
protected CKEditor5PluginManagerInterface $ckeditor5PluginManager;

/**
Expand Down
7 changes: 4 additions & 3 deletions modules/tide_ckeditor/tide_ckeditor.install
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ function tide_ckeditor_update_10002() {
if ($filter) {
// Add <colgroup>, <col>, and <col style> to allowed HTML.
$additional_allowed_tags = '<colgroup> <col> <col style>';
// Append the new tags to the allowed HTML, making sure not to add duplicates
// Append the new tags to the allowed HTML,
// making sure not to add duplicates.
$replaced = $allowed_html . ' ' . $additional_allowed_tags;
$replaced = trim($replaced, ',');
// Set the updated allowed HTML tags in the filter
// Set the updated allowed HTML tags in the filter.
$filter->set('filters.filter_html.settings.allowed_html', $replaced);

$filter->set('filters.filter_resize_tablecolumns', [
'id' => 'filter_resize_tablecolumns',
'provider' => 'ckeditor_tablecol_resize',
'status' => true,
'status' => TRUE,
'weight' => 99,
'settings' => [],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public function replaceUnicodeWhitespace(array $data) {
return $data;
}

/**
* Helper function to add table styles to processed field.
*/
public function addTableStylesToProcessed(&$data) {
// Check if 'value' and 'processed' keys exist in $data.
if (isset($data['value']) && isset($data['processed'])) {
Expand All @@ -91,7 +94,7 @@ public function addTableStylesToProcessed(&$data) {
$processedDom = new \DOMDocument();

// Suppress warnings for malformed HTML in $value and $processed.
libxml_use_internal_errors(true);
libxml_use_internal_errors(TRUE);
$valueDom->loadHTML($data['value']);
$processedDom->loadHTML($data['processed']);
libxml_clear_errors();
Expand All @@ -117,14 +120,14 @@ public function addTableStylesToProcessed(&$data) {
$processedCol = $processedCols->item($j);

if ($valueCol->hasAttribute('style')) {
// Parse the style attribute.
// Parse the style attribute.
$styleValue = $valueCol->getAttribute('style');
$styles = explode(';', $styleValue);

foreach ($styles as $style) {
$style = trim($style);
if (!empty($style)) {
list($property, $value) = explode(':', $style, 2);
[$property, $value] = explode(':', $style, 2);
$property = trim($property);
$value = trim($value);

Expand All @@ -149,4 +152,5 @@ public function addTableStylesToProcessed(&$data) {
}
return $data;
}

}

0 comments on commit 7653705

Please sign in to comment.