Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/ckeditor/js/ckeditor.stylescombo.admin.es6.js @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
1 /** | 1 /** |
2 * @file | 2 * @file |
3 * CKEditor StylesCombo admin behavior. | 3 * CKEditor StylesCombo admin behavior. |
4 */ | 4 */ |
5 | 5 |
6 (function ($, Drupal, drupalSettings, _) { | 6 (function($, Drupal, drupalSettings, _) { |
7 /** | 7 /** |
8 * Ensures that the "stylescombo" button's metadata remains up-to-date. | 8 * Ensures that the "stylescombo" button's metadata remains up-to-date. |
9 * | 9 * |
10 * Triggers the CKEditorPluginSettingsChanged event whenever the "stylescombo" | 10 * Triggers the CKEditorPluginSettingsChanged event whenever the "stylescombo" |
11 * plugin settings change, to ensure that the corresponding feature metadata | 11 * plugin settings change, to ensure that the corresponding feature metadata |
28 // CKEditor instance to be updated and a drupalEditorFeatureModified event | 28 // CKEditor instance to be updated and a drupalEditorFeatureModified event |
29 // to fire.) | 29 // to fire.) |
30 const $ckeditorActiveToolbar = $context | 30 const $ckeditorActiveToolbar = $context |
31 .find('.ckeditor-toolbar-configuration') | 31 .find('.ckeditor-toolbar-configuration') |
32 .find('.ckeditor-toolbar-active'); | 32 .find('.ckeditor-toolbar-active'); |
33 let previousStylesSet = drupalSettings.ckeditor.hiddenCKEditorConfig.stylesSet; | 33 let previousStylesSet = |
34 drupalSettings.ckeditor.hiddenCKEditorConfig.stylesSet; | |
34 const that = this; | 35 const that = this; |
35 $context.find('[name="editor[settings][plugins][stylescombo][styles]"]') | 36 $context |
36 .on('blur.ckeditorStylesComboSettings', function () { | 37 .find('[name="editor[settings][plugins][stylescombo][styles]"]') |
38 .on('blur.ckeditorStylesComboSettings', function() { | |
37 const styles = $.trim($(this).val()); | 39 const styles = $.trim($(this).val()); |
38 const stylesSet = that._generateStylesSetSetting(styles); | 40 const stylesSet = that._generateStylesSetSetting(styles); |
39 if (!_.isEqual(previousStylesSet, stylesSet)) { | 41 if (!_.isEqual(previousStylesSet, stylesSet)) { |
40 previousStylesSet = stylesSet; | 42 previousStylesSet = stylesSet; |
41 $ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [ | 43 $ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [ |
72 if (style.length === 0) { | 74 if (style.length === 0) { |
73 continue; | 75 continue; |
74 } | 76 } |
75 | 77 |
76 // Validate syntax: element[.class...]|label pattern expected. | 78 // Validate syntax: element[.class...]|label pattern expected. |
77 if (style.match(/^ *[a-zA-Z0-9]+ *(\.[a-zA-Z0-9_-]+ *)*\| *.+ *$/) === null) { | 79 if ( |
80 style.match(/^ *[a-zA-Z0-9]+ *(\.[a-zA-Z0-9_-]+ *)*\| *.+ *$/) === | |
81 null | |
82 ) { | |
78 // Instead of failing, we just ignore any invalid styles. | 83 // Instead of failing, we just ignore any invalid styles. |
79 continue; | 84 continue; |
80 } | 85 } |
81 | 86 |
82 // Parse. | 87 // Parse. |
107 * @prop {Drupal~behaviorAttach} attach | 112 * @prop {Drupal~behaviorAttach} attach |
108 * Attaches summary behaviour to the plugin settings vertical tab. | 113 * Attaches summary behaviour to the plugin settings vertical tab. |
109 */ | 114 */ |
110 Drupal.behaviors.ckeditorStylesComboSettingsSummary = { | 115 Drupal.behaviors.ckeditorStylesComboSettingsSummary = { |
111 attach() { | 116 attach() { |
112 $('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary((context) => { | 117 $('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary(context => { |
113 const styles = $.trim($('[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]').val()); | 118 const styles = $.trim( |
119 $( | |
120 '[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]', | |
121 ).val(), | |
122 ); | |
114 if (styles.length === 0) { | 123 if (styles.length === 0) { |
115 return Drupal.t('No styles configured'); | 124 return Drupal.t('No styles configured'); |
116 } | 125 } |
117 | 126 |
118 const count = $.trim(styles).split('\n').length; | 127 const count = $.trim(styles).split('\n').length; |
119 return Drupal.t('@count styles configured', { '@count': count }); | 128 return Drupal.t('@count styles configured', { '@count': count }); |
120 }); | 129 }); |
121 }, | 130 }, |
122 }; | 131 }; |
123 }(jQuery, Drupal, drupalSettings, _)); | 132 })(jQuery, Drupal, drupalSettings, _); |