summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/ckeditor5/js/ckeditor5.image.admin.js
blob: 5d9d9f9a16336c442538b8a576e8fa32a22bf6e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * @file
 * CKEditor 5 Image admin behavior.
 */

(function ($, Drupal) {
  /**
   * Provides the summary for the "image" plugin settings vertical tab.
   *
   * @type {Drupal~behavior}
   *
   * @prop {Drupal~behaviorAttach} attach
   *   Attaches summary behavior to the plugin settings vertical tab.
   */
  Drupal.behaviors.ckeditor5ImageSettingsSummary = {
    attach() {
      $('[data-ckeditor5-plugin-id="ckeditor5_image"]').drupalSetSummary(
        (context) => {
          const uploadsEnabled = document.querySelector(
            '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-image-status"]',
          ).checked;
          if (uploadsEnabled) {
            return Drupal.t('Images can only be uploaded.');
          }
          return Drupal.t('Images can only be added by URL.');
        },
      );
    },
  };
})(jQuery, Drupal);