diff --git a/CHANGELOG.md b/CHANGELOG.md index d4915e80..500817bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fixed a bug where “Edit entry” buttons were only partially translated. ([#337](https://github.com/craftcms/ckeditor/issues/337)) - Fixed a bug where copying and pasting nested entries wasn’t working on non-primary sites. ([#315](https://github.com/craftcms/ckeditor/issues/315)) - Fixed an error that could occur when editing nested entries on newly-created provisional drafts. ([#339](https://github.com/craftcms/ckeditor/pull/339)) +- Fixed an error that occurred when editing a CKEditor field, if its CKEditor config had been deleted. ([#344](https://github.com/craftcms/ckeditor/issues/344)) ## 4.4.0 - 2024-11-12 diff --git a/src/Field.php b/src/Field.php index 9058b2c4..ef4c5165 100644 --- a/src/Field.php +++ b/src/Field.php @@ -621,8 +621,17 @@ public function getSettingsHtml(): ?string ]; } + $ckeConfig = null; + if ($this->ckeConfig) { + try { + $ckeConfig = Plugin::getInstance()->getCkeConfigs()->getByUid($this->ckeConfig); + } catch (InvalidArgumentException) { + } + } + return $view->renderTemplate('ckeditor/_field-settings.twig', [ 'field' => $this, + 'ckeConfig' => $ckeConfig, 'purifierConfigOptions' => $this->configOptions('htmlpurifier'), 'volumeOptions' => $volumeOptions, 'transformOptions' => $transformOptions, diff --git a/src/templates/_field-settings.twig b/src/templates/_field-settings.twig index 219af324..45718648 100644 --- a/src/templates/_field-settings.twig +++ b/src/templates/_field-settings.twig @@ -5,7 +5,7 @@ id: 'cke-config', name: 'ckeConfig', options: plugin('ckeditor').ckeConfigs.getAll(), - value: field.ckeConfig ? plugin('ckeditor').ckeConfigs.getByUid(field.ckeConfig) : null, + value: ckeConfig ?? null, limit: 1, createAction: 'ckeditor/cke-configs/edit', }) }}