Physikerwelt has submitted this change and it was merged.

Change subject: Add VisualEditor support
......................................................................


Add VisualEditor support

Moved from the VisualEditor extension, where it was removed in 
Iab0c56246626de1e0f

Change-Id: I8e582ee6deadc2750d30b49f0c6de31ed9c16a50
---
M Math.hooks.php
M Math.i18n.php
M Math.php
A betafeatures-icon-VisualEditor-formulae-ltr.svg
A betafeatures-icon-VisualEditor-formulae-rtl.svg
A modules/VisualEditor/ve.ce.MWMathNode.css
A modules/VisualEditor/ve.ce.MWMathNode.js
A modules/VisualEditor/ve.dm.MWMathNode.js
A modules/VisualEditor/ve.ui.MWMathInspector.js
A modules/VisualEditor/ve.ui.MWMathInspectorTool.js
10 files changed, 744 insertions(+), 1 deletion(-)

Approvals:
  Physikerwelt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Math.hooks.php b/Math.hooks.php
index a4ab39e..2a1827b 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -151,6 +151,28 @@
                return true;
        }
 
+       public static function onGetBetaPreferences( $user, &$preferences ) {
+               global $wgExtensionAssetsPath;
+               if ( class_exists( 'VisualEditorHooks' ) ) {
+                       // Add beta feature if VisualEditor is installed
+                       $dir = 
RequestContext::getMain()->getLanguage()->getDir();
+                       $preferences['math-enable-visualeditor'] = array(
+                               'version' => '1.0',
+                               'label-message' => 
'math-preference-mwmathinspector-label',
+                               'desc-message' => 
'math-preference-mwmathinspector-description',
+                               'screenshot' => $wgExtensionAssetsPath .
+                                       
"/Math/betafeatures-icon-VisualEditor-formulae-$dir.svg",
+                               'info-message' => 
'math-preference-mwmathinspector-info-link',
+                               'discussion-message' => 
'math-preference-mwmathinspector-info-link',
+                               'requirements' => array(
+                                       'betafeatures' => array(
+                                               'visualeditor-enable',
+                                       ),
+                               ),
+                       );
+               }
+       }
+
        /**
         * List of message keys for the various math output settings.
         *
diff --git a/Math.i18n.php b/Math.i18n.php
index b3bae14..82aab84 100644
--- a/Math.i18n.php
+++ b/Math.i18n.php
@@ -40,7 +40,14 @@
        'math_latexml_invalidresponse' => 'LaTeXML Invalid response (\'$2\') 
from server \'$1\':',
        'math_latexml_invalidxml' => 'LaTeXML MathML is invalid XML.',
        'math_latexml_invalidjson'  => 'LaTeXML Server response is invalid 
JSON.',
-       'math_latexml_xmlversion' => 'Warning: XML type check skipped! Check if 
your MediaWiki installation is version wmf/1.22wmf7 or newer.'
+       'math_latexml_xmlversion' => 'Warning: XML type check skipped! Check if 
your MediaWiki installation is version wmf/1.22wmf7 or newer.',
+
+       // VisualEditor math plugin
+       'math-visualeditor-mwmathinspector-title' => 'Formula',
+       'math-preference-mwmathinspector-description' => 'Add experimental 
support to VisualEditor for creating and editing of mathematical formulae for 
testing, ahead of general release. Please remember to always review your 
changes before saving when using experimental features.',
+       'math-preference-mwmathinspector-discussion-link' => 
'//mediawiki.org/wiki/Special:MyLanguage/Talk:VisualEditor/Beta_Features/Formulae',
+       'math-preference-mwmathinspector-info-link' => 
'//mediawiki.org/wiki/Special:MyLanguage/VisualEditor/Beta_Features/Formulae',
+       'math-preference-mwmathinspector-label' => 'VisualEditor formulae 
editing',
 );
 
 /** Message documentation (Message documentation)
@@ -165,6 +172,21 @@
 
 This message follows the message {{msg-mw|Math failure}}.',
        'math_latexml_xmlversion' => 'Warning that XML checking of MathML 
requires wmf/1.22wmf7 or newer.',
+       'math-visualeditor-mwmathinspector-title' => 'Title for the inspector 
to edit <nowiki><math></nowiki> formula blocks.
+{{Identical|Formula}}',
+       'math-preference-mwmathinspector-description' => 'Used in 
[[Special:Preferences]].
+
+Used as description for the checkbox to enable editing of mathematical 
formulae in VisualEditor.
+
+The label for this checkbox is 
{{msg-mw|Visualeditor-preference-mwmath-label}}.',
+       'math-preference-mwmathinspector-discussion-link' => '{{optional|Used 
on [[Special:Preferences]] as a link to a page where users can discuss this 
Beta Feature. Defaults to a page on MediaWiki.org.}}',
+       'math-preference-mwmathinspector-info-link' => '{{optional|Used on 
[[Special:Preferences]] as a link to a page where users can learn about this 
Beta Feature. Defaults to a page on MediaWiki.org.}}',
+       'math-preference-mwmathinspector-label' => 'Used in 
[[Special:Preferences]].
+
+Used as label for checkbox to enable editing of mathematical formulae in 
VisualEditor.
+
+The description for this checkbox is:
+* {{msg-mw|Visualeditor-preference-mwmath-description}}',
 );
 
 /** Achinese (Acèh)
diff --git a/Math.php b/Math.php
index 5d4d93e..2ecd9cc 100644
--- a/Math.php
+++ b/Math.php
@@ -147,6 +147,7 @@
 
 $wgExtensionFunctions[] = 'MathHooks::setup';
 $wgHooks['ParserFirstCallInit'][] = 'MathHooks::onParserFirstCallInit';
+$wgHooks['GetBetaFeaturePreferences'][] = 'MathHooks::onGetBetaPreferences';
 $wgHooks['GetPreferences'][] = 'MathHooks::onGetPreferences';
 $wgHooks['LoadExtensionSchemaUpdates'][] = 
'MathHooks::onLoadExtensionSchemaUpdates';
 $wgHooks['ParserTestTables'][] = 'MathHooks::onParserTestTables';
@@ -395,3 +396,26 @@
                'scripts' => array( 'Fraktur/Bold/BasicLatin.js', 
'Fraktur/Bold/Other.js', 'Fraktur/Bold/PUA.js', 
'Fraktur/Regular/BasicLatin.js', 'Fraktur/Regular/Other.js', 
'Fraktur/Regular/PUA.js', 'SansSerif/Bold/BasicLatin.js', 
'SansSerif/Bold/CombDiacritMarks.js', 'SansSerif/Bold/Other.js', 
'SansSerif/Italic/BasicLatin.js', 'SansSerif/Italic/CombDiacritMarks.js', 
'SansSerif/Italic/Other.js', 'SansSerif/Regular/BasicLatin.js', 
'SansSerif/Regular/CombDiacritMarks.js', 'SansSerif/Regular/Other.js', 
'Script/Regular/BasicLatin.js', 'Typewriter/Regular/BasicLatin.js', 
'Typewriter/Regular/CombDiacritMarks.js', 'Typewriter/Regular/Other.js' )
        ) + $moduleTemplateSVG
 );
+
+$moduleTemplate = array(
+    'localBasePath' => dirname( __FILE__ ) . '/modules',
+    'remoteExtPath' => 'Math/modules',
+);
+
+$wgResourceModules['ext.math.visualEditor'] = array(
+       'scripts' => array(
+               'VisualEditor/ve.dm.MWMathNode.js',
+               'VisualEditor/ve.ce.MWMathNode.js',
+               'VisualEditor/ve.ui.MWMathInspector.js',
+               'VisualEditor/ve.ui.MWMathInspectorTool.js',
+       ),
+       'dependencies' => array(
+               'ext.visualEditor.mwcore',
+       ),
+       'messages' => array(
+               'math-visualeditor-mwmathinspector-title',
+       ),
+       'targets' => array( 'desktop', 'mobile' ),
+) + $moduleTemplate;
+
+$wgVisualEditorPreferenceModules['math-enable-visualeditor'] = 
'ext.math.visualEditor';
diff --git a/betafeatures-icon-VisualEditor-formulae-ltr.svg 
b/betafeatures-icon-VisualEditor-formulae-ltr.svg
new file mode 100644
index 0000000..72d66ae
--- /dev/null
+++ b/betafeatures-icon-VisualEditor-formulae-ltr.svg
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   version="1.1"
+   width="264"
+   height="162"
+   viewBox="0 0 264 162"
+   id="Layer_1"
+   xml:space="preserve"><metadata
+     id="metadata3213"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; 
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+     id="defs3211" /><g
+     id="g3120-2"><polygon
+       points="0.5,151.749 0.5,0.5 263.5,0.5 263.5,152.249 254.5,158.954 
254.5,42.5 215.5,42.5 215.5,155.1 211.107,151.369 203.5,156.699 203.5,42.5 
48.5,42.5 48.5,153.35 38.749,161.38 24.833,151.361 13.366,161.357 "
+       id="polygon3122-9"
+       style="fill:#ffffff" /><g
+       id="g3124-5"><path
+         d="m 263,1 v 150.998 l -8,5.96 V 43 42 h -1 -38 -1 v 1 111.02 l 
-3.274,-2.781 -0.589,-0.498 -0.633,0.441 -6.504,4.556 V 43 42 H 203 49 48 v 1 
110.1 l -9.257,7.66 -13.295,-9.57 -0.645,-0.463 -0.598,0.521 -10.864,9.47 L 
1,151.499 V 1 h 262 m 1,-1 H 0 V 152 L 13.391,162 24.865,152 38.756,162 
49,153.6 V 43 H 203 V 157.66 L 211.078,152 216,156.18 V 43 h 38 v 116.95 l 
10,-7.45 V 0 l 0,0 z"
+         id="path3126-5"
+         style="fill:#e5e5e5" /></g></g><path
+     d="M 203,157.66 V 43 H 49 v 110.6 l 2.145,-1.6 12.555,10 13.809,-10 
14.229,10 12.972,-10 12.973,10 13.811,-10 12.136,10 13.391,-10 14.229,10 
12.972,-10 12.974,10 5.804,-4.34 z"
+     id="path3128-1"
+     style="fill:#e5e5e5" /><path
+     d="m 11,36 c 0,-7.732 6.268,-14 14,-14 7.732,0 14,6.268 14,14 0,7.732 
-6.268,14 -14,14 -7.732,0 -14,-6.268 -14,-14 z"
+     id="Ellipse-2"
+     style="fill:#e5e5e5" /><path
+     d="M 254,159.95 V 43 h -38 v 113.18 l 7.551,5.82 13.811,-10 13.891,10 
2.747,-2.05 z"
+     id="path3131-8"
+     style="fill:#e5e5e5" /><path
+     d="M 38,107 V 72 H 13 v 35 h 25 z"
+     id="path3133-5"
+     style="fill:#e5e5e5" /><path
+     d="m 232.51,5 h 26 v 6 h -26 V 5 z"
+     id="path3135-8"
+     style="fill:#e5e5e5" /><rect
+     width="22"
+     height="6"
+     x="208.51001"
+     y="5"
+     id="rect3137-5"
+     style="fill:#e5e5e5" /><path
+     d="m 142,6 v 4 H 50 V 6 h 92 m 1,-1 H 49 v 6 h 94 V 5 l 0,0 z"
+     id="path3139-9"
+     style="fill:#e5e5e5" /><rect
+     width="22"
+     height="6"
+     x="184.51001"
+     y="5"
+     id="rect3141-9"
+     style="fill:#e5e5e5" /><rect
+     width="13"
+     height="6"
+     x="161.51001"
+     y="5"
+     id="rect3143-3"
+     style="fill:#e5e5e5" /><rect
+     width="6"
+     height="6"
+     x="176.51001"
+     y="5"
+     id="rect3145-7"
+     style="fill:#e5e5e5" /><rect
+     width="6"
+     height="6"
+     x="153.51001"
+     y="5"
+     id="rect3147-6"
+     style="fill:#e5e5e5" /><rect
+     width="32"
+     height="6"
+     x="9"
+     y="5"
+     id="rect3149-5"
+     style="fill:#e5e5e5" /><path
+     d="M 2,14.5 H 262"
+     id="path3151-9"
+     style="fill:#e5e5e5;stroke:#e5e5e5" /><rect
+     width="2"
+     height="2"
+     x="52"
+     y="7"
+     id="rect3153-5"
+     style="fill:#e5e5e5" /><path
+     d="M 38,59 V 54 H 13 v 5 h 25 z"
+     id="path3155-4"
+     style="fill:#e5e5e5" /><g
+     id="g3157-6"><path
+       d="M 202.957,157.619 V 42.958 h -154 v 110.601 l 2.145,-1.6 12.556,10 
13.809,-10 14.229,10 12.972,-10 12.973,10 13.811,-10 12.136,10 13.391,-10 
14.229,10 12.973,-10 12.973,10 5.803,-4.34 z"
+       id="path3159-6"
+       style="fill:#e4e4e4" /></g><g
+     id="g3161-2"
+     style="opacity:0.2"><rect
+       width="156.08501"
+       height="21.667"
+       x="48.040001"
+       y="42.041"
+       id="rect3163-6"
+       style="fill:#4f89c8" /></g><g
+     id="g3165-8"
+     style="opacity:0.8"><rect
+       width="54"
+       height="5.9990001"
+       x="58.957001"
+       y="72.292"
+       id="rect3167-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3169-6"
+     style="opacity:0.3"><path
+       d="m 189.957,84.293 h -39 v 30 h 39 v -30 z m -26.348,13.043 h 1.402 l 
8.701,8.604 4.725,-2.834 7.117,5.943 v 0.025 h -31.148 l 9.203,-11.738 z"
+       id="path3171-4"
+       style="fill:#9b9b9b" /></g><g
+     id="g3173-1"
+     style="opacity:0.8"><rect
+       width="131"
+       height="3"
+       x="58.957001"
+       y="123.293"
+       id="rect3175-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3177-3"
+     style="opacity:0.8"><rect
+       width="104"
+       height="3"
+       x="58.957001"
+       y="133.293"
+       id="rect3179-0"
+       style="fill:#cccbcb" /></g><g
+     id="g3181-8"
+     style="opacity:0.8"><rect
+       width="84"
+       height="3"
+       x="58.957001"
+       y="89.292999"
+       id="rect3183-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3185-7"
+     style="opacity:0.8"><rect
+       width="84"
+       height="3"
+       x="58.957001"
+       y="99.292999"
+       id="rect3187-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3189-6"
+     style="opacity:0.8"><rect
+       width="39"
+       height="3"
+       x="58.957001"
+       y="109.293"
+       id="rect3191-0"
+       style="fill:#cccbcb" /></g><g
+     id="g3193-4"
+     style="opacity:0.4"><g
+       id="g3195-4"><path
+         d="m 58.957,48.291 h 25 v 10 h -25 v -10 z"
+         id="path3197-0"
+         style="fill:#9b9b9b" /></g><g
+       id="g3199-1"><rect
+         width="10"
+         height="10"
+         x="92.457001"
+         y="48.291"
+         id="rect3201-3"
+         style="fill:#9b9b9b" /></g><g
+       id="g3203-9"><rect
+         width="10"
+         height="10"
+         x="109.457"
+         y="48.291"
+         id="rect3205-6"
+         style="fill:#9b9b9b" /></g></g><g
+     transform="translate(129.3,41.6)"
+     id="math-2"
+     style="opacity:0.75;fill:#222222;fill-opacity:1"><path
+       d="M 13.609,11.391 10.004,16.004 16,16 l 0,-1 1,0 0,3 -10,0 5,-6 -5,-6 
10,0 0,3 -1,0 0,-2 -6,0 3.609,4.391"
+       id="sigma-7"
+       style="fill:#222222;fill-opacity:1;fill-rule:nonzero;stroke:none" 
/></g></svg>
\ No newline at end of file
diff --git a/betafeatures-icon-VisualEditor-formulae-rtl.svg 
b/betafeatures-icon-VisualEditor-formulae-rtl.svg
new file mode 100644
index 0000000..15a2aa9
--- /dev/null
+++ b/betafeatures-icon-VisualEditor-formulae-rtl.svg
@@ -0,0 +1,238 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   version="1.1"
+   width="264"
+   height="162"
+   viewBox="0 0 264 162"
+   id="Layer_1"
+   xml:space="preserve"
+   inkscape:version="0.48.4 r9939"
+   
sodipodi:docname="betafeatures-icon-VisualEditor-formulae-ltr.svg"><sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="640"
+     inkscape:window-height="480"
+     id="namedview51"
+     showgrid="false"
+     inkscape:zoom="1.1022727"
+     inkscape:cx="132"
+     inkscape:cy="81"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="Layer_1" /><metadata
+     id="metadata3213"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; 
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+     id="defs3211" /><g
+     id="g3120-2"
+     transform="matrix(-1,0,0,1,264,0)"><polygon
+       points="0.5,0.5 263.5,0.5 263.5,152.249 254.5,158.954 254.5,42.5 
215.5,42.5 215.5,155.1 211.107,151.369 203.5,156.699 203.5,42.5 48.5,42.5 
48.5,153.35 38.749,161.38 24.833,151.361 13.366,161.357 0.5,151.749 "
+       id="polygon3122-9"
+       style="fill:#ffffff" /><g
+       id="g3124-5"><path
+         d="m 263,1 v 150.998 l -8,5.96 V 43 42 h -1 -38 -1 v 1 111.02 l 
-3.274,-2.781 -0.589,-0.498 -0.633,0.441 -6.504,4.556 V 43 42 H 203 49 48 v 1 
110.1 l -9.257,7.66 -13.295,-9.57 -0.645,-0.463 -0.598,0.521 -10.864,9.47 L 
1,151.499 V 1 h 262 m 1,-1 H 0 V 152 L 13.391,162 24.865,152 38.756,162 
49,153.6 V 43 H 203 V 157.66 L 211.078,152 216,156.18 V 43 h 38 v 116.95 l 
10,-7.45 V 0 l 0,0 z"
+         id="path3126-5"
+         style="fill:#e5e5e5"
+         inkscape:connector-curvature="0" /></g></g><path
+     d="M 61,157.66 V 43 H 215 V 153.6 L 212.855,152 200.3,162 186.491,152 
172.262,162 159.29,152 146.317,162 132.506,152 120.37,162 106.979,152 92.75,162 
79.778,152 66.804,162 61,157.66 z"
+     id="path3128-1"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><path
+     d="m 253,36 c 0,-7.732 -6.268,-14 -14,-14 -7.732,0 -14,6.268 -14,14 
0,7.732 6.268,14 14,14 7.732,0 14,-6.268 14,-14 z"
+     id="Ellipse-2"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><path
+     d="M 10,159.95 V 43 H 48 V 156.18 L 40.449,162 26.638,152 12.747,162 
10,159.95 z"
+     id="path3131-8"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><path
+     d="M 226,107 V 72 h 25 v 35 h -25 z"
+     id="path3133-5"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><path
+     d="m 31.49,5 h -26 v 6 h 26 V 5 z"
+     id="path3135-8"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><rect
+     width="22"
+     height="6"
+     x="-55.48999"
+     y="5"
+     id="rect3137-5"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><path
+     d="m 122,6 v 4 h 92 V 6 h -92 m -1,-1 h 94 v 6 H 121 V 5 l 0,0 z"
+     id="path3139-9"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><rect
+     width="22"
+     height="6"
+     x="-79.48999"
+     y="5"
+     id="rect3141-9"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><rect
+     width="13"
+     height="6"
+     x="-102.48999"
+     y="5"
+     id="rect3143-3"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><rect
+     width="6"
+     height="6"
+     x="-87.48999"
+     y="5"
+     id="rect3145-7"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><rect
+     width="6"
+     height="6"
+     x="-110.48999"
+     y="5"
+     id="rect3147-6"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><rect
+     width="32"
+     height="6"
+     x="-255"
+     y="5"
+     id="rect3149-5"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><path
+     d="M 262,14.5 H 2"
+     id="path3151-9"
+     style="fill:#e5e5e5;stroke:#e5e5e5"
+     inkscape:connector-curvature="0" /><rect
+     width="2"
+     height="2"
+     x="-212"
+     y="7"
+     id="rect3153-5"
+     style="fill:#e5e5e5"
+     transform="scale(-1,1)" /><path
+     d="m 226,59 v -5 h 25 v 5 h -25 z"
+     id="path3155-4"
+     style="fill:#e5e5e5"
+     inkscape:connector-curvature="0" /><g
+     id="g3157-6"
+     transform="matrix(-1,0,0,1,264,0)"><path
+       d="M 202.957,157.619 V 42.958 h -154 v 110.601 l 2.145,-1.6 12.556,10 
13.809,-10 14.229,10 12.972,-10 12.973,10 13.811,-10 12.136,10 13.391,-10 
14.229,10 12.973,-10 12.973,10 5.803,-4.34 z"
+       id="path3159-6"
+       style="fill:#e4e4e4"
+       inkscape:connector-curvature="0" /></g><g
+     id="g3161-2"
+     style="opacity:0.2"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="156.08501"
+       height="21.667"
+       x="48.040001"
+       y="42.041"
+       id="rect3163-6"
+       style="fill:#4f89c8" /></g><g
+     id="g3165-8"
+     style="opacity:0.8"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="54"
+       height="5.9990001"
+       x="58.957001"
+       y="72.292"
+       id="rect3167-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3169-6"
+     style="opacity:0.3"
+     transform="matrix(-1,0,0,1,264,0)"><path
+       d="m 189.957,84.293 h -39 v 30 h 39 v -30 z m -26.348,13.043 h 1.402 l 
8.701,8.604 4.725,-2.834 7.117,5.943 v 0.025 h -31.148 l 9.203,-11.738 z"
+       id="path3171-4"
+       style="fill:#9b9b9b"
+       inkscape:connector-curvature="0" /></g><g
+     id="g3173-1"
+     style="opacity:0.8"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="131"
+       height="3"
+       x="58.957001"
+       y="123.293"
+       id="rect3175-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3177-3"
+     style="opacity:0.8"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="104"
+       height="3"
+       x="58.957001"
+       y="133.293"
+       id="rect3179-0"
+       style="fill:#cccbcb" /></g><g
+     id="g3181-8"
+     style="opacity:0.8"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="84"
+       height="3"
+       x="58.957001"
+       y="89.292999"
+       id="rect3183-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3185-7"
+     style="opacity:0.8"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="84"
+       height="3"
+       x="58.957001"
+       y="99.292999"
+       id="rect3187-5"
+       style="fill:#cccbcb" /></g><g
+     id="g3189-6"
+     style="opacity:0.8"
+     transform="matrix(-1,0,0,1,264,0)"><rect
+       width="39"
+       height="3"
+       x="58.957001"
+       y="109.293"
+       id="rect3191-0"
+       style="fill:#cccbcb" /></g><g
+     id="g3193-4"
+     style="opacity:0.4"
+     transform="matrix(-1,0,0,1,264,0)"><g
+       id="g3195-4"><path
+         d="m 58.957,48.291 h 25 v 10 h -25 v -10 z"
+         id="path3197-0"
+         style="fill:#9b9b9b"
+         inkscape:connector-curvature="0" /></g><g
+       id="g3199-1"><rect
+         width="10"
+         height="10"
+         x="92.457001"
+         y="48.291"
+         id="rect3201-3"
+         style="fill:#9b9b9b" /></g><g
+       id="g3203-9"><rect
+         width="10"
+         height="10"
+         x="109.457"
+         y="48.291"
+         id="rect3205-6"
+         style="fill:#9b9b9b" /></g></g><g
+     transform="translate(110.7,41.6)"
+     id="math-2"
+     style="opacity:0.75;fill:#222222;fill-opacity:1"><path
+       d="M 13.609,11.391 10.004,16.004 16,16 l 0,-1 1,0 0,3 -10,0 5,-6 -5,-6 
10,0 0,3 -1,0 0,-2 -6,0 3.609,4.391"
+       id="sigma-7"
+       style="fill:#222222;fill-opacity:1;fill-rule:nonzero;stroke:none"
+       inkscape:connector-curvature="0" /></g></svg>
\ No newline at end of file
diff --git a/modules/VisualEditor/ve.ce.MWMathNode.css 
b/modules/VisualEditor/ve.ce.MWMathNode.css
new file mode 100644
index 0000000..4fa349e
--- /dev/null
+++ b/modules/VisualEditor/ve.ce.MWMathNode.css
@@ -0,0 +1,3 @@
+.ve-ce-mwMathNode {
+       display: inline-block;
+}
diff --git a/modules/VisualEditor/ve.ce.MWMathNode.js 
b/modules/VisualEditor/ve.ce.MWMathNode.js
new file mode 100644
index 0000000..bf529dd
--- /dev/null
+++ b/modules/VisualEditor/ve.ce.MWMathNode.js
@@ -0,0 +1,65 @@
+/*!
+ * VisualEditor ContentEditable MWMathNode class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/*global MathJax, ve, OO */
+
+/**
+ * ContentEditable MediaWiki math node.
+ *
+ * @class
+ * @extends ve.ce.MWExtensionNode
+ *
+ * @constructor
+ * @param {ve.dm.MWMathNode} model Model to observe
+ * @param {Object} [config] Configuration options
+ */
+ve.ce.MWMathNode = function VeCeMWMathNode( model, config ) {
+       // Parent constructor
+       ve.ce.MWExtensionNode.call( this, model, config );
+
+       // DOM changes
+       this.$element.addClass( 've-ce-mwMathNode' );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ce.MWMathNode, ve.ce.MWExtensionNode );
+
+/* Static Properties */
+
+ve.ce.MWMathNode.static.name = 'mwMath';
+
+/* Methods */
+
+/** */
+ve.ce.MWMathNode.prototype.onParseSuccess = function ( deferred, response ) {
+       var data = response.visualeditor, contentNodes = this.$( data.content 
).get();
+       if ( contentNodes[0] && contentNodes[0].childNodes ) {
+               contentNodes = Array.prototype.slice.apply( 
contentNodes[0].childNodes );
+       }
+       deferred.resolve( contentNodes );
+};
+
+/** */
+ve.ce.MWExtensionNode.prototype.afterRender = function ( domElements ) {
+       if ( this.$( domElements ).is( 'span.tex' ) ) {
+               // MathJax
+               MathJax.Hub.Queue(
+                       [ 'Typeset', MathJax.Hub, this.$element[0] ],
+                       [ this, this.emit, 'rerender' ]
+               );
+       } else {
+               // Rerender after image load
+               this.$element.find( 'img.tex' ).on( 'load', ve.bind( function 
() {
+                       this.emit( 'rerender' );
+               }, this ) );
+       }
+};
+
+/* Registration */
+
+ve.ce.nodeFactory.register( ve.ce.MWMathNode );
diff --git a/modules/VisualEditor/ve.dm.MWMathNode.js 
b/modules/VisualEditor/ve.dm.MWMathNode.js
new file mode 100644
index 0000000..3af2817
--- /dev/null
+++ b/modules/VisualEditor/ve.dm.MWMathNode.js
@@ -0,0 +1,39 @@
+/*!
+ * VisualEditor DataModel MWMathNode class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/*global ve, OO */
+
+/**
+ * DataModel MediaWiki math node.
+ *
+ * @class
+ * @extends ve.dm.MWExtensionNode
+ *
+ * @constructor
+ * @param {number} [length] Length of content data (ignored, forced to 0)
+ * @param {Object} [element] Reference to element in linear model
+ */
+ve.dm.MWMathNode = function VeDmMWMathNode( length, element ) {
+       // Parent constructor
+       ve.dm.MWExtensionNode.call( this, 0, element );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.dm.MWMathNode, ve.dm.MWExtensionNode );
+
+/* Static members */
+
+ve.dm.MWMathNode.static.name = 'mwMath';
+
+ve.dm.MWMathNode.static.tagName = 'img';
+
+ve.dm.MWMathNode.static.extensionName = 'math';
+
+/* Registration */
+
+ve.dm.modelRegistry.register( ve.dm.MWMathNode );
diff --git a/modules/VisualEditor/ve.ui.MWMathInspector.js 
b/modules/VisualEditor/ve.ui.MWMathInspector.js
new file mode 100644
index 0000000..37eb427
--- /dev/null
+++ b/modules/VisualEditor/ve.ui.MWMathInspector.js
@@ -0,0 +1,117 @@
+/*!
+ * VisualEditor UserInterface MWMathInspector class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/*global ve, OO */
+
+/**
+ * MediaWiki math inspector.
+ *
+ * @class
+ * @extends ve.ui.MWExtensionInspector
+ *
+ * @constructor
+ * @param {ve.ui.WindowSet} windowSet Window set this inspector is part of
+ * @param {Object} [config] Configuration options
+ */
+ve.ui.MWMathInspector = function VeUiMWMathInspector( windowSet, config ) {
+       // Parent constructor
+       ve.ui.MWExtensionInspector.call( this, windowSet, config );
+
+       this.onChangeHandler = ve.debounce( ve.bind( this.updatePreview, this 
), 250 );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.MWMathInspector, ve.ui.MWExtensionInspector );
+
+/* Static properties */
+
+ve.ui.MWMathInspector.static.name = 'math';
+
+ve.ui.MWMathInspector.static.icon = 'math';
+
+ve.ui.MWMathInspector.static.titleMessage = 
'math-visualeditor-mwmathinspector-title';
+
+ve.ui.MWMathInspector.static.nodeView = ve.ce.MWMathNode;
+
+ve.ui.MWMathInspector.static.nodeModel = ve.dm.MWMathNode;
+
+/* Methods */
+
+/**
+ * Update the math node rendering to reflect the content entered into the 
inspector.
+ */
+ve.ui.MWMathInspector.prototype.updatePreview = function () {
+       var newsrc = this.input.getValue();
+       if ( this.visible ) {
+               this.node.update( { 'extsrc': newsrc } );
+       }
+};
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWMathInspector.prototype.setup = function ( data ) {
+       // Parent method
+       ve.ui.MWExtensionInspector.prototype.setup.call( this, data );
+
+       var mw, surfaceModel = this.surface.getModel();
+
+       this.node = this.surface.getView().getFocusedNode();
+       if ( !this.node ) {
+               // Create a dummy node, needed for live preview
+               mw = {
+                       'name': 'math',
+                       'attrs': {},
+                       'body': {
+                               'extsrc': ''
+                       }
+               };
+               surfaceModel.getFragment().collapseRangeToEnd().insertContent( [
+                       {
+                               'type': 'mwMath',
+                               'attributes': {
+                                       'mw': mw
+                               }
+                       },
+                       { 'type': '/mwMath' }
+               ] );
+               this.node = this.surface.getView().getFocusedNode();
+       }
+
+       this.input.on( 'change', this.onChangeHandler );
+
+       // Override directionality settings, inspector's input
+       // should always be LTR:
+       this.input.setRTL( false );
+};
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWMathInspector.prototype.teardown = function ( data ) {
+       var newsrc = this.input.getValue(),
+               surfaceModel = this.surface.getModel();
+
+       this.input.off( 'change', this.onChangeHandler );
+
+       if ( newsrc !== '' ) {
+               // Parent method
+               ve.ui.MWExtensionInspector.prototype.teardown.call( this, data 
);
+       } else {
+               // The user tried to empty the node, remove it
+               surfaceModel.change( ve.dm.Transaction.newFromRemoval(
+                       surfaceModel.getDocument(), this.node.getOuterRange()
+               ) );
+               // Grandparent method; we're overriding the parent behavior in 
this case
+               ve.ui.Inspector.prototype.teardown.call( this, data );
+       }
+};
+
+/* Registration */
+
+ve.ui.inspectorFactory.register( ve.ui.MWMathInspector );
diff --git a/modules/VisualEditor/ve.ui.MWMathInspectorTool.js 
b/modules/VisualEditor/ve.ui.MWMathInspectorTool.js
new file mode 100644
index 0000000..3e1e66a
--- /dev/null
+++ b/modules/VisualEditor/ve.ui.MWMathInspectorTool.js
@@ -0,0 +1,29 @@
+/*!
+ * VisualEditor MediaWiki UserInterface math tool class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/*global ve, OO */
+
+/**
+ * MediaWiki UserInterface math tool.
+ *
+ * @class
+ * @extends ve.ui.InspectorTool
+ * @constructor
+ * @param {OO.ui.ToolGroup} toolGroup
+ * @param {Object} [config] Configuration options
+ */
+ve.ui.MWMathInspectorTool = function VeUiMWMathInspectorTool( toolGroup, 
config ) {
+       ve.ui.InspectorTool.call( this, toolGroup, config );
+};
+OO.inheritClass( ve.ui.MWMathInspectorTool, ve.ui.InspectorTool );
+ve.ui.MWMathInspectorTool.static.name = 'math';
+ve.ui.MWMathInspectorTool.static.group = 'object';
+ve.ui.MWMathInspectorTool.static.icon = 'math';
+ve.ui.MWMathInspectorTool.static.titleMessage = 
'math-visualeditor-mwmathinspector-title';
+ve.ui.MWMathInspectorTool.static.inspector = 'math';
+ve.ui.MWMathInspectorTool.static.modelClasses = [ ve.dm.MWMathNode ];
+ve.ui.toolFactory.register( ve.ui.MWMathInspectorTool );

-- 
To view, visit https://gerrit.wikimedia.org/r/105647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8e582ee6deadc2750d30b49f0c6de31ed9c16a50
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to