mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-12-04 18:59:10 +00:00
fbdf65a344
This fixes the double-click/press-enter to edit functionality. Change-Id: I275c505d8a3abb7d7e3686ffacf52e54235241e7
92 lines
2.5 KiB
JavaScript
92 lines
2.5 KiB
JavaScript
/*!
|
|
* 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 = 'syntaxhighlightDialog';
|
|
|
|
/* 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';
|
|
|
|
ve.ce.MWInlineSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightInspector';
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWBlockSyntaxHighlightNode );
|
|
ve.ce.nodeFactory.register( ve.ce.MWInlineSyntaxHighlightNode );
|