|
|
@@ -10,13 +10,13 @@
|
|
|
import Command from '@ckeditor/ckeditor5-core/src/command';
|
|
|
|
|
|
/**
|
|
|
- * A extension of the base {@link module:core/command~Command} class, which provides utilities for a command
|
|
|
- * which toggles a single attribute on a text or an element.
|
|
|
+ * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
|
|
|
+ * that toggles a single attribute on a text or an element.
|
|
|
*
|
|
|
* `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
|
|
|
* to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
|
|
|
*
|
|
|
- * The command checks {@link module:engine/model/document~Document#schema} to decide if it can be enabled
|
|
|
+ * The command checks the {@link module:engine/model/document~Document#schema} to decide if it can be enabled
|
|
|
* for the current selection and to which nodes the attribute can be applied.
|
|
|
*
|
|
|
* @extends module:core/command~Command
|
|
|
@@ -41,9 +41,9 @@ export default class AttributeCommand extends Command {
|
|
|
* Flag indicating whether the command is active. The command is active when the
|
|
|
* {@link module:engine/model/selection~Selection#hasAttribute selection has the attribute} which means that:
|
|
|
*
|
|
|
- * * if the selection is not empty that it starts in a text (or other node) which has the attribute set,
|
|
|
- * * if the selection is empty that the selection has the attribute itself (which means that newly typed
|
|
|
- * text will have this attribute too).
|
|
|
+ * * If the selection is not empty – That it starts in a text (or another node) which has the attribute set.
|
|
|
+ * * If the selection is empty – That the selection has the attribute itself (which means that newly typed
|
|
|
+ * text will have this attribute, too).
|
|
|
*
|
|
|
* @observable
|
|
|
* @readonly
|
|
|
@@ -52,7 +52,7 @@ export default class AttributeCommand extends Command {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Updates command's {@link #value} based on the current selection.
|
|
|
+ * Updates the command's {@link #value} based on the current selection.
|
|
|
*/
|
|
|
refresh() {
|
|
|
const doc = this.editor.document;
|
|
|
@@ -62,25 +62,25 @@ export default class AttributeCommand extends Command {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Executes the command – applies or removes the attribute from the selection.
|
|
|
+ * Executes the command — applies the attribute to the selection or removes it from the selection.
|
|
|
*
|
|
|
* If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
|
|
|
*
|
|
|
* The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
|
|
|
*
|
|
|
- * * if selection is on a range, the command applies the attribute on all nodes in that range
|
|
|
- * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}),
|
|
|
- * * if selection is collapsed in non-empty node, the command applies attribute to the
|
|
|
- * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from selection),
|
|
|
- * * if selection is collapsed in empty node, the command applies attribute to the parent node of selection (note
|
|
|
- * that selection inherits all attributes from a node if it is in empty node).
|
|
|
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
|
|
|
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
|
|
|
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
|
|
|
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
|
|
|
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
|
|
|
+ * that the selection inherits all attributes from a node if it is in an empty node).
|
|
|
*
|
|
|
* @fires execute
|
|
|
- * @param {Object} [options] Options of command.
|
|
|
- * @param {Boolean} [options.forceValue] If set it will force the command behavior. If `true`, command will apply the attribute,
|
|
|
+ * @param {Object} [options] Command options.
|
|
|
+ * @param {Boolean} [options.forceValue] If set, it will force the command behavior. If `true`, the command will apply the attribute,
|
|
|
* otherwise the command will remove the attribute.
|
|
|
- * If not set, the command will look for it's current value to decide what it should do.
|
|
|
- * @param {module:engine/model/batch~Batch} [options.batch] Batch to group undo steps.
|
|
|
+ * If not set, the command will look for its current value to decide what it should do.
|
|
|
+ * @param {module:engine/model/batch~Batch} [options.batch] A batch to group undo steps.
|
|
|
*/
|
|
|
execute( options = {} ) {
|
|
|
const doc = this.editor.document;
|