2015-05-27 16:15:00 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MWSyntaxHighlightNode class.
|
|
|
|
*
|
2024-02-29 15:13:03 +00:00
|
|
|
* @copyright VisualEditor Team and others
|
2015-05-27 16:15:00 +00:00
|
|
|
* @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 () {
|
2024-06-06 15:32:22 +00:00
|
|
|
return mw.loader.using( 'ext.pygments' ).then(
|
2024-04-23 11:29:42 +00:00
|
|
|
// Parent method
|
2024-06-06 15:32:22 +00:00
|
|
|
() => ve.ce.MWExtensionNode.prototype.generateContents.apply( this, arguments )
|
2024-04-23 11:29:42 +00:00
|
|
|
);
|
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
|
|
|
};
|