mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-12 09:10:32 +00:00
Merge "Template reflist: Re-render when converting for preview (e.g. visual diff)"
This commit is contained in:
commit
557e311ab4
|
@ -152,41 +152,6 @@ ve.dm.citeExample.domToDataCases = {
|
|||
'</li>' +
|
||||
'</ol>' +
|
||||
'</div>',
|
||||
previewBody:
|
||||
'<p>Foo' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a>' +
|
||||
'</sup>' +
|
||||
' Baz' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" class="mw-ref">' +
|
||||
'<a data-mw-group="g1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[g1 1]</span></a>' +
|
||||
'</sup>' +
|
||||
' Whee' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<a href=\\"./Bar\\" rel=\\"mw:WikiLink\\">Bar' +
|
||||
'</a>"},"attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a>' +
|
||||
'</sup>' +
|
||||
' Yay' +
|
||||
// This reference has .body.id instead of .body.html
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"id":"mw-cite-3"},"attrs":{"group":"g1"}}" class="mw-ref">' +
|
||||
'<a data-mw-group="g1" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[g1 2]</span></a>' +
|
||||
'</sup>' +
|
||||
' Quux' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a>' +
|
||||
'</sup>' +
|
||||
' Foo' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" class="mw-ref">' +
|
||||
'<a data-mw-group="g1" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[g1 3]</span></a>' +
|
||||
'</sup>' +
|
||||
'</p>' +
|
||||
'<div typeof="mw:Extension/references" ' +
|
||||
'data-mw="{"name":"references","attrs":{"group":"g1"},"body":{' +
|
||||
'"html":"<sup 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;},&quot;body&quot;:{&quot;html&quot;:&quot;Ref in refs&quot;}}' +
|
||||
'\\" class=\\"mw-ref\\"><a data-mw-group=\\"g1\\" style=\\"counter-reset: mw-Ref 3;\\"><span class=\\"mw-reflink-text\\">[g1 3]</span></a></sup>"}}">' +
|
||||
'</div>',
|
||||
head: '<base href="http://example.com" />',
|
||||
data: [
|
||||
{ type: 'paragraph' },
|
||||
|
|
|
@ -106,7 +106,7 @@ ve.dm.MWReferencesListNode.static.toDataElement = function ( domElements, conver
|
|||
ve.dm.MWReferencesListNode.static.toDomElements = function ( data, doc, converter ) {
|
||||
var el, els, mwData, originalMw, contentsHtml, originalHtml, nextIndex, nextElement, modelNode, viewNode,
|
||||
isResponsiveDefault = mw.config.get( 'wgCiteResponsiveReferences' ),
|
||||
isForClipboard = converter.isForClipboard(),
|
||||
isForParser = converter.isForParser(),
|
||||
wrapper = doc.createElement( 'div' ),
|
||||
originalHtmlWrapper = doc.createElement( 'div' ),
|
||||
dataElement = data[ 0 ],
|
||||
|
@ -114,12 +114,12 @@ ve.dm.MWReferencesListNode.static.toDomElements = function ( data, doc, converte
|
|||
contentsData = data.slice( 1, -1 );
|
||||
|
||||
// If we are sending a template generated ref back to Parsoid, output it as a template.
|
||||
// This works because the dataElement already as mw, originalMw and originalDomIndex properties.
|
||||
if ( attrs.templateGenerated && !isForClipboard ) {
|
||||
// This works because the dataElement already has mw, originalMw and originalDomIndex properties.
|
||||
if ( attrs.templateGenerated && isForParser ) {
|
||||
return ve.dm.MWTransclusionNode.static.toDomElements.call( this, dataElement, doc, converter );
|
||||
}
|
||||
|
||||
if ( isForClipboard ) {
|
||||
if ( !isForParser ) {
|
||||
// Output needs to be read so re-render
|
||||
modelNode = ve.dm.nodeFactory.createFromElement( dataElement );
|
||||
modelNode = new ve.dm.MWReferencesListNode( dataElement );
|
||||
|
|
Loading…
Reference in a new issue