view core/modules/ckeditor/js/models/Model.es6.js @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
line wrap: on
line source
/**
 * @file
 * A Backbone Model for the state of a CKEditor toolbar configuration .
 */

(function (Drupal, Backbone) {
  /**
   * Backbone model for the CKEditor toolbar configuration state.
   *
   * @constructor
   *
   * @augments Backbone.Model
   */
  Drupal.ckeditor.Model = Backbone.Model.extend(/** @lends Drupal.ckeditor.Model# */{

    /**
     * Default values.
     *
     * @type {object}
     */
    defaults: /** @lends Drupal.ckeditor.Model# */{

      /**
       * The CKEditor configuration that is being manipulated through the UI.
       */
      activeEditorConfig: null,

      /**
       * The textarea that contains the serialized representation of the active
       * CKEditor configuration.
       */
      $textarea: null,

      /**
       * Tracks whether the active toolbar DOM structure has been changed. When
       * true, activeEditorConfig needs to be updated, and when that is updated,
       * $textarea will also be updated.
       */
      isDirty: false,

      /**
       * The configuration for the hidden CKEditor instance that is used to
       * build the features metadata.
       */
      hiddenEditorConfig: null,

      /**
       * A hash that maps buttons to features.
       */
      buttonsToFeatures: null,

      /**
       * A hash, keyed by a feature name, that details CKEditor plugin features.
       */
      featuresMetadata: null,

      /**
       * Whether the button group names are currently visible.
       */
      groupNamesVisible: false,
    },

    /**
     * @method
     */
    sync() {
      // Push the settings into the textarea.
      this.get('$textarea').val(JSON.stringify(this.get('activeEditorConfig')));
    },
  });
}(Drupal, Backbone));