mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-12-04 18:59:10 +00:00
b403b58682
Most functionality is provided by MWExtensionNode & MWLiveExtensionInspector. Bug: T45126 Bug: T60388 Bug: T69515 Change-Id: If502a8bd2199b6ceb824e02fdfd13c81c39b53b4
68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWSyntaxHighlightNode class.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel MediaWiki syntax highlight node.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.MWBlockExtensionNode
|
|
*
|
|
* @constructor
|
|
* @param {Object} [element]
|
|
*/
|
|
ve.dm.MWSyntaxHighlightNode = function VeDmMWSyntaxHighlightNode() {
|
|
// Parent constructor
|
|
ve.dm.MWSyntaxHighlightNode.super.apply( this, arguments );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.dm.MWSyntaxHighlightNode, ve.dm.MWBlockExtensionNode );
|
|
|
|
/* Static members */
|
|
|
|
ve.dm.MWSyntaxHighlightNode.static.name = 'mwSyntaxHighlight';
|
|
|
|
ve.dm.MWSyntaxHighlightNode.static.tagName = 'div';
|
|
|
|
ve.dm.MWSyntaxHighlightNode.static.extensionName = 'syntaxhighlight';
|
|
|
|
ve.dm.MWSyntaxHighlightNode.static.getMatchRdfaTypes = function () {
|
|
return [ 'mw:Extension/syntaxhighlight', 'mw:Extension/source' ];
|
|
};
|
|
|
|
/* Static methods */
|
|
|
|
/**
|
|
* Check if a language is supported
|
|
*
|
|
* @param {string} langauge Language name
|
|
* @return {boolean} The language is supported
|
|
*/
|
|
ve.dm.MWSyntaxHighlightNode.static.isLanguageSupported = function ( language ) {
|
|
return mw.config.get( 'wgGeSHiSupportedLanguages' ).indexOf( language ) !== -1;
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Check if the node's current language is supported
|
|
*
|
|
* @return {boolean} The language is supported
|
|
*/
|
|
ve.dm.MWSyntaxHighlightNode.prototype.isLanguageSupported = function () {
|
|
return this.constructor.static.isLanguageSupported( this.getLanguage() );
|
|
};
|
|
|
|
ve.dm.MWSyntaxHighlightNode.prototype.getLanguage = function () {
|
|
return this.getAttribute( 'mw' ).attrs.lang;
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWSyntaxHighlightNode );
|