diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e1e9459..19048a23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - The link modal UI now reflects Craft’s native Link fields. ([#375](https://github.com/craftcms/ckeditor/pull/375)) - Added support for drag-n-drop image uploading. ([#486](https://github.com/craftcms/ckeditor/pull/486)) - Added the “Advanced Link Fields” setting to CKEditor configs. ([#375](https://github.com/craftcms/ckeditor/pull/375)) +- Custom editor styles now get registered with a higher specificity than the default editor styles. ([#433](https://github.com/craftcms/ckeditor/pull/433)) - Added `craft\ckeditor\helpers\CkeditorConfig`. ([#363](https://github.com/craftcms/ckeditor/pull/363)) - Added `craft\ckeditor\web\assets\BaseCkeditorPackageAsset::$namespace`. ([#363](https://github.com/craftcms/ckeditor/pull/363)) - Added `craft\ckeditor\CkeConfig::$advancedLinkFields`. diff --git a/src/Field.php b/src/Field.php index a4b3feb3..7ecadfb1 100644 --- a/src/Field.php +++ b/src/Field.php @@ -1308,11 +1308,8 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat ['type' => 'module'] ); - if ($ckeConfig->css) { - $view->registerCss($ckeConfig->css); - } - $value = $this->prepValueForInput($value, $element); + $inputId = Html::id('input-ckeditor-' . $id); $html = Html::textarea($this->handle, $value, [ 'id' => $id, 'class' => 'hidden', @@ -1325,10 +1322,15 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat ]); } + if ($ckeConfig->css) { + $view->registerCss("#{$view->namespaceInputId($inputId)} { $ckeConfig->css }"); + } + return Html::tag('div', $html, [ 'class' => array_filter([ $this->showWordCount ? 'ck-with-show-word-count' : null, ]), + 'id' => $inputId, 'data' => [ 'element-id' => $element?->id, 'config' => $this->ckeConfig,