mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 09:40:49 +00:00
Merge "Preserve reflist CSS in dynamic mode"
This commit is contained in:
commit
20c6967f76
|
@ -187,6 +187,12 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
||||||
emptyText = ve.msg( 'cite-ve-referenceslist-isempty-default' );
|
emptyText = ve.msg( 'cite-ve-referenceslist-isempty-default' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let originalDomElements;
|
||||||
|
if ( model.getElement().originalDomElementsHash ) {
|
||||||
|
originalDomElements = model.getStore().value(
|
||||||
|
model.getElement().originalDomElementsHash
|
||||||
|
);
|
||||||
|
}
|
||||||
// Use the Parsoid-provided DOM if:
|
// Use the Parsoid-provided DOM if:
|
||||||
//
|
//
|
||||||
// * There are no references in the model
|
// * There are no references in the model
|
||||||
|
@ -196,13 +202,11 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
||||||
if (
|
if (
|
||||||
!hasModelReferences &&
|
!hasModelReferences &&
|
||||||
!this.modified &&
|
!this.modified &&
|
||||||
model.getElement().originalDomElementsHash
|
originalDomElements
|
||||||
) {
|
) {
|
||||||
// Create a copy when importing to the main document, as extensions may
|
// Create a copy when importing to the main document, as extensions may
|
||||||
|
this.$originalRefList = $( ve.copyDomElements( originalDomElements, document ) );
|
||||||
// modify DOM nodes in the main doc.
|
// modify DOM nodes in the main doc.
|
||||||
this.$originalRefList = $( ve.copyDomElements( model.getStore().value(
|
|
||||||
model.getElement().originalDomElementsHash
|
|
||||||
), document ) );
|
|
||||||
if ( this.$originalRefList.find( 'li' ).length ) {
|
if ( this.$originalRefList.find( 'li' ).length ) {
|
||||||
this.$element.append( this.$originalRefList );
|
this.$element.append( this.$originalRefList );
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,6 +220,17 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
||||||
this.$originalRefList.remove();
|
this.$originalRefList.remove();
|
||||||
this.$originalRefList = null;
|
this.$originalRefList = null;
|
||||||
}
|
}
|
||||||
|
// Copy CSS to dynamic ref list
|
||||||
|
if ( originalDomElements ) {
|
||||||
|
// Get first container, e.g. skipping TemplateStyles
|
||||||
|
const divs = originalDomElements.filter( ( element ) => element.tagName === 'DIV' );
|
||||||
|
if ( divs.length ) {
|
||||||
|
// eslint-disable-next-line mediawiki/class-doc
|
||||||
|
this.$element.addClass( divs[ 0 ].getAttribute( 'class' ) );
|
||||||
|
this.$element.attr( 'style', divs[ 0 ].getAttribute( 'style' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.$reflist.detach().empty().attr( 'data-mw-group', refGroup || null );
|
this.$reflist.detach().empty().attr( 'data-mw-group', refGroup || null );
|
||||||
this.$refmsg.detach();
|
this.$refmsg.detach();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue