@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.
- package/CHANGELOG.md +4 -0
- package/README.md +4 -0
- package/build/style.js +1 -1
- package/build/translations/ar.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/vi.js +1 -0
- package/ckeditor5-metadata.json +4 -1
- package/lang/translations/ar.po +33 -0
- package/lang/translations/bg.po +33 -0
- package/lang/translations/bn.po +33 -0
- package/lang/translations/ca.po +33 -0
- package/lang/translations/da.po +33 -0
- package/lang/translations/es.po +33 -0
- package/lang/translations/et.po +33 -0
- package/lang/translations/fi.po +33 -0
- package/lang/translations/fr.po +33 -0
- package/lang/translations/he.po +33 -0
- package/lang/translations/hi.po +33 -0
- package/lang/translations/hu.po +33 -0
- package/lang/translations/id.po +33 -0
- package/lang/translations/ja.po +33 -0
- package/lang/translations/ko.po +33 -0
- package/lang/translations/lt.po +33 -0
- package/lang/translations/ms.po +33 -0
- package/lang/translations/no.po +33 -0
- package/lang/translations/pt.po +33 -0
- package/lang/translations/ro.po +33 -0
- package/lang/translations/ru.po +33 -0
- package/lang/translations/sv.po +33 -0
- package/lang/translations/th.po +33 -0
- package/lang/translations/tr.po +33 -0
- package/lang/translations/uk.po +33 -0
- package/lang/translations/ur.po +33 -0
- package/lang/translations/vi.po +33 -0
- package/package.json +36 -35
- package/src/stylecommand.js +11 -5
- package/src/styleui.js +5 -2
package/src/stylecommand.js
CHANGED
|
@@ -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 {
|
|
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 (
|
|
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
|
-
|
|
89
|
-
|
|
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.
|