Uploaded image for project: '{RETIRED} CKEditor Integration'
  1. {RETIRED} CKEditor Integration
  2. CKEDITOR-43

CKEditor sometimes fails to load due to missing jQuery variable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 1.4
    • 1.3
    • None
    • None

    Description

      Randomly We have been seeing the below JavaScript errors being logged in the Console. When these errors occur, CKEditor fails to load. Refreshing the page has fixed the issue.
      The JavaScript Errors:

      Uncaught ReferenceError: jQuery is not defined(anonymous function) @ ckeditor.js:1115(anonymous function) @ ckeditor.js:1127(anonymous function) @ ckeditor.js:1163
      

      Uncaught TypeError: Cannot read property 'split' of undefined window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.skin.loadPart @ ckeditor.js:459 
      d @ ckeditor.js:231 
      (anonymous function) @ ckeditor.js:231
      d @ ckeditor.js:11 ...
      

      I believe this to be caused by a race condition where CKEditor is loaded before jQuery is loaded.
      A couple XWiki plugins for CKEditor cache the jQuery global variable to be used later. But if jQuery hasn't loaded before CKEditor is loading then these plugins will cache undefined instead. So when the plugin is being used later when the editor instance is being constructed, the plugin throws an exception.

      To fix this, jQuery should be set as a dependency of CKEditor in the requireJS config so that CKEditor is not loaded until jQuery has been.
      CKEditor.EditSheet:

      require.config({
        paths: {
          ckeditor: "$!ckeditorPath"
        },
        shim: {
          ckeditor: {
            deps: ['jquery'], // Added jQuery as an explicit dependency.
            exports: 'CKEDITOR'
          }
        }
      });
      

      Attachments

        Activity

          People

            mflorea Marius Dumitru Florea
            jmiklos Jim Miklos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: