diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/SyntaxHighlight_GeSHi/modules |
first commit
Diffstat (limited to 'www/wiki/extensions/SyntaxHighlight_GeSHi/modules')
14 files changed, 972 insertions, 0 deletions
diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/pygments.generated.css b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/pygments.generated.css new file mode 100644 index 00000000..2321fdc5 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/pygments.generated.css @@ -0,0 +1,70 @@ +/* Stylesheet generated by updateCSS.php */ +.mw-highlight .hll { background-color: #ffffcc } +.mw-highlight { background: #f8f8f8; } +.mw-highlight .c { color: #408080; font-style: italic } /* Comment */ +.mw-highlight .err { border: 1px solid #FF0000 } /* Error */ +.mw-highlight .k { color: #008000; font-weight: bold } /* Keyword */ +.mw-highlight .o { color: #666666 } /* Operator */ +.mw-highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */ +.mw-highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ +.mw-highlight .cp { color: #BC7A00 } /* Comment.Preproc */ +.mw-highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */ +.mw-highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ +.mw-highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ +.mw-highlight .gd { color: #A00000 } /* Generic.Deleted */ +.mw-highlight .ge { font-style: italic } /* Generic.Emph */ +.mw-highlight .gr { color: #FF0000 } /* Generic.Error */ +.mw-highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.mw-highlight .gi { color: #00A000 } /* Generic.Inserted */ +.mw-highlight .go { color: #888888 } /* Generic.Output */ +.mw-highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.mw-highlight .gs { font-weight: bold } /* Generic.Strong */ +.mw-highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.mw-highlight .gt { color: #0044DD } /* Generic.Traceback */ +.mw-highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.mw-highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.mw-highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.mw-highlight .kp { color: #008000 } /* Keyword.Pseudo */ +.mw-highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.mw-highlight .kt { color: #B00040 } /* Keyword.Type */ +.mw-highlight .m { color: #666666 } /* Literal.Number */ +.mw-highlight .s { color: #BA2121 } /* Literal.String */ +.mw-highlight .na { color: #7D9029 } /* Name.Attribute */ +.mw-highlight .nb { color: #008000 } /* Name.Builtin */ +.mw-highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ +.mw-highlight .no { color: #880000 } /* Name.Constant */ +.mw-highlight .nd { color: #AA22FF } /* Name.Decorator */ +.mw-highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ +.mw-highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.mw-highlight .nf { color: #0000FF } /* Name.Function */ +.mw-highlight .nl { color: #A0A000 } /* Name.Label */ +.mw-highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.mw-highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.mw-highlight .nv { color: #19177C } /* Name.Variable */ +.mw-highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.mw-highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.mw-highlight .mb { color: #666666 } /* Literal.Number.Bin */ +.mw-highlight .mf { color: #666666 } /* Literal.Number.Float */ +.mw-highlight .mh { color: #666666 } /* Literal.Number.Hex */ +.mw-highlight .mi { color: #666666 } /* Literal.Number.Integer */ +.mw-highlight .mo { color: #666666 } /* Literal.Number.Oct */ +.mw-highlight .sa { color: #BA2121 } /* Literal.String.Affix */ +.mw-highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ +.mw-highlight .sc { color: #BA2121 } /* Literal.String.Char */ +.mw-highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ +.mw-highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.mw-highlight .s2 { color: #BA2121 } /* Literal.String.Double */ +.mw-highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.mw-highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.mw-highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.mw-highlight .sx { color: #008000 } /* Literal.String.Other */ +.mw-highlight .sr { color: #BB6688 } /* Literal.String.Regex */ +.mw-highlight .s1 { color: #BA2121 } /* Literal.String.Single */ +.mw-highlight .ss { color: #19177C } /* Literal.String.Symbol */ +.mw-highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.mw-highlight .fm { color: #0000FF } /* Name.Function.Magic */ +.mw-highlight .vc { color: #19177C } /* Name.Variable.Class */ +.mw-highlight .vg { color: #19177C } /* Name.Variable.Global */ +.mw-highlight .vi { color: #19177C } /* Name.Variable.Instance */ +.mw-highlight .vm { color: #19177C } /* Name.Variable.Magic */ +.mw-highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/pygments.wrapper.css b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/pygments.wrapper.css new file mode 100644 index 00000000..5588b415 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/pygments.wrapper.css @@ -0,0 +1,63 @@ +.mw-highlight { + /* All supported programming languages are written left-to-right */ + /* @noflip */ + direction: ltr; + unicode-bidi: embed; +} + +.mw-highlight pre { + /* Use a more commonly found tab size of 4 (e.g. as used in CodeEditor) + instead of the browser-default value of 8 */ + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; +} + +/* Avoid displaying double borders for nested 'code' elements. + Before we started using the 'code' tag for inline code snippets, + <code><syntaxhighlight enclose=none ...>...</syntaxhighlight></code> + was a common pattern. Continue supporting it in existing content. */ +code code.mw-highlight { + background-color: transparent; + border: 0; + padding: 0; +} + +/* The nested pre already has a background. T126010 */ +div.mw-hightlight { + background-color: inherit; +} + +/* + * Don't show a red border around syntax errors. This behavior may be useful + * in code editors, but it is not useful in a wiki environment, especially + * given the longstanding habit of using an existing, mostly-compatible lexer + * to highlight a language for which no lexer exists. + */ +.mw-highlight .err { + border: 0; +} + +/* Highlight background of whole lines, not just text in them */ +.mw-highlight .hll { + display: block; +} + +/* Make line numbers non copyable */ +.mw-highlight .lineno { + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* To interact better with the 'display: block' above, doesn't affect other uses */ +/* @noflip */ +.mw-highlight.mw-content-ltr .lineno { + float: left; +} + +/* @noflip */ +.mw-highlight.mw-content-rtl .lineno { + float: right; +} diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/AUTHORS.txt b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/AUTHORS.txt new file mode 100644 index 00000000..921784f9 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/AUTHORS.txt @@ -0,0 +1,6 @@ +The following people have contributed to the writing of this module: + +Alex Monk +Ed Sanders +Florian Schmidt +Timo Tijhof diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/LICENSE.txt b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/LICENSE.txt new file mode 100644 index 00000000..919d30f4 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/LICENSE.txt @@ -0,0 +1,20 @@ +The MIT License (MIT) +Copyright (c) 2016 Visual Editor Team + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.css b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.css new file mode 100644 index 00000000..d768b232 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.css @@ -0,0 +1,11 @@ +/*! + * VisualEditor ContentEditable MWSyntaxHighlightNode styles. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +.ve-ce-mwSyntaxHighlightNode pre { + /* Prevent silly wrapping on Safari and Chrome (https://bugs.webkit.org/show_bug.cgi?id=35935) */ + word-wrap: normal; +} diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js new file mode 100644 index 00000000..0d1cc57f --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js @@ -0,0 +1,92 @@ +/*! + * 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'; + +/* Methods */ + +// Inherits from ve.ce.GeneratedContentNode +ve.ce.MWSyntaxHighlightNode.prototype.generateContents = function () { + var node = this, + args = arguments; + // Parent method + return mw.loader.using( 'ext.pygments' ).then( function () { + return ve.ce.MWExtensionNode.prototype.generateContents.apply( node, args ); + } ); +}; + +// Inherits from ve.ce.BranchNode +ve.ce.MWSyntaxHighlightNode.prototype.onSetup = function () { + // Parent method + ve.ce.MWExtensionNode.prototype.onSetup.call( this ); + + // DOM changes + this.$element.addClass( 've-ce-mwSyntaxHighlightNode' ); +}; + +// Inherits from ve.ce.FocusableNode +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.MWBlockSyntaxHighlightNode.static.primaryCommandName = 'syntaxhighlightDialog'; + +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 ); diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.dm.MWSyntaxHighlightNode.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.dm.MWSyntaxHighlightNode.js new file mode 100644 index 00000000..d05ec01d --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.dm.MWSyntaxHighlightNode.js @@ -0,0 +1,166 @@ +/*! + * 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 + * @abstract + * + * @constructor + */ +ve.dm.MWSyntaxHighlightNode = function VeDmMWSyntaxHighlightNode() { +}; + +/* Inheritance */ + +OO.initClass( ve.dm.MWSyntaxHighlightNode ); + +/* Static members */ + +ve.dm.MWSyntaxHighlightNode.static.name = 'mwSyntaxHighlight'; + +ve.dm.MWSyntaxHighlightNode.static.extensionName = 'syntaxhighlight'; + +ve.dm.MWSyntaxHighlightNode.static.getMatchRdfaTypes = function () { + return [ 'mw:Extension/syntaxhighlight', 'mw:Extension/source' ]; +}; + +/* Static methods */ + +/** + * @inheritdoc + */ +ve.dm.MWSyntaxHighlightNode.static.toDataElement = function ( domElements, converter ) { + // Parent method + var isInline = this.isHybridInline( domElements, converter ), + type = isInline ? 'mwInlineSyntaxHighlight' : 'mwBlockSyntaxHighlight', + dataElement = ve.dm.MWExtensionNode.static.toDataElement.call( this, domElements, converter, type ); + + return dataElement; +}; + +( function () { + var supportedLanguages = [ undefined ], + geshiToPygmentsMap, + pygmentsToAceMap; + + /** + * Register supported Pygments languages. + * + * @param {Array} languages + */ + ve.dm.MWSyntaxHighlightNode.static.addPygmentsLanguages = function ( languages ) { + ve.batchPush( supportedLanguages, languages ); + }; + + /** + * Register map from Geshi to pygments lexer names. + * + * @param {Array} map + */ + ve.dm.MWSyntaxHighlightNode.static.addGeshiToPygmentsMap = function ( map ) { + geshiToPygmentsMap = map; + ve.batchPush( supportedLanguages, Object.keys( geshiToPygmentsMap ) ); + }; + + /** + * Register a map from pygments to Ace lexer names. + * + * @param {Array} map + */ + ve.dm.MWSyntaxHighlightNode.static.addPygmentsToAceMap = function ( map ) { + pygmentsToAceMap = map; + }; + + /** + * Converts a (valid) language as recognized by the SyntaxHighlight wikicode + * to a compatible Ace lexer name (to be used by CodeEditor) + * + * @param {string} language Language name + * @return {string} The name of the ace lexer + */ + ve.dm.MWSyntaxHighlightNode.static.convertLanguageToAce = function ( language ) { + language = geshiToPygmentsMap[ language ] || language; + return ( pygmentsToAceMap[ language ] || language ).toLowerCase(); + }; + + /** + * Check if a language is supported + * + * @param {string} language Language name + * @return {boolean} The language is supported + */ + ve.dm.MWSyntaxHighlightNode.static.isLanguageSupported = function ( language ) { + return supportedLanguages.indexOf( language || undefined ) !== -1; + }; + + /** + * Get an array of all languages (both Pygments and former GeSHi names) + * + * @return {Array} All currently supported languages + */ + ve.dm.MWSyntaxHighlightNode.static.getLanguages = function () { + return supportedLanguages.slice(); + }; +}() ); + +/* 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; +}; + +/* Concrete subclasses */ + +ve.dm.MWBlockSyntaxHighlightNode = function VeDmMWBlockSyntaxHighlightNode() { + // Parent method + ve.dm.MWBlockExtensionNode.super.apply( this, arguments ); + + // Mixin method + ve.dm.MWSyntaxHighlightNode.call( this ); +}; + +OO.inheritClass( ve.dm.MWBlockSyntaxHighlightNode, ve.dm.MWBlockExtensionNode ); + +OO.mixinClass( ve.dm.MWBlockSyntaxHighlightNode, ve.dm.MWSyntaxHighlightNode ); + +ve.dm.MWBlockSyntaxHighlightNode.static.name = 'mwBlockSyntaxHighlight'; + +ve.dm.MWBlockSyntaxHighlightNode.static.tagName = 'div'; + +ve.dm.MWInlineSyntaxHighlightNode = function VeDmMWInlineSyntaxHighlightNode() { + // Parent method + ve.dm.MWInlineExtensionNode.super.apply( this, arguments ); + + // Mixin method + ve.dm.MWSyntaxHighlightNode.call( this ); +}; + +OO.inheritClass( ve.dm.MWInlineSyntaxHighlightNode, ve.dm.MWInlineExtensionNode ); + +OO.mixinClass( ve.dm.MWInlineSyntaxHighlightNode, ve.dm.MWSyntaxHighlightNode ); + +ve.dm.MWInlineSyntaxHighlightNode.static.name = 'mwInlineSyntaxHighlight'; + +ve.dm.MWInlineSyntaxHighlightNode.static.tagName = 'code'; + +ve.dm.MWInlineSyntaxHighlightNode.static.isContent = true; + +/* Registration */ + +ve.dm.modelRegistry.register( ve.dm.MWBlockSyntaxHighlightNode ); +ve.dm.modelRegistry.register( ve.dm.MWInlineSyntaxHighlightNode ); diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialog.css b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialog.css new file mode 100644 index 00000000..de51edd5 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialog.css @@ -0,0 +1,20 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightDialog styles. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +.ve-ui-mwSyntaxHighlightDialog-content .ve-ui-mwExtensionWindow-input { + max-width: none; +} + +.ve-ui-mwSyntaxHighlightDialog-content .ve-ui-mwExtensionWindow-input textarea { + /* T176636 */ + font-family: monospace, monospace; +} + +.ve-ui-mwSyntaxHighlightDialog-content .ve-ui-mwSyntaxHighlightWindow-languageField, +.ve-ui-mwSyntaxHighlightDialog-content .ve-ui-mwSyntaxHighlightWindow-startLineField { + max-width: 30em; +} diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialog.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialog.js new file mode 100644 index 00000000..76ed7a25 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialog.js @@ -0,0 +1,150 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightDialog class. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * MediaWiki syntax highlight dialog. + * + * @class + * @extends ve.ui.MWExtensionDialog + * @mixins ve.ui.MWSyntaxHighlightWindow + * + * @constructor + * @param {Object} [config] Configuration options + */ +ve.ui.MWSyntaxHighlightDialog = function VeUiMWSyntaxHighlightDialog() { + // Parent constructor + ve.ui.MWSyntaxHighlightDialog.super.apply( this, arguments ); + + // Mixin constructor + ve.ui.MWSyntaxHighlightWindow.call( this ); +}; + +/* Inheritance */ + +OO.inheritClass( ve.ui.MWSyntaxHighlightDialog, ve.ui.MWExtensionDialog ); + +OO.mixinClass( ve.ui.MWSyntaxHighlightDialog, ve.ui.MWSyntaxHighlightWindow ); + +/* Static properties */ + +ve.ui.MWSyntaxHighlightDialog.static.name = 'syntaxhighlightDialog'; + +ve.ui.MWSyntaxHighlightDialog.static.size = 'larger'; + +ve.ui.MWSyntaxHighlightDialog.static.modelClasses = [ ve.dm.MWBlockSyntaxHighlightNode ]; + +/* Methods */ + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightDialog.prototype.initialize = function () { + // Parent method + ve.ui.MWSyntaxHighlightDialog.super.prototype.initialize.call( this ); + + this.input = new ve.ui.MWAceEditorWidget( { + limit: 1, + rows: 10, + maxRows: 25, + autosize: true, + autocomplete: 'live', + classes: [ 've-ui-mwExtensionWindow-input' ] + } ); + + this.input.connect( this, { resize: 'updateSize' } ); + + // Mixin method + ve.ui.MWSyntaxHighlightWindow.prototype.initialize.call( this ); + + this.languageField.setAlignment( 'left' ); + + this.contentLayout = new OO.ui.PanelLayout( { + scrollable: true, + padded: true, + expanded: false, + content: [ + this.languageField, + this.codeField, + this.showLinesField, + this.startLineField + ] + } ); + + // Initialization + this.$content.addClass( 've-ui-mwSyntaxHighlightDialog-content' ); + this.$body.append( this.contentLayout.$element ); +}; + +/** + * @inheritdoc MWSyntaxHighlightWindow + */ +ve.ui.MWSyntaxHighlightDialog.prototype.onLanguageInputChange = function () { + var validity, dialog = this; + + // Mixin method + ve.ui.MWSyntaxHighlightWindow.prototype.onLanguageInputChange.call( this ); + + validity = this.language.getValidity(); + validity.always( function () { + var language = ve.dm.MWSyntaxHighlightNode.static.convertLanguageToAce( dialog.language.getValue() ); + dialog.input.setLanguage( validity.state() === 'resolved' ? language : 'text' ); + } ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightDialog.prototype.getReadyProcess = function ( data ) { + // Parent process + var process = ve.ui.MWSyntaxHighlightDialog.super.prototype.getReadyProcess.call( this, data ); + // Mixin process + return ve.ui.MWSyntaxHighlightWindow.prototype.getReadyProcess.call( this, data, process ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightDialog.prototype.getSetupProcess = function ( data ) { + // Parent process + var process = ve.ui.MWSyntaxHighlightDialog.super.prototype.getSetupProcess.call( this, data ); + // Mixin process + return ve.ui.MWSyntaxHighlightWindow.prototype.getSetupProcess.call( this, data, process ) + .first( function () { + this.input.setup(); + }, this ) + .next( function () { + this.onShowLinesCheckboxChange(); + this.input.clearUndoStack(); + }, this ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightDialog.prototype.getTeardownProcess = function ( data ) { + // Parent process + var process = ve.ui.MWSyntaxHighlightDialog.super.prototype.getTeardownProcess.call( this, data ); + // Mixin process + return ve.ui.MWSyntaxHighlightWindow.prototype.getTeardownProcess.call( this, data, process ).first( function () { + this.language.setValue( '' ); + this.input.teardown(); + }, this ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightDialog.prototype.updateMwData = function () { + // Parent method + ve.ui.MWSyntaxHighlightDialog.super.prototype.updateMwData.apply( this, arguments ); + // Mixin method + ve.ui.MWSyntaxHighlightWindow.prototype.updateMwData.apply( this, arguments ); +}; + +/* Registration */ + +ve.ui.windowFactory.register( ve.ui.MWSyntaxHighlightDialog ); diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialogTool.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialogTool.js new file mode 100644 index 00000000..e91e35f4 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightDialogTool.js @@ -0,0 +1,49 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightDialogTool class. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * MediaWiki UserInterface syntax highlight tool. + * + * @class + * @extends ve.ui.FragmentWindowTool + * @constructor + * @param {OO.ui.ToolGroup} toolGroup + * @param {Object} [config] Configuration options + */ +ve.ui.MWSyntaxHighlightDialogTool = function VeUiMWSyntaxHighlightDialogTool() { + ve.ui.MWSyntaxHighlightDialogTool.super.apply( this, arguments ); +}; +OO.inheritClass( ve.ui.MWSyntaxHighlightDialogTool, ve.ui.FragmentWindowTool ); +ve.ui.MWSyntaxHighlightDialogTool.static.name = 'syntaxhighlightDialog'; +ve.ui.MWSyntaxHighlightDialogTool.static.group = 'object'; +ve.ui.MWSyntaxHighlightDialogTool.static.icon = 'markup'; +ve.ui.MWSyntaxHighlightDialogTool.static.title = OO.ui.deferMsg( + 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-title' ); +ve.ui.MWSyntaxHighlightDialogTool.static.modelClasses = [ ve.dm.MWBlockSyntaxHighlightNode ]; +ve.ui.MWSyntaxHighlightDialogTool.static.commandName = 'syntaxhighlightDialog'; +ve.ui.toolFactory.register( ve.ui.MWSyntaxHighlightDialogTool ); + +ve.ui.commandRegistry.register( + new ve.ui.Command( + 'syntaxhighlightDialog', 'window', 'open', + { args: [ 'syntaxhighlightDialog' ], supportedSelections: [ 'linear' ] } + ) +); + +ve.ui.sequenceRegistry.register( + // Don't wait for the user to type out the full <syntaxhighlight> tag + new ve.ui.Sequence( 'wikitextSyntax', 'syntaxhighlightDialog', '<syntax', 7 ) +); + +ve.ui.sequenceRegistry.register( + new ve.ui.Sequence( 'wikitextSource', 'syntaxhighlightDialog', '<source', 7 ) +); + +ve.ui.commandHelpRegistry.register( 'insert', 'syntax', { + sequences: [ 'wikitextSyntax', 'wikitextSource' ], + label: OO.ui.deferMsg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-title' ) +} ); diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspector.css b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspector.css new file mode 100644 index 00000000..32ff1c0b --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspector.css @@ -0,0 +1,15 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightInspector styles. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +.ve-ui-mwSyntaxHighlightInspector-content .ve-ui-mwExtensionWindow-input textarea { + /* T176636 */ + font-family: monospace, monospace; +} + +.ve-ui-mwSyntaxHighlightInspector-content .oo-ui-numberInputWidget { + width: 10em; +} diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspector.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspector.js new file mode 100644 index 00000000..fe12327b --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspector.js @@ -0,0 +1,104 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightInspector class. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * MediaWiki syntax highlight inspector. + * + * @class + * @extends ve.ui.MWLiveExtensionInspector + * @mixins ve.ui.MWSyntaxHighlightWindow + * + * @constructor + * @param {Object} [config] Configuration options + */ +ve.ui.MWSyntaxHighlightInspector = function VeUiMWSyntaxHighlightInspector() { + // Parent constructor + ve.ui.MWSyntaxHighlightInspector.super.apply( this, arguments ); + + // Mixin constructor + ve.ui.MWSyntaxHighlightWindow.call( this ); +}; + +/* Inheritance */ + +OO.inheritClass( ve.ui.MWSyntaxHighlightInspector, ve.ui.MWLiveExtensionInspector ); + +OO.mixinClass( ve.ui.MWSyntaxHighlightInspector, ve.ui.MWSyntaxHighlightWindow ); + +/* Static properties */ + +ve.ui.MWSyntaxHighlightInspector.static.name = 'syntaxhighlightInspector'; + +ve.ui.MWSyntaxHighlightInspector.static.modelClasses = [ ve.dm.MWInlineSyntaxHighlightNode ]; + +/* Methods */ + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightInspector.prototype.initialize = function () { + // Parent method + ve.ui.MWSyntaxHighlightInspector.super.prototype.initialize.call( this ); + + // Mixin method + ve.ui.MWSyntaxHighlightWindow.prototype.initialize.call( this ); + + // Initialization + this.$content.addClass( 've-ui-mwSyntaxHighlightInspector-content' ); + this.form.$element.prepend( + this.languageField.$element, + this.codeField.$element + ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightInspector.prototype.getReadyProcess = function ( data ) { + // Parent process + var process = ve.ui.MWSyntaxHighlightInspector.super.prototype.getReadyProcess.call( this, data ); + // Mixin process + return ve.ui.MWSyntaxHighlightWindow.prototype.getReadyProcess.call( this, data, process ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightInspector.prototype.getSetupProcess = function ( data ) { + // Parent process + var process = ve.ui.MWSyntaxHighlightInspector.super.prototype.getSetupProcess.call( this, data ); + // Mixin process + return ve.ui.MWSyntaxHighlightWindow.prototype.getSetupProcess.call( this, data, process ).next( function () { + this.language.on( 'change', this.onChangeHandler ); + }, this ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightInspector.prototype.getTeardownProcess = function ( data ) { + // Parent process + var process = ve.ui.MWSyntaxHighlightInspector.super.prototype.getTeardownProcess.call( this, data ); + // Mixin process + return ve.ui.MWSyntaxHighlightWindow.prototype.getTeardownProcess.call( this, data, process ).first( function () { + this.language.off( 'change', this.onChangeHandler ); + }, this ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightInspector.prototype.updateMwData = function () { + // Parent method + ve.ui.MWSyntaxHighlightInspector.super.prototype.updateMwData.apply( this, arguments ); + // Mixin method + ve.ui.MWSyntaxHighlightWindow.prototype.updateMwData.apply( this, arguments ); +}; + +/* Registration */ + +ve.ui.windowFactory.register( ve.ui.MWSyntaxHighlightInspector ); diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspectorTool.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspectorTool.js new file mode 100644 index 00000000..47e26f16 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightInspectorTool.js @@ -0,0 +1,36 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightInspectorTool class. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * MediaWiki UserInterface syntax highlight tool. + * + * @class + * @extends ve.ui.FragmentInspectorTool + * @constructor + * @param {OO.ui.ToolGroup} toolGroup + * @param {Object} [config] Configuration options + */ +ve.ui.MWSyntaxHighlightInspectorTool = function VeUiMWSyntaxHighlightInspectorTool() { + ve.ui.MWSyntaxHighlightInspectorTool.super.apply( this, arguments ); +}; +OO.inheritClass( ve.ui.MWSyntaxHighlightInspectorTool, ve.ui.FragmentInspectorTool ); +ve.ui.MWSyntaxHighlightInspectorTool.static.name = 'syntaxhighlightInspector'; +ve.ui.MWSyntaxHighlightInspectorTool.static.group = 'object'; +ve.ui.MWSyntaxHighlightInspectorTool.static.icon = 'markup'; +ve.ui.MWSyntaxHighlightInspectorTool.static.title = OO.ui.deferMsg( + 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-title' ); +ve.ui.MWSyntaxHighlightInspectorTool.static.modelClasses = [ ve.dm.MWInlineSyntaxHighlightNode ]; +ve.ui.MWSyntaxHighlightInspectorTool.static.commandName = 'syntaxhighlightInspector'; +ve.ui.MWSyntaxHighlightInspectorTool.static.autoAddToCatchall = false; +ve.ui.toolFactory.register( ve.ui.MWSyntaxHighlightInspectorTool ); + +ve.ui.commandRegistry.register( + new ve.ui.Command( + 'syntaxhighlightInspector', 'window', 'open', + { args: [ 'syntaxhighlightInspector' ], supportedSelections: [ 'linear' ] } + ) +); diff --git a/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightWindow.js b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightWindow.js new file mode 100644 index 00000000..beaf1f35 --- /dev/null +++ b/www/wiki/extensions/SyntaxHighlight_GeSHi/modules/ve-syntaxhighlight/ve.ui.MWSyntaxHighlightWindow.js @@ -0,0 +1,170 @@ +/*! + * VisualEditor UserInterface MWSyntaxHighlightWindow class. + * + * @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +/** + * MediaWiki syntax highlight window. + * + * @class + * @abstract + * + * @constructor + */ +ve.ui.MWSyntaxHighlightWindow = function VeUiMWSyntaxHighlightWindow() { +}; + +/* Inheritance */ + +OO.initClass( ve.ui.MWSyntaxHighlightWindow ); + +/* Static properties */ + +ve.ui.MWSyntaxHighlightWindow.static.icon = 'alienextension'; + +ve.ui.MWSyntaxHighlightWindow.static.title = OO.ui.deferMsg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-title' ); + +ve.ui.MWSyntaxHighlightWindow.static.dir = 'ltr'; + +/* Methods */ + +/** + * @inheritdoc + */ +ve.ui.MWSyntaxHighlightWindow.prototype.initialize = function () { + var noneMsg = ve.msg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-none' ); + + this.language = new OO.ui.ComboBoxInputWidget( { + $overlay: this.$overlay, + menu: { + filterFromInput: true, + items: $.map( ve.dm.MWSyntaxHighlightNode.static.getLanguages(), function ( lang ) { + return new OO.ui.MenuOptionWidget( { data: lang, label: lang || noneMsg } ); + } ) + }, + validate: function ( input ) { + return ve.dm.MWSyntaxHighlightNode.static.isLanguageSupported( input ); + } + } ); + + this.showLinesCheckbox = new OO.ui.CheckboxInputWidget(); + + this.startLineNumber = new OO.ui.NumberInputWidget( { + min: 0, + isInteger: true + } ); + + // Events + this.language.connect( this, { change: 'onLanguageInputChange' } ); + this.showLinesCheckbox.connect( this, { change: 'onShowLinesCheckboxChange' } ); + this.startLineNumber.connect( this, { change: 'onStartLineNumberChange' } ); + + this.languageField = new OO.ui.FieldLayout( this.language, { + classes: [ 've-ui-mwSyntaxHighlightWindow-languageField' ], + align: 'top', + label: ve.msg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-language' ) + } ); + this.codeField = new OO.ui.FieldLayout( this.input, { + align: 'top', + label: ve.msg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-code' ) + } ); + this.showLinesField = new OO.ui.FieldLayout( this.showLinesCheckbox, { + align: 'inline', + label: ve.msg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-showlines' ) + } ); + this.startLineField = new OO.ui.FieldLayout( this.startLineNumber, { + classes: [ 've-ui-mwSyntaxHighlightWindow-startLineField' ], + align: 'left', + label: ve.msg( 'syntaxhighlight-visualeditor-mwsyntaxhighlightinspector-startingline' ) + } ); +}; + +/** + * Handle input change events + * + * @param {string} value New value + */ +ve.ui.MWSyntaxHighlightWindow.prototype.onLanguageInputChange = function () { + var validity, inspector = this; + validity = this.language.getValidity(); + validity.always( function () { + inspector.getActions().setAbilities( { done: validity.state() === 'resolved' } ); + } ); +}; + +/** + * Handle change events from the show lines chechbox + * + * @param {boolean} value Widget value + */ +ve.ui.MWSyntaxHighlightWindow.prototype.onShowLinesCheckboxChange = function () { + var showLines = this.showLinesCheckbox.isSelected(); + this.input.toggleLineNumbers( showLines ); + this.startLineNumber.setDisabled( !showLines ); +}; + +/** + * Handle change events from the start line input + * + * @param {string} value Widget value + */ +ve.ui.MWSyntaxHighlightWindow.prototype.onStartLineNumberChange = function ( value ) { + var input = this.input; + + input.loadingPromise.done( function () { + input.editor.setOption( 'firstLineNumber', value !== '' ? +value : 1 ); + } ); +}; + +/** + * @inheritdoc OO.ui.Window + */ +ve.ui.MWSyntaxHighlightWindow.prototype.getReadyProcess = function ( data, process ) { + return process.next( function () { + this.language.getMenu().toggle( false ); + if ( !this.language.getValue() ) { + this.language.focus(); + } else { + this.input.focus(); + } + }, this ); +}; + +/** + * @inheritdoc OO.ui.Window + */ +ve.ui.MWSyntaxHighlightWindow.prototype.getSetupProcess = function ( data, process ) { + return process.next( function () { + var attrs = this.selectedNode ? this.selectedNode.getAttribute( 'mw' ).attrs : {}, + language = attrs.lang || '', + showLines = attrs.line !== undefined, + startLine = attrs.start; + + this.language.setValue( language ); + + this.showLinesCheckbox.setSelected( showLines ); + this.startLineNumber.setValue( startLine ); + }, this ); +}; + +/** + * @inheritdoc OO.ui.Window + */ +ve.ui.MWSyntaxHighlightWindow.prototype.getTeardownProcess = function ( data, process ) { + return process; +}; + +/** + * @inheritdoc ve.ui.MWExtensionWindow + */ +ve.ui.MWSyntaxHighlightWindow.prototype.updateMwData = function ( mwData ) { + var language = this.language.getValue(), + showLines = this.showLinesCheckbox.isSelected(), + startLine = this.startLineNumber.getValue(); + + mwData.attrs.lang = language || undefined; + mwData.attrs.line = showLines ? '1' : undefined; + mwData.attrs.start = startLine !== '' ? startLine : undefined; +}; |