Merge "Render subrefs indented under parent"

This commit is contained in:
jenkins-bot 2024-07-03 09:55:58 +00:00 committed by Gerrit Code Review
commit de1445d2e3

View file

@ -244,7 +244,7 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
const topLevelNodes = groupedByParent[ '' ] || []; const topLevelNodes = groupedByParent[ '' ] || [];
this.$reflist.append( this.$reflist.append(
topLevelNodes.map( ( node ) => this.renderListItem( topLevelNodes.map( ( node ) => this.renderListItem(
nodes, internalList, refGroup, node nodes, internalList, groupedByParent, refGroup, node
) ) ) )
); );
@ -259,11 +259,13 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
* @private * @private
* @param {Object} nodes Node group object, containing nodes and key order array * @param {Object} nodes Node group object, containing nodes and key order array
* @param {ve.dm.InternalList} internalList Internal list * @param {ve.dm.InternalList} internalList Internal list
* @param {Object.<string, ve.dm.MWReferenceNode[]>} groupedByParent Mapping
* from parent ref name (or '' for top-level) to refs
* @param {string} refGroup Reference group * @param {string} refGroup Reference group
* @param {ve.dm.MWReferenceNode} node Reference node to render as a footnote body * @param {ve.dm.MWReferenceNode} node Reference node to render as a footnote body
* @return {jQuery} Rendered list item * @return {jQuery} Rendered list item
*/ */
ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internalList, refGroup, node ) { ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internalList, groupedByParent, refGroup, node ) {
const listIndex = node.getAttribute( 'listIndex' ); const listIndex = node.getAttribute( 'listIndex' );
const key = internalList.keys[ listIndex ]; const key = internalList.keys[ listIndex ];
const keyedNodes = ( nodes.keyedNodes[ key ] || [] ) const keyedNodes = ( nodes.keyedNodes[ key ] || [] )
@ -317,6 +319,17 @@ ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internal
e.preventDefault(); e.preventDefault();
} ); } );
} }
const listKey = node.getAttribute( 'listKey' );
const subrefs = groupedByParent[ listKey ] || [];
if ( subrefs.length ) {
$li.append(
$( '<ol>' ).append(
subrefs.map( ( subNode ) => this.renderListItem(
nodes, internalList, groupedByParent, refGroup, subNode
) )
)
);
}
} else { } else {
$li.append( $li.append(
$( '<span>' ) $( '<span>' )