diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
commit | a2190ac74dd4d7080b12bab90e552d7aa81209ef (patch) | |
tree | 8b31f38de9882d18df54cf8d9e0de74167a094eb /extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js')
-rw-r--r-- | extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js b/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js new file mode 100644 index 00000000..fb5a0be6 --- /dev/null +++ b/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js @@ -0,0 +1,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 ); |