From 45db97bc80c3401d7f30515a1d3ee8567df283d7 Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Fri, 6 Jun 2025 10:59:47 -0500 Subject: [PATCH 1/2] Fixes #326 --- src/Field.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Field.php b/src/Field.php index 1f68bb61..c673c0d6 100644 --- a/src/Field.php +++ b/src/Field.php @@ -1184,11 +1184,8 @@ protected function inputHtml(mixed $value, ?ElementInterface $element, $inline): ['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', @@ -1201,10 +1198,15 @@ protected function inputHtml(mixed $value, ?ElementInterface $element, $inline): ]); } + if ($ckeConfig->css) { + $html .= Html::tag('style', "#{$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, From 538a5d17aec25c9910439d09e9d55d3f40f975b4 Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Mon, 16 Jun 2025 10:51:50 -0500 Subject: [PATCH 2/2] Use `registerCss` and namespace the ID --- src/Field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Field.php b/src/Field.php index c673c0d6..472273b7 100644 --- a/src/Field.php +++ b/src/Field.php @@ -1199,7 +1199,7 @@ protected function inputHtml(mixed $value, ?ElementInterface $element, $inline): } if ($ckeConfig->css) { - $html .= Html::tag('style', "#{$inputId} { $ckeConfig->css }"); + $view->registerCss("#{$view->namespaceInputId($inputId)} { $ckeConfig->css }"); } return Html::tag('div', $html, [