mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Show redirect meta items in visual diff
Bug: T161290 Change-Id: Icf68f6d085ab2de802350df0d29208f0653ceb66
This commit is contained in:
parent
860d9ae926
commit
db5f13fc93
|
@ -40,18 +40,22 @@ ve.dm.MWFlaggedMetaItem.static.toDataElement = function ( domElements ) {
|
|||
return { type: this.name, attributes: { property: property } };
|
||||
};
|
||||
|
||||
ve.dm.MWFlaggedMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
||||
var meta = doc.createElement( 'meta' ),
|
||||
property = OO.getProp( dataElement, 'attributes', 'property' );
|
||||
ve.dm.MWFlaggedMetaItem.static.toDomElements = function ( dataElement, doc, converter ) {
|
||||
var domElement;
|
||||
var property = OO.getProp( dataElement, 'attributes', 'property' );
|
||||
|
||||
if ( !property || this.matchRdfaTypes.indexOf( property ) === -1 ) {
|
||||
// Fallback to first item if somehow unset
|
||||
property = this.matchRdfaTypes[ 0 ];
|
||||
}
|
||||
|
||||
meta.setAttribute( 'property', property );
|
||||
|
||||
return [ meta ];
|
||||
if ( converter.isForPreview() ) {
|
||||
domElement = doc.createElement( 'div' );
|
||||
domElement.innerText = property;
|
||||
} else {
|
||||
domElement = doc.createElement( 'meta' );
|
||||
domElement.setAttribute( 'property', property );
|
||||
}
|
||||
return [ domElement ];
|
||||
};
|
||||
|
||||
/* No registration, as this is not a valid meta item, just an abstract class. */
|
||||
|
|
|
@ -39,12 +39,19 @@ ve.dm.MWRedirectMetaItem.static.toDataElement = function ( domElements, converte
|
|||
return linkData;
|
||||
};
|
||||
|
||||
ve.dm.MWRedirectMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
||||
var meta = doc.createElement( 'link' );
|
||||
meta.setAttribute( 'rel', 'mw:PageProp/redirect' );
|
||||
// HACK piggy-back on MWInternalLinkAnnotation's logic
|
||||
meta.setAttribute( 'href', ve.dm.MWInternalLinkAnnotation.static.getHref( dataElement ) );
|
||||
return [ meta ];
|
||||
ve.dm.MWRedirectMetaItem.static.toDomElements = function ( dataElement, doc, converter ) {
|
||||
var domElement;
|
||||
var href = ve.dm.MWInternalLinkAnnotation.static.getHref( dataElement );
|
||||
if ( converter.isForPreview() ) {
|
||||
// TODO: Move this a DM utility that doesn't use jQuery internally
|
||||
domElement = ve.init.mw.ArticleTarget.static.buildRedirectMsg( dataElement.attributes.title )[ 0 ];
|
||||
} else {
|
||||
domElement = doc.createElement( 'link' );
|
||||
domElement.setAttribute( 'rel', 'mw:PageProp/redirect' );
|
||||
// HACK piggy-back on MWInternalLinkAnnotation's logic
|
||||
domElement.setAttribute( 'href', href );
|
||||
}
|
||||
return [ domElement ];
|
||||
};
|
||||
|
||||
ve.dm.MWRedirectMetaItem.static.describeChange = function ( key, change ) {
|
||||
|
@ -57,3 +64,19 @@ ve.dm.MWRedirectMetaItem.static.describeChange = function ( key, change ) {
|
|||
/* Registration */
|
||||
|
||||
ve.dm.modelRegistry.register( ve.dm.MWRedirectMetaItem );
|
||||
|
||||
ve.ui.metaListDiffRegistry.register( 'mwRedirect', function ( diffElement, diffQueue, documentNode, documentSpacerNode ) {
|
||||
diffQueue = diffElement.processQueue( diffQueue );
|
||||
|
||||
if ( !diffQueue.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var redirects = document.createElement( 'div' );
|
||||
diffElement.renderQueue(
|
||||
diffQueue,
|
||||
redirects,
|
||||
documentSpacerNode
|
||||
);
|
||||
documentNode.insertBefore( redirects, documentNode.firstChild );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue