2 * VisualEditor ContentEditable MWSyntaxHighlightNode class.
4 * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
9 * ContentEditable MediaWiki syntax highlight node.
16 ve.ce.MWSyntaxHighlightNode = function VeCeMWSyntaxHighlightNode() {
21 OO.initClass( ve.ce.MWSyntaxHighlightNode );
23 /* Static Properties */
25 ve.ce.MWSyntaxHighlightNode.static.name = 'mwSyntaxHighlight';
29 // Inherits from ve.ce.GeneratedContentNode
30 ve.ce.MWSyntaxHighlightNode.prototype.generateContents = function () {
34 return mw.loader.using( 'ext.pygments' ).then( function () {
35 return ve.ce.MWExtensionNode.prototype.generateContents.apply( node, args );
39 // Inherits from ve.ce.BranchNode
40 ve.ce.MWSyntaxHighlightNode.prototype.onSetup = function () {
42 ve.ce.MWExtensionNode.prototype.onSetup.call( this );
45 this.$element.addClass( 've-ce-mwSyntaxHighlightNode' );
48 // Inherits from ve.ce.FocusableNode
49 ve.ce.MWSyntaxHighlightNode.prototype.getBoundingRect = function () {
50 // HACK: Because nodes can overflow due to the pre tag, just use the
51 // first rect (of the wrapper div) for placing the context.
52 return this.rects[ 0 ];
55 /* Concrete subclasses */
57 ve.ce.MWBlockSyntaxHighlightNode = function VeCeMWBlockSyntaxHighlightNode() {
59 ve.ce.MWBlockExtensionNode.super.apply( this, arguments );
62 ve.ce.MWSyntaxHighlightNode.call( this );
65 OO.inheritClass( ve.ce.MWBlockSyntaxHighlightNode, ve.ce.MWBlockExtensionNode );
67 OO.mixinClass( ve.ce.MWBlockSyntaxHighlightNode, ve.ce.MWSyntaxHighlightNode );
69 ve.ce.MWBlockSyntaxHighlightNode.static.name = 'mwBlockSyntaxHighlight';
71 ve.ce.MWBlockSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightDialog';
73 ve.ce.MWInlineSyntaxHighlightNode = function VeCeMWInlineSyntaxHighlightNode() {
75 ve.ce.MWInlineExtensionNode.super.apply( this, arguments );
78 ve.ce.MWSyntaxHighlightNode.call( this );
81 OO.inheritClass( ve.ce.MWInlineSyntaxHighlightNode, ve.ce.MWInlineExtensionNode );
83 OO.mixinClass( ve.ce.MWInlineSyntaxHighlightNode, ve.ce.MWSyntaxHighlightNode );
85 ve.ce.MWInlineSyntaxHighlightNode.static.name = 'mwInlineSyntaxHighlight';
87 ve.ce.MWInlineSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightInspector';
91 ve.ce.nodeFactory.register( ve.ce.MWBlockSyntaxHighlightNode );
92 ve.ce.nodeFactory.register( ve.ce.MWInlineSyntaxHighlightNode );