CKEditor JS error when source editing plugin disabled

Created on 30 June 2023, over 1 year ago
Updated 27 July 2024, 4 months ago

Hi,

If I'd like to disable source editing tool for some of Text formats I get codemirror dependency error in browser which stops CKEditor normal initialisation.

Steps to reproduce:
1. Go to admin/config/content/formats
2. Click configure some of Text formats (Basic HTML, for example)
3. Remove Source Editing tool from toolbar
4. You may also disable codemirror plugin for this text format, but it doesn't matter.
5. Save text format
6. Go to create some content with CKEditor body field, select Basic HTML format
7. You'll have error in console while trying to initialise CKEditor

The issue is that CKEditor5 loads codemirror plugin even if no Source Editing tool is present on toolbar.

How to solve:
- attached patch adds proper dependencies for codemirror plugin - it actually depends on Source Editing tool.

Attached patch will prevent codemirror plugin loading in case Source Editing tool deactivated.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡·πŸ‡ΊRussia Mav-im

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Mav-im
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    2 fail
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States cedewey Denver, CO
  • Current issues should target the dev branch.

  • πŸ‡ΊπŸ‡ΈUnited States pcate

    I ran into this same issue with a Drupal 10 upgrade. A text format didn't have the source editing enabled and CKEditor was failing to load on pages where it was used. The following error was printing in the browser console.

    ckeditor5.js?s2u53n:477 CKEditorError: plugincollection-soft-required {"missingPlugin":"SourceEditing","requiredBy":"SourceEditingCodeMirror"}
    Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-plugincollection-soft-required
        at ckeditor5-dll.js?v=39.0.1:5:99918
        at ckeditor5-dll.js?v=39.0.1:5:100062
        at Array.forEach (<anonymous>)
        at u (ckeditor5-dll.js?v=39.0.1:5:99864)
        at ckeditor5-dll.js?v=39.0.1:5:98495
        at Array.reduce (<anonymous>)
        at e (ckeditor5-dll.js?v=39.0.1:5:98446)
        at l.init (ckeditor5-dll.js?v=39.0.1:5:98571)
        at D.initPlugins (ckeditor5-dll.js?v=39.0.1:5:105102)
        at editor-classic.js?v=39.0.1:4:9630
    (anonymous) @ ckeditor5.js?s2u53n:477
    Promise.catch (async)
    attach @ ckeditor5.js?s2u53n:471
    Drupal.editorAttach @ editor.js?v=10.1.5:302
    (anonymous) @ editor.js?v=10.1.5:226
    attach @ editor.js?v=10.1.5:209
    (anonymous) @ drupal.js?v=10.1.5:166
    Drupal.attachBehaviors @ drupal.js?v=10.1.5:162
    (anonymous) @ big_pipe.js?v=10.1.5:118
    (anonymous) @ big_pipe.js?v=10.1.5:138
    12:14:35.818 
    

    The patch resolved the issue.

    Not setting to RTBC since there are failing tests, but I think the fix is correct.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    2 fail
  • Status changed to Needs work 9 months ago
  • πŸ‡¨πŸ‡¦Canada dstorozhuk Chicago πŸ‡ΊπŸ‡Έ, Toronto πŸ‡¨πŸ‡¦, Kyiv πŸ‡ΊπŸ‡¦

    I think module should not load code mirror plugin is source code plugin is not enabled for particular Text format configuration.

  • πŸ‡ΊπŸ‡ΈUnited States jesss

    Can confirm that I was seeing the same behavior (CKEditor would not load if CodeMirror plugin/Source Code button disabled). This patch resolves the issue.

    • wells β†’ committed bc33237c on 3.0.x
      Issue #3371709 by Mav-im, cedewey, solideogloria, PCate, jesss,...
  • Status changed to Fixed 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States wells Seattle, WA

    Thanks, all!

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Just hit this, thanks for the fix. Upgrading now.

Production build 0.71.5 2024