From b70b87ae0b25db7cd5bd07d989f9500109aa2edb Mon Sep 17 00:00:00 2001 From: Markus Hofmann Date: Fri, 18 Jul 2025 10:02:56 +0200 Subject: [PATCH] [TASK] Add default presets for RTE For usage of the `DeepL Write` optimization feature it is required overriding the default RTE presets ensuring direct usage of the feature within RTE editors without changing the defaults. Used Commands: ``` Build/Scripts/runTests.sh -t 12 -p 8.1 -s composer -- --dev require \ "typo3/cms-rte-ckeditor":"^12.4 || ^13.4" Build/Scripts/runTests.sh -t 12 -p 8.1 -s composer -- config \ suggest.typo3/cms-rte-ckeditor "Allows Additional RTE feature \ optimizing text" ``` --- Configuration/RTE/DeeplWritePreset.yaml | 9 +--- Configuration/RTE/Default.yaml | 37 ++++++++++++++++ Configuration/RTE/Full.yaml | 59 +++++++++++++++++++++++++ Configuration/RTE/Minimal.yaml | 17 +++++++ composer.json | 4 +- ext_emconf.php | 1 + ext_localconf.php | 25 +++++++++-- 7 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 Configuration/RTE/Default.yaml create mode 100644 Configuration/RTE/Full.yaml create mode 100644 Configuration/RTE/Minimal.yaml diff --git a/Configuration/RTE/DeeplWritePreset.yaml b/Configuration/RTE/DeeplWritePreset.yaml index ce52cc5..4c50204 100644 --- a/Configuration/RTE/DeeplWritePreset.yaml +++ b/Configuration/RTE/DeeplWritePreset.yaml @@ -1,14 +1,9 @@ +# This file is only an example and should help to implement the DeepL write plugin to customized RTE configurations. +# The configuration below is only short-handed and not full ready usable. editor: config: importModules: - { module: '@web-vision/deepl-write/deeplwrite-plugin.js', exports: [ 'Deeplwrite' ] } toolbar: items: - - bold - - italic - - '|' - - clipboard - - undo - - redo - - '|' - deeplwrite diff --git a/Configuration/RTE/Default.yaml b/Configuration/RTE/Default.yaml new file mode 100644 index 0000000..82a1ef0 --- /dev/null +++ b/Configuration/RTE/Default.yaml @@ -0,0 +1,37 @@ +editor: + config: + importModules: + - { module: '@web-vision/deepl-write/deeplwrite-plugin.js', exports: [ 'Deeplwrite' ] } + toolbar: + items: + - style + - heading + # grouping separator + - '|' + - bold + - italic + - subscript + - superscript + - softhyphen + - '|' + - bulletedList + - numberedList + - blockQuote + - alignment + - '|' + - findAndReplace + - link + - '|' + - removeFormat + - undo + - redo + - '|' + - insertTable + - '|' + - specialCharacters + - horizontalLine + - sourceEditing + - '|' + - deeplwrite +imports: + - { resource: 'EXT:rte_ckeditor/Configuration/RTE/Default.yaml' } diff --git a/Configuration/RTE/Full.yaml b/Configuration/RTE/Full.yaml new file mode 100644 index 0000000..91730f4 --- /dev/null +++ b/Configuration/RTE/Full.yaml @@ -0,0 +1,59 @@ +imports: + - { resource: 'EXT:rte_ckeditor/Configuration/RTE/Full.yaml' } + +editor: + config: + importModules: + - { module: '@web-vision/deepl-write/deeplwrite-plugin.js', exports: [ 'Deeplwrite' ] } + toolbar: + items: + - removeFormat + - undo + - redo + # grouping separator + - '|' + - findAndReplace + - link + - '|' + - insertTable + - tableColumn + - tableRow + - mergeTableCells + - TableProperties + - TableCellProperties + - '|' + - selectAll + - '|' + - sourceEditing + - showBlocks + - horizontalLine + # line break + - '-' + - bold + - italic + - underline + - strikethrough + - subscript + - superscript + - softhyphen + - '|' + - bulletedList + - numberedList + - blockQuote + - indent + - outdent + - alignment + - '|' + - specialCharacters + - '-' + - style + - heading + - fontFamily + - fontBackgroundColor + - fontColor + - fontSize + - textPartLanguage + - highlight + - highlight:greenMarker + - '|' + - deeplwrite diff --git a/Configuration/RTE/Minimal.yaml b/Configuration/RTE/Minimal.yaml new file mode 100644 index 0000000..5497f9d --- /dev/null +++ b/Configuration/RTE/Minimal.yaml @@ -0,0 +1,17 @@ +imports: + - { resource: 'EXT:rte_ckeditor/Configuration/RTE/Minimal.yaml' } + +editor: + config: + importModules: + - { module: '@web-vision/deepl-write/deeplwrite-plugin.js', exports: [ 'Deeplwrite' ] } + toolbar: + items: + - bold + - italic + - '|' + - clipboard + - undo + - redo + - '|' + - deeplwrite diff --git a/composer.json b/composer.json index 4528307..b5474db 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.5", "saschaegerer/phpstan-typo3": "^1.9", + "typo3/cms-rte-ckeditor": "^12.4 || ^13.4", "typo3/testing-framework": "^8.2.7" }, "license": "GPL-2.0-or-later", @@ -60,6 +61,7 @@ } }, "suggest": { - "web-vision/deepltranslate-core": "*" + "web-vision/deepltranslate-core": "*", + "typo3/cms-rte-ckeditor": "Allows Additional RTE feature optimizing text" } } diff --git a/ext_emconf.php b/ext_emconf.php index 335d0a2..2159a3f 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -24,6 +24,7 @@ 'install' => '*', 'enable_translated_content' => '*', 'deepltranslate_core' => '*', + 'rte_ckeditor' => '12.4.0-13.4.99', ], ], ]; diff --git a/ext_localconf.php b/ext_localconf.php index a004fe5..78a79ce 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -6,9 +6,28 @@ (static function (): void { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['deeplWrite'] = WriteHook::class; - - $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['deeplwrite'] - = 'EXT:deepl_write/Configuration/RTE/DeeplWritePreset.yaml'; + // Register the presets + // override default presets from EXT:rte_ckeditor + // by using them as import and add `deeplwrite` + // respect overrides by other extensions beside EXT:rte_ckeditor + if ( + empty($GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['default']) + || $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['default'] === 'EXT:rte_ckeditor/Configuration/RTE/Default.yaml' + ) { + $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['default'] = 'EXT:deepl_write/Configuration/RTE/Default.yaml'; + } + if ( + empty($GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['minimal']) + || $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['minimal'] === 'EXT:rte_ckeditor/Configuration/RTE/Minimal.yaml' + ) { + $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['minimal'] = 'EXT:deepl_write/Configuration/RTE/Minimal.yaml'; + } + if ( + empty($GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['full']) + || $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['full'] === 'EXT:rte_ckeditor/Configuration/RTE/Full.yaml' + ) { + $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['full'] = 'EXT:deepl_write/Configuration/RTE/Full.yaml'; + } $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'][1750182029] = PageRendererHook::class . '->renderPreProcess';