mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-25 08:50:22 +00:00
bca14cbe03
Depends-On: I49733aa6aa2c1e61a88e7c88e84f1f4338acfac1 Change-Id: I9586d07ded0e41afdcfbd6e46364bb1f837cf1c0
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
/*!
|
|
* 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
|
|
* @mixes ve.dm.FocusableNode
|
|
*
|
|
* @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,
|
|
prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
|
|
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() )
|
|
);
|
|
|
|
return [ document.createTextNode( prefix ) ].concat( domElements );
|
|
};
|
|
|
|
// toDataElement should never be called for this node
|
|
DmMWPingNode.static.toDataElement = null;
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( DmMWPingNode );
|