2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model example data sets.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-04-27 21:59:52 +00:00
|
|
|
/* Static Members */
|
|
|
|
|
|
|
|
ve.dm.example = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Serialized HTML.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* This is what the parser will emit.
|
|
|
|
*/
|
|
|
|
ve.dm.example.html =
|
|
|
|
'<h1>a<b>b</b><i>c</i></h1>' +
|
|
|
|
'<table>' +
|
|
|
|
'<tr>' +
|
|
|
|
'<td>' +
|
|
|
|
'<p>d</p>' +
|
|
|
|
'<ul>' +
|
|
|
|
'<li>' +
|
2012-06-12 01:03:00 +00:00
|
|
|
'e' + // Not wrapped in a <p> due to Parsoid behavior
|
|
|
|
"\n" + // Workaround for Parsoid bug
|
2012-04-27 21:59:52 +00:00
|
|
|
'<ul>' +
|
|
|
|
'<li>' +
|
2012-06-12 01:03:00 +00:00
|
|
|
'f' + // Not wrapped in a <p> due to Parsoid behavior
|
|
|
|
"\n" + // Workaround for Parsoid bug
|
2012-04-27 21:59:52 +00:00
|
|
|
'</li>' +
|
|
|
|
'</ul>' +
|
|
|
|
'</li>' +
|
|
|
|
'</ul>' +
|
|
|
|
'<ol>' +
|
|
|
|
'<li>' +
|
2012-06-12 01:03:00 +00:00
|
|
|
'g' + // Not wrapped in a <p> due to Parsoid behavior
|
|
|
|
"\n" + // Workaround for Parsoid bug
|
2012-04-27 21:59:52 +00:00
|
|
|
'</li>' +
|
|
|
|
'</ol>' +
|
|
|
|
'</td>' +
|
|
|
|
'</tr>' +
|
|
|
|
'</table>' +
|
2012-05-04 18:56:32 +00:00
|
|
|
'<pre>h<img src="image.png">i</pre>'+
|
|
|
|
'<dl>' +
|
|
|
|
'<dt>' +
|
|
|
|
'<p>j</p>' +
|
|
|
|
'</dt>' +
|
|
|
|
'<dd>' +
|
|
|
|
'<p>k</p>' +
|
|
|
|
'</dd>' +
|
2012-05-16 20:33:27 +00:00
|
|
|
'</dl>' +
|
|
|
|
'<p>l</p>' +
|
|
|
|
'<p>m</p>';
|
2012-04-27 21:59:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Linear data.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* This is what we convert serialized HTML from the parser into so we can work with it more easily.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* There are three types of components in content data:
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* {String} Plain text character
|
2012-05-15 00:15:28 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* {Array} Annotated character
|
|
|
|
* 0: {String} Character
|
|
|
|
* 1: {Object} List of references to immutable annotation objects, keyed by JSON
|
|
|
|
* serializations of their values (hashes)
|
2012-05-15 00:15:28 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* {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', { '{"type":"textStyle/bold"}': { 'type': 'textStyle/bold' } }],
|
|
|
|
// 3 - Italic "c"
|
|
|
|
['c', { '{"type":"textStyle/italic"}': { 'type': 'textStyle/italic' } }],
|
|
|
|
// 4 - End of heading
|
|
|
|
{ 'type': '/heading' },
|
|
|
|
// 5 - Beginning of table
|
|
|
|
{ 'type': 'table' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 6 - Beginning of body
|
|
|
|
{ 'type': 'tableSection', 'attributes': { 'style': 'body' } },
|
|
|
|
// 7 - Beginning of row
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'tableRow' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 8 - Beginning of cell
|
2012-06-08 05:02:25 +00:00
|
|
|
{ 'type': 'tableCell', 'attributes': { 'style': 'data' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 9 - Beginning of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 10 - Plain "d"
|
2012-04-27 21:59:52 +00:00
|
|
|
'd',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 11 - End of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 12 - Beginning of bullet list
|
2012-05-03 21:54:27 +00:00
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 13 - Beginning of list item
|
2012-05-04 22:50:32 +00:00
|
|
|
{ 'type': 'listItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 14 - Beginning of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 15 - Plain "e"
|
2012-04-27 21:59:52 +00:00
|
|
|
'e',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 16 - End of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 17 - Beginning of nested bullet list
|
2012-05-03 21:54:27 +00:00
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 18 - Beginning of nested bullet list item
|
2012-05-04 22:50:32 +00:00
|
|
|
{ 'type': 'listItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 19 - Beginning of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 20 - Plain "f"
|
2012-04-27 21:59:52 +00:00
|
|
|
'f',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 21 - End of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 22 - End of nested bullet list item
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/listItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 23 - End of nested bullet list
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/list' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 24 - End of bullet list item
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/listItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 25 - End of bullet list
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/list' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 26 - Beginning of numbered list
|
2012-05-03 21:54:27 +00:00
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'number' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 27 - Beginning of numbered list item
|
2012-05-04 22:50:32 +00:00
|
|
|
{ 'type': 'listItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 28 - Beginning of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 29 - Plain "g"
|
2012-04-27 21:59:52 +00:00
|
|
|
'g',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 30 - End of paragraph
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 31 - End of item
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/listItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 32 - End of list
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/list' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 33 - End of cell
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/tableCell' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 34 - End of row
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/tableRow' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 35 - End of body
|
|
|
|
{ 'type': '/tableSection' },
|
|
|
|
// 36 - End of table
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/table' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 37 - Beginning of preformatted
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'preformatted' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 38 - Plain "h"
|
2012-04-27 21:59:52 +00:00
|
|
|
'h',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 39 - Beginning of inline image
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': 'image', 'attributes': { 'html/src': 'image.png' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 40 - End of inline image
|
2012-04-27 21:59:52 +00:00
|
|
|
{ 'type': '/image' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 41 - Plain "i"
|
2012-04-27 21:59:52 +00:00
|
|
|
'i',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 42 - End of preformatted
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': '/preformatted' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 43 - Beginning of definition list
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': 'definitionList' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 44 - Beginning of definition list term item
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': 'definitionListItem', 'attributes': { 'style': 'term' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 45 - Beginning of paragraph
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 46 - Plain "j"
|
2012-05-04 18:56:32 +00:00
|
|
|
'j',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 47 - End of paragraph
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 48 - End of definition list term item
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': '/definitionListItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 49 - Beginning of definition list definition item
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': 'definitionListItem', 'attributes': { 'style': 'definition' } },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 50 - Beginning of paragraph
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 51 - Plain "k"
|
2012-05-11 17:29:09 +00:00
|
|
|
'k',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 52 - End of paragraph
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 53 - End of definition list definition item
|
2012-05-04 18:56:32 +00:00
|
|
|
{ 'type': '/definitionListItem' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 54 - End of definition list
|
2012-05-16 20:33:27 +00:00
|
|
|
{ 'type': '/definitionList' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 55 - Beginning of paragraph
|
2012-05-16 20:33:27 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 56 - Plain "l"
|
2012-05-16 20:33:27 +00:00
|
|
|
'l',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 57 - End of paragraph
|
2012-05-16 20:33:27 +00:00
|
|
|
{ 'type': '/paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 58 - Beginning of paragraph
|
2012-05-16 20:33:27 +00:00
|
|
|
{ 'type': 'paragraph' },
|
2012-06-08 05:08:49 +00:00
|
|
|
// 59 - Plain "m"
|
2012-05-16 20:33:27 +00:00
|
|
|
'm',
|
2012-06-08 05:08:49 +00:00
|
|
|
// 60 - End of paragraph
|
2012-05-16 20:33:27 +00:00
|
|
|
{ 'type': '/paragraph' }
|
2012-06-08 05:08:49 +00:00
|
|
|
// 61 - End of document
|
2012-06-04 22:59:04 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
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 - End of document
|
2012-04-27 21:59:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sample content data index.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-27 21:59:52 +00:00
|
|
|
* This is part of what a ve.dm.DocumentFragment generates when given linear data.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-04 18:56:32 +00:00
|
|
|
* (21) branch nodes
|
2012-04-30 20:23:46 +00:00
|
|
|
* (01) document node
|
|
|
|
* (01) heading node
|
|
|
|
* (01) table node
|
|
|
|
* (01) tableRow node
|
|
|
|
* (01) tableCell node
|
2012-05-04 18:56:32 +00:00
|
|
|
* (06) paragraph nodes
|
2012-04-30 20:23:46 +00:00
|
|
|
* (03) list nodes
|
|
|
|
* (03) listItem nodes
|
|
|
|
* (01) preformatted node
|
2012-05-04 18:56:32 +00:00
|
|
|
* (01) definitionList node
|
|
|
|
* (02) definitionListItem nodes
|
|
|
|
* (10) leaf nodes
|
|
|
|
* (09) text nodes
|
2012-04-30 20:23:46 +00:00
|
|
|
* (01) image node
|
2012-04-27 21:59:52 +00:00
|
|
|
*/
|
2012-04-30 19:37:08 +00:00
|
|
|
ve.dm.example.tree = new ve.dm.DocumentNode( [
|
2012-04-27 21:59:52 +00:00
|
|
|
// Heading with "abc"
|
|
|
|
new ve.dm.HeadingNode( [new ve.dm.TextNode( 3 )], ve.dm.example.data[0].attributes ),
|
|
|
|
new ve.dm.TableNode( [
|
2012-06-08 05:08:49 +00:00
|
|
|
new ve.dm.TableSectionNode( [
|
|
|
|
new ve.dm.TableRowNode( [
|
|
|
|
new ve.dm.TableCellNode( [
|
|
|
|
// Paragraph with "d"
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] ),
|
|
|
|
new ve.dm.ListNode( [
|
|
|
|
// 1st level bullet list item with "e"
|
|
|
|
new ve.dm.ListItemNode( [
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] ),
|
|
|
|
new ve.dm.ListNode( [
|
|
|
|
// 2nd level bullet list item with "f"
|
|
|
|
new ve.dm.ListItemNode( [
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] )
|
|
|
|
] )
|
|
|
|
], ve.dm.example.data[17].attributes )
|
|
|
|
] )
|
|
|
|
], ve.dm.example.data[12].attributes ),
|
|
|
|
new ve.dm.ListNode( [
|
|
|
|
// Numbered list item with "g"
|
|
|
|
new ve.dm.ListItemNode( [
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] )
|
|
|
|
] )
|
|
|
|
], ve.dm.example.data[26].attributes )
|
|
|
|
], ve.dm.example.data[8].attributes )
|
|
|
|
] )
|
|
|
|
], ve.dm.example.data[6].attributes )
|
2012-04-27 21:59:52 +00:00
|
|
|
] ),
|
|
|
|
// Preformatted with "h[image.png]i"
|
|
|
|
new ve.dm.PreformattedNode( [
|
|
|
|
new ve.dm.TextNode( 1 ),
|
2012-06-08 05:08:49 +00:00
|
|
|
new ve.dm.ImageNode( [], ve.dm.example.data[39].attributes ),
|
2012-04-27 21:59:52 +00:00
|
|
|
new ve.dm.TextNode( 1 )
|
2012-05-04 18:56:32 +00:00
|
|
|
] ),
|
|
|
|
new ve.dm.DefinitionListNode( [
|
|
|
|
// Definition list term item with "j"
|
|
|
|
new ve.dm.DefinitionListItemNode( [
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] )
|
2012-06-08 05:08:49 +00:00
|
|
|
], ve.dm.example.data[44].attributes ),
|
2012-05-04 18:56:32 +00:00
|
|
|
// Definition list definition item with "k"
|
|
|
|
new ve.dm.DefinitionListItemNode( [
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] )
|
2012-06-08 05:08:49 +00:00
|
|
|
], ve.dm.example.data[49].attributes )
|
2012-05-16 20:33:27 +00:00
|
|
|
] ),
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] ),
|
|
|
|
new ve.dm.ParagraphNode( [new ve.dm.TextNode( 1 )] )
|
2012-04-30 19:37:08 +00:00
|
|
|
] );
|
2012-04-27 21:59:52 +00:00
|
|
|
|
2012-06-06 17:17:30 +00:00
|
|
|
ve.dm.example.conversions = {
|
|
|
|
'definitionListItem term': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'dt' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'definitionListItem', 'attributes': { 'style': 'term' } }
|
|
|
|
},
|
|
|
|
'definitionListItem definition': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'dd' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'definitionListItem', 'attributes': { 'style': 'definition' } }
|
|
|
|
},
|
|
|
|
'definitionList definition': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'dl' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'definitionList' }
|
|
|
|
},
|
|
|
|
'heading level 1': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'h1' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'heading', 'attributes': { 'level': 1 } }
|
|
|
|
},
|
|
|
|
'heading level 2': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'h2' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'heading', 'attributes': { 'level': 2 } }
|
|
|
|
},
|
|
|
|
'heading level 3': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'h3' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'heading', 'attributes': { 'level': 3 } }
|
|
|
|
},
|
|
|
|
'heading level 4': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'h4' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'heading', 'attributes': { 'level': 4 } }
|
|
|
|
},
|
|
|
|
'heading level 5': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'h5' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'heading', 'attributes': { 'level': 5 } }
|
|
|
|
},
|
|
|
|
'heading level 6': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'h6' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'heading', 'attributes': { 'level': 6 } }
|
|
|
|
},
|
|
|
|
'image': {
|
2012-06-08 22:16:55 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'img' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'image' }
|
|
|
|
},
|
|
|
|
'listItem': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'li' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'listItem' }
|
|
|
|
},
|
|
|
|
'list bullet': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'ul' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'list', 'attributes': { 'style': 'bullet' } }
|
|
|
|
},
|
|
|
|
'list number': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'ol' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'list', 'attributes': { 'style': 'number' } }
|
|
|
|
},
|
|
|
|
'paragraph': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'p' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'paragraph' }
|
|
|
|
},
|
|
|
|
'preformatted': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'pre' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'preformatted' }
|
|
|
|
},
|
|
|
|
'tableCell': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'td' ),
|
2012-06-08 05:02:25 +00:00
|
|
|
'dataElement': { 'type': 'tableCell', 'attributes': { 'style': 'data' } }
|
2012-06-06 17:17:30 +00:00
|
|
|
},
|
|
|
|
'table': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'table' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'table' }
|
|
|
|
},
|
|
|
|
'tableRow': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'tr' ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'tableRow' }
|
|
|
|
},
|
|
|
|
'paragraph with mw-data attribute': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'p', { 'data-mw': '{"test":1234}' } ),
|
2012-06-07 00:47:27 +00:00
|
|
|
'dataElement': { 'type': 'paragraph', 'attributes': { 'html/data-mw': '{"test":1234}' } }
|
2012-06-06 17:17:30 +00:00
|
|
|
},
|
2012-06-07 00:47:27 +00:00
|
|
|
'paragraph with style attribute': {
|
2012-06-07 22:02:25 +00:00
|
|
|
'domElement': ve.example.createDomElement( 'p', { 'style': 'color:blue' } ),
|
2012-06-06 17:17:30 +00:00
|
|
|
'dataElement': { 'type': 'paragraph', 'attributes': { 'html/style': 'color:blue' } }
|
|
|
|
}
|
|
|
|
};
|
2012-06-08 05:00:25 +00:00
|
|
|
|
|
|
|
ve.dm.example.domToDataCases = {
|
|
|
|
'paragraph with plain text': {
|
|
|
|
'html': '<p>abc</p>',
|
|
|
|
'data': [
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'a',
|
|
|
|
'b',
|
|
|
|
'c',
|
|
|
|
{ 'type': '/paragraph' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'annotated text with bold, italic, underline formatting': {
|
|
|
|
'html': '<p><b>a</b><i>b</i><u>c</u></p>',
|
|
|
|
'data': [
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
['a', { '{"type":"textStyle/bold"}': { 'type': 'textStyle/bold' } }],
|
|
|
|
['b', { '{"type":"textStyle/italic"}': { 'type': 'textStyle/italic' } }],
|
|
|
|
['c', { '{"type":"textStyle/underline"}': { 'type': 'textStyle/underline' } }],
|
|
|
|
{ 'type': '/paragraph' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'image': {
|
|
|
|
'html': '<img src="image.png">',
|
|
|
|
'data': [
|
|
|
|
{ 'type': 'image', 'attributes' : { 'html/src' : 'image.png' } },
|
|
|
|
{ 'type' : '/image' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
'paragraph with alienInline inside': {
|
|
|
|
'html': '<p>a<a href="b.html" data-mw-gc="">b</a>c</p>',
|
|
|
|
'data': [
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'a',
|
|
|
|
{
|
|
|
|
'type': 'alienInline',
|
|
|
|
'attributes': { 'html': '<a href="b.html" data-mw-gc="">b</a>' }
|
|
|
|
},
|
|
|
|
{ 'type': '/alienInline' },
|
|
|
|
'c',
|
|
|
|
{ 'type': '/paragraph' }
|
|
|
|
]
|
|
|
|
},
|
2012-06-19 23:03:41 +00:00
|
|
|
// TODO these last two are broken due to newline hacks, will be unbroken once we remove the newline hacks
|
2012-06-08 05:00:25 +00:00
|
|
|
'paragraphs with an alienBlock between them': {
|
|
|
|
'html': '<p>abc</p><p data-mw-gc="">abc</p><p>def</p>',
|
|
|
|
'data': [
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'a',
|
|
|
|
'b',
|
|
|
|
'c',
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': 'alienBlock', 'attributes': { 'html': '<p data-mw-gc="">abc</p>' } },
|
|
|
|
{ 'type': '/alienBlock' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'd',
|
|
|
|
'e',
|
|
|
|
'f',
|
|
|
|
{ 'type': '/paragraph' }
|
|
|
|
]
|
2012-06-08 22:16:55 +00:00
|
|
|
},
|
|
|
|
'example document': {
|
|
|
|
'html': ve.dm.example.html,
|
|
|
|
'data': ve.dm.example.data
|
|
|
|
},
|
|
|
|
'list item with space followed by link': {
|
2012-06-12 01:03:00 +00:00
|
|
|
// This HTML is weird because of workarounds for Parsoid bugs:
|
|
|
|
// * newline before </li>
|
|
|
|
// * first paragraph in an <li> not wrapped in <p>
|
2012-06-19 23:03:41 +00:00
|
|
|
'html': '<ul><li> <a rel="mw:wikiLink" href="/foo" data-mw="{"sHref":"foo"}">bar</a>\n</li></ul>',
|
2012-06-08 22:16:55 +00:00
|
|
|
'data': [
|
|
|
|
{ 'type': 'list', 'attributes': { 'style': 'bullet' } },
|
|
|
|
{ 'type': 'listItem' },
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
' ',
|
|
|
|
[
|
|
|
|
'b',
|
|
|
|
{
|
2012-06-19 23:03:41 +00:00
|
|
|
'{"type":"link/wikiLink","data":{"title":"foo","mw":"{\\"sHref\\":\\"foo\\"}"}}':
|
|
|
|
{ 'type': 'link/wikiLink', 'data': {
|
2012-06-14 01:54:24 +00:00
|
|
|
'title': 'foo',
|
2012-06-19 23:03:41 +00:00
|
|
|
'mw': '{"sHref":"foo"}'
|
2012-06-14 01:54:24 +00:00
|
|
|
}
|
2012-06-08 22:16:55 +00:00
|
|
|
}
|
|
|
|
}],
|
|
|
|
[
|
|
|
|
'a',
|
|
|
|
{
|
2012-06-19 23:03:41 +00:00
|
|
|
'{"type":"link/wikiLink","data":{"title":"foo","mw":"{\\"sHref\\":\\"foo\\"}"}}':
|
|
|
|
{ 'type': 'link/wikiLink', 'data': {
|
2012-06-14 01:54:24 +00:00
|
|
|
'title': 'foo',
|
2012-06-19 23:03:41 +00:00
|
|
|
'mw': '{"sHref":"foo"}'
|
2012-06-14 01:54:24 +00:00
|
|
|
}
|
2012-06-08 22:16:55 +00:00
|
|
|
}
|
|
|
|
}],
|
|
|
|
[
|
|
|
|
'r',
|
|
|
|
{
|
2012-06-19 23:03:41 +00:00
|
|
|
'{"type":"link/wikiLink","data":{"title":"foo","mw":"{\\"sHref\\":\\"foo\\"}"}}':
|
|
|
|
{ 'type': 'link/wikiLink', 'data': {
|
2012-06-14 01:54:24 +00:00
|
|
|
'title': 'foo',
|
2012-06-19 23:03:41 +00:00
|
|
|
'mw': '{"sHref":"foo"}'
|
2012-06-14 01:54:24 +00:00
|
|
|
}
|
2012-06-08 22:16:55 +00:00
|
|
|
}
|
|
|
|
}],
|
|
|
|
{ 'type': '/paragraph' },
|
|
|
|
{ 'type': '/listItem' },
|
|
|
|
{ 'type': '/list' }
|
|
|
|
]
|
2012-06-08 05:00:25 +00:00
|
|
|
}
|
|
|
|
};
|