/*! * VisualEditor DataModel MediaWiki-specific example data sets. * * @copyright See AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ /** * @class * @singleton * @ignore */ ve.dm.mwExample = {}; ve.dm.mwExample.baseUri = 'http://example.com/wiki/'; ve.dm.mwExample.createExampleDocument = ( name, store, base ) => ve.dm.example.createExampleDocumentFromObject( name, store, ve.dm.mwExample, base || ve.dm.mwExample.baseUri ); ve.dm.mwExample.createExampleDocumentFromData = ( data, store, base ) => ve.dm.example.createExampleDocumentFromData( data, store, base || ve.dm.mwExample.baseUri ); ve.dm.mwExample.MWTransclusion = { blockOpen: ve.dm.example.singleLine`
Hello, world!
', blockContentClipboard: 'Hello, world!
', inlineOpen: ve.dm.example.singleLine` `, inlineOpenModified: ve.dm.example.singleLine` `, inlineOpenFromData: ve.dm.example.singleLine` `, inlineOpenClipboard: ve.dm.example.singleLine` `, inlineOpenFromDataModified: ve.dm.example.singleLine` `, inlineOpenModifiedClipboard: ve.dm.example.singleLine` `, inlineContent: '$1,234.00', inlineClose: '', mixed: ve.dm.example.singleLine` Foo `, mixedFromData: ve.dm.example.singleLine` `, mixedClipboard: ve.dm.example.singleLine` Foo `, pairOne: ve.dm.example.singleLine`foo
`, pairTwo: ve.dm.example.singleLine`foo
`, pairFromData: ve.dm.example.singleLine` `, pairClipboard: ve.dm.example.singleLine`foo
`, meta: ve.dm.example.singleLine` \n `, metaFromData: ve.dm.example.singleLine` `, metaClipboard: ve.dm.example.singleLine` ` }; ve.dm.mwExample.MWTransclusion.blockData = { type: 'mwTransclusionBlock', attributes: { mw: { parts: [ { template: { target: { wt: 'Test', href: './Template:Test' }, params: { 1: { wt: 'Hello, world!' } }, i: 0 } } ] }, originalMw: '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}' } }; ve.dm.mwExample.MWTransclusion.inlineData = { type: 'mwTransclusionInline', attributes: { mw: { parts: [ { template: { target: { wt: 'Inline', href: './Template:Inline' }, params: { 1: { wt: '1,234' } }, i: 0 } } ] }, originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}' } }; ve.dm.mwExample.MWTransclusion.mixedDataOpen = { type: 'mwTransclusionInline', attributes: { mw: { parts: [ { template: { target: { wt: 'Inline', href: './Template:Inline' }, params: { 1: { wt: '5,678' } }, i: 0 } } ] }, originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}' } }; ve.dm.mwExample.MWTransclusion.mixedDataClose = { type: '/mwTransclusionInline' }; ve.dm.mwExample.MWTransclusion.blockParamsHash = OO.getHash( [ ve.dm.MWTransclusionNode.static.getHashObject( ve.dm.mwExample.MWTransclusion.blockData ), undefined ] ); ve.dm.mwExample.MWTransclusion.blockStoreItems = {}; ve.dm.mwExample.MWTransclusion.blockStoreItems[ ve.dm.HashValueStore.prototype.hashOfValue( null, ve.dm.mwExample.MWTransclusion.blockParamsHash ) ] = $.parseHTML( ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent ); ve.dm.mwExample.MWTransclusion.inlineParamsHash = OO.getHash( [ ve.dm.MWTransclusionNode.static.getHashObject( ve.dm.mwExample.MWTransclusion.inlineData ), undefined ] ); ve.dm.mwExample.MWTransclusion.inlineStoreItems = {}; ve.dm.mwExample.MWTransclusion.inlineStoreItems[ ve.dm.HashValueStore.prototype.hashOfValue( null, ve.dm.mwExample.MWTransclusion.inlineParamsHash ) ] = $.parseHTML( ve.dm.mwExample.MWTransclusion.inlineOpen + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose ); ve.dm.mwExample.MWTransclusion.mixedParamsHash = OO.getHash( [ ve.dm.MWTransclusionNode.static.getHashObject( ve.dm.mwExample.MWTransclusion.mixedDataOpen ), undefined ] ); ve.dm.mwExample.MWTransclusion.mixedStoreItems = {}; ve.dm.mwExample.MWTransclusion.mixedStoreItems[ ve.dm.HashValueStore.prototype.hashOfValue( null, ve.dm.mwExample.MWTransclusion.mixedParamsHash ) ] = $.parseHTML( ve.dm.mwExample.MWTransclusion.mixed ); ve.dm.mwExample.MWInternalLink = { absoluteHref: new URL( './Foo/Bar', ve.dm.mwExample.baseUri ).toString() }; ve.dm.mwExample.MWInternalLink.absoluteOpen = ''; ve.dm.mwExample.MWInternalLink.absoluteData = { type: 'link/mwInternal', attributes: { title: 'Foo/Bar', normalizedTitle: 'Foo/Bar', lookupTitle: 'Foo/Bar' } }; ve.dm.mwExample.MWInternalSectionLink = { absoluteHref: new URL( './Foo#Bar', ve.dm.mwExample.baseUri ).toString() }; ve.dm.mwExample.MWInternalSectionLink.absoluteOpen = ''; ve.dm.mwExample.MWInternalSectionLink.absoluteData = { type: 'link/mwInternal', attributes: { title: 'Foo#Bar', normalizedTitle: 'Foo#Bar', lookupTitle: 'Foo' } }; ve.dm.mwExample.MWMediaLinkExistsData = { type: 'link/mwInternal', attributes: { lookupTitle: 'Media:Exists.png', normalizedTitle: 'Media:Exists.png', title: 'Media:Exists.png' } }; ve.dm.mwExample.MWMediaLinkMissingData = { type: 'link/mwInternal', attributes: { lookupTitle: 'Media:Missing.png', normalizedTitle: 'Media:Missing.png', title: 'Media:Missing.png' } }; ve.dm.mwExample.MWBlockImage = { html: ve.dm.example.singleLine` `, data: [ { type: 'mwBlockImage', attributes: { type: 'thumb', align: 'right', href: './Foo', imageClassAttr: 'mw-file-element', imgWrapperClassAttr: 'mw-file-description', mediaClass: 'Image', mediaTag: 'img', src: ve.ce.minImgDataUri, width: 1, height: 2, alt: 'alt text', isError: false, errorText: null, resource: './FooBar', mw: {}, originalClasses: 'mw-halign-right foobar', unrecognizedClasses: [ 'foobar' ] } }, { type: 'mwImageCaption' }, { type: 'paragraph', internal: { generated: 'wrapper' } }, ...'abc', { type: '/paragraph' }, { type: '/mwImageCaption' }, { type: '/mwBlockImage' } ], storeItems: { h1d9b405cfd633576: ve.ce.minImgDataUri } }; ve.dm.mwExample.MWInlineImage = { html: ve.dm.example.singleLine` `, data: { type: 'mwInlineImage', attributes: { src: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png', href: './File:Wiki.png', imageClassAttr: 'mw-file-element', imgWrapperClassAttr: 'mw-file-description', mediaClass: 'Image', mediaTag: 'img', width: 135, height: 155, alt: 'alt text', isError: false, errorText: null, valign: 'text-top', resource: './File:Wiki.png', mw: {}, type: 'none', originalClasses: 'foo mw-valign-text-top', unrecognizedClasses: [ 'foo' ] } }, storeItems: { hbb0aeb2b8e907b74: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png' } }; ve.dm.mwExample.MWInlineImageWithoutWrapperClass = { html: ve.dm.example.singleLine` `, data: { type: 'mwInlineImage', attributes: { src: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png', href: './File:Wiki.png', imageClassAttr: 'mw-file-element', imgWrapperClassAttr: null, mediaClass: 'Image', mediaTag: 'img', width: 135, height: 155, alt: 'alt text', isError: false, errorText: null, valign: 'text-top', resource: './File:Wiki.png', mw: {}, type: 'none', originalClasses: 'foo mw-valign-text-top', unrecognizedClasses: [ 'foo' ] } } }; ve.dm.mwExample.mwNowikiAnnotation = { type: 'mwNowiki' }; ve.dm.mwExample.mwNowiki = [ { type: 'paragraph' }, ...'Foo', [ '[', [ ve.dm.mwExample.mwNowikiAnnotation ] ], [ '[', [ ve.dm.mwExample.mwNowikiAnnotation ] ], [ 'B', [ ve.dm.mwExample.mwNowikiAnnotation ] ], [ 'a', [ ve.dm.mwExample.mwNowikiAnnotation ] ], [ 'r', [ ve.dm.mwExample.mwNowikiAnnotation ] ], [ ']', [ ve.dm.mwExample.mwNowikiAnnotation ] ], [ ']', [ ve.dm.mwExample.mwNowikiAnnotation ] ], ...'Baz', { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ]; ve.dm.mwExample.mwNowikiHtml = 'Foo[[Bar]]Baz
'; ve.dm.mwExample.mwNowikiHtmlFromData = 'Foo[[Bar]]Baz
'; ve.dm.mwExample.withMeta = [ { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: 'comment', attributes: { text: ' No conversion ' } }, { type: '/comment' }, { type: '/paragraph' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'paragraph' }, ...'Foo', { type: 'mwCategory', attributes: { category: 'Category:Bar', sortkey: '' } }, { type: '/mwCategory' }, ...'Bar', { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, ...'Ba', { type: 'comment', attributes: { text: ' inline ' } }, { type: '/comment' }, 'z', { type: '/paragraph' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: 'comment', attributes: { text: 'barbaz' } }, { type: '/comment' }, { type: '/paragraph' }, { type: 'mwCategory', attributes: { category: 'Category:Foo foo', sortkey: 'Bar baz#quux' } }, { type: '/mwCategory' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'internalList' }, { type: '/internalList' } ]; ve.dm.mwExample.withMetaRealData = [ { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: 'comment', attributes: { text: ' No conversion ' } }, { type: '/comment' }, { type: '/paragraph' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'paragraph' }, ...'FooBarBa', { type: 'comment', attributes: { text: ' inline ' } }, { type: '/comment' }, 'z', { type: '/paragraph' }, { type: 'mwCategory', attributes: { category: 'Category:Bar', sortkey: '' } }, { type: '/mwCategory' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: 'comment', attributes: { text: 'barbaz' } }, { type: '/comment' }, { type: '/paragraph' }, { type: 'mwCategory', attributes: { category: 'Category:Foo foo', sortkey: 'Bar baz#quux' } }, { type: '/mwCategory' }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: '/mwAlienMeta' }, { type: 'internalList' }, { type: '/internalList' } ]; ve.dm.mwExample.withMetaMetaData = [ [ { type: 'alienMeta', originalDomElements: $.parseHTML( '' ) }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) } ], undefined, undefined, undefined, [ { type: 'mwCategory', attributes: { category: 'Category:Bar', sortkey: '' } } ], undefined, undefined, [ { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) } ], undefined, [ { type: 'alienMeta', originalDomElements: $.parseHTML( '' ) } ], undefined, [ { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) }, { type: 'comment', attributes: { text: 'barbaz' } }, { type: 'mwCategory', attributes: { category: 'Category:Foo foo', sortkey: 'Bar baz#quux' } }, { type: 'mwAlienMeta', originalDomElements: $.parseHTML( '' ) } ], undefined, undefined ]; ve.dm.mwExample.domToDataCases = { 'adjacent annotations (data-parsoid)': { preserveAnnotationDomElements: true, body: ve.dm.example.singleLine` a b c d d `, data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, [ 'a', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'a' ) } ] ], [ 'b', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'b' ) } ] ], [ 'c', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'c' ) } ] ], ' ', [ 'd', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'a' ) } ] ], [ 'd', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'a' ) } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], modify: ( model ) => { const data = [ 'x', [ ve.dm.example.bold ] ], linearData = ve.dm.example.preprocessAnnotations( [ data ], model.getStore() ); model.data.data.splice( 3, 0, linearData.data[ 0 ] ); }, normalizedBody: ve.dm.example.singleLine` a bx c dd `, fromDataBody: ve.dm.example.singleLine` a bx c dda b c d d `, data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, [ 'a', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'a' ) } ] ], [ 'b', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'b' ) } ] ], [ 'c', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'c' ) } ] ], ' ', [ 'd', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'a' ) } ] ], [ 'd', [ { type: 'textStyle/bold', attributes: { nodeName: 'b' }, originalDomElements: $.parseHTML( 'a' ) } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], modify: ( model ) => { const data = [ 'x', [ ve.dm.example.bold ] ], linearData = ve.dm.example.preprocessAnnotations( [ data ], model.getStore() ); model.data.data.splice( 3, 0, linearData.data[ 0 ] ); }, normalizedBody: ve.dm.example.singleLine` a bx c dd `, fromDataBody: ve.dm.example.singleLine` a bx c dd ` }, mwImage: { body: `${ ve.dm.mwExample.MWInlineImage.html }
`, data: [ { type: 'paragraph' }, ve.dm.mwExample.MWInlineImage.data, { type: '/mwInlineImage' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], ceHtml: ve.dm.example.singleLine` ${ ve.dm.example.ceParagraph } ${ ve.dm.example.inlineSlug } ${ ve.dm.example.inlineSlug } `, storeItems: ve.dm.mwExample.MWInlineImage.storeItems }, mwImageWithoutWrapperClass: { body: '' + ve.dm.mwExample.MWInlineImageWithoutWrapperClass.html + '
', data: [ { type: 'paragraph' }, ve.dm.mwExample.MWInlineImageWithoutWrapperClass.data, { type: '/mwInlineImage' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], ceHtml: ve.dm.example.singleLine` ${ ve.dm.example.ceParagraph } ${ ve.dm.example.inlineSlug } ${ ve.dm.example.inlineSlug } `, storeItems: ve.dm.mwExample.MWInlineImage.storeItems }, 'mwHeading and mwPreformatted nodes': { body: 'Bar', data: [ { type: 'mwHeading', attributes: { level: 2 } }, ...'Foo', { type: '/mwHeading' }, { type: 'mwPreformatted' }, ...'Bar', { type: '/mwPreformatted' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'mwTable with duplicate class attributes': { body: '
Foo |
Foo |
foo
` ) } }, 'mw:Transclusion containing only meta data': { body: ve.dm.mwExample.MWTransclusion.meta, fromDataBody: ve.dm.mwExample.MWTransclusion.metaFromData, clipboardBody: ve.dm.mwExample.MWTransclusion.metaClipboard, previewBody: false, data: [ { internal: { generated: 'wrapper' }, type: 'paragraph' }, { type: 'mwTransclusionInline', attributes: { mw: { parts: [ { template: { target: { wt: 'Template:Echo', href: './Template:Echo' }, params: { 1: { wt: '[[Category:Page]]\n[[Category:Book]]' } }, i: 0 } } ] }, originalMw: '{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}' } }, { type: '/mwTransclusionInline' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'mw:Transclusion which is also a language annotation': { body: 'content', data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: 'mwTransclusionInline', attributes: { mw: {}, originalMw: '{}' }, originalDomElements: $.parseHTML( 'content' ) }, { type: '/mwTransclusionInline' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], clipboardBody: 'content', previewBody: false }, 'mw:AlienBlockExtension': { body: ve.dm.example.singleLine``, normalizedBody: ve.dm.example.singleLine`
`, data: [ { type: 'paragraph' }, { type: 'mwAlienInlineExtension', attributes: { mw: { name: 'score', attrs: {}, body: { extsrc: '\\relative c\' { e d c d e e e }' } }, originalMw: '{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c\' { e d c d e e e }"}}' }, originalDomElements: $.parseHTML( `` ) }, { type: '/mwAlienInlineExtension' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], modify: ( model ) => { model.data.modifyData( 1, ( item ) => { item.attributes.mw.body.extsrc = '\\relative c\' { d d d e e e }'; } ); } }, 'internal link with absolute path': { body: '
' + ve.dm.mwExample.MWInternalLink.absoluteOpen + 'Foo
', base: ve.dm.mwExample.baseUri, data: [ { type: 'paragraph' }, [ 'F', [ ve.dm.mwExample.MWInternalLink.absoluteData ] ], [ 'o', [ ve.dm.mwExample.MWInternalLink.absoluteData ] ], [ 'o', [ ve.dm.mwExample.MWInternalLink.absoluteData ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: '', mwConfig: { wgArticlePath: '/wiki/$1' } }, 'internal link with absolute path and section': { body: '' + ve.dm.mwExample.MWInternalSectionLink.absoluteOpen + 'Foo
', base: ve.dm.mwExample.baseUri, data: [ { type: 'paragraph' }, [ 'F', [ ve.dm.mwExample.MWInternalSectionLink.absoluteData ] ], [ 'o', [ ve.dm.mwExample.MWInternalSectionLink.absoluteData ] ], [ 'o', [ ve.dm.mwExample.MWInternalSectionLink.absoluteData ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: '', mwConfig: { wgArticlePath: '/wiki/$1' } }, 'internal link with href set to ./': { body: '', base: ve.dm.mwExample.baseUri, data: [ { type: 'paragraph' }, [ 'x', [ { type: 'link/mwInternal', attributes: { title: '', normalizedTitle: '', lookupTitle: '' } } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'internal link with special characters': { body: '', ignoreXmlWarnings: true, base: ve.dm.mwExample.baseUri, data: [ { type: 'paragraph' }, [ 'x', [ { type: 'link/mwInternal', attributes: { title: 'Foo?+%&Bar', normalizedTitle: 'Foo?+%&Bar', lookupTitle: 'Foo?+%&Bar' } } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'mw:MediaLink (exists)': { body: '', data: [ { type: 'paragraph' }, [ 'M', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'e', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'd', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'i', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'a', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ ':', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'E', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'x', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'i', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 's', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 't', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 's', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ '.', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'p', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'n', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], [ 'g', [ ve.dm.mwExample.MWMediaLinkExistsData ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: '', fromDataBody: '' }, 'mw:MediaLink (missing)': { body: '', data: [ { type: 'paragraph' }, [ 'M', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'e', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'd', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'i', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'a', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ ':', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'M', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'i', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 's', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 's', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'i', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'n', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'g', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ '.', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'p', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'n', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], [ 'g', [ ve.dm.mwExample.MWMediaLinkMissingData ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: '', fromDataBody: '' }, 'numbered external link (empty mw:Extlink)': { body: '', data: [ { type: 'paragraph' }, ...'Foo', { type: 'link/mwNumberedExternal', attributes: { href: 'http://www.example.com' } }, { type: '/link/mwNumberedExternal' }, ...'Bar', { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], clipboardBody: 'Foo[1]Bar
' }, 'numbered external link (non-empty mw:Extlink as cross-document paste)': { body: 'Foo[1]Bar
', data: [ { type: 'paragraph' }, ...'Foo', { type: 'link/mwNumberedExternal', attributes: { href: 'http://www.example.com' } }, { type: '/link/mwNumberedExternal' }, ...'Bar', { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], clipboardBody: 'Foo[1]Bar
', normalizedBody: '' }, 'URL link': { body: '', data: [ { type: 'paragraph' }, [ 'm', [ { type: 'link/mwExternal', attributes: { href: 'https://www.mediawiki.org/', rel: 'mw:ExtLink' } } ] ], [ 'w', [ { type: 'link/mwExternal', attributes: { href: 'https://www.mediawiki.org/', rel: 'mw:ExtLink' } } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], previewBody: '' }, /* FIXME T185902: Temporarily commented out failing test case 'whitespace preservation with wrapped comments and language links': { body: 'Foo\n' + \n '', data: [ { type: 'paragraph', internal: { generated: 'wrapper', metaItems: [ { originalDomElementsHash: 'h188ab6af88887790', type: 'mwLanguage', attributes: { href: 'http://de.wikipedia.org/wiki/Foo' }, internal: { loadMetaParentHash: 'hbc66e1df10d058e6', loadMetaParentOffset: 3 } }, { originalDomElementsHash: 'h188ab6ff88887790', type: 'mwLanguage', attributes: { href: 'http://fr.wikipedia.org/wiki/Foo' }, internal: { loadMetaParentHash: 'h4e7ce2a82b7ce627', loadMetaParentOffset: 6 } } ], whitespace: [ undefined, undefined, undefined, '\n' ] } }, ...'Foo', { type: '/paragraph' }, { type: 'mwLanguage', attributes: { href: 'http://de.wikipedia.org/wiki/Foo' }, internal: { whitespace: [ '\n', undefined, undefined, '\n' ] } }, { type: '/mwLanguage' }, { type: 'mwLanguage', attributes: { href: 'http://fr.wikipedia.org/wiki/Foo' }, internal: { whitespace: [ '\n' ] } }, { type: '/mwLanguage' }, { type: 'internalList' }, { type: '/internalList' } ] }, */ 'document with meta elements': { body: ve.dm.example.singleLine`Foo Bar Baz< /p> `, clipboardBody: ve.dm.example.singleLine`
Foo Bar Ba z
`, previewBody: ve.dm.example.singleLine` ${ ve.dm.example.commentNodePreview( ' No conversion ' ) }Foo Bar Bar Ba${ ve.dm.example.commentNodePreview( ' inline ' ) }z
${ ve.dm.example.commentNodePreview( 'barbaz' ) } Foo foo `, base: ve.dm.mwExample.baseUri, data: ve.dm.mwExample.withMeta, realData: ve.dm.mwExample.withMetaRealData }, 'RDFa types spread across two attributes, about grouping is forced': { body: ve.dm.mwExample.MWTransclusion.mixed, fromDataBody: ve.dm.mwExample.MWTransclusion.mixedFromData, clipboardBody: ve.dm.mwExample.MWTransclusion.mixedClipboard, previewBody: ve.dm.mwExample.MWTransclusion.mixed, data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, ve.dm.mwExample.MWTransclusion.mixedDataOpen, ve.dm.mwExample.MWTransclusion.mixedDataClose, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], storeItems: ve.dm.mwExample.MWTransclusion.mixedStoreItems }, 'mw:Entity': { body: 'a¢b¥™
', data: [ { type: 'paragraph' }, 'a', { type: 'mwEntity', attributes: { character: '¢' } }, { type: '/mwEntity' }, 'b', { type: 'mwEntity', attributes: { character: '¥' } }, { type: '/mwEntity' }, { type: 'mwEntity', attributes: { character: '™' } }, { type: '/mwEntity' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'mw:DisplaySpace': { body: 'a : b
', data: [ { type: 'paragraph' }, 'a', { type: 'mwEntity', attributes: { character: '\u00a0', displaySpace: true } }, { type: '/mwEntity' }, ...': b', { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'wrapping with mw:Entity': { body: 'a¢b¥™', data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, 'a', { type: 'mwEntity', attributes: { character: '¢' } }, { type: '/mwEntity' }, 'b', { type: 'mwEntity', attributes: { character: '¥' } }, { type: '/mwEntity' }, { type: 'mwEntity', attributes: { character: '™' } }, { type: '/mwEntity' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'whitespace preservation with mw:Entity': { body: 'a b ¥\t™
', data: [ { type: 'paragraph', internal: { whitespace: [ undefined, ' ' ] } }, ...'a ', { type: 'mwEntity', attributes: { character: ' ' } }, { type: '/mwEntity' }, ...' b ', { type: 'mwEntity', attributes: { character: '¥' } }, { type: '/mwEntity' }, '\t', { type: 'mwEntity', attributes: { character: '™' } }, { type: '/mwEntity' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'category default sort key': { body: '', data: [ { type: 'mwDefaultSort', attributes: { prefix: 'DEFAULTSORT', sortkey: 'foo' } }, { type: '/mwDefaultSort' }, { type: 'paragraph', internal: { generated: 'empty' } }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'thumb image': { body: ve.dm.mwExample.MWBlockImage.html, data: [ ...ve.dm.mwExample.MWBlockImage.data, { type: 'internalList' }, { type: '/internalList' } ], storeItems: ve.dm.mwExample.MWBlockImage.storeItems }, 'broken block image': { body: ve.dm.example.singleLine` `, data: [ { type: 'mwBlockImage', attributes: { type: 'thumb', align: 'default', href: './Special:FilePath/Missing_image.jpg', imageClassAttr: 'mw-file-element mw-broken-media', imgWrapperClassAttr: null, mediaClass: 'Image', mediaTag: 'span', src: null, defaultSize: true, width: 220, height: null, originalWidth: 220, originalHeight: null, alt: null, isError: true, errorText: 'File:Missing image.jpg', resource: './File:Missing_image.jpg', mw: { errors: [ { key: 'apierror-filedoesnotexist', message: 'This image does not exist.' } ] }, originalClasses: 'mw-default-size', unrecognizedClasses: [] } }, { type: 'mwImageCaption' }, { type: 'paragraph', internal: { generated: 'wrapper' } }, ...'abc', { type: '/paragraph' }, { type: '/mwImageCaption' }, { type: '/mwBlockImage' }, { type: 'internalList' }, { type: '/internalList' } ], previewBody: ve.dm.example.singleLine` ` }, 'broken inline image': { body: ve.dm.example.singleLine` `, data: [ { type: 'paragraph' }, { type: 'mwInlineImage', attributes: { type: 'none', href: './Special:FilePath/Missing_image.jpg', imageClassAttr: 'mw-file-element mw-broken-media', imgWrapperClassAttr: null, mediaClass: 'Image', mediaTag: 'span', src: null, width: 200, height: null, valign: 'default', alt: null, isError: true, errorText: 'File:Missing image.jpg', resource: './File:Missing_image.jpg', mw: { errors: [ { key: 'apierror-filedoesnotexist', message: 'This image does not exist.' } ] }, originalClasses: null, unrecognizedClasses: [] } }, { type: '/mwInlineImage' }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], previewBody: ve.dm.example.singleLine` ` }, 'attribute preservation does not crash due to text node split': { body: ve.dm.example.singleLine` `, fromDataBody: ve.dm.example.singleLine` `, base: ve.dm.mwExample.baseUri, data: [ { type: 'mwBlockImage', attributes: { type: 'thumb', align: 'default', href: './Foo', imageClassAttr: 'mw-file-element', imgWrapperClassAttr: 'mw-file-description', mediaClass: 'Image', mediaTag: 'img', src: ve.ce.minImgDataUri, width: 1, height: 2, alt: null, mw: {}, isError: false, errorText: null, resource: './FooBar' } }, { type: 'mwImageCaption', internal: { whitespace: [ undefined, ' ' ] } }, { type: 'paragraph', internal: { generated: 'wrapper', whitespace: [ ' ' ] } }, ...'foo ', [ 'b', [ { type: 'link/mwInternal', attributes: { title: 'Bar', normalizedTitle: 'Bar', lookupTitle: 'Bar' } } ] ], [ 'a', [ { type: 'link/mwInternal', attributes: { title: 'Bar', normalizedTitle: 'Bar', lookupTitle: 'Bar' } } ] ], [ 'r', [ { type: 'link/mwInternal', attributes: { title: 'Bar', normalizedTitle: 'Bar', lookupTitle: 'Bar' } } ] ], ...' baz', { type: '/paragraph' }, { type: '/mwImageCaption' }, { type: '/mwBlockImage' }, { type: 'internalList' }, { type: '/internalList' } ] }, 'mw:Nowiki': { body: ve.dm.mwExample.mwNowikiHtml, data: ve.dm.mwExample.mwNowiki, fromDataBody: ve.dm.mwExample.mwNowikiHtmlFromData }, 'mw:Nowiki unwraps when text modified': { data: ve.dm.mwExample.mwNowiki, modify: ( model ) => { model.data.modifyData( 7, ( item ) => { item[ 0 ] = 'z'; } ); }, normalizedBody: 'Foo[[Bzr]]Baz
' }, 'mw:Nowiki unwraps when annotations modified': { data: ve.dm.mwExample.mwNowiki, modify: ( model ) => { model.data.modifyData( 7, ( item ) => { item[ 1 ].push( model.getStore().hash( ve.dm.example.createAnnotation( ve.dm.example.bold ) ) ); } ); }, normalizedBody: 'Foo[[Bar]]Baz
' }, 'plain external links when pasted are converted to link/mwExternal': { fromClipboard: true, body: 'ab', data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, [ 'a', [ { type: 'link/mwExternal', attributes: { href: 'https://www.mediawiki.org/' } } ] ], [ 'b', [ { type: 'link/mwExternal', attributes: { href: 'https://www.mediawiki.org/' } } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: 'ab', previewBody: 'ab' }, 'plain internal links when pasted are converted to link/mwInternal': { fromClipboard: true, body: 'ab', base: ve.dm.mwExample.baseUri, data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, [ 'a', [ { type: 'link/mwInternal', attributes: { title: 'Foo/Bar', normalizedTitle: 'Foo/Bar', lookupTitle: 'Foo/Bar' } } ] ], [ 'b', [ { type: 'link/mwInternal', attributes: { title: 'Foo/Bar', normalizedTitle: 'Foo/Bar', lookupTitle: 'Foo/Bar' } } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: 'ab', mwConfig: { wgArticlePath: '/wiki/$1' } }, 'plain href-less anchors when pasted are converted to spans': { fromClipboard: true, body: 'ab', data: [ { type: 'paragraph', internal: { generated: 'wrapper' } }, [ 'a', [ { type: 'textStyle/span', attributes: { nodeName: 'span' } } ] ], [ 'b', [ { type: 'textStyle/span', attributes: { nodeName: 'span' } } ] ], { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } ], normalizedBody: 'ab', fromDataBody: 'ab' } };