diff --git a/typo3/sysext/core/Classes/Configuration/CKEditor5Migrator.php b/typo3/sysext/core/Classes/Configuration/CKEditor5Migrator.php index 8b21056cf9f1ceb139774958320ece19dbf628a8..f5dbacef2944d7a59c7093503bb916c2aacf703a 100644 --- a/typo3/sysext/core/Classes/Configuration/CKEditor5Migrator.php +++ b/typo3/sysext/core/Classes/Configuration/CKEditor5Migrator.php @@ -719,7 +719,7 @@ class CKEditor5Migrator // Ensure editor.config.style.definitions exists $this->configuration['editor']['config']['style']['definitions'] ??= []; - $allowedClasses = is_array($this->configuration['buttons']['link']['properties']['class']['allowedClasses']) + $allowedClassSets = is_array($this->configuration['buttons']['link']['properties']['class']['allowedClasses']) ? $this->configuration['buttons']['link']['properties']['class']['allowedClasses'] : GeneralUtility::trimExplode(',', $this->configuration['buttons']['link']['properties']['class']['allowedClasses'], true); @@ -731,19 +731,20 @@ class CKEditor5Migrator } } - foreach ($allowedClasses as $allowedClass) { + foreach ($allowedClassSets as $classSet) { + $allowedClasses = GeneralUtility::trimExplode(' ', $classSet); foreach ($this->configuration['editor']['config']['style']['definitions'] as $styleSetDefinition) { - if ($styleSetDefinition['element'] === 'a' && $styleSetDefinition['classes'] === [$allowedClass]) { - // allowedClass is already configured, continue with next one + if ($styleSetDefinition['element'] === 'a' && $styleSetDefinition['classes'] === $allowedClasses) { + // allowedClasses is already configured, continue with next one continue 2; } } - // We're still here, this means $allowedClass wasn't found + // We're still here, this means $allowedClasses wasn't found array_splice($this->configuration['editor']['config']['style']['definitions'], $indexToInsertElementsAt, 0, [[ - 'classes' => [$allowedClass], + 'classes' => $allowedClasses, 'element' => 'a', - 'name' => $allowedClass, // we lack a human-readable name here... + 'name' => implode(' ', $allowedClasses), // we lack a human-readable name here... ]]); $indexToInsertElementsAt++; } diff --git a/typo3/sysext/core/Tests/Unit/Configuration/CKEditor5MigratorTest.php b/typo3/sysext/core/Tests/Unit/Configuration/CKEditor5MigratorTest.php index e826bbd2acddc9a10214f591bf098944156e6490..d31f96f359016e79bbd315f95dd43b07c292a4c0 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/CKEditor5MigratorTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/CKEditor5MigratorTest.php @@ -1557,7 +1557,7 @@ final class CKEditor5MigratorTest extends UnitTestCase 'link' => [ 'properties' => [ 'class' => [ - 'allowedClasses' => 'link-arrow, link-chevron, class-karl', + 'allowedClasses' => 'link-arrow, btn btn-default, link-chevron, class-karl', ], ], ], @@ -1573,6 +1573,11 @@ final class CKEditor5MigratorTest extends UnitTestCase 'element' => 'a', 'name' => 'Link Arrow', ], + [ + 'classes' => ['btn', 'btn-default'], + 'element' => 'a', + 'name' => 'btn btn-default', + ], [ 'classes' => ['link-chevron'], 'element' => 'a', @@ -1616,7 +1621,7 @@ final class CKEditor5MigratorTest extends UnitTestCase 'link' => [ 'properties' => [ 'class' => [ - 'allowedClasses' => 'link-arrow, link-chevron, class-karl', + 'allowedClasses' => 'link-arrow, btn btn-default, link-chevron, class-karl', ], ], ],