From c06aa668540733609fceedae263306af804b63fc Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 22 May 2024 15:13:40 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B05298=20-=20Fix=20CKEditor=20not=20using?= =?UTF-8?q?=20width/height=20from=20the=20datamodel=20since=20upgrade=20to?= =?UTF-8?q?=20v5=20in=20the=20backoffice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/ui.htmleditorwidget.class.inc.php | 1 - js/ckeditor.handler.js | 10 ++++++++++ sources/Application/Helper/CKEditorHelper.php | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/application/ui.htmleditorwidget.class.inc.php b/application/ui.htmleditorwidget.class.inc.php index 030edc712..15ab2afc7 100644 --- a/application/ui.htmleditorwidget.class.inc.php +++ b/application/ui.htmleditorwidget.class.inc.php @@ -81,7 +81,6 @@ class UIHTMLEditorWidget if ($sWidthSpec != '') { /*N°6543 - the function min allow to keep text inside the column when width is defined*/ $aConfig['width'] = "min($sWidthSpec,100%)"; - $sJSDefineWidth = '$("#cke_'.$iId.' iframe").contents().find("body").css("width", "'.$sWidthSpec.'")'; } $sHeightSpec = addslashes(trim($this->m_oAttDef->GetHeight())); if ($sHeightSpec != '') { diff --git a/js/ckeditor.handler.js b/js/ckeditor.handler.js index b1905c83f..59293f913 100644 --- a/js/ckeditor.handler.js +++ b/js/ckeditor.handler.js @@ -49,6 +49,16 @@ const CombodoCKEditorHandler = { return this.instances_promise[sElem] = new Promise((resolve, reject) => { ClassicEditor.create($(sElem)[0], aConfiguration) .then(editor => { + // Adjust size if passed in configuration + // - Width + if (aConfiguration.width !== undefined) { + editor.editing.view.change( writer => { writer.setStyle( 'width', aConfiguration.width, editor.editing.view.document.getRoot() ); } ); + } + // - Height + if (aConfiguration.height !== undefined) { + editor.editing.view.change( writer => { writer.setStyle( 'height', aConfiguration.height, editor.editing.view.document.getRoot() ); } ); + } + this.instances[sElem] = editor; resolve(editor); }) diff --git a/sources/Application/Helper/CKEditorHelper.php b/sources/Application/Helper/CKEditorHelper.php index 09899f4c6..70abdc3f7 100644 --- a/sources/Application/Helper/CKEditorHelper.php +++ b/sources/Application/Helper/CKEditorHelper.php @@ -61,18 +61,18 @@ class CKEditorHelper */ static public function GetCkeditorPref() { - // extract language from user preferences + // Extract language from user preferences $sLanguageCountry = trim(UserRights::GetUserLanguage()); $sLanguage = strtolower(explode(' ', $sLanguageCountry)[0]); $aDefaultConf = array( - 'language'=> $sLanguage, + 'language' => $sLanguage, ); - // mentions + // Mentions $aDefaultConf['mention'] = self::GetMentionConfiguration(); - // rich text config + // Rich text config $aRichTextConfig = json_decode(appUserPreferences::GetPref('richtext_config', '{}'), true); return array_merge($aDefaultConf, $aRichTextConfig);