2015-05-27 16:15:00 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MWSyntaxHighlightNode class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ContentEditable MediaWiki syntax highlight node.
|
|
|
|
*
|
|
|
|
* @class
|
2015-09-16 16:23:02 +00:00
|
|
|
* @abstract
|
2015-05-27 16:15:00 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
ve.ce.MWSyntaxHighlightNode = function VeCeMWSyntaxHighlightNode() {
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2015-09-16 16:23:02 +00:00
|
|
|
OO.initClass( ve.ce.MWSyntaxHighlightNode );
|
2015-05-27 16:15:00 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ce.MWSyntaxHighlightNode.static.name = 'mwSyntaxHighlight';
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2016-11-19 13:56:05 +00:00
|
|
|
// Inherits from ve.ce.GeneratedContentNode
|
2015-05-27 16:15:00 +00:00
|
|
|
ve.ce.MWSyntaxHighlightNode.prototype.generateContents = function () {
|
2016-09-20 21:38:24 +00:00
|
|
|
var node = this,
|
|
|
|
args = arguments;
|
2015-05-27 16:15:00 +00:00
|
|
|
// Parent method
|
2016-09-20 21:38:24 +00:00
|
|
|
return mw.loader.using( 'ext.pygments' ).then( function () {
|
|
|
|
return ve.ce.MWExtensionNode.prototype.generateContents.apply( node, args );
|
|
|
|
} );
|
2015-05-27 16:15:00 +00:00
|
|
|
};
|
|
|
|
|
2016-11-19 13:56:05 +00:00
|
|
|
// Inherits from ve.ce.BranchNode
|
2015-05-27 16:15:00 +00:00
|
|
|
ve.ce.MWSyntaxHighlightNode.prototype.onSetup = function () {
|
|
|
|
// Parent method
|
2015-09-16 16:23:02 +00:00
|
|
|
ve.ce.MWExtensionNode.prototype.onSetup.call( this );
|
2015-05-27 16:15:00 +00:00
|
|
|
|
|
|
|
// DOM changes
|
|
|
|
this.$element.addClass( 've-ce-mwSyntaxHighlightNode' );
|
|
|
|
};
|
|
|
|
|
2016-11-19 13:56:05 +00:00
|
|
|
// Inherits from ve.ce.FocusableNode
|
2015-06-06 16:40:26 +00:00
|
|
|
ve.ce.MWSyntaxHighlightNode.prototype.getBoundingRect = function () {
|
|
|
|
// HACK: Because nodes can overflow due to the pre tag, just use the
|
|
|
|
// first rect (of the wrapper div) for placing the context.
|
2015-09-16 16:23:02 +00:00
|
|
|
return this.rects[ 0 ];
|
2015-06-06 16:40:26 +00:00
|
|
|
};
|
|
|
|
|
2015-09-16 16:23:02 +00:00
|
|
|
/* Concrete subclasses */
|
|
|
|
|
|
|
|
ve.ce.MWBlockSyntaxHighlightNode = function VeCeMWBlockSyntaxHighlightNode() {
|
|
|
|
// Parent method
|
|
|
|
ve.ce.MWBlockExtensionNode.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Mixin method
|
|
|
|
ve.ce.MWSyntaxHighlightNode.call( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ce.MWBlockSyntaxHighlightNode, ve.ce.MWBlockExtensionNode );
|
|
|
|
|
|
|
|
OO.mixinClass( ve.ce.MWBlockSyntaxHighlightNode, ve.ce.MWSyntaxHighlightNode );
|
|
|
|
|
|
|
|
ve.ce.MWBlockSyntaxHighlightNode.static.name = 'mwBlockSyntaxHighlight';
|
|
|
|
|
2015-06-09 15:00:04 +00:00
|
|
|
ve.ce.MWBlockSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightDialog';
|
|
|
|
|
2015-09-16 16:23:02 +00:00
|
|
|
ve.ce.MWInlineSyntaxHighlightNode = function VeCeMWInlineSyntaxHighlightNode() {
|
|
|
|
// Parent method
|
|
|
|
ve.ce.MWInlineExtensionNode.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Mixin method
|
|
|
|
ve.ce.MWSyntaxHighlightNode.call( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ce.MWInlineSyntaxHighlightNode, ve.ce.MWInlineExtensionNode );
|
|
|
|
|
|
|
|
OO.mixinClass( ve.ce.MWInlineSyntaxHighlightNode, ve.ce.MWSyntaxHighlightNode );
|
|
|
|
|
|
|
|
ve.ce.MWInlineSyntaxHighlightNode.static.name = 'mwInlineSyntaxHighlight';
|
|
|
|
|
2016-02-07 23:31:16 +00:00
|
|
|
ve.ce.MWInlineSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightInspector';
|
|
|
|
|
2015-05-27 16:15:00 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2015-09-16 16:23:02 +00:00
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWBlockSyntaxHighlightNode );
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWInlineSyntaxHighlightNode );
|