Hieroglyphics support

Mostly as a demonstration of how easy this is with MWExtensionNode.

The icon was chosen with the following criteria:
1. Recognisable (the ankh is quite common in popular culture, right?)
2. Doesn't look idiotic to academics (I've consulted an Egyptology
   PhD and they can confirm it's not the glyph for penis)
3. Renders well at <16x16

That said it does look a little like a stick man...

Bug: 43118

Change-Id: I9f9e8af501401866bfeecf0eec3690a705fbd4db
This commit is contained in:
Ed Sanders 2013-08-03 15:41:22 +01:00 committed by Catrope
parent 671c7d3b25
commit 0d1617a627
12 changed files with 206 additions and 1 deletions

View file

@ -132,6 +132,7 @@ $messages['en'] = array(
'visualeditor-linkinspector-suggest-matching-page' => 'Matching page',
'visualeditor-linkinspector-suggest-new-page' => 'New page',
'visualeditor-linkinspector-title' => 'Hyperlink',
'visualeditor-mwhieroinspector-title' => 'Hieroglyphics',
'visualeditor-mwmathinspector-title' => 'LaTeX',
'visualeditor-languageinspector-title' => 'Language',
'visualeditor-languageinspector-block-tooltip' => 'Language block: $1',
@ -427,6 +428,7 @@ Parameters:
{{Identical|New page}}',
'visualeditor-linkinspector-title' => 'Title of the link inspector dialog.
{{Identical|Hyperlink}}',
'visualeditor-mwhieroinspector-title' => 'Used as title for hieroglyphics inspector.',
'visualeditor-mwmathinspector-title' => 'Used as title for MathInspector.
See [[w:LaTeX]].',

View file

@ -713,9 +713,13 @@ $wgResourceModules += array(
'scripts' => array(
've-mw/dm/nodes/ve.dm.MWExtensionNode.js',
've-mw/ce/nodes/ve.ce.MWExtensionNode.js',
've-mw/dm/nodes/ve.dm.MWHieroNode.js',
've-mw/ce/nodes/ve.ce.MWHieroNode.js',
've-mw/dm/nodes/ve.dm.MWMathNode.js',
've-mw/ce/nodes/ve.ce.MWMathNode.js',
've-mw/ui/inspectors/ve.ui.MWExtensionInspector.js',
've-mw/ui/inspectors/ve.ui.MWHieroInspector.js',
've-mw/ui/tools/buttons/ve.ui.MWHieroButtonTool.js',
've-mw/ui/inspectors/ve.ui.MWMathInspector.js',
've-mw/ui/tools/buttons/ve.ui.MWMathButtonTool.js',
've/dm/annotations/ve.dm.LanguageAnnotation.js',
@ -732,6 +736,7 @@ $wgResourceModules += array(
),
'messages' => array(
// VE messages needed by code that is only in experimental mode
'visualeditor-mwhieroinspector-title',
'visualeditor-mwmathinspector-title',
'visualeditor-annotationbutton-language-tooltip',
'visualeditor-annotationbutton-strikethrough-tooltip',

View file

@ -0,0 +1,50 @@
/*!
* VisualEditor ContentEditable MWHieroNode class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable MediaWiki hieroglyphics node.
*
* @class
* @extends ve.ce.MWExtensionNode
*
* @constructor
* @param {ve.dm.MWHieroNode} model Model to observe
* @param {Object} [config] Config options
*/
ve.ce.MWHieroNode = function VeCeMWHieroNode( model, config ) {
// Parent constructor
ve.ce.MWExtensionNode.call( this, model, config );
// DOM Changes
this.$.addClass( 've-ce-mwHieroNode' );
};
/* Inheritance */
ve.inheritClass( ve.ce.MWHieroNode, ve.ce.MWExtensionNode );
/* Static Properties */
ve.ce.MWHieroNode.static.name = 'mwHiero';
ve.ce.MWHieroNode.static.tagName = 'div';
/* Methods */
/** */
ve.ce.MWHieroNode.prototype.onParseSuccess = function ( deferred, response ) {
var data = response.visualeditor, contentNodes = $( data.content ).get();
deferred.resolve( contentNodes );
// Rerender after image load
this.$.find( 'img' ).on( 'load', ve.bind( function () {
this.emit( 'rerender' );
}, this ) );
};
/* Registration */
ve.ce.nodeFactory.register( ve.ce.MWHieroNode );

View file

@ -50,3 +50,9 @@
.ve-ce-mwMathNode {
display: inline-block;
}
/* ve.ce.MWHieroNode */
.ve-ce-mwHieroNode {
display: table;
}

View file

@ -0,0 +1,35 @@
/*!
* VisualEditor DataModel MWHieroNode class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* DataModel MediaWiki hieroglyphics node.
*
* @class
* @extends ve.dm.MWExtensionNode
*
* @constructor
*/
ve.dm.MWHieroNode = function VeDmMWHieroNode( length, element ) {
// Parent constructor
ve.dm.MWExtensionNode.call( this, 0, element );
};
/* Inheritance */
ve.inheritClass( ve.dm.MWHieroNode, ve.dm.MWExtensionNode );
/* Static members */
ve.dm.MWHieroNode.static.name = 'mwHiero';
ve.dm.MWHieroNode.static.tagName = 'table';
ve.dm.MWHieroNode.static.extensionName = 'hiero';
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWHieroNode );

View file

@ -172,7 +172,7 @@ ve.init.mw.ViewPageTarget.static.toolbarTools = [
{ 'items': [ 'mwFormat' ] },
{ 'items': [ 'bold', 'italic', 'mwLink', 'language', 'code', 'strikethrough', 'clear' ] },
{ 'items': [ 'number', 'bullet', 'outdent', 'indent' ] },
{ 'items': [ 'mwMediaInsert', 'mwReference', 'mwReferenceList', 'mwTransclusion', 'mwMath' ] }
{ 'items': [ 'mwMediaInsert', 'mwReference', 'mwReferenceList', 'mwTransclusion', 'mwMath', 'mwHiero' ] }
];
ve.init.mw.ViewPageTarget.static.surfaceCommands = [

View file

@ -0,0 +1,49 @@
/*!
* VisualEditor UserInterface MWHieroInspector class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* MediaWiki hieroglyphics inspector.
*
* @class
* @extends ve.ui.MWExtensionInspector
*
* @constructor
* @param {ve.ui.Surface} surface
* @param {Object} [config] Config options
*/
ve.ui.MWHieroInspector = function VeUiMWHieroInspector( surface, config ) {
// Parent constructor
ve.ui.MWExtensionInspector.call( this, surface, config );
};
/* Inheritance */
ve.inheritClass( ve.ui.MWHieroInspector, ve.ui.MWExtensionInspector );
/* Static properties */
ve.ui.MWHieroInspector.static.icon = 'hiero';
ve.ui.MWHieroInspector.static.titleMessage = 'visualeditor-mwhieroinspector-title';
ve.ui.MWHieroInspector.static.nodeView = ve.ce.MWHieroNode;
ve.ui.MWHieroInspector.static.nodeModel = ve.dm.MWHieroNode;
/* Methods */
ve.ui.MWHieroInspector.prototype.initialize = function () {
// Parent method
ve.ui.MWExtensionInspector.prototype.initialize.call( this );
this.input.$.addClass( 've-ui-mwHieroInspector-input' );
};
/* Registration */
ve.ui.inspectorFactory.register( 'mwHieroInspector', ve.ui.MWHieroInspector );

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<g id="hiero" opacity="0.75">
<path id="ankh" d="m 9.0045786,8.4037839 c 0.408197,1.3287357 1.4031084,2.8056531 2.2058904,3.7584441 L 6.969,11.969103 c 0.1279068,0.414647 0.1155421,0.82887 0,1.243515 L 11.210469,13.028527 10.924165,19 c 0.569216,-0.151198 1.0357,-0.09337 1.484575,0 l -0.261619,-5.971473 3.821884,0.184091 c -0.103706,-0.414645 -0.138812,-0.828868 0,-1.243515 l -3.821884,0.193125 C 12.857348,11.130195 13.853548,9.7831196 14.211705,8.2738643 14.935527,5.2236985 13.022035,5.0015265 11.603171,5 10.184306,4.9984831 8.1310072,5.5601434 9.0045786,8.4037839 z M 11.584645,6 c 1.520843,-0.010056 3.080433,1.9804496 0.11698,5.577337 C 8.581706,8.0207315 10.063806,6.0100704 11.584645,6 z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -5,6 +5,11 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
.ve-ui-icon-hiero {
/* @embed */
background-image: url(images/icons/hiero.png);
}
.ve-ui-icon-language {
/* @embed */
background-image: url(images/icons/language.png);

View file

@ -5,6 +5,11 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
.ve-ui-icon-hiero {
/* @embed */
background-image: url(images/icons/hiero.svg);
}
.ve-ui-icon-language {
/* @embed */
background-image: url(images/icons/language.svg);

View file

@ -0,0 +1,40 @@
/*!
* VisualEditor UserInterface MWHieroButtonTool class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* UserInterface MediaWiki hieroglyphics button tool.
*
* @class
* @extends ve.ui.InspectorButtonTool
* @constructor
* @param {ve.ui.Toolbar} toolbar
* @param {Object} [config] Config options
*/
ve.ui.MWHieroButtonTool = function VeUiMWHieroButtonTool( toolbar, config ) {
// Parent constructor
ve.ui.InspectorButtonTool.call( this, toolbar, config );
};
/* Inheritance */
ve.inheritClass( ve.ui.MWHieroButtonTool, ve.ui.InspectorButtonTool );
/* Static Properties */
ve.ui.MWHieroButtonTool.static.name = 'mwHiero';
ve.ui.MWHieroButtonTool.static.icon = 'hiero';
ve.ui.MWHieroButtonTool.static.titleMessage = 'visualeditor-mwhieroinspector-title';
ve.ui.MWHieroButtonTool.static.inspector = 'mwHieroInspector';
ve.ui.MWHieroButtonTool.static.modelClasses = [ ve.dm.MWHieroNode ];
/* Registration */
ve.ui.toolFactory.register( 'mwHiero', ve.ui.MWHieroButtonTool );