|
@@ -8,11 +8,17 @@
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
import Command from 'ckeditor5-core/src/command/command';
|
|
import Command from 'ckeditor5-core/src/command/command';
|
|
|
-
|
|
|
|
|
-// TODO: isImage to image utils.
|
|
|
|
|
import { isImage } from '../utils';
|
|
import { isImage } from '../utils';
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * The image alternate text command. It is used to change `alt` attribute on `image` elements.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @extends module:core/command/command~Command
|
|
|
|
|
+ */
|
|
|
export default class ImageAlternateTextCommand extends Command {
|
|
export default class ImageAlternateTextCommand extends Command {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritDoc
|
|
|
|
|
+ */
|
|
|
constructor( editor ) {
|
|
constructor( editor ) {
|
|
|
super( editor );
|
|
super( editor );
|
|
|
|
|
|
|
@@ -25,6 +31,11 @@ export default class ImageAlternateTextCommand extends Command {
|
|
|
} );
|
|
} );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Updates command's value.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
|
|
+ */
|
|
|
_updateValue() {
|
|
_updateValue() {
|
|
|
const doc = this.editor.document;
|
|
const doc = this.editor.document;
|
|
|
const element = doc.selection.getSelectedElement();
|
|
const element = doc.selection.getSelectedElement();
|
|
@@ -36,12 +47,24 @@ export default class ImageAlternateTextCommand extends Command {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritDoc
|
|
|
|
|
+ */
|
|
|
_checkEnabled() {
|
|
_checkEnabled() {
|
|
|
const element = this.editor.document.selection.getSelectedElement();
|
|
const element = this.editor.document.selection.getSelectedElement();
|
|
|
|
|
|
|
|
return isImage( element );
|
|
return isImage( element );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Executes command.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @protected
|
|
|
|
|
+ * @param {Object} options
|
|
|
|
|
+ * @param {String} options.newValue New value of `alt` attribute to set.
|
|
|
|
|
+ * @param {module:engine/model/batch~Batch} [options.batch] Batch to collect all the change steps. New batch will be
|
|
|
|
|
+ * created if this option is not set.
|
|
|
|
|
+ */
|
|
|
_doExecute( options ) {
|
|
_doExecute( options ) {
|
|
|
const editor = this.editor;
|
|
const editor = this.editor;
|
|
|
const doc = editor.document;
|
|
const doc = editor.document;
|