/*! * VisualEditor DataModel example data sets. * * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ /** * @class * @singleton * @ignore */ ve.dm.example = {}; /* Methods */ /** * Convert arrays of shorthand annotations in a data fragment to AnnotationSets with real * annotation objects, and wraps the result in a ve.dm.ElementLinearData object. * * Shorthand notation for annotations is: * [ 'a', [ { 'type': 'link', 'attributes': { 'href': '...' } ] ] * * The actual storage format has an instance of ve.dm.LinkAnnotation instead of the plain object, * and an instance of ve.dm.AnnotationSet instead of the array. * * @method * @param {Array} data Linear model data * @param {ve.dm.IndexValueStore} [store] Index-value store to use, creates one if undefined * @returns {ve.dm.ElementLinearData} Element linear data store * @throws {Error} Example data passed to preprocessAnnotations by reference */ ve.dm.example.preprocessAnnotations = function ( data, store ) { var i, key; // Sanity check to make sure ve.dm.example data has not been passed in // by reference. Always use ve.copyArray. for ( i in ve.dm.example ) { if ( data === ve.dm.example[i] ) { throw new Error( 'Example data passed to preprocessAnnotations by reference' ); } } store = store || new ve.dm.IndexValueStore(); for ( i = 0; i < data.length; i++ ) { key = data[i].annotations ? 'annotations' : 1; // check for shorthand annotation objects in array if ( ve.isArray( data[i][key] ) && data[i][key][0].type ) { data[i][key] = ve.dm.example.createAnnotationSet( store, data[i][key] ).getIndexes(); } } return new ve.dm.ElementLinearData( store, data ); }; /** * Create an annotation object from shorthand notation. * @method * @param {Object} annotation Plain object with type and attributes properties * @returns {ve.dm.Annotation} Instance of the right ve.dm.Annotation subclass */ ve.dm.example.createAnnotation = function ( annotation ) { return ve.dm.annotationFactory.create( annotation.type, annotation ); }; /** * Create an AnnotationSet from an array of shorthand annotations. * * This calls ve.dm.example.createAnnotation() for each element and puts the result in an * AnnotationSet. * * @method * @param {Array} annotations Array of annotations in shorthand format * @returns {ve.dm.AnnotationSet} */ ve.dm.example.createAnnotationSet = function ( store, annotations ) { var i; for ( i = 0; i < annotations.length; i++ ) { annotations[i] = ve.dm.example.createAnnotation( annotations[i] ); } return new ve.dm.AnnotationSet( store, store.indexes( annotations ) ); }; /* Some common annotations in shorthand format */ ve.dm.example.bold = { 'type': 'textStyle/bold' }; ve.dm.example.italic = { 'type': 'textStyle/italic' }; ve.dm.example.underline = { 'type': 'textStyle/underline' }; ve.dm.example.span = { 'type': 'textStyle/span' }; /** * Creates a document from example data. * * Defaults to ve.dm.example.data if no name is supplied. * * @param {string} [name='data'] Named element of ve.dm.example * @param {ve.dm.IndexValueStore} [store] A specific index-value store to use, optionally. * @returns {ve.dm.Document} Document * @throws {Error} Example data not found */ ve.dm.example.createExampleDocument = function ( name, store ) { var doc, i; name = name || 'data'; store = store || new ve.dm.IndexValueStore(); if ( ve.dm.example[name] === undefined ) { throw new Error( 'Example data \'' + name + '\' not found' ); } doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( ve.copyArray( ve.dm.example[name] ), store ) ); // HACK internalList isn't populated when creating a document from data if ( ve.dm.example[name].internalItems ) { for ( i = 0; i < ve.dm.example[name].internalItems.length; i++ ) { doc.internalList.queueItemHtml( ve.dm.example[name].internalItems[i].key, ve.dm.example[name].internalItems[i].body ); } } return doc; }; /** * Looks up a value in a node tree. * * @method * @param {ve.Node} root Root node to lookup from * @param {number...} [paths] Index path * @returns {ve.Node} Node at given path */ ve.dm.example.lookupNode = function ( root ) { var i, node = root; for ( i = 1; i < arguments.length; i++ ) { node = node.children[arguments[i]]; } return node; }; ve.dm.example.createDomElement = function ( type, attributes ) { var key, element = document.createElement( type ); for ( key in attributes ) { element.setAttribute( key, attributes[key] ); } return element; }; ve.dm.example.testDir = window.mw ? ( window.mw.config.get( 'wgExtensionAssetsPath' ) + '/VisualEditor/modules/ve/test' ) : '.'; ve.dm.example.imgSrc = ve.dm.example.testDir + '/example.png'; /** * Serialized HTML. * * This is what the parser will emit. * TODO remove some of the
s here to test automatic wrapping */ ve.dm.example.html = '
' +
' d ' + '
| ' +
'
hi'+ '
j
' + 'k
' + 'l
' + 'm
'; /* * Linear data. * * This is what we convert serialized HTML from the parser into so we can work with it more easily. * * There are three types of components in content data: * * {string} Plain text character * * {Array} Annotated character * 0: {string} Character * 1: {Object} List of references to immutable annotation objects, keyed by JSON * serializations of their values (hashes) * * {Object} Opening or closing structural element * type: {string} Symbolic node type name, if closing element first character will be "/" * [attributes]: {Object} List of symbolic attribute name and literal value pairs */ ve.dm.example.data = [ // 0 - Beginning of heading { 'type': 'heading', 'attributes': { 'level': 1 } }, // 1 - Plain "a" 'a', // 2 - Bold "b" ['b', [ ve.dm.example.bold ]], // 3 - Italic "c" ['c', [ ve.dm.example.italic ]], // 4 - End of heading { 'type': '/heading' }, // 5 - Beginning of table { 'type': 'table' }, // 6 - Beginning of body { 'type': 'tableSection', 'attributes': { 'style': 'body' } }, // 7 - Beginning of row { 'type': 'tableRow' }, // 8 - Beginning of cell { 'type': 'tableCell', 'attributes': { 'style': 'data' } }, // 9 - Beginning of paragraph { 'type': 'paragraph' }, // 10 - Plain "d" 'd', // 11 - End of paragraph { 'type': '/paragraph' }, // 12 - Beginning of bullet list { 'type': 'list', 'attributes': { 'style': 'bullet' } }, // 13 - Beginning of list item { 'type': 'listItem' }, // 14 - Beginning of paragraph { 'type': 'paragraph' }, // 15 - Plain "e" 'e', // 16 - End of paragraph { 'type': '/paragraph' }, // 17 - Beginning of nested bullet list { 'type': 'list', 'attributes': { 'style': 'bullet' } }, // 18 - Beginning of nested bullet list item { 'type': 'listItem' }, // 19 - Beginning of paragraph { 'type': 'paragraph' }, // 20 - Plain "f" 'f', // 21 - End of paragraph { 'type': '/paragraph' }, // 22 - End of nested bullet list item { 'type': '/listItem' }, // 23 - End of nested bullet list { 'type': '/list' }, // 24 - End of bullet list item { 'type': '/listItem' }, // 25 - End of bullet list { 'type': '/list' }, // 26 - Beginning of numbered list { 'type': 'list', 'attributes': { 'style': 'number' } }, // 27 - Beginning of numbered list item { 'type': 'listItem' }, // 28 - Beginning of paragraph { 'type': 'paragraph' }, // 29 - Plain "g" 'g', // 30 - End of paragraph { 'type': '/paragraph' }, // 31 - End of item { 'type': '/listItem' }, // 32 - End of lis t { 'type': '/list' }, // 33 - End of cell { 'type': '/tableCell' }, // 34 - End of row { 'type': '/tableRow' }, // 35 - End of body { 'type': '/tableSection' }, // 36 - End of table { 'type': '/table' }, // 37 - Beginning of preformatted { 'type': 'preformatted' }, // 38 - Plain "h" 'h', // 39 - Beginning of inline image { 'type': 'image', 'attributes': { 'src': ve.dm.example.imgSrc, 'width': null, 'height': null }, 'htmlAttributes': [ { 'values': { 'src': ve.dm.example.imgSrc } } ] }, // 40 - End of inline image { 'type': '/image' }, // 41 - Plain "i" 'i', // 42 - End of preformatted { 'type': '/preformatted' }, // 43 - Beginning of definition list { 'type': 'definitionList' }, // 44 - Beginning of definition list term item { 'type': 'definitionListItem', 'attributes': { 'style': 'term' } }, // 45 - Beginning of paragraph { 'type': 'paragraph' }, // 46 - Plain "j" 'j', // 47 - End of paragraph { 'type': '/paragraph' }, // 48 - End of definition list term item { 'type': '/definitionListItem' }, // 49 - Beginning of definition list definition item { 'type': 'definitionListItem', 'attributes': { 'style': 'definition' } }, // 50 - Beginning of paragraph { 'type': 'paragraph' }, // 51 - Plain "k" 'k', // 52 - End of paragraph { 'type': '/paragraph' }, // 53 - End of definition list definition item { 'type': '/definitionListItem' }, // 54 - End of definition list { 'type': '/definitionList' }, // 55 - Beginning of paragraph { 'type': 'paragraph' }, // 56 - Plain "l" 'l', // 57 - End of paragraph { 'type': '/paragraph' }, // 58 - Beginning of paragraph { 'type': 'paragraph' }, // 59 - Plain "m" 'm', // 60 - End of paragraph { 'type': '/paragraph' }, // 61 - Beginning of internalList { 'type': 'internalList' }, // 62 - End of internalList { 'type': '/internalList' } // 63 - End of document ]; ve.dm.example.alienData = [ // 0 - Open alienBlock { 'type': 'alienBlock' }, // 1 - Close alienBlock { 'type': '/alienBlock' }, // 2 - Open paragraph { 'type': 'paragraph' }, // 3 - Plain character 'a' 'a', // 4 - Open alienInline { 'type': 'alienBlock' }, // 5 - Close alienInline { 'type': '/alienBlock' }, // 6 - Plain character 'b' 'b', // 7 - Close paragraph { 'type': '/paragraph' }, // 8 - Open alienBlock { 'type': 'alienBlock' }, // 9 - Close alienBlock { 'type': '/alienBlock' }, // 10 - Beginning of internalList { 'type': 'internalList' }, // 11 - End of internalList { 'type': '/internalList' } // 12 - End of document ]; ve.dm.example.internalData = [ { 'type': 'paragraph' }, 'F', 'o', 'o', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': 'internalItem' }, { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'B', 'a', 'r', { 'type': '/paragraph' }, { 'type': '/internalItem' }, { 'type': 'internalItem' }, { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'B', 'a', 'z', { 'type': '/paragraph' }, { 'type': '/internalItem' }, { 'type': '/internalList' }, { 'type': 'paragraph' }, 'Q', 'u', 'u', 'x', { 'type': '/paragraph' } ]; ve.dm.example.internalData.internalItems = [ { 'key': 'bar', 'body': 'Bar' }, { 'key': 'baz', 'body': 'Baz' } ]; ve.dm.example.withMeta = [ { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/mwAlienMeta' }, { 'type': 'paragraph' }, 'F', 'o', 'o', { 'type': 'mwCategory', 'attributes': { 'hrefPrefix': './', 'category': 'Category:Bar', 'origCategory': 'Category:Bar', 'sortkey': '', 'origSortkey': '' }, 'htmlAttributes': [ { 'values': { 'rel': 'mw:WikiLink/Category', 'href': './Category:Bar' } } ] }, { 'type': '/mwCategory' }, 'B', 'a', 'r', { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/mwAlienMeta' }, 'B', 'a', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, 'z', { 'type': '/paragraph' }, { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/mwAlienMeta' }, { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, { 'type': 'mwCategory', 'attributes': { 'hrefPrefix': './', 'category': 'Category:Foo foo', 'origCategory': 'Category:Foo_foo', 'sortkey': 'Bar baz#quux', 'origSortkey': 'Bar baz%23quux' }, 'htmlAttributes': [ { 'values': { 'rel': 'mw:WikiLink/Category', 'href': './Category:Foo_foo#Bar baz%23quux' } } ] }, { 'type': '/mwCategory' }, { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/mwAlienMeta' }, { 'type': 'internalList' }, { 'type': '/internalList' } ]; ve.dm.example.withMetaPlainData = [ { 'type': 'paragraph' }, 'F', 'o', 'o', 'B', 'a', 'r', 'B', 'a', 'z', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ]; ve.dm.example.withMetaMetaData = [ [ { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } } ], undefined, undefined, undefined, [ { 'type': 'mwCategory', 'attributes': { 'hrefPrefix': './', 'category': 'Category:Bar', 'origCategory': 'Category:Bar', 'sortkey': '', 'origSortkey': '' }, 'htmlAttributes': [ { 'values': { 'rel': 'mw:WikiLink/Category', 'href': './Category:Bar' } } ] } ], undefined, undefined, [ { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } } ], undefined, [ { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } } ], undefined, [ { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': 'mwCategory', 'attributes': { 'hrefPrefix': './', 'category': 'Category:Foo foo', 'origCategory': 'Category:Foo_foo', 'sortkey': 'Bar baz#quux', 'origSortkey': 'Bar baz%23quux' }, 'htmlAttributes': [ { 'values': { 'rel': 'mw:WikiLink/Category', 'href': './Category:Foo_foo#Bar baz%23quux' } } ] }, { 'type': 'mwAlienMeta', 'attributes': { 'domElements': $( '' ).toArray() } } ], undefined, undefined ]; ve.dm.example.complexTableHtml = 'Bar | |
---|---|
Baz | |
Quux | Whee |
abc
', 'data': [ { 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'annotated text with bold, italic, underline formatting': { 'html': 'abc
', 'data': [ { 'type': 'paragraph' }, ['a', [ ve.dm.example.bold ]], ['b', [ ve.dm.example.italic ]], ['c', [ ve.dm.example.underline ]], { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'image': { 'html': '', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, { 'type': 'image', 'attributes' : { 'width': null, 'height': null, 'src': ve.dm.example.imgSrc }, 'htmlAttributes': [ { 'values': { 'src': ve.dm.example.imgSrc } } ] }, { 'type' : '/image' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'paragraph with alienInline inside': { 'html': 'abc
', 'data': [ { 'type': 'paragraph' }, 'a', { 'type': 'alienInline', 'attributes': { 'domElements': $( 'b' ).toArray() } }, { 'type': '/alienInline' }, 'c', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'paragraphs with an alienBlock between them': { 'html': 'abc
def
', 'data': [ { 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }, { 'type': 'alienBlock', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienBlock' }, { 'type': 'paragraph' }, 'd', 'e', 'f', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'annotated inline nodes': { 'html': 'abc' +
'
de
bar
', 'data': [ { 'type': 'paragraph' }, { 'type': 'alienMeta', 'annotations': [ ve.dm.example.bold ], 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, [ 'b', [ ve.dm.example.bold ] ], [ 'a', [ ve.dm.example.bold ] ], [ 'r', [ ve.dm.example.bold ] ], { 'type': 'alienMeta', 'annotations': [ ve.dm.example.bold ], 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'annotated metadata in a wrapper': { 'html': 'barquux', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, { 'type': 'alienMeta', 'annotations': [ ve.dm.example.bold ], 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, [ 'b', [ ve.dm.example.bold ] ], [ 'a', [ ve.dm.example.bold ] ], [ 'r', [ ve.dm.example.bold ] ], { 'type': 'alienMeta', 'annotations': [ ve.dm.example.bold ], 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, [ 'q', [ ve.dm.example.bold ] ], [ 'u', [ ve.dm.example.bold ] ], [ 'u', [ ve.dm.example.bold ] ], [ 'x', [ ve.dm.example.bold ] ], { 'type': 'alienMeta', 'annotations': [ ve.dm.example.bold ], 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'metadata in a wrapper followed by annotated text': { 'html': 'FooBaz', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'F', 'o', 'o', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, [ 'B', [ ve.dm.example.bold ] ], [ 'a', [ ve.dm.example.bold ] ], [ 'z', [ ve.dm.example.bold ] ], { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'wrapping of bare content': { 'html': 'abc', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'a', 'b', 'c', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'wrapping of bare content with inline node': { 'html': '1abc
def', 'data': [ { 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' }, { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'd', 'e', 'f', { 'type': '/paragraph' }, { 'type': 'paragraph' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'wrapping prevents empty list items': { 'html': 'Foo
' }, 'empty list item with content added by the editor': { 'html': null, 'data': [ { 'type': 'list', 'attributes': { 'style': 'bullet' } }, { 'type': 'listItem' }, { 'type': 'paragraph', 'internal': { 'generated': 'empty' } }, 'F', 'o', 'o', { 'type': '/paragraph' }, { 'type': '/listItem' }, { 'type': '/list' }, { 'type': 'internalList' }, { 'type': '/internalList' } ], 'normalizedHtml': 'Foo
FooBar
', 'data': [ { 'type': 'paragraph' }, 'F', 'o', 'o', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, 'B', 'a', 'r', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'empty annotation in wrapper paragraph': { 'html': 'FooBar', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'F', 'o', 'o', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, 'B', 'a', 'r', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'nested empty annotation': { 'html': 'FooBar
', 'data': [ { 'type': 'paragraph' }, 'F', 'o', 'o', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, 'B', 'a', 'r', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'empty annotation inside nonempty annotation': { 'html': 'Foo
', 'data': [ { 'type': 'paragraph' }, [ 'F', [ ve.dm.example.italic ] ], [ 'o', [ ve.dm.example.italic ] ], [ 'o', [ ve.dm.example.italic ] ], { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() }, 'annotations': [ ve.dm.example.italic ] }, { 'type': '/alienMeta' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'empty annotation with comment': { 'html': 'FooBaz
', 'data': [ { 'type': 'paragraph' }, 'F', 'o', 'o', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, 'B', 'a', 'z', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'list item with space followed by link': { 'html': '', 'data': [ { 'type': 'list', 'attributes': { 'style': 'bullet' } }, { 'type': 'listItem' }, { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ' ] } }, [ 'b', [ { 'type': 'link', 'attributes': { 'href': 'Foobar' }, 'htmlAttributes': [ { 'values': { 'href': 'Foobar' } } ] } ] ], [ 'a', [ { 'type': 'link', 'attributes': { 'href': 'Foobar' }, 'htmlAttributes': [ { 'values': { 'href': 'Foobar' } } ] } ] ], [ 'r', [ { 'type': 'link', 'attributes': { 'href': 'Foobar' }, 'htmlAttributes': [ { 'values': { 'href': 'Foobar' } } ] } ] ], { 'type': '/paragraph' }, { 'type': '/listItem' }, { 'type': '/list' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace between unwrapped inline nodes': { 'html': '' + 'c d\ne' + '', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, { 'type': 'alienInline', 'attributes': { 'domElements': $( 'c' ).toArray() } }, { 'type': '/alienInline' }, ' ', { 'type': 'alienInline', 'attributes': { 'domElements': $( 'd' ).toArray() } }, { 'type': '/alienInline' }, '\n', { 'type': 'alienInline', 'attributes': { 'domElements': $( 'e' ).toArray() } }, { 'type': '/alienInline' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation in headings': { 'html': 'Foo
', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', ' ' ] } }, [ ' ', [ ve.dm.example.italic ] ], [ ' ', [ ve.dm.example.italic ] ], [ 'F', [ ve.dm.example.italic ] ], [ 'o', [ ve.dm.example.italic ] ], [ 'o', [ ve.dm.example.italic ] ], [ ' ', [ ve.dm.example.italic ] ], [ ' ', [ ve.dm.example.italic ] ], [ ' ', [ ve.dm.example.italic ] ], { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'outer whitespace preservation in a list with bare text and a wrapper paragraph': { 'html': '\n\t\tP\t\t\t
\t\t\t\tP
A B C\t\t\tD\t\t\t
\nE\n\nF\n\n\n\n\n\n\nG H ', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', '\t\t\t', '\n' ] } }, 'A', ' ', ' ', 'B', ' ', ' ', ' ', [ ' ', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], [ 'C', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], '\t', '\t', 'D', { 'type': '/paragraph' }, { 'type': 'paragraph', 'internal': { 'generated': 'wrapper', 'whitespace': [ '\n', undefined, undefined, ' ' ] } }, 'E', '\n', '\n', 'F', '\n', '\n', '\n', [ '\n', [ ve.dm.example.bold ] ], [ '\n', [ ve.dm.example.bold ] ], [ '\n', [ ve.dm.example.bold ] ], [ '\n', [ ve.dm.example.bold ] ], [ 'G', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], ' ', ' ', 'H', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation with non-edge content whitespace with nested annotations': { 'html': 'A B C\t\t\tD\t\t\t\t\t\t\tE\n\n\nF\n\n\n
', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', '\n\n\n' ] } }, 'A', ' ', ' ', 'B', ' ', ' ', ' ', [ ' ', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], [ ' ', [ ve.dm.example.bold ] ], [ 'C', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ 'D', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], [ 'E', [ ve.dm.example.bold ] ], [ '\n', [ ve.dm.example.bold ] ], '\n', '\n', 'F', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation with tightly nested annotations': { 'html': 'A B \t\tC\t\t\t\n\nD\n\n\n
', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', '\n\n\n' ] } }, 'A', ' ', ' ', 'B', ' ', ' ', ' ', [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ 'C', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], '\n', '\n', 'D', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation with nested annotations with whitespace on the left side': { 'html': 'A B \n\t\t\tC\t\t\t\n\nD\n\n\n
', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', '\n\n\n' ] } }, 'A', ' ', ' ', 'B', ' ', ' ', ' ', [ '\n', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ 'C', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], '\n', '\n', 'D', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation with nested annotations with whitespace on the right side': { 'html': 'A B \t\tC\t\t\t\n\t\n\nD\n\n\n
', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', '\n\n\n' ] } }, 'A', ' ', ' ', 'B', ' ', ' ', ' ', [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ 'C', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\t', [ ve.dm.example.bold, ve.dm.example.italic ] ], [ '\n', [ ve.dm.example.bold ] ], [ '\t', [ ve.dm.example.bold ] ], '\n', '\n', 'D', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation with aliens': { 'html': '\tFoo\t\t\t\t\tBar\t\t\t\t\nBaz\n\n\n\n\nQuux\n\n\n\n \tWhee \n
\t\n \n ', 'data': [ { 'type': 'alienBlock', 'attributes': { 'domElements': $( '' ).toArray() }, 'internal': { 'whitespace': [ ' ', undefined, undefined, ' ' ] } }, { 'type': '/alienBlock' }, { 'type': 'paragraph', 'internal': { 'whitespace': [ ' ', '\t', ' \n', '\t\n' ] } }, 'F', 'o', 'o', '\t', '\t', { 'type': 'alienInline', 'attributes': { 'domElements': $( '\t\t\tBar\t\t\t\t' ).toArray() } }, { 'type': '/alienInline' }, '\n', 'B', 'a', 'z', '\n', '\n', { 'type': 'alienInline', 'attributes': { 'domElements': $( '\n\n\nQuux\n\n\n\n' ).toArray() } }, { 'type': '/alienInline' }, ' ', '\t', 'W', 'h', 'e', 'e', { 'type': '/paragraph' }, { 'type': 'alienBlock', 'attributes': { 'domElements': $( '' ).toArray() }, 'internal': { 'whitespace': [ '\t\n', undefined, undefined, ' \n ' ] } }, { 'type': '/alienBlock' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation not triggered inside': { 'html': '\n\n\n\nFoo\n\n\nBar\n\n\n\n\n\n\n\n\n', 'data': [ { 'type': 'preformatted', 'internal': { 'whitespace': ['\n', undefined, undefined, '\n\n\n\n\n' ] } }, '\n', '\n', 'F', 'o', 'o', '\n', '\n', '\n', 'B', 'a', 'r', '\n', '\n', '\n', '\n', { 'type': '/preformatted' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation in table cell starting with text and ending with annotation': { 'html': '
Foo Bar |
bar
', 'data': [ { 'type': 'paragraph', 'internal': { 'whitespace': [ undefined, ' ', ' ' ] } }, { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, 'b', 'a', 'r', { 'type': 'alienMeta', 'attributes': { 'domElements': $( '' ).toArray() } }, { 'type': '/alienMeta' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation in empty branch node': { 'html': '\tA\n
B
Foo
', 'data': [ { 'type': 'paragraph' }, [ 'F', [ ve.dm.example.bold, ve.dm.example.underline, ve.dm.example.italic ] ], [ 'o', [ ve.dm.example.bold, ve.dm.example.underline, ve.dm.example.italic ] ], [ 'o', [ ve.dm.example.bold, ve.dm.example.underline, ve.dm.example.italic ] ], { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'nested annotations are closed and reopened in the correct order': { 'html': 'Foobarbaz
', 'data': [ { 'type': 'paragraph' }, [ 'F', [ { 'type': 'link', 'attributes': { 'href': 'Foo' }, 'htmlAttributes': [ { 'values': { 'href': 'Foo' } } ] } ] ], [ 'o', [ { 'type': 'link', 'attributes': { 'href': 'Foo' }, 'htmlAttributes': [ { 'values': { 'href': 'Foo' } } ] }, ve.dm.example.bold ] ], [ 'o', [ { 'type': 'link', 'attributes': { 'href': 'Foo' }, 'htmlAttributes': [ { 'values': { 'href': 'Foo' } } ] }, ve.dm.example.bold, ve.dm.example.italic ] ], [ 'b', [ { 'type': 'link', 'attributes': { 'href': 'Foo' }, 'htmlAttributes': [ { 'values': { 'href': 'Foo' } } ] }, ve.dm.example.italic ] ], [ 'a', [ ve.dm.example.italic ] ], [ 'r', [ ve.dm.example.italic, ve.dm.example.bold ] ], [ 'b', [ ve.dm.example.italic ] ], [ 'a', [ ve.dm.example.italic, ve.dm.example.underline ] ], [ 'z', [ ve.dm.example.italic ] ], { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'about grouping': { 'html': '' + '' + '' + 'Quux' + 'Whee
' + 'Yay' + '' + 'Meh', 'data': [ { 'type': 'alienBlock', 'attributes': { 'domElements': $( '' + '' ).toArray() } }, { 'type': '/alienBlock' }, { 'type': 'alienBlock', 'attributes': { 'domElements': $( '' + 'Quux' ).toArray() } }, { 'type': '/alienBlock' }, { 'type': 'paragraph' }, 'W', 'h', 'e', 'e', { 'type': '/paragraph' }, { 'type': 'alienBlock', 'attributes': { 'domElements': $( 'Yay' + '' ).toArray() } }, { 'type': '/alienBlock' }, { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, { 'type': 'alienInline', 'attributes': { 'domElements': $( 'Meh' ).toArray() } }, { 'type': '/alienInline' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace preservation with an about group': { 'html': ' \t\t\t' + ' ', 'data': [ { 'type': 'alienBlock', 'attributes': { 'domElements': $( '\t\t\t' + '' ).toArray() }, 'internal': { 'whitespace': [ ' ', undefined, undefined, ' ' ] } }, { 'type': '/alienBlock' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'block node inside annotation node is alienated': { 'html': '\nBar
', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, [ '\n', [ ve.dm.example.span ] ], { 'type': 'alienInline', 'attributes': { 'domElements': $( 'Bar
' ).toArray() }, 'annotations': [ ve.dm.example.span ] }, { 'type': '/alienInline' }, { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'block node inside annotation node surrounded by tables': { 'html': 'Bar
Bar
' ).toArray() }, 'annotations': [ ve.dm.example.span ] }, { 'type': '/alienInline' }, { 'type': '/paragraph' }, { 'type': 'table' }, { 'type': '/table' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'block node inside annotation node is alienated and continues wrapping': { 'html': 'Foo\nBar
Baz', 'data': [ { 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } }, 'F', 'o', 'o', [ '\n', [ ve.dm.example.span ] ], { 'type': 'alienInline', 'attributes': { 'domElements': $( 'Bar
' ).toArray() }, 'annotations': [ ve.dm.example.span ] }, { 'type': '/alienInline' }, 'B', 'a', 'z', { 'type': '/paragraph' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] }, 'whitespace before meta node in wrapping mode': { 'html': 'Foo\n |
abcde
', 'data': [ { 'type': 'div', 'htmlAttributes': [ { 'values': { 'style': 'direction: rtl;' } } ] }, { 'type': 'paragraph' }, 'a', ['b', [ ve.dm.example.bold ]], 'c', ['d', [ ve.dm.example.italic ]], 'e', { 'type': '/paragraph' }, { 'type': '/div' }, { 'type': 'internalList' }, { 'type': '/internalList' } ] } }; ve.dm.example.isolationHtml = 'Cell 1 | Cell 2 | Cell 3 |
Cell 4 |
Preformatted in list
P1
P2
P3