/*! * VisualEditor DataModel Cite-specific example data sets. * * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt * @license MIT */ ve.dm.citeExample = {}; ve.dm.citeExample.createExampleDocument = function ( name, store ) { return ve.dm.example.createExampleDocumentFromObject( name, store, ve.dm.citeExample ); }; ve.dm.citeExample.refListItemClipboard = function ( text ) { return '' + '
' + '' + '

' + text + '

' + '
' + '
' + '
'; }; ve.dm.citeExample.domToDataCases = { 'mw:Reference': { // Wikitext: // Foo BazQuux Whee[[Bar]] // YayNo name QuuxDifferent content Foo // // // Ref in refs body: '

Foo' + '' + '[1]' + '' + ' Baz' + '' + '[g1 1]' + '' + ' Whee' + '' + '[1]' + '' + ' Yay' + // This reference has .body.id instead of .body.html '' + '[g1 2]' + '' + ' Quux' + '' + '[1]' + '' + ' Foo' + '' + '[g1 3]' + '' + '

' + // The HTML below is enriched to wrap reference contents in // which Parsoid doesn't do yet, but T88290 asks for '
    ' + '
  1. Quux
  2. ' + '
  3. No name
  4. ' + '
  5. Ref in refs
  6. ' + '
', fromDataBody: '

Foo' + '' + '' + ' Baz' + '' + '' + ' Whee' + '' + '' + ' Yay' + '' + '' + ' Quux' + '' + '' + ' Foo' + '' + '' + '

' + '
' + '
', clipboardBody: '

Foo' + '' + '[1]' + '' + ' Baz' + '' + '[g1 1]' + '' + ' Whee' + '' + '[1]' + '' + ' Yay' + // This reference has .body.id instead of .body.html '' + '[g1 2]' + '' + ' Quux' + '' + '[1]' + '' + ' Foo' + '' + '[g1 3]' + '' + '

' + // The HTML below is enriched to wrap reference contents in // which Parsoid doesn't do yet, but T88290 asks for '
' + '
    ' + '
  1. ' + '' + ve.dm.citeExample.refListItemClipboard( 'Quux' ) + '
  2. ' + '
  3. ' + '' + ve.dm.citeExample.refListItemClipboard( 'No name' ) + '
  4. ' + '
  5. ' + '' + ve.dm.citeExample.refListItemClipboard( 'Ref in refs' ) + '
  6. ' + '
' + '
', head: '', data: [ { type: 'paragraph' }, 'F', 'o', 'o', { type: 'mwReference', attributes: { listIndex: 0, listGroup: 'mwReference/', listKey: 'literal/bar', refGroup: '', mw: { name: 'ref', attrs: { name: 'bar' } }, originalMw: '{"name":"ref","attrs":{"name":"bar"}}', contentsUsed: false } }, { type: '/mwReference' }, ' ', 'B', 'a', 'z', { type: 'mwReference', attributes: { listIndex: 1, listGroup: 'mwReference/g1', listKey: 'literal/:0', refGroup: 'g1', mw: { name: 'ref', body: { html: 'Quux' }, attrs: { group: 'g1', name: ':0' } }, originalMw: '{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}', contentsUsed: true } }, { type: '/mwReference' }, ' ', 'W', 'h', 'e', 'e', { type: 'mwReference', attributes: { listIndex: 0, listGroup: 'mwReference/', listKey: 'literal/bar', refGroup: '', mw: { name: 'ref', body: { html: 'Bar' }, attrs: { name: 'bar' } }, originalMw: '{"name":"ref","body":{"html":"Bar"},"attrs":{"name":"bar"}}', contentsUsed: true } }, { type: '/mwReference' }, ' ', 'Y', 'a', 'y', { type: 'mwReference', attributes: { listIndex: 2, listGroup: 'mwReference/g1', listKey: 'auto/0', refGroup: 'g1', mw: { name: 'ref', body: { id: 'mw-cite-3' }, attrs: { group: 'g1' } }, originalMw: '{"name":"ref","body":{"id":"mw-cite-3"},"attrs":{"group":"g1"}}', contentsUsed: true, refListItemId: 'mw-cite-3' } }, { type: '/mwReference' }, ' ', 'Q', 'u', 'u', 'x', { type: 'mwReference', attributes: { listIndex: 0, listGroup: 'mwReference/', listKey: 'literal/bar', refGroup: '', mw: { name: 'ref', body: { html: 'Different content' }, attrs: { name: 'bar' } }, originalMw: '{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}', contentsUsed: false } }, { type: '/mwReference' }, ' ', 'F', 'o', 'o', { type: 'mwReference', attributes: { listGroup: 'mwReference/g1', listIndex: 3, listKey: 'literal/foo', refGroup: 'g1', mw: { name: 'ref', attrs: { group: 'g1', name: 'foo' } }, originalMw: '{"name":"ref","attrs":{"group":"g1","name":"foo"}}', contentsUsed: false } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: 'mwReferencesList', attributes: { mw: { name: 'references', attrs: { group: 'g1' }, body: { html: '[3]' } }, originalMw: '{"name":"references","body":{"html":"[3]"},"attrs":{"group":"g1"}}', listGroup: 'mwReference/g1', refGroup: 'g1', isResponsive: true, templateGenerated: false } }, { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/g1', listIndex: 3, listKey: 'literal/foo', mw: { name: 'ref', attrs: { group: 'g1', name: 'foo' }, body: { html: 'Ref in refs' } }, originalMw: '{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"group":"g1","name":"foo"}}', refGroup: 'g1' } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: '/mwReferencesList' }, { type: 'internalList' }, { type: 'internalItem', attributes: { originalHtml: 'Bar' } }, { type: 'paragraph', internal: { generated: 'wrapper' } }, [ 'B', [ { type: 'link/mwInternal', attributes: { title: 'Bar', origTitle: 'Bar', normalizedTitle: 'Bar', lookupTitle: 'Bar' } } ] ], [ 'a', [ { type: 'link/mwInternal', attributes: { title: 'Bar', origTitle: 'Bar', normalizedTitle: 'Bar', lookupTitle: 'Bar' } } ] ], [ 'r', [ { type: 'link/mwInternal', attributes: { title: 'Bar', origTitle: 'Bar', normalizedTitle: 'Bar', lookupTitle: 'Bar' } } ] ], { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem', attributes: { originalHtml: 'Quux' } }, { type: 'paragraph', internal: { generated: 'wrapper' } }, 'Q', 'u', 'u', 'x', { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem', attributes: { originalHtml: 'No name' } }, { type: 'paragraph', internal: { generated: 'wrapper' } }, 'N', 'o', ' ', 'n', 'a', 'm', 'e', { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem', attributes: { originalHtml: 'Ref in refs' } }, { type: 'paragraph', internal: { generated: 'wrapper' } }, 'R', 'e', 'f', ' ', 'i', 'n', ' ', 'r', 'e', 'f', 's', { type: '/paragraph' }, { type: '/internalItem' }, { type: '/internalList' } ] }, 'mw:Reference with comment': { body: '

' + '[1]

', fromDataBody: '

', clipboardBody: '

' + '[1]

', previewBody: '

' + '[1]

', head: '', data: [ { type: 'paragraph' }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/', listIndex: 0, listKey: 'auto/0', mw: { attrs: {}, body: { html: 'Foo' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"html":"Foo"},"attrs":{}}', refGroup: '' } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: 'internalList' }, { type: 'internalItem', attributes: { originalHtml: 'Foo' } }, { internal: { generated: 'wrapper' }, type: 'paragraph' }, 'F', 'o', 'o', { type: 'comment', attributes: { text: ' bar ' } }, { type: '/comment' }, { type: '/paragraph' }, { type: '/internalItem' }, { type: '/internalList' } ] }, 'Template generated reflist': { body: '

[notes 1]

' + '
' + '
    ' + '
  1. Foo
  2. ' + '
' + '
', fromDataBody: '

' + '', clipboardBody: '

[notes 1]

' + '
' + // TODO: This should list should get populated on copy '
    ' + '
    ', previewBody: false, data: [ { type: 'paragraph' }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/notes', listIndex: 0, listKey: 'auto/0', mw: { attrs: { group: 'notes' }, body: { id: 'mw-reference-text-cite_note-1' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{"group":"notes"}}', refGroup: 'notes', refListItemId: 'mw-reference-text-cite_note-1' } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: 'mwReferencesList', attributes: { mw: { parts: [ { template: { params: { 1: { wt: '' } }, target: { wt: 'echo', href: './Template:Echo' }, i: 0 } } ] }, originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}', refGroup: '', listGroup: 'mwReference/', isResponsive: true, templateGenerated: true } }, { type: '/mwReferencesList' }, { type: 'internalList' }, { type: 'internalItem', attributes: { originalHtml: 'Foo' } }, { internal: { generated: 'wrapper' }, type: 'paragraph' }, 'F', 'o', 'o', { type: '/paragraph' }, { type: '/internalItem' }, { type: '/internalList' } ] }, 'Template generated reflist (div wrapped)': { body: '

    [1]

    ' + '
    ' + '
    ' + '
      ' + '
    1. Foo
    2. ' + '
    ' + '
    ' + '
    ', fromDataBody: '

    ' + '', clipboardBody: '

    [1]

    ' + '
    ' + '
      ' + '
    1. ' + '' + ve.dm.citeExample.refListItemClipboard( 'Foo' ) + '
    2. ' + '
    ' + '
    ', previewBody: false, data: [ { type: 'paragraph' }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/', listIndex: 0, listKey: 'auto/0', mw: { attrs: {}, body: { id: 'mw-reference-text-cite_note-1' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}', refGroup: '', refListItemId: 'mw-reference-text-cite_note-1' } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: 'mwReferencesList', attributes: { mw: { name: 'references', attrs: {} }, originalMw: '{"name":"references","attrs":{}}', refGroup: '', listGroup: 'mwReference/', isResponsive: true, templateGenerated: true } }, { type: '/mwReferencesList' }, { type: 'internalList' }, { type: 'internalItem', attributes: { originalHtml: 'Foo' } }, { internal: { generated: 'wrapper' }, type: 'paragraph' }, 'F', 'o', 'o', { type: '/paragraph' }, { type: '/internalItem' }, { type: '/internalList' } ] } }; ve.dm.citeExample.references = [ { type: 'paragraph' }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/', listIndex: 0, listKey: 'auto/0', mw: { attrs: {}, body: { html: 'No name 1' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"html":"No name 1"},"attrs":{}}', refGroup: '' } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: 'paragraph' }, 'F', 'o', 'o', { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/', listIndex: 1, listKey: 'literal/bar', mw: { attrs: { name: 'bar' }, body: { html: 'Bar' }, name: 'ref' }, originalMw: '{"body":{"html":""},"attrs":{"name":"bar"}}', refGroup: '' } }, { type: '/mwReference' }, ' ', 'B', 'a', 'z', { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/', listIndex: 2, listKey: 'literal/:3', mw: { attrs: { name: ':3' }, body: { html: 'Quux' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"html":"Quux"},"attrs":{"name":":3"}}', refGroup: '' } }, { type: '/mwReference' }, ' ', 'W', 'h', 'e', 'e', { type: 'mwReference', attributes: { contentsUsed: false, listGroup: 'mwReference/', listIndex: 1, listKey: 'literal/bar', mw: { attrs: { name: 'bar' }, name: 'ref' }, originalMw: '{"body":{"html":""},"attrs":{"name":"bar"}}', refGroup: '' } }, { type: '/mwReference' }, ' ', 'Y', 'a', 'y', { type: '/paragraph' }, { type: 'paragraph' }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/', listIndex: 3, listKey: 'auto/1', mw: { attrs: {}, body: { html: 'No name 2' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"html":"No name 2"},"attrs":{}}', refGroup: '' } }, { type: '/mwReference' }, { type: 'mwReference', attributes: { contentsUsed: true, listGroup: 'mwReference/foo', listIndex: 4, listKey: 'auto/2', mw: { attrs: { group: 'foo' }, body: { html: 'No name 3' }, name: 'ref' }, originalMw: '{"name":"ref","body":{"html":"No name 3"},"attrs":{"group":"foo"}}', refGroup: 'foo' } }, { type: '/mwReference' }, { type: '/paragraph' }, { type: 'mwReferencesList', // originalDomElements: HTML, attributes: { mw: { name: 'references', attrs: { group: 'g1' } }, originalMw: '{"name":"references","attrs":{"group":"g1"}"}', listGroup: 'mwReference/', refGroup: '', isResponsive: true, templateGenerated: false } }, { type: '/mwReferencesList' }, { type: 'internalList' }, { type: 'internalItem' }, { type: 'paragraph' }, 'N', 'o', ' ', 'n', 'a', 'm', 'e', ' ', '1', { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem' }, { type: 'paragraph' }, 'B', 'a', 'r', { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem' }, { type: 'paragraph' }, 'Q', 'u', 'u', 'x', { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem' }, { type: 'paragraph' }, 'N', 'o', ' ', 'n', 'a', 'm', 'e', ' ', '2', { type: '/paragraph' }, { type: '/internalItem' }, { type: 'internalItem' }, { type: 'paragraph' }, 'N', 'o', ' ', 'n', 'a', 'm', 'e', ' ', '3', { type: '/paragraph' }, { type: '/internalItem' }, { type: '/internalList' } ]; ve.dm.citeExample.complexInternalData = [ // 0 { type: 'paragraph' }, 'F', [ 'o', [ ve.dm.example.bold ] ], [ 'o', [ ve.dm.example.italic ] ], // 4 { type: 'mwReference', attributes: { about: '#mwt1', listIndex: 0, listGroup: 'mwReference/', listKey: 'auto/0', refGroup: '' } }, // 5 { type: '/mwReference' }, // 6 { type: '/paragraph' }, // 7 { type: 'internalList' }, // 8 { type: 'internalItem' }, // 9 { type: 'paragraph', internal: { generated: 'wrapper' } }, 'R', [ 'e', [ ve.dm.example.bold ] ], 'f', // 13 'e', [ 'r', [ ve.dm.example.italic ] ], [ 'e', [ ve.dm.example.italic ] ], // 16 { type: 'mwReference', attributes: { mw: {}, about: '#mwt2', listIndex: 1, listGroup: 'mwReference/', listKey: 'foo', refGroup: '', contentsUsed: true } }, // 17 { type: '/mwReference' }, 'n', 'c', 'e', // 21 { type: '/paragraph' }, // 22 { type: '/internalItem' }, // 23 { type: 'internalItem' }, // 24 { type: 'preformatted' }, // 25 { type: 'mwEntity', attributes: { character: '€' } }, // 26 { type: '/mwEntity' }, '2', '5', '0', // 30 { type: '/preformatted' }, // 31 { type: '/internalItem' }, // 32 { type: '/internalList' } // 33 ]; ve.dm.citeExample.complexInternalData.internalItems = [ { group: 'mwReference', key: null, body: 'First reference' }, { group: 'mwReference', key: 'foo', body: 'Table in ref:
    because I can
    ' } ]; ve.dm.citeExample.complexInternalData.internalListNextUniqueNumber = 1;