Commit bd7e90b1 authored by catch's avatar catch
Browse files

Issue #3248430 by nod_, Wim Leers, lauriii: Improve Drupal.ckeditor5 documentation

(cherry picked from commit f7f880f8)
parent 12210b1f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
    "Sortable": true,
    "once": true,
    "CKEDITOR": true,
    "CKEditor5": true,
    "tabbable": true
  },
  "settings": {
+50 −7
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 * @file
 * CKEditor 5 implementation of {@link Drupal.editors} API.
 */
/* global CKEditor5 */

((Drupal, debounce, CKEditor5, $, once) => {
  // CKEditor 5 is incompatible with IE11. When IE11 is detected, the CKEditor 5
  // variable is null. In those instances, exit early since CKEditor 5 is not
@@ -12,7 +12,7 @@
  }

  /**
   * The CKEDITOR instances.
   * The CKEditor 5 instances.
   *
   * @type {Map}
   */
@@ -32,6 +32,17 @@
   */
  const required = new Set();

  /**
   * Get the value of the (deep) property on name from scope.
   *
   * @param {object} scope
   *  Object used to search for the function.
   * @param {string} name
   *  The path to access in the scope object.
   *
   * @return {null|function}
   *  The corresponding function from the scope object.
   */
  function findFunc(scope, name) {
    if (!scope) {
      return null;
@@ -44,6 +55,16 @@
    return typeof scope[parts[0]] === 'function' ? scope[parts[0]] : null;
  }

  /**
   * Transform a config key in a callback function or execute the function
   * to dynamically build the configuration entry.
   *
   * @param {object} config
   *  The plugin configuration object.
   *
   * @return {null|function|*}
   *  Resulting configuration value.
   */
  function buildFunc(config) {
    const { func } = config;
    // Assuming a global object.
@@ -155,7 +176,7 @@
  /**
   * Select CKEditor 5 plugin classes to include.
   *
   * Found in the CKEditor5 global js object as {package.Class}.
   * Found in the CKEditor 5 global JavaScript object as {package.Class}.
   *
   * @param {Array} plugins
   *  List of package and Class name of plugins
@@ -365,7 +386,11 @@
  }

  /**
   * Integration of CKEditor 5 with the Drupal editor API.
   *
   * @namespace
   *
   * @see Drupal.editorAttach
   */
  Drupal.editors.ckeditor5 = {
    /**
@@ -582,6 +607,11 @@
    },
  };

  /**
   * Public API for Drupal CKEditor 5 integration.
   *
   * @namespace
   */
  Drupal.ckeditor5 = {
    /**
     * Variable storing the current dialog's save callback.
@@ -590,6 +620,19 @@
     */
    saveCallback: null,

    /**
     * Open a dialog for a Drupal-based plugin.
     *
     * This dynamically loads jQuery UI (if necessary) using the Drupal AJAX
     * framework, then opens a dialog at the specified Drupal path.
     *
     * @param {string} url
     *   The URL that contains the contents of the dialog.
     * @param {function} saveCallback
     *   A function to be called upon saving the dialog.
     * @param {object} dialogSettings
     *   An object containing settings to be passed to the jQuery UI.
     */
    openDialog(url, saveCallback, dialogSettings) {
      // Add a consistent dialog class.
      const classes = dialogSettings.dialogClass