2020-06-26 16:23:07 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWPingNode class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel MediaWiki ping node. A ping is just a link to a user page, but
|
|
|
|
* by defining it as a node we can make is a single FocusableNode.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.dm.LeafNode
|
2020-08-26 22:46:34 +00:00
|
|
|
* @mixes ve.dm.FocusableNode
|
2020-06-26 16:23:07 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [element] Reference to element in linear model
|
|
|
|
*/
|
|
|
|
function DmMWPingNode() {
|
|
|
|
// Parent constructor
|
|
|
|
DmMWPingNode.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Mixin constructor
|
|
|
|
ve.dm.FocusableNode.call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( DmMWPingNode, ve.dm.LeafNode );
|
|
|
|
|
|
|
|
OO.mixinClass( DmMWPingNode, ve.dm.FocusableNode );
|
|
|
|
|
|
|
|
/* Static members */
|
|
|
|
|
|
|
|
DmMWPingNode.static.name = 'mwPing';
|
|
|
|
|
|
|
|
DmMWPingNode.static.isContent = true;
|
|
|
|
|
|
|
|
DmMWPingNode.static.matchTagNames = null;
|
|
|
|
|
|
|
|
DmMWPingNode.static.matchRdfaTypes = [];
|
|
|
|
|
|
|
|
DmMWPingNode.static.matchFunction = function () {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
DmMWPingNode.static.disallowedAnnotationTypes = [ 'link' ];
|
|
|
|
|
|
|
|
DmMWPingNode.static.toDomElements = function ( dataElement, doc, converter ) {
|
|
|
|
var domElements,
|
2020-06-29 13:57:07 +00:00
|
|
|
prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
|
2022-01-19 16:29:10 +00:00
|
|
|
suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
|
2020-06-26 16:23:07 +00:00
|
|
|
title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, dataElement.attributes.user );
|
|
|
|
|
|
|
|
dataElement = ve.dm.MWInternalLinkAnnotation.static.dataElementFromTitle( title );
|
|
|
|
domElements = ve.dm.MWInternalLinkAnnotation.static.toDomElements( dataElement, doc, converter );
|
|
|
|
domElements[ 0 ].appendChild(
|
|
|
|
doc.createTextNode( title.getMainText() )
|
|
|
|
);
|
2022-01-19 16:29:10 +00:00
|
|
|
domElements.unshift( document.createTextNode( prefix ) );
|
|
|
|
domElements.push( document.createTextNode( suffix ) );
|
2020-06-26 16:23:07 +00:00
|
|
|
|
2022-01-19 16:29:10 +00:00
|
|
|
return domElements;
|
2020-06-26 16:23:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// toDataElement should never be called for this node
|
|
|
|
DmMWPingNode.static.toDataElement = null;
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.modelRegistry.register( DmMWPingNode );
|