]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / extensions / SyntaxHighlight_GeSHi / modules / ve-syntaxhighlight / ve.ce.MWSyntaxHighlightNode.js
1 /*!
2  * VisualEditor ContentEditable MWSyntaxHighlightNode class.
3  *
4  * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
5  * @license The MIT License (MIT); see LICENSE.txt
6  */
7
8 /**
9  * ContentEditable MediaWiki syntax highlight node.
10  *
11  * @class
12  * @abstract
13  *
14  * @constructor
15  */
16 ve.ce.MWSyntaxHighlightNode = function VeCeMWSyntaxHighlightNode() {
17 };
18
19 /* Inheritance */
20
21 OO.initClass( ve.ce.MWSyntaxHighlightNode );
22
23 /* Static Properties */
24
25 ve.ce.MWSyntaxHighlightNode.static.name = 'mwSyntaxHighlight';
26
27 /* Methods */
28
29 // Inherits from ve.ce.GeneratedContentNode
30 ve.ce.MWSyntaxHighlightNode.prototype.generateContents = function () {
31         var node = this,
32                 args = arguments;
33         // Parent method
34         return mw.loader.using( 'ext.pygments' ).then( function () {
35                 return ve.ce.MWExtensionNode.prototype.generateContents.apply( node, args );
36         } );
37 };
38
39 // Inherits from ve.ce.BranchNode
40 ve.ce.MWSyntaxHighlightNode.prototype.onSetup = function () {
41         // Parent method
42         ve.ce.MWExtensionNode.prototype.onSetup.call( this );
43
44         // DOM changes
45         this.$element.addClass( 've-ce-mwSyntaxHighlightNode' );
46 };
47
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 ];
53 };
54
55 /* Concrete subclasses */
56
57 ve.ce.MWBlockSyntaxHighlightNode = function VeCeMWBlockSyntaxHighlightNode() {
58         // Parent method
59         ve.ce.MWBlockExtensionNode.super.apply( this, arguments );
60
61         // Mixin method
62         ve.ce.MWSyntaxHighlightNode.call( this );
63 };
64
65 OO.inheritClass( ve.ce.MWBlockSyntaxHighlightNode, ve.ce.MWBlockExtensionNode );
66
67 OO.mixinClass( ve.ce.MWBlockSyntaxHighlightNode, ve.ce.MWSyntaxHighlightNode );
68
69 ve.ce.MWBlockSyntaxHighlightNode.static.name = 'mwBlockSyntaxHighlight';
70
71 ve.ce.MWBlockSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightDialog';
72
73 ve.ce.MWInlineSyntaxHighlightNode = function VeCeMWInlineSyntaxHighlightNode() {
74         // Parent method
75         ve.ce.MWInlineExtensionNode.super.apply( this, arguments );
76
77         // Mixin method
78         ve.ce.MWSyntaxHighlightNode.call( this );
79 };
80
81 OO.inheritClass( ve.ce.MWInlineSyntaxHighlightNode, ve.ce.MWInlineExtensionNode );
82
83 OO.mixinClass( ve.ce.MWInlineSyntaxHighlightNode, ve.ce.MWSyntaxHighlightNode );
84
85 ve.ce.MWInlineSyntaxHighlightNode.static.name = 'mwInlineSyntaxHighlight';
86
87 ve.ce.MWInlineSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightInspector';
88
89 /* Registration */
90
91 ve.ce.nodeFactory.register( ve.ce.MWBlockSyntaxHighlightNode );
92 ve.ce.nodeFactory.register( ve.ce.MWInlineSyntaxHighlightNode );