Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / ckeditor / js / ckeditor.stylescombo.admin.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal, drupalSettings, _) {
9   Drupal.behaviors.ckeditorStylesComboSettings = {
10     attach: function attach(context) {
11       var $context = $(context);
12
13       var $ckeditorActiveToolbar = $context.find('.ckeditor-toolbar-configuration').find('.ckeditor-toolbar-active');
14       var previousStylesSet = drupalSettings.ckeditor.hiddenCKEditorConfig.stylesSet;
15       var that = this;
16       $context.find('[name="editor[settings][plugins][stylescombo][styles]"]').on('blur.ckeditorStylesComboSettings', function () {
17         var styles = $.trim($(this).val());
18         var stylesSet = that._generateStylesSetSetting(styles);
19         if (!_.isEqual(previousStylesSet, stylesSet)) {
20           previousStylesSet = stylesSet;
21           $ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [{ stylesSet: stylesSet }]);
22         }
23       });
24     },
25     _generateStylesSetSetting: function _generateStylesSetSetting(styles) {
26       var stylesSet = [];
27
28       styles = styles.replace(/\r/g, '\n');
29       var lines = styles.split('\n');
30       for (var i = 0; i < lines.length; i++) {
31         var style = $.trim(lines[i]);
32
33         if (style.length === 0) {
34           continue;
35         }
36
37         if (style.match(/^ *[a-zA-Z0-9]+ *(\.[a-zA-Z0-9_-]+ *)*\| *.+ *$/) === null) {
38           continue;
39         }
40
41         var parts = style.split('|');
42         var selector = parts[0];
43         var label = parts[1];
44         var classes = selector.split('.');
45         var element = classes.shift();
46
47         stylesSet.push({
48           attributes: { class: classes.join(' ') },
49           element: element,
50           name: label
51         });
52       }
53
54       return stylesSet;
55     }
56   };
57
58   Drupal.behaviors.ckeditorStylesComboSettingsSummary = {
59     attach: function attach() {
60       $('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary(function (context) {
61         var styles = $.trim($('[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]').val());
62         if (styles.length === 0) {
63           return Drupal.t('No styles configured');
64         }
65
66         var count = $.trim(styles).split('\n').length;
67         return Drupal.t('@count styles configured', { '@count': count });
68       });
69     }
70   };
71 })(jQuery, Drupal, drupalSettings, _);