Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74807


Change subject: MWMath cleanup
......................................................................

MWMath cleanup

VisualEditor.php
* Add CSS file.

ve.ce.MWMathNode.js
* Wrap the image in a span, so GenerateContentNode doesn't
  try to nested an image inside an image.
* Remove unnecessary attribute setting.
* Only pass unwrapped image to deferred.resolve.

ve.ce.Node.css
* Use inline-block for image wrapper.

ve.ui.MWMathInspector.js
* Remove static.InputWidget, not required in this architecture.
* Use multiline TextInputWidget.

ve.ui.MWInspector.css
* Set height of TextInputWidget.

Change-Id: I520f8ccc9f89a2ce70aa1d9e02ed0c6cacbecc2f
---
M VisualEditor.php
M modules/ve-mw/ce/nodes/ve.ce.MWMathNode.js
M modules/ve-mw/ce/styles/ve.ce.Node.css
M modules/ve-mw/ui/inspectors/ve.ui.MWMathInspector.js
A modules/ve-mw/ui/styles/ve.ui.MWInspector.css
5 files changed, 36 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/07/74807/1

diff --git a/VisualEditor.php b/VisualEditor.php
index 1ea12f7..19c903a 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -565,6 +565,7 @@
                        've/ui/styles/ve.ui.Widget.css',
                        've-mw/ui/styles/ve.ui.Widget.css',
                        've/ui/styles/ve.ui.Inspector.css',
+                       've-mw/ui/styles/ve.ui.MWInspector.css',
                        've/ui/styles/ve.ui.Dialog.css',
                        've-mw/ui/styles/ve.ui.MWDialog.css',
                ),
diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWMathNode.js 
b/modules/ve-mw/ce/nodes/ve.ce.MWMathNode.js
index 2a56e70..86f9418 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWMathNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWMathNode.js
@@ -20,8 +20,16 @@
  * @param {Object} [config] Config options
  */
 ve.ce.MWMathNode = function VeCeMWMathNode( model, config ) {
+       var wrapper;
+
        // Parent constructor
        ve.ce.LeafNode.call( this, model, config );
+
+       // Wrap image
+       this.$image = this.$;
+       wrapper = $( '<span> ');
+       this.$.wrap( wrapper );
+       this.$ = wrapper;
 
        // Mixin constructors
        ve.ce.FocusableNode.call( this );
@@ -34,8 +42,6 @@
 
        // DOM Changes
        this.$.addClass( 've-ce-mwMathNode' );
-       this.$.attr( 'src', model.getAttribute( 'src' ) );
-       this.$.attr( 'alt', model.getAttribute( 'alt' ) );
 };
 
 /* Inheritance */
@@ -85,8 +91,10 @@
  */
 ve.ce.MWMathNode.prototype.onParseSuccess = function ( deferred, response ) {
        var data = response.visualeditor, contentNodes = $( data.content 
).get();
-       this.$.attr( 'alt', contentNodes[0].childNodes[0].getAttribute( 'alt' ) 
);
-       this.$.attr( 'src', contentNodes[0].childNodes[0].getAttribute( 'src' ) 
);
+       // HACK: unwrap paragraph from PHP parser
+       contentNodes = Array.prototype.slice.apply( contentNodes[0].childNodes 
);
+       this.$.attr( 'alt', contentNodes[0].getAttribute( 'alt' ) );
+       this.$.attr( 'src', contentNodes[0].getAttribute( 'src' ) );
        deferred.resolve( contentNodes );
 };
 
diff --git a/modules/ve-mw/ce/styles/ve.ce.Node.css 
b/modules/ve-mw/ce/styles/ve.ce.Node.css
index df7d934..deee191 100644
--- a/modules/ve-mw/ce/styles/ve.ce.Node.css
+++ b/modules/ve-mw/ce/styles/ve.ce.Node.css
@@ -47,3 +47,9 @@
 .ve-ce-mwInlineImageNode {
        display: inline-block;
 }
+
+/* ve.ce.MWMathNode */
+
+.ve-ce-mwMathNode {
+       display: inline-block;
+}
diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWMathInspector.js 
b/modules/ve-mw/ui/inspectors/ve.ui.MWMathInspector.js
index 1bd1068..8467513 100644
--- a/modules/ve-mw/ui/inspectors/ve.ui.MWMathInspector.js
+++ b/modules/ve-mw/ui/inspectors/ve.ui.MWMathInspector.js
@@ -30,8 +30,6 @@
 
 ve.ui.MWMathInspector.static.titleMessage = 
'visualeditor-mwmathinspector-title';
 
-ve.ui.MWMathInspector.static.InputWidget = ve.ui.InputWidget;
-
 /* Methods */
 
 /**
@@ -43,9 +41,12 @@
        // Parent method
        ve.ui.Inspector.prototype.initialize.call( this );
 
-       this.input = new this.constructor.static.InputWidget( {
-               '$$': this.frame.$$, 'overlay': this.surface.$localOverlay
+       this.input = new ve.ui.TextInputWidget( {
+               '$$': this.frame.$$,
+               'overlay': this.surface.$localOverlay,
+               'multiline': true
        } );
+       this.input.$.addClass( 've-ui-mwMathInspector-input' );
 
        // Initialization
        this.$form.append( this.input.$ );
diff --git a/modules/ve-mw/ui/styles/ve.ui.MWInspector.css 
b/modules/ve-mw/ui/styles/ve.ui.MWInspector.css
new file mode 100644
index 0000000..82e3386
--- /dev/null
+++ b/modules/ve-mw/ui/styles/ve.ui.MWInspector.css
@@ -0,0 +1,12 @@
+/*!
+ * VisualEditor MediaWiki UserInterface Inspector styles.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/* ve.ui.MWMathInspector */
+
+.ve-ui-mwMathInspector-input textarea {
+       height: 8em;
+}
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I520f8ccc9f89a2ce70aa1d9e02ed0c6cacbecc2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to