jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/358375 )

Change subject: Visual diff: Show correct reference indices in diff
......................................................................


Visual diff: Show correct reference indices in diff

Bug: T162819
Change-Id: I7eec4ee12a24ff99388cc0c95a24d50f321511f9
---
M includes/CiteHooks.php
M modules/ve-cite/i18n/en.json
M modules/ve-cite/i18n/qqq.json
M modules/ve-cite/tests/ve.dm.citeExample.js
M modules/ve-cite/ve.dm.MWReferenceNode.js
M modules/ve-cite/ve.dm.MWReferencesListNode.js
6 files changed, 52 insertions(+), 25 deletions(-)

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



diff --git a/includes/CiteHooks.php b/includes/CiteHooks.php
index c433384..43d48f4 100644
--- a/includes/CiteHooks.php
+++ b/includes/CiteHooks.php
@@ -106,7 +106,9 @@
                        "messages" => [
                                "cite-ve-referenceslist-isempty",
                                "cite-ve-referenceslist-isempty-default",
-                               "cite-ve-referenceslist-missingref"
+                               "cite-ve-referenceslist-missingref",
+                               
"visualeditor-internal-list-diff-default-group-name-mwreference",
+                               
"visualeditor-internal-list-diff-group-name-mwreference"
                        ],
                        "targets" => [
                                "desktop",
diff --git a/modules/ve-cite/i18n/en.json b/modules/ve-cite/i18n/en.json
index 6e6f7ae..5b193ee 100644
--- a/modules/ve-cite/i18n/en.json
+++ b/modules/ve-cite/i18n/en.json
@@ -51,5 +51,7 @@
        "cite-ve-referenceslist-isempty-default": "There are no references on 
this page to include in this list.",
        "cite-ve-referenceslist-missingref": "This reference is defined in a 
template or other generated block, and for now can only be edited in source 
mode.",
        "cite-ve-toolbar-group-label": "Cite",
-       "cite-ve-othergroup-item": "$1 reference"
+       "cite-ve-othergroup-item": "$1 reference",
+       "visualeditor-internal-list-diff-default-group-name-mwreference": 
"References",
+       "visualeditor-internal-list-diff-group-name-mwreference": "Reference 
group name: \"$1\""
 }
diff --git a/modules/ve-cite/i18n/qqq.json b/modules/ve-cite/i18n/qqq.json
index ae99ba8..69c7835 100644
--- a/modules/ve-cite/i18n/qqq.json
+++ b/modules/ve-cite/i18n/qqq.json
@@ -62,5 +62,7 @@
        "cite-ve-referenceslist-isempty-default": "Message that appears in the 
references list when there are no references on the page in the default group.",
        "cite-ve-referenceslist-missingref": "Message that appears in the 
references list, and as a tooltip on the reference itself, for references that 
are generated by a template or are otherwise uneditable.\n\nSee also:\n* 
{{msg-mw|visualeditor-dialog-meta-languages-readonlynote}}",
        "cite-ve-toolbar-group-label": "Label text for the toolbar button for 
inserting customized references.\n{{Identical|Cite}}",
-       "cite-ve-othergroup-item": "Label text for the toolbar items under the 
'Insert' (other) group if VisualEditor is configured that 
way.\n\nParameters:\n* $1 - citation type label\n{{Identical|Reference}}"
+       "cite-ve-othergroup-item": "Label text for the toolbar items under the 
'Insert' (other) group if VisualEditor is configured that 
way.\n\nParameters:\n* $1 - citation type label\n{{Identical|Reference}}",
+       "visualeditor-internal-list-diff-default-group-name-mwreference": 
"Heading in the visual diff for the default reference group.",
+       "visualeditor-internal-list-diff-group-name-mwreference": "Heading in 
the visual diff to indicate the reference group name, when the reference group 
is not the default group.\n\nParameters:\n* $1 - reference-group name"
 }
diff --git a/modules/ve-cite/tests/ve.dm.citeExample.js 
b/modules/ve-cite/tests/ve.dm.citeExample.js
index d89f70c..a531cd4 100644
--- a/modules/ve-cite/tests/ve.dm.citeExample.js
+++ b/modules/ve-cite/tests/ve.dm.citeExample.js
@@ -91,31 +91,31 @@
                        '</div>',
                clipboardBody:
                        '<p>Foo' +
-                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}">'
 +
-                                       '<a><span 
class="mw-reflink-text">[1]</span></a>' +
+                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}"
 class="mw-ref">' +
+                                       '<a style="counter-reset: mw-Ref 
1;"><span class="mw-reflink-text">[1]</span></a>' +
                                '</span>' +
                                ' Baz' +
-                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Quux&quot;},&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;:0&quot;}}">'
 +
-                                       '<a><span class="mw-reflink-text">[g1 
1]</span></a>' +
+                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Quux&quot;},&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;:0&quot;}}"
 class="mw-ref">' +
+                                       '<a data-mw-group="g1" 
style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[g1 
1]</span></a>' +
                                '</span>' +
                                ' Whee' +
                                '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;'
 +
                                '<a href=\\&quot;./Bar\\&quot; 
rel=\\&quot;mw:WikiLink\\&quot;>Bar' +
-                               
'</a>&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}">' +
-                                       '<a><span 
class="mw-reflink-text">[1]</span></a>' +
+                               
'</a>&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}" 
class="mw-ref">' +
+                                       '<a style="counter-reset: mw-Ref 
1;"><span class="mw-reflink-text">[1]</span></a>' +
                                '</span>' +
                                ' Yay' +
                                // This reference has .body.id instead of 
.body.html
-                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;id&quot;:&quot;mw-cite-3&quot;,&quot;html&quot;:&quot;No
 name&quot;},&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;}}">' +
-                                       '<a><span class="mw-reflink-text">[g1 
2]</span></a>' +
+                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;id&quot;:&quot;mw-cite-3&quot;,&quot;html&quot;:&quot;No
 name&quot;},&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;}}" 
class="mw-ref">' +
+                                       '<a data-mw-group="g1" 
style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[g1 
2]</span></a>' +
                                '</span>' +
                                ' Quux' +
-                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Different
 content&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}">' +
-                                       '<a><span 
class="mw-reflink-text">[1]</span></a>' +
+                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Different
 content&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}" 
class="mw-ref">' +
+                                       '<a style="counter-reset: mw-Ref 
1;"><span class="mw-reflink-text">[1]</span></a>' +
                                '</span>' +
                                ' Foo' +
-                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;foo&quot;}}">'
 +
-                                       '<a><span class="mw-reflink-text">[g1 
3]</span></a>' +
+                               '<span typeof="mw:Extension/ref" 
data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;foo&quot;}}"
 class="mw-ref">' +
+                                       '<a data-mw-group="g1" 
style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[g1 
3]</span></a>' +
                                '</span>' +
                        '</p>' +
                        // The HTML below is enriched to wrap reference 
contents in <span id="mw-cite-[...]">
@@ -124,7 +124,7 @@
                                
'data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;},&quot;body&quot;:{'
 +
                                '&quot;html&quot;:&quot;<span 
typeof=\\&quot;mw:Extension/ref\\&quot; ' +
                                
'data-mw=\\&quot;{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;attrs&amp;quot;:{&amp;quot;group&amp;quot;:&amp;quot;g1&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;foo&amp;quot;},&amp;quot;body&amp;quot;:{&amp;quot;html&amp;quot;:&amp;quot;Ref
 in refs&amp;quot;}}' +
-                               '\\&quot;><a><span 
class=\\&quot;mw-reflink-text\\&quot;>[g1 3]</span></a></span>&quot;}}">' +
+                               '\\&quot; class=\\&quot;mw-ref\\&quot;><a 
data-mw-group=\\&quot;g1\\&quot; style=\\&quot;counter-reset: mw-Ref 
3;\\&quot;><span class=\\&quot;mw-reflink-text\\&quot;>[g1 
3]</span></a></span>&quot;}}">' +
                        '</div>',
                head: '<base href="http://example.com"; />',
                data: [
@@ -321,8 +321,8 @@
                clipboardBody: '<p><span typeof="mw:Extension/ref" ' +
                        'data-mw="{&quot;attrs&quot;:{},&quot;body&quot;:' +
                        '{&quot;html&quot;:&quot;Foo<span 
rel=\\&quot;ve:Comment\\&quot; data-ve-comment=\\&quot; bar 
\\&quot;>&amp;nbsp;</span>&quot;},&quot;name&quot;:&quot;ref&quot;}" ' +
-                       '>' +
-                       '<a><span 
class="mw-reflink-text">[1]</span></a></span></p>',
+                       ' class="mw-ref">' +
+                       '<a style="counter-reset: mw-Ref 1;"><span 
class="mw-reflink-text">[1]</span></a></span></p>',
                head: '<base href="http://example.com"; />',
                data: [
                        { type: 'paragraph' },
diff --git a/modules/ve-cite/ve.dm.MWReferenceNode.js 
b/modules/ve-cite/ve.dm.MWReferenceNode.js
index 08586c0..de55223 100644
--- a/modules/ve-cite/ve.dm.MWReferenceNode.js
+++ b/modules/ve-cite/ve.dm.MWReferenceNode.js
@@ -102,7 +102,7 @@
 
 ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, 
converter ) {
        var itemNodeHtml, originalHtml, mwData, i, iLen, keyedNodes, 
setContents, contentsAlreadySet,
-               originalMw, listKeyParts, name,
+               originalMw, listKeyParts, name, group, $link,
                isForClipboard = converter.isForClipboard(),
                el = doc.createElement( 'span' ),
                itemNodeWrapper = doc.createElement( 'div' ),
@@ -221,9 +221,17 @@
                }
        } else {
                el.setAttribute( 'data-mw', JSON.stringify( mwData ) );
+
                // HTML for the external clipboard, it will be ignored by the 
converter
-               $( el ).append(
-                       $( '<a>', doc ).append(
+               group = this.getGroup( dataElement );
+               $link = $( '<a>', doc ).css(
+                       'counterReset', 'mw-Ref ' + this.getIndex( dataElement, 
converter.internalList )
+               );
+               if ( group ) {
+                       $link.attr( 'data-mw-group', this.getGroup( dataElement 
) );
+               }
+               $( el ).addClass( 'mw-ref' ).append(
+                       $link.append(
                                $( '<span>', doc ).addClass( 'mw-reflink-text' 
).text( this.getIndexLabel( dataElement, converter.internalList ) )
                        )
                );
@@ -264,9 +272,16 @@
  * @return {number} Index
  */
 ve.dm.MWReferenceNode.static.getIndex = function ( dataElement, internalList ) 
{
-       var listIndex = dataElement.attributes.listIndex,
-               listGroup = dataElement.attributes.listGroup,
-               position = internalList.getIndexPosition( listGroup, listIndex 
);
+       var listIndex, listGroup, position,
+               overrideIndex = ve.getProp( dataElement, 'internal', 
'overrideIndex' );
+
+       if ( overrideIndex ) {
+               return overrideIndex;
+       }
+
+       listIndex = dataElement.attributes.listIndex;
+       listGroup = dataElement.attributes.listGroup;
+       position = internalList.getIndexPosition( listGroup, listIndex );
 
        return position + 1;
 };
@@ -319,8 +334,11 @@
                }
                return ve.msg( 'cite-ve-changedesc-reflist-group-to', change.to 
);
        }
+       if ( key === 'listGroup' || key === 'originalMw' ) {
+               return null;
+       }
 
-       return null;
+       return ve.dm.MWReferenceNode.parent.static.describeChange.apply( this, 
arguments );
 };
 
 /* Methods */
diff --git a/modules/ve-cite/ve.dm.MWReferencesListNode.js 
b/modules/ve-cite/ve.dm.MWReferencesListNode.js
index e1235c9..c0d7007 100644
--- a/modules/ve-cite/ve.dm.MWReferencesListNode.js
+++ b/modules/ve-cite/ve.dm.MWReferencesListNode.js
@@ -134,6 +134,9 @@
                }
                return ve.msg( 'cite-ve-changedesc-ref-group-to', change.to );
        }
+       if ( key === 'originalMw' ) {
+               return null;
+       }
 
        return null;
 };

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7eec4ee12a24ff99388cc0c95a24d50f321511f9
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Cite
Gerrit-Branch: master
Gerrit-Owner: Tchanders <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Tchanders <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to