Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,8 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat
$idJs = Json::encode($view->namespaceInputId($id));
$wordCountId = "$id-counts";
$wordCountIdJs = Json::encode($view->namespaceInputId($wordCountId));
$inputId = Html::id('input-ckeditor-' . $id);
$namespacedInputId = $view->namespaceInputId($inputId);

$baseConfig = array_filter([
'defaultTransform' => $defaultTransform?->handle,
Expand Down Expand Up @@ -1719,6 +1721,7 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat
$wordLimitJs,
$characterLimitJs,
$imageMode,
$namespacedInputIdJs,
) => <<<JS
$imports
$uiTranslationImport
Expand Down Expand Up @@ -1773,6 +1776,30 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat
config.heading.options = Object.values(headings);
}

// special case for fullscreen mode and Custom Styles
// see https://github.com/craftcms/ckeditor/issues/614
if (config.toolbar.items.indexOf('fullscreen') >= 0) {
const fullscreenConfig = customConfig?.fullscreen ?? {};
const userOnEnterCallback = fullscreenConfig?.onEnterCallback;
const userOnLeaveCallback = fullscreenConfig?.onLeaveCallback;
const fieldInputId = $namespacedInputIdJs;
config.fullscreen = {
...fullscreenConfig,
onEnterCallback: (container) => {
container.classList.add(fieldInputId);
if (userOnEnterCallback) {
userOnEnterCallback(container);
}
},
onLeaveCallback: (container) => {
if (userOnLeaveCallback) {
userOnLeaveCallback(container);
}
container.classList.remove(fieldInputId);
},
};
}

const extraRemovePlugins = [];
if ($showWordCountJs) {
if (typeof config.wordCount === 'undefined') {
Expand Down Expand Up @@ -1841,13 +1868,13 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat
$this->wordLimit ?: 0,
$this->characterLimit ?: 0,
$this->imageMode,
$namespacedInputId,
],
View::POS_END,
['type' => 'module']
);

$value = $this->prepValueForInput($value, $element);
$inputId = Html::id('input-ckeditor-' . $id);
$html = Html::textarea($this->handle, $value, [
'id' => $id,
'class' => 'hidden',
Expand All @@ -1873,7 +1900,9 @@ private function _inputHtml(mixed $value, ?ElementInterface $element, bool $stat
}
$css = trim($css);
if ($css !== '') {
$view->registerCss("#{$view->namespaceInputId($inputId)} { $css }");
// the id is needed for the regular field
// the class is used by the fullscreen mode (there can only be one at the time)
$view->registerCss("#{$namespacedInputId}, .{$namespacedInputId} { $css }");
}
}

Expand Down
Loading