diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseSystemLanguageRows.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseSystemLanguageRows.php index bd9a59efc9c5676efb8d8c2cfa88ebff16d0b4c1..e6de1296a1b43074254afdb0dded109ec5abebb9 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseSystemLanguageRows.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseSystemLanguageRows.php @@ -61,6 +61,7 @@ class DatabaseSystemLanguageRows implements FormDataProviderInterface 'title' => $language->getTitle(), 'iso' => $iso, 'flagIconIdentifier' => $language->getFlagIdentifier(), + 'direction' => $language->getDirection(), ]; if (empty($iso)) { diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseSystemLanguageRowsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseSystemLanguageRowsTest.php index 6976fecf0175e4f6036f23cbf395f36b93ec185e..9cbdf93501bb3ea5f4a94250804d7be6dc43c6cb 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseSystemLanguageRowsTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseSystemLanguageRowsTest.php @@ -59,15 +59,18 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase $siteLanguageMinusOne->getLanguageId()->willReturn(-1); $siteLanguageMinusOne->getTitle()->willReturn('All'); $siteLanguageMinusOne->getFlagIdentifier()->willReturn('flags-multiple'); + $siteLanguageMinusOne->getDirection()->willReturn(''); $siteLanguageZero = $this->prophesize(SiteLanguage::class); $siteLanguageZero->getLanguageId()->willReturn(0); $siteLanguageZero->getTitle()->willReturn('English'); $siteLanguageZero->getFlagIdentifier()->willReturn('empty-empty'); + $siteLanguageZero->getDirection()->willReturn('ltr'); $siteLanguageOne = $this->prophesize(SiteLanguage::class); $siteLanguageOne->getLanguageId()->willReturn(1); $siteLanguageOne->getTitle()->willReturn('Dutch'); $siteLanguageOne->getFlagIdentifier()->willReturn('flag-nl'); $siteLanguageOne->getTwoLetterIsoCode()->willReturn('NL'); + $siteLanguageOne->getDirection()->willReturn('rtl'); $siteLanguages = [ $siteLanguageMinusOne->reveal(), $siteLanguageZero->reveal(), @@ -85,18 +88,21 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase 'title' => 'All', 'iso' => 'DEF', 'flagIconIdentifier' => 'flags-multiple', + 'direction' => '', ], 0 => [ 'uid' => 0, 'title' => 'English', 'iso' => 'DEF', 'flagIconIdentifier' => 'empty-empty', + 'direction' => 'ltr', ], 1 => [ 'uid' => 1, 'title' => 'Dutch', 'iso' => 'NL', 'flagIconIdentifier' => 'flag-nl', + 'direction' => 'rtl', ], ], ]; diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Feature-97778-SupportOfLanguageDirectionInCkeditor.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Feature-97778-SupportOfLanguageDirectionInCkeditor.rst new file mode 100644 index 0000000000000000000000000000000000000000..0d2a2aae6189999acfe60d37b3fea0f1ec6a0f2a --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Feature-97778-SupportOfLanguageDirectionInCkeditor.rst @@ -0,0 +1,28 @@ +.. include:: /Includes.rst.txt + +.. _feature-97778-1655732248: + +=========================================================== +Feature: #97778 - Support of language direction in ckeditor +=========================================================== + +See :issue:`97778` + +Description +=========== + +The configuration `contentsLangDirection` of the ckeditor is used to define the +direction of the content. It is now filled by the direction defined in the site +language of the current element. + +As fallback the Page TsConfig configuration :typoscript:`RTE.config.contentsLanguageDirection = rtl` +can be used. + + +Impact +====== + +The direction of the content inside the RichText element is defined by the +language of record. + +.. index:: Backend, RTE, ext:rte_ckeditor diff --git a/typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php b/typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php index fba817c69eb1e27a5b5490f7d66d2b12e321aecb..d83a00680b07d92f39ff88e6fa897b11be70453a 100644 --- a/typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php +++ b/typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php @@ -195,6 +195,19 @@ class RichTextElement extends AbstractFormElement return $contentLanguage; } + /** + * Determine the language direction + */ + protected function getLanguageDirectionOfContent(): string + { + $currentLanguageUid = ($this->data['databaseRow']['sys_language_uid'] ?? 0); + if (is_array($currentLanguageUid)) { + $currentLanguageUid = $currentLanguageUid[0]; + } + $contentLanguageUid = (int)max($currentLanguageUid, 0); + return $this->data['systemLanguageRows'][$contentLanguageUid]['direction'] ?? ''; + } + /** * Gets the JavaScript code for CKEditor module * Compiles the configuration, and then adds plugins @@ -364,6 +377,7 @@ class RichTextElement extends AbstractFormElement $configuration['language'] = $userLang === 'default' ? 'en' : $userLang; } $configuration['contentsLanguage'] = $this->getLanguageIsoCodeOfContent(); + $configuration['contentsLangDirection'] = $this->getLanguageDirectionOfContent(); // Replace all label references $configuration = $this->replaceLanguageFileReferences($configuration);