summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js
blob: fb5a0be669d4b4ec473b871686538ee59045eb24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*!
 * 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
 * @abstract
 *
 * @constructor
 */
ve.ce.MWSyntaxHighlightNode = function VeCeMWSyntaxHighlightNode() {
};

/* Inheritance */

OO.initClass( ve.ce.MWSyntaxHighlightNode );

/* Static Properties */

ve.ce.MWSyntaxHighlightNode.static.name = 'mwSyntaxHighlight';

ve.ce.MWSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlight';

/* Methods */

/** */
ve.ce.MWSyntaxHighlightNode.prototype.generateContents = function () {
	if ( !this.getModel().isLanguageSupported() ) {
		return $.Deferred().reject().promise();
	}
	// Parent method
	return ve.ce.MWExtensionNode.prototype.generateContents.apply( this, arguments );
};

/** */
ve.ce.MWSyntaxHighlightNode.prototype.onSetup = function () {
	// Parent method
	ve.ce.MWExtensionNode.prototype.onSetup.call( this );

	// DOM changes
	this.$element.addClass( 've-ce-mwSyntaxHighlightNode' );
};

/** */
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.
	return this.rects[ 0 ];
};

/* 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';

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';

/* Registration */

ve.ce.nodeFactory.register( ve.ce.MWBlockSyntaxHighlightNode );
ve.ce.nodeFactory.register( ve.ce.MWInlineSyntaxHighlightNode );