Skip to content

Commit

Permalink
Merge pull request #137 from craftcms/bugfix/136-html-purifier-for-li…
Browse files Browse the repository at this point in the history
…st-style

conditionally allow style attribute for ul and ol tags
  • Loading branch information
brandonkelly authored Sep 13, 2023
2 parents 909223e + 2a2321d commit 37687dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for CKEditor for Craft CMS

## Unreleased

- HTML Purifier is now configured to allow `style` attributes on `<ol>` and `<ul>` tags, when bulleted/numbered lists are allowed. ([#136](https://github.com/craftcms/ckeditor/issues/136))

## 3.5.1 - 2023-08-29

- Fixed a bug where CKEditor inputs weren’t getting any padding within slideouts. ([#126](https://github.com/craftcms/ckeditor/issues/126))
Expand Down
12 changes: 12 additions & 0 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,18 @@ private function _adjustPurifierConfig(HTMLPurifier_Config $purifierConfig): HTM
]);
}

if (in_array('numberedList', $ckeConfig->toolbar)) {
/** @var HTMLPurifier_HTMLDefinition|null $def */
$def = $purifierConfig->getDefinition('HTML', true);
$def?->addAttribute('ol', 'style', 'Text');
}

if (in_array('bulletedList', $ckeConfig->toolbar)) {
/** @var HTMLPurifier_HTMLDefinition|null $def */
$def = $purifierConfig->getDefinition('HTML', true);
$def?->addAttribute('ul', 'style', 'Text');
}

return $purifierConfig;
}
}

0 comments on commit 37687dc

Please sign in to comment.