Update VE core submodule to master (a1fd90540)

New changes:
71baf1c02 Create an 'htmlMsg' function for HTML messages with HTML or DOM arguments
9a7af223e Use ve.htmlMsg to highlight values in attribute changes
a1fd90540 DiffElement: Refactor describeChanges tests

Local changes:
Implement getHtmlMessage in mw.Platform and use for DiffElement

Bug: T195243
Depends-On: Ib4ad16858e4241d33d018830dbcfded63ff703af
Change-Id: Ib5fa39e4f2f529948354b03a141542e23d169fe0
This commit is contained in:
Ed Sanders 2018-06-19 13:30:21 +01:00 committed by Bartosz Dziewoński
parent 4948925351
commit 534b3d66cb
7 changed files with 38 additions and 11 deletions

2
lib/ve

@ -1 +1 @@
Subproject commit e72749663a072bda113c672bcd4b9bc42743caa9
Subproject commit a1fd90540cc79b045f4262c2420b90874609ecdd

View file

@ -74,7 +74,7 @@ ve.dm.MWExternalLinkAnnotation.static.toDomElements = function ( dataElement, do
ve.dm.MWExternalLinkAnnotation.static.describeChange = function ( key, change ) {
if ( key === 'href' ) {
return ve.msg( 'visualeditor-changedesc-link-href', change.from, change.to );
return ve.htmlMsg( 'visualeditor-changedesc-link-href', $( '<del>' ).text( change.from ), $( '<ins>' ).text( change.to ) );
}
return null;
};

View file

@ -212,7 +212,7 @@ ve.dm.MWInternalLinkAnnotation.static.getFragment = function ( original ) {
ve.dm.MWInternalLinkAnnotation.static.describeChange = function ( key, change ) {
if ( key === 'title' ) {
return ve.msg( 'visualeditor-changedesc-link-href', change.from, change.to );
return ve.htmlMsg( 'visualeditor-changedesc-link-href', $( '<del>' ).text( change.from ), $( '<ins>' ).text( change.to ) );
}
return null;
};

View file

@ -49,7 +49,7 @@ ve.dm.MWRedirectMetaItem.static.toDomElements = function ( dataElement, doc ) {
ve.dm.MWRedirectMetaItem.static.describeChange = function ( key, change ) {
if ( key === 'title' ) {
return ve.msg( 'visualeditor-changedesc-mwredirect', change.from, change.to );
return ve.htmlMsg( 'visualeditor-changedesc-mwredirect', $( '<del>' ).text( change.from ), $( '<ins>' ).text( change.to ) );
}
return null;
};

View file

@ -136,7 +136,9 @@ ve.dm.MWImageNode.static.describeChanges = function ( attributeChanges, attribut
);
}
descriptions.push( ve.msg( 'visualeditor-changedesc-image-size', sizeFrom, sizeTo ) );
descriptions.push(
ve.htmlMsg( 'visualeditor-changedesc-image-size', $( '<del>' ).text( sizeFrom ), $( '<ins>' ).text( sizeTo ) )
);
}
for ( key in attributeChanges ) {
if ( customKeys.indexOf( key ) === -1 ) {
@ -154,13 +156,13 @@ ve.dm.MWImageNode.static.describeChanges = function ( attributeChanges, attribut
ve.dm.MWImageNode.static.describeChange = function ( key, change ) {
switch ( key ) {
case 'align':
return ve.msg( 'visualeditor-changedesc-align',
return ve.htmlMsg( 'visualeditor-changedesc-align',
// Messages used:
// visualeditor-align-desc-left, visualeditor-align-desc-right,
// visualeditor-align-desc-center, visualeditor-align-desc-default,
// visualeditor-align-desc-none
ve.msg( 'visualeditor-align-desc-' + change.from ),
ve.msg( 'visualeditor-align-desc-' + change.to )
$( '<del>' ).text( ve.msg( 'visualeditor-align-desc-' + change.from ) ),
$( '<ins>' ).text( ve.msg( 'visualeditor-align-desc-' + change.to ) )
);
case 'originalClasses':
case 'unrecognizedClasses':

View file

@ -70,6 +70,13 @@ ve.init.mw.Platform.prototype.addMessages = function ( messages ) {
*/
ve.init.mw.Platform.prototype.getMessage = mw.msg.bind( mw );
/**
* @inheritdoc
*/
ve.init.mw.Platform.prototype.getHtmlMessage = function () {
return mw.message.apply( mw.message, arguments ).parseDom();
};
/**
* @method
* @inheritdoc

View file

@ -19,6 +19,26 @@
};
ve.test.utils.MWDummyTarget = MWDummyTarget;
function MWDummyPlatform() {
MWDummyPlatform.super.apply( this, arguments );
// Disable some API requests from platform
this.imageInfoCache = null;
}
OO.inheritClass( MWDummyPlatform, ve.init.mw.Platform );
MWDummyPlatform.prototype.getMessage = function () { return Array.prototype.join.call( arguments, ',' ); };
MWDummyPlatform.prototype.getHtmlMessage = function () {
var $wrapper = $( '<div>' );
Array.prototype.forEach.call( arguments, function ( arg, i, args ) {
$wrapper.append( arg );
if ( i < args.length - 1 ) {
$wrapper.append( ',' );
}
} );
// Re-parse HTML to merge text nodes
return $( $.parseHTML( $wrapper.html() ) );
};
ve.test.utils.MWDummyPlatform = MWDummyPlatform;
// Unregister MW override nodes.
// They are temporarily registered in setup/teardown.
ve.dm.modelRegistry.unregister( ve.dm.MWHeadingNode );
@ -44,9 +64,7 @@
corePlatform = ve.init.platform;
coreTarget = ve.init.target;
mwPlatform = new ve.init.mw.Platform();
// Disable some API requests from platform
mwPlatform.imageInfoCache = null;
mwPlatform = new ve.test.utils.MWDummyPlatform();
// Unregister mwPlatform
ve.init.platform = corePlatform;