@ckeditor/ckeditor5-style 34.2.0 → 35.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +4 -0
  3. package/build/style.js +1 -1
  4. package/build/translations/ar.js +1 -0
  5. package/build/translations/bg.js +1 -0
  6. package/build/translations/bn.js +1 -0
  7. package/build/translations/ca.js +1 -0
  8. package/build/translations/da.js +1 -0
  9. package/build/translations/es.js +1 -0
  10. package/build/translations/et.js +1 -0
  11. package/build/translations/fi.js +1 -0
  12. package/build/translations/fr.js +1 -0
  13. package/build/translations/he.js +1 -0
  14. package/build/translations/hi.js +1 -0
  15. package/build/translations/hu.js +1 -0
  16. package/build/translations/id.js +1 -0
  17. package/build/translations/ja.js +1 -0
  18. package/build/translations/ko.js +1 -0
  19. package/build/translations/lt.js +1 -0
  20. package/build/translations/ms.js +1 -0
  21. package/build/translations/no.js +1 -0
  22. package/build/translations/pt.js +1 -0
  23. package/build/translations/ro.js +1 -0
  24. package/build/translations/ru.js +1 -0
  25. package/build/translations/sv.js +1 -0
  26. package/build/translations/th.js +1 -0
  27. package/build/translations/tr.js +1 -0
  28. package/build/translations/uk.js +1 -0
  29. package/build/translations/ur.js +1 -0
  30. package/build/translations/vi.js +1 -0
  31. package/ckeditor5-metadata.json +4 -1
  32. package/lang/translations/ar.po +33 -0
  33. package/lang/translations/bg.po +33 -0
  34. package/lang/translations/bn.po +33 -0
  35. package/lang/translations/ca.po +33 -0
  36. package/lang/translations/da.po +33 -0
  37. package/lang/translations/es.po +33 -0
  38. package/lang/translations/et.po +33 -0
  39. package/lang/translations/fi.po +33 -0
  40. package/lang/translations/fr.po +33 -0
  41. package/lang/translations/he.po +33 -0
  42. package/lang/translations/hi.po +33 -0
  43. package/lang/translations/hu.po +33 -0
  44. package/lang/translations/id.po +33 -0
  45. package/lang/translations/ja.po +33 -0
  46. package/lang/translations/ko.po +33 -0
  47. package/lang/translations/lt.po +33 -0
  48. package/lang/translations/ms.po +33 -0
  49. package/lang/translations/no.po +33 -0
  50. package/lang/translations/pt.po +33 -0
  51. package/lang/translations/ro.po +33 -0
  52. package/lang/translations/ru.po +33 -0
  53. package/lang/translations/sv.po +33 -0
  54. package/lang/translations/th.po +33 -0
  55. package/lang/translations/tr.po +33 -0
  56. package/lang/translations/uk.po +33 -0
  57. package/lang/translations/ur.po +33 -0
  58. package/lang/translations/vi.po +33 -0
  59. package/package.json +36 -35
  60. package/src/stylecommand.js +11 -5
  61. package/src/styleui.js +5 -2
@@ -147,10 +147,14 @@ export default class StyleCommand extends Command {
147
147
  * * If the selection is on a range, the command applies the style classes to the nearest block parent element.
148
148
  *
149
149
  * @fires execute
150
- * @param {String} styleName Style name matching the one defined in the
150
+ * @param {Object} [options] Command options.
151
+ * @param {String} options.styleName Style name matching the one defined in the
151
152
  * {@link module:style/style~StyleConfig#definitions configuration}.
153
+ * @param {Boolean} [options.forceValue] Whether the command should add given style (`true`) or remove it (`false`) from the selection.
154
+ * If not set (default), the command will toggle the style basing on the first selected node. Note, that this will not force
155
+ * setting a style on an element that cannot receive given style.
152
156
  */
153
- execute( styleName ) {
157
+ execute( { styleName, forceValue } ) {
154
158
  if ( !this.enabledStyles.includes( styleName ) ) {
155
159
  /**
156
160
  * Style command can be executed only with a correct style name.
@@ -177,6 +181,8 @@ export default class StyleCommand extends Command {
177
181
  ...this._styleDefinitions.block
178
182
  ].find( ( { name } ) => name == styleName );
179
183
 
184
+ const shouldAddStyle = forceValue === undefined ? !this.value.includes( definition.name ) : forceValue;
185
+
180
186
  model.change( () => {
181
187
  let selectables;
182
188
 
@@ -187,10 +193,10 @@ export default class StyleCommand extends Command {
187
193
  }
188
194
 
189
195
  for ( const selectable of selectables ) {
190
- if ( this.value.includes( definition.name ) ) {
191
- htmlSupport.removeModelHtmlClass( definition.element, definition.classes, selectable );
192
- } else {
196
+ if ( shouldAddStyle ) {
193
197
  htmlSupport.addModelHtmlClass( definition.element, definition.classes, selectable );
198
+ } else {
199
+ htmlSupport.removeModelHtmlClass( definition.element, definition.classes, selectable );
194
200
  }
195
201
  }
196
202
  } );
package/src/styleui.js CHANGED
@@ -85,8 +85,11 @@ export default class StyleUI extends Plugin {
85
85
  panelView.delegate( 'execute' ).to( dropdown );
86
86
 
87
87
  // Execute the command when a style is selected in the styles panel.
88
- panelView.on( 'execute', evt => {
89
- editor.execute( 'style', evt.source.styleDefinition.name );
88
+ // Also focus the editable after executing the command.
89
+ // It overrides a default behaviour where the focus is moved to the dropdown button (#12125).
90
+ dropdown.on( 'execute', evt => {
91
+ editor.execute( 'style', { styleName: evt.source.styleDefinition.name } );
92
+ editor.editing.view.focus();
90
93
  } );
91
94
 
92
95
  // Bind the state of the styles panel to the command.