mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
Merge "Clickable inline images"
This commit is contained in:
commit
906f4cf21d
|
@ -59,8 +59,20 @@ ve.ce.MWImageNode.prototype.onUpdate = function () {
|
||||||
* @param {jQuery.Event} e Click event
|
* @param {jQuery.Event} e Click event
|
||||||
*/
|
*/
|
||||||
ve.ce.MWImageNode.prototype.onClick = function ( e ) {
|
ve.ce.MWImageNode.prototype.onClick = function ( e ) {
|
||||||
e.preventDefault();
|
var range,
|
||||||
return false;
|
surfaceModel = this.getRoot().getSurface().getModel(),
|
||||||
|
selection = surfaceModel.getSelection();
|
||||||
|
|
||||||
|
range = new ve.Range(
|
||||||
|
this.model.getOffset(),
|
||||||
|
this.model.getOffset() + this.model.getOuterLength()
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( e.shiftKey ) {
|
||||||
|
range = ve.Range.newCoveringRange( [ selection, range ], selection.from > range.from );
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getRoot().getSurface().getModel().change( null, range );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,10 +43,11 @@ ve.Range.newFromTranslatedRange = function ( range, distance ) {
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {Array} ranges Array of ve.Range objects (at least one)
|
* @param {Array} ranges Array of ve.Range objects (at least one)
|
||||||
|
* @param {boolean} backwards Return a backwards range
|
||||||
* @returns {ve.Range} Range that spans all of the given ranges
|
* @returns {ve.Range} Range that spans all of the given ranges
|
||||||
*/
|
*/
|
||||||
ve.Range.newCoveringRange = function ( ranges ) {
|
ve.Range.newCoveringRange = function ( ranges, backwards ) {
|
||||||
var minStart, maxEnd, i;
|
var minStart, maxEnd, i, range;
|
||||||
if ( !ranges || ranges.length === 0 ) {
|
if ( !ranges || ranges.length === 0 ) {
|
||||||
throw new Error( 'newCoveringRange() requires at least one range' );
|
throw new Error( 'newCoveringRange() requires at least one range' );
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,12 @@ ve.Range.newCoveringRange = function ( ranges ) {
|
||||||
maxEnd = ranges[i].end;
|
maxEnd = ranges[i].end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ve.Range( minStart, maxEnd );
|
if ( backwards ) {
|
||||||
|
range = new ve.Range( maxEnd, minStart );
|
||||||
|
} else {
|
||||||
|
range = new ve.Range( minStart, maxEnd );
|
||||||
|
}
|
||||||
|
return range;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
Loading…
Reference in a new issue