Update gallery alt with caption when set as same

Follow up to Idf297d8a98995971c5835b0cea56c3317a3626e2

Bug: T330842
Change-Id: Ia5e180f03a8199d8347558803336617472492a23
This commit is contained in:
Arlo Breault 2023-03-09 14:40:19 -05:00
parent fc1c0b2b9b
commit 8c73feb0b3

View file

@ -517,7 +517,7 @@ ve.ui.MWGalleryDialog.prototype.getSetupProcess = function ( data ) {
this.captionTarget.connect( this, { change: 'updateActions' } );
this.highlightedAltTextInput.connect( this, { change: 'updateActions' } );
this.altTextSameAsCaption.connect( this, { change: 'onAltTextSameAsCaptionChange' } );
this.highlightedCaptionTarget.connect( this, { change: 'updateActions' } );
this.highlightedCaptionTarget.connect( this, { change: 'onHighlightedCaptionTargetChange' } );
return this.imagesPromise;
}, this );
@ -839,12 +839,26 @@ ve.ui.MWGalleryDialog.prototype.onModeDropdownChange = function () {
this.updateActions();
};
/**
* Handle change event for this.highlightedCaptionTarget
*/
ve.ui.MWGalleryDialog.prototype.onHighlightedCaptionTargetChange = function () {
if ( this.altTextSameAsCaption.isSelected() ) {
var surfaceModel = this.highlightedCaptionTarget.getSurface().getModel();
var caption = surfaceModel.getLinearFragment(
surfaceModel.getDocument().getDocumentRange()
).getText();
this.highlightedAltTextInput.setValue( caption );
}
this.updateActions();
};
/**
* Handle change event for this.altTextSameAsCaption
*/
ve.ui.MWGalleryDialog.prototype.onAltTextSameAsCaptionChange = function () {
this.highlightedAltTextInput.setReadOnly( this.isReadOnly() || this.altTextSameAsCaption.isSelected() );
this.updateActions();
this.onHighlightedCaptionTargetChange();
};
/**