Bug #88302

CKEditor language plugin not loadable, crash

Added by dermueller no-lastname-given over 1 year ago. Updated 7 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
-
Start date:
2019-05-08
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I use TYPO3 version 8.7.25. My YAML configuration file for CKEditor works fine in general, so there is no problem with not accepting my configuration in general. But:

editor:
  externalPlugins:
    language: { resource: "EXT:rte_ckeditor/Resources/Public/JavaScript/Contrib/plugins/language/" }

This crashes the RTE.

Browser console says: "TypeError: e.toLowerCase is not a function > ckeditor.js:244:345"

The results of my investigation so far:

sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/ckeditor.js has this method:

load:function(a,e,b){a&&CKEDITOR.lang.languages[a]||(a=this.detect(e,a));

if "a" is not present, the detect method is executed:

detect:function(a,e){var b=this.languages;e=e||navigator.userLanguage||navigator.language||a;var c=e.toLowerCase()...

This variable "a" is "languageCode" in the original code from https://github.com/ckeditor/ckeditor-dev/blob/major/core/lang.js

So, back to sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/ckeditor.js, we find

CKEDITOR.lang.load(a.config.language

But config.language is empty. Setting this in YAML has no effect:

editor:
  config:
    language: "de" 

The only thing that works is manipulation of ckeditor.js itself, by chaning the line above to (and thus skipping detection):

load:function(a,e,b){a&&CKEDITOR.lang.languages[a]||(a="de");

typo3_ckeditor_plugin_config.patch View (2.32 KB) DANIEL Rémy, 2019-05-15 08:37

Associated revisions

Revision 06188d7f (diff)
Added by Benjamin Kott 7 months ago

[BUGFIX] Prevent overriding ckeditor config from plugins

Configuration from external plugins is now only set if the plugin actually
provided some. By default, the plugin name is used for any configuration
provided by an external plugin. Since the name of the internal configuration
setting can be chosen by the author of a plugin we now provide a new option
to adjust the name that should be used.

Resolves: #88302
Releases: master, 9.5, 8.7
Change-Id: I5c1f921f4897cf15e11199015454d0927915a30e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004
Tested-by: TYPO3com <>
Tested-by: Georg Ringer <>
Tested-by: Susanne Moog <>
Reviewed-by: Benni Mack <>
Reviewed-by: Georg Ringer <>
Reviewed-by: Susanne Moog <>

Revision 933fcd88 (diff)
Added by Benjamin Kott 7 months ago

[BUGFIX] Prevent overriding ckeditor config from plugins

Configuration from external plugins is now only set if the plugin actually
provided some. By default, the plugin name is used for any configuration
provided by an external plugin. Since the name of the internal configuration
setting can be chosen by the author of a plugin we now provide a new option
to adjust the name that should be used.

Resolves: #88302
Releases: master, 9.5, 8.7
Change-Id: I5c1f921f4897cf15e11199015454d0927915a30e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63891
Tested-by: TYPO3com <>
Tested-by: Susanne Moog <>
Reviewed-by: Susanne Moog <>

History

#1 Updated by DANIEL Rémy over 1 year ago

I confirm the issue on TYPO3 8.7.24

#2 Updated by DANIEL Rémy over 1 year ago

It is because the name of the external plugin (here "language") overrides the config.language setting.

Renaming the plugin is not possible because CKEditor needs to load it with this hardcoded "language" name.

This problem was introduced by https://forge.typo3.org/issues/81263 and the merging of the externalPlugins config with the main configuration.

#3 Updated by DANIEL Rémy over 1 year ago

So TYPO3 is doing wrong with plugins configuration, because editor's config can be overwritten by the plugin config.
TYPO3 is doing this way for passing config defined in the yaml file to the JS plugins.

I will submit a patch to prevent this.

#4 Updated by DANIEL Rémy over 1 year ago

@dermueller

By the way, the "language" plugin is a core plugin of CKeditor, you do not need to add it manually.
You just need this yaml config:

editor:
  config:
    extraPlugins:
      - language
    language_list:
      - fr:Français
      - en:English

Also, the toolbar "bidi" needs to be present somewhere in "editor.config.toolbarGroups" because the language plugin adds its buttons in this toolbar.

#5 Updated by DANIEL Rémy over 1 year ago

I've attached a working patch for TYPO3 8.7. I will submit a review in gerrit soon.

#6 Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60816

#7 Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60816

#8 Updated by Gerrit Code Review 9 months ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#9 Updated by Gerrit Code Review 9 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#10 Updated by Gerrit Code Review 9 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#11 Updated by Gerrit Code Review 9 months ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#12 Updated by Gerrit Code Review 9 months ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#13 Updated by Gerrit Code Review 9 months ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#14 Updated by Gerrit Code Review 8 months ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#15 Updated by Gerrit Code Review 8 months ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63004

#16 Updated by Gerrit Code Review 7 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63891

#17 Updated by Gerrit Code Review 7 months ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63892

#18 Updated by Benjamin Kott 7 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#19 Updated by Benni Mack 7 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF