Catrope has uploaded a new change for review.

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


Change subject: Make reference editing work
......................................................................

Make reference editing work

The only reason it doesn't save correctly right now is because Parsoid
doesn't serialize reference edits correctly.

Change-Id: Ia0f272c07cc28ee829372eb848f23aec99eb92f0
---
M modules/ve/dm/nodes/ve.dm.MWReferenceNode.js
M modules/ve/dm/ve.dm.InternalList.js
2 files changed, 6 insertions(+), 9 deletions(-)


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

diff --git a/modules/ve/dm/nodes/ve.dm.MWReferenceNode.js 
b/modules/ve/dm/nodes/ve.dm.MWReferenceNode.js
index 9855603..7ebe962 100644
--- a/modules/ve/dm/nodes/ve.dm.MWReferenceNode.js
+++ b/modules/ve/dm/nodes/ve.dm.MWReferenceNode.js
@@ -36,12 +36,10 @@
 ve.dm.MWReferenceNode.static.toDataElement = function ( domElements, converter 
) {
        var dataElement, listIndex,
                about = domElements[0].getAttribute( 'about' ),
-               // TODO: this is always-present in the new spec, so "|| '{}'" 
can be removed later
                mw = JSON.parse( domElements[0].getAttribute( 'data-mw' ) || 
'{}' ),
-               // TODO: this will be stored in mw.body.html in the new spec
-               body = JSON.parse( domElements[0].getAttribute( 'data-parsoid' 
) ).src,
-               // TODO: this will be stored in mw.name in the new spec
-               name = $( body ).attr( 'name' ),
+               body = mw.body.html,
+               // TODO: this should be in mw.name but that's always set to 
'ref'
+               name = $( domElements[0] ).children( 'a' ).attr( 'href' ),
                key = name !== null ? name : ve.getHash( body );
 
        listIndex = converter.internalList.addItem( key, body );
@@ -73,9 +71,8 @@
        ),
        itemNodeHtml = $( itemNodeWrapper ).html();
 
-       // TODO: store internalNodeHtml in data.mw:
-       // dataElement.attributes.mw.body.html = itemNodeHtml;
-       // span.setAttribute( 'data-mw', JSON.stringify( 
dataElement.attributes.mw ) );
+       dataElement.attributes.mw.body.html = itemNodeHtml;
+       span.setAttribute( 'data-mw', JSON.stringify( dataElement.attributes.mw 
) );
 
        return [ span ];
 };
diff --git a/modules/ve/dm/ve.dm.InternalList.js 
b/modules/ve/dm/ve.dm.InternalList.js
index db5cb82..db39eaa 100644
--- a/modules/ve/dm/ve.dm.InternalList.js
+++ b/modules/ve/dm/ve.dm.InternalList.js
@@ -118,7 +118,7 @@
        if ( itemsHtml.length ) {
                list.push( { 'type': 'internalList' } );
                for ( i = 0, length = itemsHtml.length; i < length; i++ ) {
-                       itemData = converter.getDataFromDomRecursion( $( 
itemsHtml[i] )[0] );
+                       itemData = converter.getDataFromDomRecursion( $( 
'<div>' ).html( itemsHtml[i] )[0] );
                        list = list.concat(
                                [{ 'type': 'internalItem' }],
                                itemData,

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

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

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

Reply via email to