Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/tests/dm/ve.dm.mwExample.js

raw symbols SCIP
1 /*!
2 * VisualEditor DataModel MediaWiki-specific example data sets.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * @class
10 * @singleton
11 * @ignore
12 */
13 ve.dm.mwExample = {};
14
15 ve.dm.mwExample.baseUri = 'http://example.com/wiki/';
16
17 ve.dm.mwExample.createExampleDocument = ( name, store, base ) => ve.dm.example.createExampleDocumentFromObject( name, store, ve.dm.mwExample, base || ve.dm.mwExample.baseUri );
18
19 ve.dm.mwExample.createExampleDocumentFromData = ( data, store, base ) => ve.dm.example.createExampleDocumentFromData( data, store, base || ve.dm.mwExample.baseUri );
20
21 ve.dm.mwExample.MWTransclusion = {
22 blockOpen: ve.dm.example.singleLine`
23 <div about="#mwt1" typeof="mw:Transclusion"
24 data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'>
25 </div>
26 `,
27 blockOpenModified: ve.dm.example.singleLine`
28 <div about="#mwt1" typeof="mw:Transclusion"
29 data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, globe!"}},"i":0}}]}'>
30 </div>
31 `,
32 blockOpenFromData: ve.dm.example.singleLine`
33 <span typeof="mw:Transclusion"
34 data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'>
35 </span>
36 `,
37 blockOpenClipboard: ve.dm.example.singleLine`
38 <div about="#mwt1" typeof="mw:Transclusion"
39 data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'
40 data-ve-no-generated-contents="true">
41 &nbsp;
42 </div>
43 `,
44 blockOpenFromDataModified: ve.dm.example.singleLine`
45 <span typeof="mw:Transclusion"
46 data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, globe!"}},"i":0}}]}'>
47 </span>
48 `,
49 blockOpenModifiedClipboard: ve.dm.example.singleLine`
50 <span typeof="mw:Transclusion"
51 data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, globe!"}},"i":0}}]}'
52 data-ve-no-generated-contents="true">
53 &nbsp;
54 </span>
55 `,
56 blockContent: '<p about="#mwt1" data-parsoid="{}">Hello, world!</p>',
57 blockContentClipboard: '<p about="#mwt1" data-parsoid="{}" data-ve-ignore="true">Hello, world!</p>',
58 inlineOpen: ve.dm.example.singleLine`
59 <span about="#mwt1" typeof="mw:Transclusion"
60 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'>
61 `,
62 inlineOpenModified: ve.dm.example.singleLine`
63 <span about="#mwt1" typeof="mw:Transclusion"
64 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'>
65 `,
66 inlineOpenFromData: ve.dm.example.singleLine`
67 <span typeof="mw:Transclusion"
68 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'>
69 `,
70 inlineOpenClipboard: ve.dm.example.singleLine`
71 <span about="#mwt1" typeof="mw:Transclusion"
72 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'
73 data-ve-no-generated-contents="true">
74 `,
75 inlineOpenFromDataModified: ve.dm.example.singleLine`
76 <span typeof="mw:Transclusion"
77 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'>
78 `,
79 inlineOpenModifiedClipboard: ve.dm.example.singleLine`
80 <span typeof="mw:Transclusion"
81 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
82 data-ve-no-generated-contents="true">
83 &nbsp;
84 </span>
85 `,
86 inlineContent: '$1,234.00',
87 inlineClose: '</span>',
88 mixed: ve.dm.example.singleLine`
89 <link about="#mwt1" rel="mw:PageProp/Category" typeof="mw:Transclusion"
90 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'>
91 <span about="#mwt1">Foo</span>
92 `,
93 mixedFromData: ve.dm.example.singleLine`
94 <span typeof="mw:Transclusion"
95 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'>
96 </span>
97 `,
98 mixedClipboard: ve.dm.example.singleLine`
99 <span typeof="mw:Transclusion"
100 data-mw='{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
101 data-ve-no-generated-contents="true">
102 &nbsp;
103 </span>
104 <span about="#mwt1" data-ve-ignore="true">Foo</span>
105 `,
106 pairOne: ve.dm.example.singleLine`
107 <p about="#mwt1" typeof="mw:Transclusion"
108 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' data-parsoid="1">
109 foo
110 </p>
111 `,
112 pairTwo: ve.dm.example.singleLine`
113 <p about="#mwt2" typeof="mw:Transclusion"
114 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' data-parsoid="2">
115 foo
116 </p>
117 `,
118 pairFromData: ve.dm.example.singleLine`
119 <span typeof="mw:Transclusion"
120 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' ></span>
121 `,
122 pairClipboard: ve.dm.example.singleLine`
123 <p about="#mwt1" typeof="mw:Transclusion"
124 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
125 data-parsoid="1"
126 data-ve-no-generated-contents="true">
127 foo
128 </p>
129 `,
130 meta: ve.dm.example.singleLine`
131 <link rel="mw:PageProp/Category" href="./Category:Page" about="#mwt1" typeof="mw:Transclusion"
132 data-mw='{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}'>
133 <span about="#mwt1" data-parsoid="{}">\n</span>
134 <link rel="mw:PageProp/Category" href="./Category:Book" about="#mwt1">
135 `,
136 metaFromData: ve.dm.example.singleLine`
137 <span typeof="mw:Transclusion"
138 data-mw='{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"
139 [[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}'>
140 </span>
141 `,
142 metaClipboard: ve.dm.example.singleLine`
143 <span typeof="mw:Transclusion"
144 data-mw='{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"
145 [[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}'
146 data-ve-no-generated-contents="true">
147 &nbsp;
148 </span>
149 `
150 };
151 ve.dm.mwExample.MWTransclusion.blockData = {
152 type: 'mwTransclusionBlock',
153 attributes: {
154 mw: {
155 parts: [
156 {
157 template: {
158 target: {
159 wt: 'Test',
160 href: './Template:Test'
161 },
162 params: {
163 1: {
164 wt: 'Hello, world!'
165 }
166 },
167 i: 0
168 }
169 }
170 ]
171 },
172 originalMw: '{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"Hello, world!"}},"i":0}}]}'
173 }
174 };
175 ve.dm.mwExample.MWTransclusion.inlineData = {
176 type: 'mwTransclusionInline',
177 attributes: {
178 mw: {
179 parts: [
180 {
181 template: {
182 target: {
183 wt: 'Inline',
184 href: './Template:Inline'
185 },
186 params: {
187 1: {
188 wt: '1,234'
189 }
190 },
191 i: 0
192 }
193 }
194 ]
195 },
196 originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"1,234"}},"i":0}}]}'
197 }
198 };
199 ve.dm.mwExample.MWTransclusion.mixedDataOpen = {
200 type: 'mwTransclusionInline',
201 attributes: {
202 mw: {
203 parts: [
204 {
205 template: {
206 target: {
207 wt: 'Inline',
208 href: './Template:Inline'
209 },
210 params: {
211 1: {
212 wt: '5,678'
213 }
214 },
215 i: 0
216 }
217 }
218 ]
219 },
220 originalMw: '{"parts":[{"template":{"target":{"wt":"Inline","href":"./Template:Inline"},"params":{"1":{"wt":"5,678"}},"i":0}}]}'
221 }
222 };
223 ve.dm.mwExample.MWTransclusion.mixedDataClose = { type: '/mwTransclusionInline' };
224
225 ve.dm.mwExample.MWTransclusion.blockParamsHash = OO.getHash( [ ve.dm.MWTransclusionNode.static.getHashObject( ve.dm.mwExample.MWTransclusion.blockData ), undefined ] );
226 ve.dm.mwExample.MWTransclusion.blockStoreItems = {};
227 ve.dm.mwExample.MWTransclusion.blockStoreItems[ ve.dm.HashValueStore.prototype.hashOfValue( null, ve.dm.mwExample.MWTransclusion.blockParamsHash ) ] =
228 $.parseHTML( ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent );
229
230 ve.dm.mwExample.MWTransclusion.inlineParamsHash = OO.getHash( [ ve.dm.MWTransclusionNode.static.getHashObject( ve.dm.mwExample.MWTransclusion.inlineData ), undefined ] );
231 ve.dm.mwExample.MWTransclusion.inlineStoreItems = {};
232 ve.dm.mwExample.MWTransclusion.inlineStoreItems[ ve.dm.HashValueStore.prototype.hashOfValue( null, ve.dm.mwExample.MWTransclusion.inlineParamsHash ) ] =
233 $.parseHTML( ve.dm.mwExample.MWTransclusion.inlineOpen + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose );
234
235 ve.dm.mwExample.MWTransclusion.mixedParamsHash = OO.getHash( [ ve.dm.MWTransclusionNode.static.getHashObject( ve.dm.mwExample.MWTransclusion.mixedDataOpen ), undefined ] );
236 ve.dm.mwExample.MWTransclusion.mixedStoreItems = {};
237 ve.dm.mwExample.MWTransclusion.mixedStoreItems[ ve.dm.HashValueStore.prototype.hashOfValue( null, ve.dm.mwExample.MWTransclusion.mixedParamsHash ) ] =
238 $.parseHTML( ve.dm.mwExample.MWTransclusion.mixed );
239
240 ve.dm.mwExample.MWInternalLink = {
241 absoluteHref: new URL( './Foo/Bar', ve.dm.mwExample.baseUri ).toString()
242 };
243
244 ve.dm.mwExample.MWInternalLink.absoluteOpen = '<a rel="mw:WikiLink" href="' + ve.dm.mwExample.MWInternalLink.absoluteHref + '">';
245 ve.dm.mwExample.MWInternalLink.absoluteData = {
246 type: 'link/mwInternal',
247 attributes: {
248 title: 'Foo/Bar',
249 normalizedTitle: 'Foo/Bar',
250 lookupTitle: 'Foo/Bar'
251 }
252 };
253
254 ve.dm.mwExample.MWInternalSectionLink = {
255 absoluteHref: new URL( './Foo#Bar', ve.dm.mwExample.baseUri ).toString()
256 };
257
258 ve.dm.mwExample.MWInternalSectionLink.absoluteOpen = '<a rel="mw:WikiLink" href="' + ve.dm.mwExample.MWInternalSectionLink.absoluteHref + '">';
259 ve.dm.mwExample.MWInternalSectionLink.absoluteData = {
260 type: 'link/mwInternal',
261 attributes: {
262 title: 'Foo#Bar',
263 normalizedTitle: 'Foo#Bar',
264 lookupTitle: 'Foo'
265 }
266 };
267
268 ve.dm.mwExample.MWMediaLinkExistsData = {
269 type: 'link/mwInternal',
270 attributes: {
271 lookupTitle: 'Media:Exists.png',
272 normalizedTitle: 'Media:Exists.png',
273 title: 'Media:Exists.png'
274 }
275 };
276
277 ve.dm.mwExample.MWMediaLinkMissingData = {
278 type: 'link/mwInternal',
279 attributes: {
280 lookupTitle: 'Media:Missing.png',
281 normalizedTitle: 'Media:Missing.png',
282 title: 'Media:Missing.png'
283 }
284 };
285
286 ve.dm.mwExample.MWBlockImage = {
287 html: ve.dm.example.singleLine`
288 <figure typeof="mw:Image/Thumb" class="mw-halign-right foobar">
289 <a href="./Foo" class="mw-file-description">
290 <img src="${ ve.ce.minImgDataUri }" class="mw-file-element" width="1" height="2" resource="./FooBar" alt="alt text">
291 </a>
292 <figcaption>abc</figcaption>
293 </figure>
294 `,
295 data: [
296 {
297 type: 'mwBlockImage',
298 attributes: {
299 type: 'thumb',
300 align: 'right',
301 href: './Foo',
302 imageClassAttr: 'mw-file-element',
303 imgWrapperClassAttr: 'mw-file-description',
304 mediaClass: 'Image',
305 mediaTag: 'img',
306 src: ve.ce.minImgDataUri,
307 width: 1,
308 height: 2,
309 alt: 'alt text',
310 isError: false,
311 errorText: null,
312 resource: './FooBar',
313 mw: {},
314 originalClasses: 'mw-halign-right foobar',
315 unrecognizedClasses: [ 'foobar' ]
316 }
317 },
318 { type: 'mwImageCaption' },
319 { type: 'paragraph', internal: { generated: 'wrapper' } },
320 ...'abc',
321 { type: '/paragraph' },
322 { type: '/mwImageCaption' },
323 { type: '/mwBlockImage' }
324 ],
325 storeItems: {
326 h1d9b405cfd633576: ve.ce.minImgDataUri
327 }
328 };
329
330 ve.dm.mwExample.MWInlineImage = {
331 html: ve.dm.example.singleLine`
332 <span typeof="mw:Image" class="foo mw-valign-text-top">
333 <a href="./File:Wiki.png" class="mw-file-description">
334 <img resource="./File:Wiki.png" src="http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class="mw-file-element" height="155" width="135" alt="alt text">
335 </a>
336 </span>
337 `,
338 data: {
339 type: 'mwInlineImage',
340 attributes: {
341 src: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
342 href: './File:Wiki.png',
343 imageClassAttr: 'mw-file-element',
344 imgWrapperClassAttr: 'mw-file-description',
345 mediaClass: 'Image',
346 mediaTag: 'img',
347 width: 135,
348 height: 155,
349 alt: 'alt text',
350 isError: false,
351 errorText: null,
352 valign: 'text-top',
353 resource: './File:Wiki.png',
354 mw: {},
355 type: 'none',
356 originalClasses: 'foo mw-valign-text-top',
357 unrecognizedClasses: [ 'foo' ]
358 }
359 },
360 storeItems: {
361 hbb0aeb2b8e907b74: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png'
362 }
363 };
364
365 ve.dm.mwExample.MWInlineImageWithoutWrapperClass = {
366 html: ve.dm.example.singleLine`
367 <span typeof="mw:Image" class="foo mw-valign-text-top">
368 <a href="./File:Wiki.png">
369 <img resource="./File:Wiki.png" src="http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class="mw-file-element" height="155" width="135" alt="alt text">
370 </a>
371 </span>
372 `,
373 data: {
374 type: 'mwInlineImage',
375 attributes: {
376 src: 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
377 href: './File:Wiki.png',
378 imageClassAttr: 'mw-file-element',
379 imgWrapperClassAttr: null,
380 mediaClass: 'Image',
381 mediaTag: 'img',
382 width: 135,
383 height: 155,
384 alt: 'alt text',
385 isError: false,
386 errorText: null,
387 valign: 'text-top',
388 resource: './File:Wiki.png',
389 mw: {},
390 type: 'none',
391 originalClasses: 'foo mw-valign-text-top',
392 unrecognizedClasses: [ 'foo' ]
393 }
394 }
395 };
396
397 ve.dm.mwExample.mwNowikiAnnotation = {
398 type: 'mwNowiki'
399 };
400
401 ve.dm.mwExample.mwNowiki = [
402 { type: 'paragraph' },
403 ...'Foo',
404 [ '[', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
405 [ '[', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
406 [ 'B', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
407 [ 'a', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
408 [ 'r', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
409 [ ']', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
410 [ ']', [ ve.dm.mwExample.mwNowikiAnnotation ] ],
411 ...'Baz',
412 { type: '/paragraph' },
413 { type: 'internalList' },
414 { type: '/internalList' }
415 ];
416
417 ve.dm.mwExample.mwNowikiHtml = '<body><p>Foo<span typeof="mw:Nowiki">[[Bar]]</span>Baz</p></body>';
418
419 ve.dm.mwExample.mwNowikiHtmlFromData = '<body><p>Foo[[Bar]]Baz</p></body>';
420
421 ve.dm.mwExample.withMeta = [
422 {
423 type: 'paragraph',
424 internal: {
425 generated: 'wrapper'
426 }
427 },
428 {
429 type: 'comment',
430 attributes: {
431 text: ' No conversion '
432 }
433 },
434 { type: '/comment' },
435 { type: '/paragraph' },
436 {
437 type: 'mwAlienMeta',
438 originalDomElements: $.parseHTML( '<meta property="mw:ThisIsAnAlien" />' )
439 },
440 { type: '/mwAlienMeta' },
441 { type: 'paragraph' },
442 ...'Foo',
443 {
444 type: 'mwCategory',
445 attributes: {
446 category: 'Category:Bar',
447 sortkey: ''
448 }
449 },
450 { type: '/mwCategory' },
451 ...'Bar',
452 {
453 type: 'mwAlienMeta',
454 originalDomElements: $.parseHTML( '<meta property="mw:foo" content="bar" />' )
455 },
456 { type: '/mwAlienMeta' },
457 ...'Ba',
458 {
459 type: 'comment',
460 attributes: {
461 text: ' inline '
462 }
463 },
464 { type: '/comment' },
465 'z',
466 { type: '/paragraph' },
467 {
468 type: 'mwAlienMeta',
469 originalDomElements: $.parseHTML( '<meta property="mw:bar" content="baz" />' )
470 },
471 { type: '/mwAlienMeta' },
472 {
473 type: 'paragraph',
474 internal: {
475 generated: 'wrapper'
476 }
477 },
478 {
479 type: 'comment',
480 attributes: {
481 text: 'barbaz'
482 }
483 },
484 { type: '/comment' },
485 { type: '/paragraph' },
486 {
487 type: 'mwCategory',
488 attributes: {
489 category: 'Category:Foo foo',
490 sortkey: 'Bar baz#quux'
491 }
492 },
493 { type: '/mwCategory' },
494 {
495 type: 'mwAlienMeta',
496 originalDomElements: $.parseHTML( '<meta typeof="mw:Placeholder" data-parsoid="foobar" />' )
497 },
498 { type: '/mwAlienMeta' },
499 { type: 'internalList' },
500 { type: '/internalList' }
501 ];
502
503 ve.dm.mwExample.withMetaRealData = [
504 {
505 type: 'paragraph',
506 internal: {
507 generated: 'wrapper'
508 }
509 },
510 {
511 type: 'comment',
512 attributes: {
513 text: ' No conversion '
514 }
515 },
516 { type: '/comment' },
517 { type: '/paragraph' },
518 {
519 type: 'mwAlienMeta',
520 originalDomElements: $.parseHTML( '<meta property="mw:ThisIsAnAlien" />' )
521 },
522 { type: '/mwAlienMeta' },
523 { type: 'paragraph' },
524 ...'FooBarBa',
525 {
526 type: 'comment',
527 attributes: {
528 text: ' inline '
529 }
530 },
531 { type: '/comment' },
532 'z',
533 { type: '/paragraph' },
534 {
535 type: 'mwCategory',
536 attributes: {
537 category: 'Category:Bar',
538 sortkey: ''
539 }
540 },
541 { type: '/mwCategory' },
542 {
543 type: 'mwAlienMeta',
544 originalDomElements: $.parseHTML( '<meta property="mw:foo" content="bar" />' )
545 },
546 { type: '/mwAlienMeta' },
547 {
548 type: 'mwAlienMeta',
549 originalDomElements: $.parseHTML( '<meta property="mw:bar" content="baz" />' )
550 },
551 { type: '/mwAlienMeta' },
552 {
553 type: 'paragraph',
554 internal: {
555 generated: 'wrapper'
556 }
557 },
558 {
559 type: 'comment',
560 attributes: {
561 text: 'barbaz'
562 }
563 },
564 { type: '/comment' },
565 { type: '/paragraph' },
566 {
567 type: 'mwCategory',
568 attributes: {
569 category: 'Category:Foo foo',
570 sortkey: 'Bar baz#quux'
571 }
572 },
573 { type: '/mwCategory' },
574 {
575 type: 'mwAlienMeta',
576 originalDomElements: $.parseHTML( '<meta typeof="mw:Placeholder" data-parsoid="foobar" />' )
577 },
578 { type: '/mwAlienMeta' },
579 { type: 'internalList' },
580 { type: '/internalList' }
581 ];
582
583 ve.dm.mwExample.withMetaMetaData = [
584 [
585 {
586 type: 'alienMeta',
587 originalDomElements: $.parseHTML( '<!-- No conversion -->' )
588 },
589 {
590 type: 'mwAlienMeta',
591 originalDomElements: $.parseHTML( '<meta property="mw:ThisIsAnAlien" />' )
592 }
593 ],
594 undefined,
595 undefined,
596 undefined,
597 [
598 {
599 type: 'mwCategory',
600 attributes: {
601 category: 'Category:Bar',
602 sortkey: ''
603 }
604 }
605 ],
606 undefined,
607 undefined,
608 [
609 {
610 type: 'mwAlienMeta',
611 originalDomElements: $.parseHTML( '<meta property="mw:foo" content="bar" />' )
612 }
613 ],
614 undefined,
615 [
616 {
617 type: 'alienMeta',
618 originalDomElements: $.parseHTML( '<!-- inline -->' )
619 }
620 ],
621 undefined,
622 [
623 {
624 type: 'mwAlienMeta',
625 originalDomElements: $.parseHTML( '<meta property="mw:bar" content="baz" />' )
626 },
627 {
628 type: 'comment',
629 attributes: {
630 text: 'barbaz'
631 }
632 },
633 {
634 type: 'mwCategory',
635 attributes: {
636 category: 'Category:Foo foo',
637 sortkey: 'Bar baz#quux'
638 }
639 },
640 {
641 type: 'mwAlienMeta',
642 originalDomElements: $.parseHTML( '<meta typeof="mw:Placeholder" data-parsoid="foobar" />' )
643 }
644 ],
645 undefined,
646 undefined
647 ];
648
649 ve.dm.mwExample.domToDataCases = {
650 'adjacent annotations (data-parsoid)': {
651 preserveAnnotationDomElements: true,
652 body: ve.dm.example.singleLine`
653 <b>a</b>
654 <b data-parsoid="1">b</b>
655 <b data-parsoid="2">c</b>
656 <b>d</b>
657 <b>d</b>
658 `,
659 data: [
660 { type: 'paragraph', internal: { generated: 'wrapper' } },
661 [
662 'a',
663 [ {
664 type: 'textStyle/bold',
665 attributes: { nodeName: 'b' },
666 originalDomElements: $.parseHTML( '<b>a</b>' )
667 } ]
668 ],
669 [
670 'b',
671 [ {
672 type: 'textStyle/bold',
673 attributes: { nodeName: 'b' },
674 originalDomElements: $.parseHTML( '<b data-parsoid="1">b</b>' )
675 } ]
676 ],
677 [
678 'c',
679 [ {
680 type: 'textStyle/bold',
681 attributes: { nodeName: 'b' },
682 originalDomElements: $.parseHTML( '<b data-parsoid="2">c</b>' )
683 } ]
684 ],
685 ' ',
686 [
687 'd',
688 [ {
689 type: 'textStyle/bold',
690 attributes: { nodeName: 'b' },
691 originalDomElements: $.parseHTML( '<b>a</b>' )
692 } ]
693 ],
694 [
695 'd',
696 [ {
697 type: 'textStyle/bold',
698 attributes: { nodeName: 'b' },
699 originalDomElements: $.parseHTML( '<b>a</b>' )
700 } ]
701 ],
702 { type: '/paragraph' },
703 { type: 'internalList' },
704 { type: '/internalList' }
705 ],
706 modify: ( model ) => {
707 const data = [ 'x', [ ve.dm.example.bold ] ],
708 linearData = ve.dm.example.preprocessAnnotations( [ data ], model.getStore() );
709 model.data.data.splice( 3, 0, linearData.data[ 0 ] );
710 },
711 normalizedBody: ve.dm.example.singleLine`
712 <b>a</b>
713 <b data-parsoid="1">bx</b>
714 <b data-parsoid="2">c</b>
715 <b>dd</b>
716 `,
717 fromDataBody: ve.dm.example.singleLine`
718 <b>a</b>
719 <b data-parsoid="1">bx</b>
720 <b data-parsoid="2">c</b>
721 <b>dd</b
722 `
723 },
724 'adjacent annotations (RESTBase IDs)': {
725 preserveAnnotationDomElements: true,
726 body: ve.dm.example.singleLine`
727 <b>a</b>
728 <b id="mwAB">b</b>
729 <b id="mwCD">c</b>
730 <b>d</b>
731 <b>d</b>
732 `,
733 data: [
734 { type: 'paragraph', internal: { generated: 'wrapper' } },
735 [
736 'a',
737 [ {
738 type: 'textStyle/bold',
739 attributes: { nodeName: 'b' },
740 originalDomElements: $.parseHTML( '<b>a</b>' )
741 } ]
742 ],
743 [
744 'b',
745 [ {
746 type: 'textStyle/bold',
747 attributes: { nodeName: 'b' },
748 originalDomElements: $.parseHTML( '<b id="mwAB">b</b>' )
749 } ]
750 ],
751 [
752 'c',
753 [ {
754 type: 'textStyle/bold',
755 attributes: { nodeName: 'b' },
756 originalDomElements: $.parseHTML( '<b id="mwCD">c</b>' )
757 } ]
758 ],
759 ' ',
760 [
761 'd',
762 [ {
763 type: 'textStyle/bold',
764 attributes: { nodeName: 'b' },
765 originalDomElements: $.parseHTML( '<b>a</b>' )
766 } ]
767 ],
768 [
769 'd',
770 [ {
771 type: 'textStyle/bold',
772 attributes: { nodeName: 'b' },
773 originalDomElements: $.parseHTML( '<b>a</b>' )
774 } ]
775 ],
776 { type: '/paragraph' },
777 { type: 'internalList' },
778 { type: '/internalList' }
779 ],
780 modify: ( model ) => {
781 const data = [ 'x', [ ve.dm.example.bold ] ],
782 linearData = ve.dm.example.preprocessAnnotations( [ data ], model.getStore() );
783 model.data.data.splice( 3, 0, linearData.data[ 0 ] );
784 },
785 normalizedBody: ve.dm.example.singleLine`
786 <b>a</b>
787 <b id="mwAB">bx</b>
788 <b id="mwCD">c</b>
789 <b>dd</b>
790 `,
791 fromDataBody: ve.dm.example.singleLine`
792 <b>a</b>
793 <b id="mwAB">bx</b>
794 <b id="mwCD">c</b>
795 <b>dd</b>
796 `
797 },
798 mwImage: {
799 body: `<p>${ ve.dm.mwExample.MWInlineImage.html }</p>`,
800 data: [
801 { type: 'paragraph' },
802 ve.dm.mwExample.MWInlineImage.data,
803 { type: '/mwInlineImage' },
804 { type: '/paragraph' },
805 { type: 'internalList' },
806 { type: '/internalList' }
807 ],
808 ceHtml: ve.dm.example.singleLine`
809 ${ ve.dm.example.ceParagraph }
810 ${ ve.dm.example.inlineSlug }
811 <a class="mw-file-description ve-ce-leafNode ve-ce-focusableNode ve-ce-mwInlineImageNode" contenteditable="false" href="${ new URL( './File:Wiki.png', ve.dm.mwExample.baseUri ) }">
812 <img src="http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class="mw-file-element" width="135" height="155" style="vertical-align: text-top;">
813 </a>
814 ${ ve.dm.example.inlineSlug }
815 </p>
816 `,
817 storeItems: ve.dm.mwExample.MWInlineImage.storeItems
818 },
819 mwImageWithoutWrapperClass: {
820 body: '<p>' + ve.dm.mwExample.MWInlineImageWithoutWrapperClass.html + '</p>',
821 data: [
822 { type: 'paragraph' },
823 ve.dm.mwExample.MWInlineImageWithoutWrapperClass.data,
824 { type: '/mwInlineImage' },
825 { type: '/paragraph' },
826 { type: 'internalList' },
827 { type: '/internalList' }
828 ],
829 ceHtml: ve.dm.example.singleLine`
830 ${ ve.dm.example.ceParagraph }
831 ${ ve.dm.example.inlineSlug }
832 <a class="mw-file-description ve-ce-leafNode ve-ce-focusableNode ve-ce-mwInlineImageNode" contenteditable="false" href="${ new URL( './File:Wiki.png', ve.dm.mwExample.baseUri ) }">
833 <img src="http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" class="mw-file-element" width="135" height="155" style="vertical-align: text-top;">
834 </a>
835 ${ ve.dm.example.inlineSlug }
836 </p>
837 `,
838 storeItems: ve.dm.mwExample.MWInlineImage.storeItems
839 },
840 'mwHeading and mwPreformatted nodes': {
841 body: '<h2>Foo</h2><pre>Bar</pre>',
842 data: [
843 {
844 type: 'mwHeading',
845 attributes: {
846 level: 2
847 }
848 },
849 ...'Foo',
850 { type: '/mwHeading' },
851 { type: 'mwPreformatted' },
852 ...'Bar',
853 { type: '/mwPreformatted' },
854 { type: 'internalList' },
855 { type: '/internalList' }
856 ]
857 },
858 'mwTable with duplicate class attributes': {
859 body: '<table class="wikitable sortable wikitable"><tr><td>Foo</td></tr></table>',
860 data: [
861 {
862 type: 'mwTable',
863 attributes: {
864 hasExpandedAttrs: false,
865 wikitable: true,
866 sortable: true,
867 originalClasses: 'wikitable sortable wikitable',
868 unrecognizedClasses: []
869 }
870 },
871 { type: 'tableSection', attributes: { style: 'body' } },
872 { type: 'tableRow' },
873 { type: 'tableCell', attributes: { style: 'data' } },
874 { type: 'paragraph', internal: { generated: 'wrapper' } },
875 ...'Foo',
876 { type: '/paragraph' },
877 { type: '/tableCell' },
878 { type: '/tableRow' },
879 { type: '/tableSection' },
880 { type: '/mwTable' },
881 { type: 'internalList' },
882 { type: '/internalList' }
883 ],
884 modify: ( model ) => {
885 model.data.modifyData( 0, ( item ) => {
886 item.attributes.wikitable = false;
887 item.attributes.sortable = false;
888 } );
889 },
890 normalizedBody: '<table><tr><td>Foo</td></tr></table>'
891 },
892 'mwGalleryImage (broken image)': {
893 body: ve.dm.example.singleLine`
894 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
895 <li class="gallerybox" style="width: 155px;">
896 <div class="thumb" style="width: 150px; height: 150px;">
897 <span typeof="mw:Error mw:File" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'>
898 <a href="./Special:FilePath/!Example.jpg">
899 <span class="mw-file-element mw-broken-media" resource="./File:!Example.jpg" data-width="120" data-height="120">File:!Example.jpg</span>
900 </a>
901 </span>
902 </div>
903 <div class="gallerytext">
904 </div>
905 </li>
906 </ul>
907 `,
908 data: [
909 {
910 type: 'mwGallery',
911 attributes: {
912 mw: {
913 attrs: {},
914 body: {},
915 name: 'gallery'
916 },
917 originalMw: '{"name":"gallery","attrs":{},"body":{}}'
918 }
919 },
920 {
921 type: 'mwGalleryImage',
922 attributes: {
923 mediaClass: 'File',
924 mediaTag: 'span',
925 altText: null,
926 altTextSame: false,
927 width: 120,
928 height: 120,
929 resource: './File:!Example.jpg',
930 href: './Special:FilePath/!Example.jpg',
931 imageClassAttr: 'mw-file-element mw-broken-media',
932 imgWrapperClassAttr: null,
933 src: null,
934 isError: true,
935 errorText: 'File:!Example.jpg',
936 mw: {
937 errors: [
938 {
939 key: 'apierror-filedoesnotexist',
940 message: 'This image does not exist.'
941 }
942 ]
943 }
944 }
945 },
946 { type: 'mwGalleryImageCaption' },
947 {
948 type: 'paragraph',
949 internal: {
950 generated: 'wrapper'
951 }
952 },
953 { type: '/paragraph' },
954 { type: '/mwGalleryImageCaption' },
955 { type: '/mwGalleryImage' },
956 { type: '/mwGallery' },
957 { type: 'internalList' },
958 { type: '/internalList' }
959 ],
960 fromDataBody: ve.dm.example.singleLine`
961 <ul typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
962 <li class="gallerybox">
963 <div class="thumb">
964 <span typeof="mw:Error mw:File" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'>
965 <a href="./Special:FilePath/!Example.jpg">
966 <span class="mw-file-element mw-broken-media" resource="./File:!Example.jpg" data-width="120" data-height="120">File:!Example.jpg</span>
967 </a>
968 </span>
969 </div>
970 <div class="gallerytext"></div>
971 </li>
972 </ul>
973 `
974 },
975 'mwGalleryImage (empty caption in DOM)': {
976 body: ve.dm.example.singleLine`
977 <ul class="gallery mw-gallery-packed" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'>
978 <li class="gallerybox" style="width: 182px;">
979 <div class="thumb" style="width: 180px;">
980 <span typeof="mw:File">
981 <a href="./File:Example.jpg" class="mw-file-description">
982 <img resource="./File:Example.jpg" src="${ ve.ce.minImgDataUri }" class="mw-file-element" decoding="async" data-file-width="400"
983 data-file-height="267" data-file-type="bitmap" height="120" width="180" srcset="${ ve.ce.minImgDataUri } 2x"/>
984 </a>
985 </span>
986 </div>
987 <div class="gallerytext"></div>
988 </li>
989 </ul>
990 `,
991 data: [
992 {
993 type: 'mwGallery',
994 attributes: {
995 mw: {
996 attrs: {
997 mode: 'packed'
998 },
999 body: {},
1000 name: 'gallery'
1001 },
1002 originalMw: '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'
1003 }
1004 },
1005 {
1006 type: 'mwGalleryImage',
1007 attributes: {
1008 mediaClass: 'File',
1009 mediaTag: 'img',
1010 altText: null,
1011 altTextSame: false,
1012 width: 180,
1013 height: 120,
1014 resource: './File:Example.jpg',
1015 href: './File:Example.jpg',
1016 imageClassAttr: 'mw-file-element',
1017 imgWrapperClassAttr: 'mw-file-description',
1018 src: ve.ce.minImgDataUri,
1019 isError: false,
1020 errorText: null,
1021 mw: {}
1022 }
1023 },
1024 { type: 'mwGalleryImageCaption' },
1025 {
1026 type: 'paragraph',
1027 internal: {
1028 generated: 'wrapper'
1029 }
1030 },
1031 { type: '/paragraph' },
1032 { type: '/mwGalleryImageCaption' },
1033 { type: '/mwGalleryImage' },
1034 { type: '/mwGallery' },
1035 { type: 'internalList' },
1036 { type: '/internalList' }
1037 ],
1038 fromDataBody: ve.dm.example.singleLine`
1039 <ul typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'>
1040 <li class="gallerybox">
1041 <div class="thumb">
1042 <span typeof="mw:File">
1043 <a href="./File:Example.jpg" class="mw-file-description">
1044 <img resource="./File:Example.jpg" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="120" width="180"/>
1045 </a>
1046 </span>
1047 </div>
1048 <div class="gallerytext"></div>
1049 </li>
1050 </ul>
1051 `
1052 },
1053 'mwGalleryImage (caption with content)': {
1054 body: ve.dm.example.singleLine`
1055 <ul class="gallery mw-gallery-packed" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'>
1056 <li class="gallerybox" style="width: 182px;">
1057 <div class="thumb" style="width: 180px;">
1058 <span typeof="mw:File">
1059 <a href="./File:Example.jpg" class="mw-file-description">
1060 <img resource="./File:Example.jpg" src="${ ve.ce.minImgDataUri }" class="mw-file-element" data-file-width="400" data-file-height="267" data-file-type="bitmap" height="120" width="180"/>
1061 </a>
1062 </span>
1063 </div>
1064 <div class="gallerytext">Caption</div>
1065 </li>
1066 </ul>
1067 `,
1068 data: [
1069 {
1070 type: 'mwGallery',
1071 attributes: {
1072 mw: {
1073 attrs: {
1074 mode: 'packed'
1075 },
1076 body: {},
1077 name: 'gallery'
1078 },
1079 originalMw: '{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'
1080 }
1081 },
1082 {
1083 type: 'mwGalleryImage',
1084 attributes: {
1085 mediaClass: 'File',
1086 mediaTag: 'img',
1087 altText: null,
1088 altTextSame: false,
1089 width: 180,
1090 height: 120,
1091 resource: './File:Example.jpg',
1092 href: './File:Example.jpg',
1093 imageClassAttr: 'mw-file-element',
1094 imgWrapperClassAttr: 'mw-file-description',
1095 src: ve.ce.minImgDataUri,
1096 isError: false,
1097 errorText: null,
1098 mw: {}
1099 }
1100 },
1101 { type: 'mwGalleryImageCaption' },
1102 {
1103 type: 'paragraph',
1104 internal: {
1105 generated: 'wrapper'
1106 }
1107 },
1108 ...'Caption',
1109 { type: '/paragraph' },
1110 { type: '/mwGalleryImageCaption' },
1111 { type: '/mwGalleryImage' },
1112 { type: '/mwGallery' },
1113 { type: 'internalList' },
1114 { type: '/internalList' }
1115 ],
1116 fromDataBody: ve.dm.example.singleLine`
1117 <ul typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"packed"},"body":{}}'>
1118 <li class="gallerybox">
1119 <div class="thumb">
1120 <span typeof="mw:File">
1121 <a href="./File:Example.jpg" class="mw-file-description">
1122 <img resource="./File:Example.jpg" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="120" width="180"/>
1123 </a>
1124 </span>
1125 </div>
1126 <div class="gallerytext">Caption</div>
1127 </li>
1128 </ul>
1129 `
1130 },
1131 'mwGalleryImage (no caption in model)': {
1132 data: [
1133 {
1134 type: 'mwGallery',
1135 attributes: {
1136 mw: {
1137 attrs: {
1138 mode: 'packed'
1139 },
1140 body: {},
1141 name: 'gallery'
1142 },
1143 originalMw: '{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}'
1144 }
1145 },
1146 {
1147 type: 'mwGalleryImage',
1148 attributes: {
1149 mediaClass: 'Image',
1150 mediaTag: 'img',
1151 altText: null,
1152 altTextSame: false,
1153 width: 120,
1154 height: 120,
1155 resource: './Foo',
1156 href: './Foo',
1157 imageClassAttr: 'mw-file-element',
1158 imgWrapperClassAttr: 'mw-file-description',
1159 src: ve.ce.minImgDataUri,
1160 isError: false,
1161 errorText: null
1162 }
1163 },
1164 { type: '/mwGalleryImage' },
1165 { type: '/mwGallery' },
1166 { type: 'internalList' },
1167 { type: '/internalList' }
1168 ],
1169 fromDataBody: ve.dm.example.singleLine`
1170 <ul typeof="mw:Extension/gallery" data-mw='{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}'>
1171 <li class="gallerybox">
1172 <div class="thumb">
1173 <span typeof="mw:Image">
1174 <a href="./Foo" class="mw-file-description">
1175 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="120" width="120"/>
1176 </a>
1177 </span>
1178 </div>
1179 </li>
1180 </ul>
1181 `
1182 },
1183 'mwGalleryImage (empty caption in model)': {
1184 data: [
1185 {
1186 type: 'mwGallery',
1187 attributes: {
1188 mw: {
1189 attrs: {
1190 mode: 'packed'
1191 },
1192 body: {},
1193 name: 'gallery'
1194 },
1195 originalMw: '{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}'
1196 }
1197 },
1198 {
1199 type: 'mwGalleryImage',
1200 attributes: {
1201 mediaClass: 'Image',
1202 mediaTag: 'img',
1203 altText: null,
1204 altTextSame: false,
1205 width: 120,
1206 height: 120,
1207 resource: './Foo',
1208 href: './Foo',
1209 imageClassAttr: 'mw-file-element',
1210 imgWrapperClassAttr: 'mw-file-description',
1211 src: ve.ce.minImgDataUri,
1212 isError: false,
1213 errorText: null
1214 }
1215 },
1216 { type: 'mwGalleryImageCaption' },
1217 { type: '/mwGalleryImageCaption' },
1218 { type: '/mwGalleryImage' },
1219 { type: '/mwGallery' },
1220 { type: 'internalList' },
1221 { type: '/internalList' }
1222 ],
1223 fromDataBody: ve.dm.example.singleLine`
1224 <ul typeof="mw:Extension/gallery" data-mw='{"attrs":{"mode":"packed"},"body":{},"name":"gallery"}'>
1225 <li class="gallerybox">
1226 <div class="thumb">
1227 <span typeof="mw:Image">
1228 <a href="./Foo" class="mw-file-description">
1229 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="120" width="120"/>
1230 </a>
1231 </span>
1232 </div>
1233 <div class="gallerytext"></div>
1234 </li>
1235 </ul>
1236 `
1237 },
1238 'mwBlockImage (no caption in DOM)': {
1239 body: ve.dm.example.singleLine`
1240 <figure typeof="mw:Image/Thumb">
1241 <a href="./Foo" class="mw-file-description">
1242 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="300" width="300"/>
1243 </a>
1244 </figure>
1245 `,
1246 data: [
1247 {
1248 type: 'mwBlockImage',
1249 attributes: {
1250 align: 'default',
1251 alt: null,
1252 height: 300,
1253 href: './Foo',
1254 imageClassAttr: 'mw-file-element',
1255 imgWrapperClassAttr: 'mw-file-description',
1256 isError: false,
1257 errorText: null,
1258 mediaClass: 'Image',
1259 mediaTag: 'img',
1260 mw: {},
1261 resource: './Foo',
1262 src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
1263 type: 'thumb',
1264 width: 300
1265 }
1266 },
1267 { type: 'mwImageCaption' },
1268 {
1269 type: 'paragraph',
1270 internal: {
1271 generated: 'wrapper'
1272 }
1273 },
1274 { type: '/paragraph' },
1275 { type: '/mwImageCaption' },
1276 { type: '/mwBlockImage' },
1277 { type: 'internalList' },
1278 { type: '/internalList' }
1279 ],
1280 normalizedBody: ve.dm.example.singleLine`
1281 <figure typeof="mw:Image/Thumb">
1282 <a href="./Foo" class="mw-file-description">
1283 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="300" width="300"/>
1284 </a>
1285 <figcaption></figcaption>
1286 </figure>
1287 `
1288 },
1289 'mwBlockImage (empty caption in DOM)': {
1290 body: ve.dm.example.singleLine`
1291 <figure typeof="mw:Image/Thumb">
1292 <a href="./Foo" class="mw-file-description">
1293 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="300" width="300"/>
1294 </a>
1295 <figcaption></figcaption>
1296 </figure>
1297 `,
1298 data: [
1299 {
1300 type: 'mwBlockImage',
1301 attributes: {
1302 align: 'default',
1303 alt: null,
1304 height: 300,
1305 href: './Foo',
1306 imageClassAttr: 'mw-file-element',
1307 imgWrapperClassAttr: 'mw-file-description',
1308 isError: false,
1309 errorText: null,
1310 mediaClass: 'Image',
1311 mediaTag: 'img',
1312 mw: {},
1313 resource: './Foo',
1314 src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
1315 type: 'thumb',
1316 width: 300
1317 }
1318 },
1319 { type: 'mwImageCaption' },
1320 {
1321 type: 'paragraph',
1322 internal: {
1323 generated: 'wrapper'
1324 }
1325 },
1326 { type: '/paragraph' },
1327 { type: '/mwImageCaption' },
1328 { type: '/mwBlockImage' },
1329 { type: 'internalList' },
1330 { type: '/internalList' }
1331 ]
1332 },
1333 'mwBlockImage (caption with content in DOM)': {
1334 body: ve.dm.example.singleLine`
1335 <figure typeof="mw:Image/Thumb">
1336 <a href="./Foo" class="mw-file-description">
1337 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="300" width="300"/>
1338 </a>
1339 <figcaption>Caption</figcaption>
1340 </figure>
1341 `,
1342 data: [
1343 {
1344 type: 'mwBlockImage',
1345 attributes: {
1346 align: 'default',
1347 alt: null,
1348 height: 300,
1349 href: './Foo',
1350 imageClassAttr: 'mw-file-element',
1351 imgWrapperClassAttr: 'mw-file-description',
1352 isError: false,
1353 errorText: null,
1354 mediaClass: 'Image',
1355 mediaTag: 'img',
1356 mw: {},
1357 resource: './Foo',
1358 src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
1359 type: 'thumb',
1360 width: 300
1361 }
1362 },
1363 { type: 'mwImageCaption' },
1364 {
1365 type: 'paragraph',
1366 internal: {
1367 generated: 'wrapper'
1368 }
1369 },
1370 ...'Caption',
1371 { type: '/paragraph' },
1372 { type: '/mwImageCaption' },
1373 { type: '/mwBlockImage' },
1374 { type: 'internalList' },
1375 { type: '/internalList' }
1376 ]
1377 },
1378 'mwBlockImage (no caption in model)': {
1379 data: [
1380 {
1381 type: 'mwBlockImage',
1382 attributes: {
1383 align: 'default',
1384 alt: null,
1385 height: 300,
1386 href: './Foo',
1387 imageClassAttr: 'mw-file-element',
1388 imgWrapperClassAttr: 'mw-file-description',
1389 isError: false,
1390 errorText: null,
1391 mediaClass: 'Image',
1392 mediaTag: 'img',
1393 mw: {},
1394 resource: './Foo',
1395 src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
1396 type: 'thumb',
1397 width: 300
1398 }
1399 },
1400 { type: '/mwBlockImage' },
1401 { type: 'internalList' },
1402 { type: '/internalList' }
1403 ],
1404 fromDataBody: ve.dm.example.singleLine`
1405 <figure typeof="mw:Image/Thumb">
1406 <a href="./Foo" class="mw-file-description">
1407 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="300" width="300"/>
1408 </a>
1409 </figure>
1410 `
1411 },
1412 'mwBlockImage (empty caption in model)': {
1413 data: [
1414 {
1415 type: 'mwBlockImage',
1416 attributes: {
1417 align: 'default',
1418 alt: null,
1419 height: 300,
1420 href: './Foo',
1421 imageClassAttr: 'mw-file-element',
1422 imgWrapperClassAttr: 'mw-file-description',
1423 isError: false,
1424 errorText: null,
1425 mediaClass: 'Image',
1426 mediaTag: 'img',
1427 mw: {},
1428 resource: './Foo',
1429 src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
1430 type: 'thumb',
1431 width: 300
1432 }
1433 },
1434 { type: 'mwImageCaption' },
1435 { type: '/mwImageCaption' },
1436 { type: '/mwBlockImage' },
1437 { type: 'internalList' },
1438 { type: '/internalList' }
1439 ],
1440 fromDataBody: ve.dm.example.singleLine`
1441 <figure typeof="mw:Image/Thumb">
1442 <a href="./Foo" class="mw-file-description">
1443 <img resource="./Foo" src="${ ve.ce.minImgDataUri }" class="mw-file-element" height="300" width="300"/>
1444 </a>
1445 </figure>
1446 `
1447 },
1448 'mw:Transclusion (block level)': {
1449 body: ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent,
1450 data: [
1451 ve.dm.mwExample.MWTransclusion.blockData,
1452 { type: '/mwTransclusionBlock' },
1453 { type: 'internalList' },
1454 { type: '/internalList' }
1455 ],
1456 storeItems: ve.dm.mwExample.MWTransclusion.blockStoreItems,
1457 normalizedBody: ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent,
1458 fromDataBody: ve.dm.mwExample.MWTransclusion.blockOpenFromData,
1459 clipboardBody: ve.dm.mwExample.MWTransclusion.blockOpenClipboard + ve.dm.mwExample.MWTransclusion.blockContentClipboard,
1460 previewBody: ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent
1461 },
1462 'mw:Transclusion (block level - modified)': {
1463 body: ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent,
1464 data: [
1465 ve.dm.mwExample.MWTransclusion.blockData,
1466 { type: '/mwTransclusionBlock' },
1467 { type: 'internalList' },
1468 { type: '/internalList' }
1469 ],
1470 storeItems: ve.dm.mwExample.MWTransclusion.blockStoreItems,
1471 modify: ( model ) => {
1472 model.data.modifyData( 0, ( item ) => {
1473 item.attributes.mw.parts[ 0 ].template.params[ '1' ].wt = 'Hello, globe!';
1474 } );
1475 },
1476 normalizedBody: ve.dm.mwExample.MWTransclusion.blockOpenModified.replace( /about="#mwt1"/, '' ),
1477 fromDataBody: ve.dm.mwExample.MWTransclusion.blockOpenFromDataModified,
1478 clipboardBody: ve.dm.mwExample.MWTransclusion.blockOpenModifiedClipboard,
1479 previewBody: false
1480 },
1481 'mw:Transclusion (inline)': {
1482 body: ve.dm.mwExample.MWTransclusion.inlineOpen + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose,
1483 data: [
1484 { type: 'paragraph', internal: { generated: 'wrapper' } },
1485 ve.dm.mwExample.MWTransclusion.inlineData,
1486 { type: '/mwTransclusionInline' },
1487 { type: '/paragraph' },
1488 { type: 'internalList' },
1489 { type: '/internalList' }
1490 ],
1491 storeItems: ve.dm.mwExample.MWTransclusion.inlineStoreItems,
1492 normalizedBody: ve.dm.mwExample.MWTransclusion.inlineOpen + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose,
1493 fromDataBody: ve.dm.mwExample.MWTransclusion.inlineOpenFromData + ve.dm.mwExample.MWTransclusion.inlineClose,
1494 clipboardBody: ve.dm.mwExample.MWTransclusion.inlineOpenClipboard + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose,
1495 previewBody: ve.dm.mwExample.MWTransclusion.inlineOpen + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose
1496 },
1497 'mw:Transclusion (inline - modified)': {
1498 body: ve.dm.mwExample.MWTransclusion.inlineOpen + ve.dm.mwExample.MWTransclusion.inlineContent + ve.dm.mwExample.MWTransclusion.inlineClose,
1499 data: [
1500 { type: 'paragraph', internal: { generated: 'wrapper' } },
1501 ve.dm.mwExample.MWTransclusion.inlineData,
1502 { type: '/mwTransclusionInline' },
1503 { type: '/paragraph' },
1504 { type: 'internalList' },
1505 { type: '/internalList' }
1506 ],
1507 storeItems: ve.dm.mwExample.MWTransclusion.inlineStoreItems,
1508 modify: ( model ) => {
1509 model.data.modifyData( 1, ( item ) => {
1510 item.attributes.mw.parts[ 0 ].template.params[ '1' ].wt = '5,678';
1511 } );
1512 },
1513 normalizedBody: ve.dm.mwExample.MWTransclusion.inlineOpenModified.replace( /about="#mwt1"/, '' ) + ve.dm.mwExample.MWTransclusion.inlineClose,
1514 fromDataBody: ve.dm.mwExample.MWTransclusion.inlineOpenFromDataModified + ve.dm.mwExample.MWTransclusion.inlineClose,
1515 clipboardBody: ve.dm.mwExample.MWTransclusion.inlineOpenModifiedClipboard + ve.dm.mwExample.MWTransclusion.inlineClose,
1516 previewBody: false
1517 },
1518 'two mw:Transclusion nodes with identical params but different htmlAttributes': {
1519 body: ve.dm.mwExample.MWTransclusion.pairOne + ve.dm.mwExample.MWTransclusion.pairTwo,
1520 fromDataBody: ve.dm.mwExample.MWTransclusion.pairFromData + ve.dm.mwExample.MWTransclusion.pairFromData,
1521 clipboardBody: ve.dm.mwExample.MWTransclusion.pairClipboard + ve.dm.mwExample.MWTransclusion.pairClipboard,
1522 previewBody: ve.dm.mwExample.MWTransclusion.pairOne + ve.dm.mwExample.MWTransclusion.pairOne,
1523 data: [
1524 {
1525 type: 'mwTransclusionBlock',
1526 attributes: {
1527 mw: {
1528 parts: [
1529 {
1530 template: {
1531 target: {
1532 wt: 'echo',
1533 href: './Template:Echo'
1534 },
1535 params: {
1536 1: {
1537 wt: 'foo'
1538 }
1539 },
1540 i: 0
1541 }
1542 }
1543 ]
1544 },
1545 originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
1546 }
1547 },
1548 { type: '/mwTransclusionBlock' },
1549 {
1550 type: 'mwTransclusionBlock',
1551 attributes: {
1552 mw: {
1553 parts: [
1554 {
1555 template: {
1556 target: {
1557 wt: 'echo',
1558 href: './Template:Echo'
1559 },
1560 params: {
1561 1: {
1562 wt: 'foo'
1563 }
1564 },
1565 i: 0
1566 }
1567 }
1568 ]
1569 },
1570 originalMw: '{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'
1571 }
1572 },
1573 { type: '/mwTransclusionBlock' },
1574 { type: 'internalList' },
1575 { type: '/internalList' }
1576 ],
1577 storeItems: {
1578 hd2ff771ac84b229d: $.parseHTML( ve.dm.example.singleLine`
1579 <p about="#mwt1" typeof="mw:Transclusion"
1580 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}' data-parsoid="1">
1581 foo
1582 </p>
1583 ` )
1584 }
1585 },
1586 'mw:Transclusion containing only meta data': {
1587 body: ve.dm.mwExample.MWTransclusion.meta,
1588 fromDataBody: ve.dm.mwExample.MWTransclusion.metaFromData,
1589 clipboardBody: ve.dm.mwExample.MWTransclusion.metaClipboard,
1590 previewBody: false,
1591 data: [
1592 {
1593 internal: { generated: 'wrapper' },
1594 type: 'paragraph'
1595 },
1596 {
1597 type: 'mwTransclusionInline',
1598 attributes: {
1599 mw: {
1600 parts: [ {
1601 template: {
1602 target: {
1603 wt: 'Template:Echo',
1604 href: './Template:Echo'
1605 },
1606 params: {
1607 1: { wt: '[[Category:Page]]\n[[Category:Book]]' }
1608 },
1609 i: 0
1610 }
1611 } ]
1612 },
1613 originalMw: '{"parts":[{"template":{"target":{"wt":"Template:Echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Page]]\\n[[Category:Book]]"}},"i":0}}]}'
1614 }
1615 },
1616 { type: '/mwTransclusionInline' },
1617 { type: '/paragraph' },
1618 { type: 'internalList' },
1619 { type: '/internalList' }
1620 ]
1621 },
1622 'mw:Transclusion which is also a language annotation': {
1623 body: '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}">content</span>',
1624 data: [
1625 { type: 'paragraph', internal: { generated: 'wrapper' } },
1626 {
1627 type: 'mwTransclusionInline',
1628 attributes: {
1629 mw: {},
1630 originalMw: '{}'
1631 },
1632 originalDomElements: $.parseHTML( '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}">content</span>' )
1633 },
1634 { type: '/mwTransclusionInline' },
1635 { type: '/paragraph' },
1636 { type: 'internalList' },
1637 { type: '/internalList' }
1638 ],
1639 clipboardBody: '<span dir="ltr" about="#mwt1" typeof="mw:Transclusion" data-mw="{}" data-ve-no-generated-contents="true">content</span>',
1640 previewBody: false
1641 },
1642 'mw:AlienBlockExtension': {
1643 body: ve.dm.example.singleLine`
1644 <div about="#mwt1" typeof="mw:Extension/syntaxhighlight"
1645 data-mw='{"name":"syntaxhighlight","attrs":{"lang":"php"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
1646 data-parsoid="1">
1647 <div><span>Rendering</span></div>
1648 </div>
1649 `,
1650 normalizedBody: ve.dm.example.singleLine`
1651 <div typeof="mw:Extension/syntaxhighlight"
1652 data-mw='{"name":"syntaxhighlight","attrs":{"lang":"php5"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
1653 about="#mwt1" data-parsoid="1">
1654 </div>
1655 `,
1656 data: [
1657 {
1658 type: 'mwAlienBlockExtension',
1659 attributes: {
1660 mw: {
1661 name: 'syntaxhighlight',
1662 attrs: {
1663 lang: 'php'
1664 },
1665 body: {
1666 extsrc: '\n$foo = bar;\n'
1667 }
1668 },
1669 originalMw: '{"name":"syntaxhighlight","attrs":{"lang":"php"},"body":{"extsrc":"\\n$foo = bar;\\n"}}'
1670 },
1671 originalDomElements: $.parseHTML( '<div about="#mwt1" data-parsoid="1"></div>' )
1672 },
1673 { type: '/mwAlienBlockExtension' },
1674 { type: 'internalList' },
1675 { type: '/internalList' }
1676 ],
1677 modify: ( model ) => {
1678 model.data.modifyData( 0, ( item ) => {
1679 item.attributes.mw.attrs.lang = 'php5';
1680 } );
1681 }
1682 },
1683 'mw:AlienInlineExtension': {
1684 body: ve.dm.example.singleLine`
1685 <p>
1686 <img src="${ ve.ce.minImgDataUri }" width="100" height="20" alt="Bar" typeof="mw:Extension/score"
1687 data-mw='{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c&#39; { e d c d e e e }"}}'
1688 data-parsoid="1" about="#mwt1" />
1689 </p>
1690 `,
1691 normalizedBody: ve.dm.example.singleLine`
1692 <p>
1693 <span typeof="mw:Extension/score"
1694 data-mw='{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c&#39; { d d d e e e }"}}'
1695 src="${ ve.ce.minImgDataUri }" width="100" height="20" alt="Bar" data-parsoid="1" about="#mwt1" />
1696 </p>
1697 `,
1698 data: [
1699 { type: 'paragraph' },
1700 {
1701 type: 'mwAlienInlineExtension',
1702 attributes: {
1703 mw: {
1704 name: 'score',
1705 attrs: {},
1706 body: {
1707 extsrc: '\\relative c\' { e d c d e e e }'
1708 }
1709 },
1710 originalMw: '{"name":"score","attrs":{},"body":{"extsrc":"\\\\relative c\' { e d c d e e e }"}}'
1711 },
1712 originalDomElements: $.parseHTML( `<img src="${ ve.ce.minImgDataUri }" width="100" height="20" alt="Bar" about="#mwt1" data-parsoid="1"></img>` )
1713 },
1714 { type: '/mwAlienInlineExtension' },
1715 { type: '/paragraph' },
1716 { type: 'internalList' },
1717 { type: '/internalList' }
1718 ],
1719 modify: ( model ) => {
1720 model.data.modifyData( 1, ( item ) => {
1721 item.attributes.mw.body.extsrc = '\\relative c\' { d d d e e e }';
1722 } );
1723 }
1724 },
1725 'internal link with absolute path': {
1726 body: '<p>' + ve.dm.mwExample.MWInternalLink.absoluteOpen + 'Foo</a></p>',
1727 base: ve.dm.mwExample.baseUri,
1728 data: [
1729 { type: 'paragraph' },
1730 [
1731 'F',
1732 [ ve.dm.mwExample.MWInternalLink.absoluteData ]
1733 ],
1734 [
1735 'o',
1736 [ ve.dm.mwExample.MWInternalLink.absoluteData ]
1737 ],
1738 [
1739 'o',
1740 [ ve.dm.mwExample.MWInternalLink.absoluteData ]
1741 ],
1742 { type: '/paragraph' },
1743 { type: 'internalList' },
1744 { type: '/internalList' }
1745 ],
1746 normalizedBody: '<p><a rel="mw:WikiLink" href="./Foo/Bar">Foo</a></p>',
1747 mwConfig: {
1748 wgArticlePath: '/wiki/$1'
1749 }
1750 },
1751 'internal link with absolute path and section': {
1752 body: '<p>' + ve.dm.mwExample.MWInternalSectionLink.absoluteOpen + 'Foo</a></p>',
1753 base: ve.dm.mwExample.baseUri,
1754 data: [
1755 { type: 'paragraph' },
1756 [
1757 'F',
1758 [ ve.dm.mwExample.MWInternalSectionLink.absoluteData ]
1759 ],
1760 [
1761 'o',
1762 [ ve.dm.mwExample.MWInternalSectionLink.absoluteData ]
1763 ],
1764 [
1765 'o',
1766 [ ve.dm.mwExample.MWInternalSectionLink.absoluteData ]
1767 ],
1768 { type: '/paragraph' },
1769 { type: 'internalList' },
1770 { type: '/internalList' }
1771 ],
1772 normalizedBody: '<p><a rel="mw:WikiLink" href="./Foo#Bar">Foo</a></p>',
1773 mwConfig: {
1774 wgArticlePath: '/wiki/$1'
1775 }
1776 },
1777 'internal link with href set to ./': {
1778 body: '<p><a rel="mw:WikiLink" href="./">x</a></p>',
1779 base: ve.dm.mwExample.baseUri,
1780 data: [
1781 { type: 'paragraph' },
1782 [
1783 'x',
1784 [ {
1785 type: 'link/mwInternal',
1786 attributes: {
1787 title: '',
1788 normalizedTitle: '',
1789 lookupTitle: ''
1790 }
1791 } ]
1792 ],
1793 { type: '/paragraph' },
1794 { type: 'internalList' },
1795 { type: '/internalList' }
1796 ]
1797 },
1798 'internal link with special characters': {
1799 body: '<p><a rel="mw:WikiLink" href="./Foo%3F+%25&Bar">x</a></p>',
1800 ignoreXmlWarnings: true,
1801 base: ve.dm.mwExample.baseUri,
1802 data: [
1803 { type: 'paragraph' },
1804 [
1805 'x',
1806 [ {
1807 type: 'link/mwInternal',
1808 attributes: {
1809 title: 'Foo?+%&Bar',
1810 normalizedTitle: 'Foo?+%&Bar',
1811 lookupTitle: 'Foo?+%&Bar'
1812 }
1813 } ]
1814 ],
1815 { type: '/paragraph' },
1816 { type: 'internalList' },
1817 { type: '/internalList' }
1818 ]
1819 },
1820 'mw:MediaLink (exists)': {
1821 body: '<p><a rel="mw:MediaLink" href="//localhost/w/images/x/xx/Exists.png" resource="./Media:Exists.png" title="Exists.png">Media:Exists.png</a></p>',
1822 data: [
1823 { type: 'paragraph' },
1824 [ 'M', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1825 [ 'e', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1826 [ 'd', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1827 [ 'i', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1828 [ 'a', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1829 [ ':', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1830 [ 'E', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1831 [ 'x', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1832 [ 'i', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1833 [ 's', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1834 [ 't', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1835 [ 's', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1836 [ '.', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1837 [ 'p', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1838 [ 'n', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1839 [ 'g', [ ve.dm.mwExample.MWMediaLinkExistsData ] ],
1840 { type: '/paragraph' },
1841 { type: 'internalList' },
1842 { type: '/internalList' }
1843 ],
1844 normalizedBody: '<p><a href="./Media:Exists.png" rel="mw:WikiLink" resource="./Media:Exists.png" title="Exists.png">Media:Exists.png</a></p>',
1845 fromDataBody: '<p><a href="./Media:Exists.png" rel="mw:WikiLink">Media:Exists.png</a></p>'
1846 },
1847 'mw:MediaLink (missing)': {
1848 body: '<p><a rel="mw:MediaLink" href="./Special:FilePath/Missing.png" resource="./Media:Missing.png" title="Missing.png" typeof="mw:Error" data-mw=\'{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}\'>Media:Missing.png</a></p>',
1849 data: [
1850 { type: 'paragraph' },
1851 [ 'M', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1852 [ 'e', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1853 [ 'd', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1854 [ 'i', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1855 [ 'a', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1856 [ ':', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1857 [ 'M', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1858 [ 'i', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1859 [ 's', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1860 [ 's', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1861 [ 'i', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1862 [ 'n', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1863 [ 'g', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1864 [ '.', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1865 [ 'p', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1866 [ 'n', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1867 [ 'g', [ ve.dm.mwExample.MWMediaLinkMissingData ] ],
1868 { type: '/paragraph' },
1869 { type: 'internalList' },
1870 { type: '/internalList' }
1871 ],
1872 normalizedBody: '<p><a href="./Media:Missing.png" rel="mw:WikiLink" resource="./Media:Missing.png" title="Missing.png" typeof="mw:Error" data-mw=\'{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}\'>Media:Missing.png</a></p>',
1873 fromDataBody: '<p><a href="./Media:Missing.png" rel="mw:WikiLink">Media:Missing.png</a></p>'
1874 },
1875 'numbered external link (empty mw:Extlink)': {
1876 body: '<p>Foo<a rel="mw:ExtLink" href="http://www.example.com"></a>Bar</p>',
1877 data: [
1878 { type: 'paragraph' },
1879 ...'Foo',
1880 {
1881 type: 'link/mwNumberedExternal',
1882 attributes: {
1883 href: 'http://www.example.com'
1884 }
1885 },
1886 { type: '/link/mwNumberedExternal' },
1887 ...'Bar',
1888 { type: '/paragraph' },
1889 { type: 'internalList' },
1890 { type: '/internalList' }
1891 ],
1892 clipboardBody: '<p>Foo<a rel="ve:NumberedLink" href="http://www.example.com">[1]</a>Bar</p>'
1893 },
1894 'numbered external link (non-empty mw:Extlink as cross-document paste)': {
1895 body: '<p>Foo<a rel="ve:NumberedLink" href="http://www.example.com">[1]</a>Bar</p>',
1896 data: [
1897 { type: 'paragraph' },
1898 ...'Foo',
1899 {
1900 type: 'link/mwNumberedExternal',
1901 attributes: {
1902 href: 'http://www.example.com'
1903 }
1904 },
1905 { type: '/link/mwNumberedExternal' },
1906 ...'Bar',
1907 { type: '/paragraph' },
1908 { type: 'internalList' },
1909 { type: '/internalList' }
1910 ],
1911 clipboardBody: '<p>Foo<a rel="ve:NumberedLink" href="http://www.example.com">[1]</a>Bar</p>',
1912 normalizedBody: '<p>Foo<a rel="mw:ExtLink" href="http://www.example.com"></a>Bar</p>'
1913 },
1914 'URL link': {
1915 body: '<p><a rel="mw:ExtLink" href="https://www.mediawiki.org/">mw</a></p>',
1916 data: [
1917 { type: 'paragraph' },
1918 [
1919 'm',
1920 [ {
1921 type: 'link/mwExternal',
1922 attributes: {
1923 href: 'https://www.mediawiki.org/',
1924 rel: 'mw:ExtLink'
1925 }
1926 } ]
1927 ],
1928 [
1929 'w',
1930 [ {
1931 type: 'link/mwExternal',
1932 attributes: {
1933 href: 'https://www.mediawiki.org/',
1934 rel: 'mw:ExtLink'
1935 }
1936 } ]
1937 ],
1938 { type: '/paragraph' },
1939 { type: 'internalList' },
1940 { type: '/internalList' }
1941 ],
1942 previewBody: '<p><a rel="mw:ExtLink" class="external" href="https://www.mediawiki.org/">mw</a></p>'
1943 }, /* FIXME T185902: Temporarily commented out failing test case
1944 'whitespace preservation with wrapped comments and language links': {
1945 body: 'Foo\n' +
1946 <link rel="mw:PageProp/Language" href="http://de.wikipedia.org/wiki/Foo">\n
1947 '<link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Foo">',
1948 data: [
1949 {
1950 type: 'paragraph',
1951 internal: {
1952 generated: 'wrapper',
1953 metaItems: [
1954 {
1955 originalDomElementsHash: 'h188ab6af88887790',
1956 type: 'mwLanguage',
1957 attributes: {
1958 href: 'http://de.wikipedia.org/wiki/Foo'
1959 },
1960 internal: {
1961 loadMetaParentHash: 'hbc66e1df10d058e6',
1962 loadMetaParentOffset: 3
1963 }
1964 },
1965 {
1966 originalDomElementsHash: 'h188ab6ff88887790',
1967 type: 'mwLanguage',
1968 attributes: {
1969 href: 'http://fr.wikipedia.org/wiki/Foo'
1970 },
1971 internal: {
1972 loadMetaParentHash: 'h4e7ce2a82b7ce627',
1973 loadMetaParentOffset: 6
1974 }
1975 }
1976 ],
1977 whitespace: [ undefined, undefined, undefined, '\n' ]
1978 }
1979 },
1980 ...'Foo',
1981 { type: '/paragraph' },
1982 {
1983 type: 'mwLanguage',
1984 attributes: {
1985 href: 'http://de.wikipedia.org/wiki/Foo'
1986 },
1987 internal: {
1988 whitespace: [ '\n', undefined, undefined, '\n' ]
1989 }
1990 },
1991 { type: '/mwLanguage' },
1992 {
1993 type: 'mwLanguage',
1994 attributes: {
1995 href: 'http://fr.wikipedia.org/wiki/Foo'
1996 },
1997 internal: {
1998 whitespace: [ '\n' ]
1999 }
2000 },
2001 { type: '/mwLanguage' },
2002 { type: 'internalList' },
2003 { type: '/internalList' }
2004 ]
2005 }, */
2006 'document with meta elements': {
2007 body: ve.dm.example.singleLine`
2008 <!-- No conversion -->
2009 <meta property="mw:ThisIsAnAlien" />
2010 <p>
2011 Foo
2012 <link rel="mw:PageProp/Category" href="./Category:Bar" />
2013 Bar
2014 <meta property="mw:foo" content="bar" />
2015 Ba<!-- inline -->z<
2016 /p>
2017 <meta property="mw:bar" content="baz" />
2018 <!--barbaz-->
2019 <link rel="mw:PageProp/Category" href="./Category:Foo_foo#Bar%20baz%23quux" />
2020 <meta typeof="mw:Placeholder" data-parsoid="foobar" />
2021 `,
2022 clipboardBody: ve.dm.example.singleLine`
2023 <span rel="ve:Comment" data-ve-comment=" No conversion ">
2024 &nbsp;
2025 </span>
2026 <meta property="mw:ThisIsAnAlien" />
2027 <p>
2028 Foo
2029 <link rel="mw:PageProp/Category" href="./Category:Bar" />
2030 Bar
2031 <meta property="mw:foo" content="bar" />
2032 Ba<span rel="ve:Comment" data-ve-comment=" inline ">&nbsp;</span>z
2033 </p>
2034 <meta property="mw:bar" content="baz" />
2035 <span rel="ve:Comment" data-ve-comment="barbaz">&nbsp;</span>
2036 <link rel="mw:PageProp/Category" href="./Category:Foo_foo#Bar%20baz%23quux" />
2037 <meta typeof="mw:Placeholder" data-parsoid="foobar" />
2038 `,
2039 previewBody: ve.dm.example.singleLine`
2040 ${ ve.dm.example.commentNodePreview( ' No conversion ' ) }
2041 <meta property="mw:ThisIsAnAlien" />
2042 <p>
2043 Foo
2044 <a href="/wiki/Category:Bar">Bar</a>
2045 Bar
2046 <meta property="mw:foo" content="bar" />
2047 Ba${ ve.dm.example.commentNodePreview( ' inline ' ) }z
2048 </p>
2049 <meta property="mw:bar" content="baz" />
2050 ${ ve.dm.example.commentNodePreview( 'barbaz' ) }
2051 <a href="/wiki/Category:Foo_foo">Foo foo</a>
2052 <meta typeof="mw:Placeholder" data-parsoid="foobar" />
2053 `,
2054 base: ve.dm.mwExample.baseUri,
2055 data: ve.dm.mwExample.withMeta,
2056 realData: ve.dm.mwExample.withMetaRealData
2057 },
2058 'RDFa types spread across two attributes, about grouping is forced': {
2059 body: ve.dm.mwExample.MWTransclusion.mixed,
2060 fromDataBody: ve.dm.mwExample.MWTransclusion.mixedFromData,
2061 clipboardBody: ve.dm.mwExample.MWTransclusion.mixedClipboard,
2062 previewBody: ve.dm.mwExample.MWTransclusion.mixed,
2063 data: [
2064 { type: 'paragraph', internal: { generated: 'wrapper' } },
2065 ve.dm.mwExample.MWTransclusion.mixedDataOpen,
2066 ve.dm.mwExample.MWTransclusion.mixedDataClose,
2067 { type: '/paragraph' },
2068 { type: 'internalList' },
2069 { type: '/internalList' }
2070 ],
2071 storeItems: ve.dm.mwExample.MWTransclusion.mixedStoreItems
2072 },
2073 'mw:Entity': {
2074 body: '<p>a<span typeof="mw:Entity">¢</span>b<span typeof="mw:Entity">¥</span><span typeof="mw:Entity">™</span></p>',
2075 data: [
2076 { type: 'paragraph' },
2077 'a',
2078 {
2079 type: 'mwEntity',
2080 attributes: { character: '¢' }
2081 },
2082 { type: '/mwEntity' },
2083 'b',
2084 {
2085 type: 'mwEntity',
2086 attributes: { character: 'Â¥' }
2087 },
2088 { type: '/mwEntity' },
2089 {
2090 type: 'mwEntity',
2091 attributes: { character: 'â„¢' }
2092 },
2093 { type: '/mwEntity' },
2094 { type: '/paragraph' },
2095 { type: 'internalList' },
2096 { type: '/internalList' }
2097 ]
2098 },
2099 'mw:DisplaySpace': {
2100 body: '<p>a<span typeof="mw:DisplaySpace">&nbsp;</span>: b</p>',
2101 data: [
2102 { type: 'paragraph' },
2103 'a',
2104 {
2105 type: 'mwEntity',
2106 attributes: {
2107 character: '\u00a0',
2108 displaySpace: true
2109 }
2110 },
2111 { type: '/mwEntity' },
2112 ...': b',
2113 { type: '/paragraph' },
2114 { type: 'internalList' },
2115 { type: '/internalList' }
2116 ]
2117 },
2118 'wrapping with mw:Entity': {
2119 body: 'a<span typeof="mw:Entity">¢</span>b<span typeof="mw:Entity">¥</span><span typeof="mw:Entity">™</span>',
2120 data: [
2121 { type: 'paragraph', internal: { generated: 'wrapper' } },
2122 'a',
2123 {
2124 type: 'mwEntity',
2125 attributes: { character: '¢' }
2126 },
2127 { type: '/mwEntity' },
2128 'b',
2129 {
2130 type: 'mwEntity',
2131 attributes: { character: 'Â¥' }
2132 },
2133 { type: '/mwEntity' },
2134 {
2135 type: 'mwEntity',
2136 attributes: { character: 'â„¢' }
2137 },
2138 { type: '/mwEntity' },
2139 { type: '/paragraph' },
2140 { type: 'internalList' },
2141 { type: '/internalList' }
2142 ]
2143 },
2144 'whitespace preservation with mw:Entity': {
2145 body: '<p> a <span typeof="mw:Entity"> </span> b <span typeof="mw:Entity">Â¥</span>\t<span typeof="mw:Entity">â„¢</span></p>',
2146 data: [
2147 { type: 'paragraph', internal: { whitespace: [ undefined, ' ' ] } },
2148 ...'a ',
2149 {
2150 type: 'mwEntity',
2151 attributes: { character: ' ' }
2152 },
2153 { type: '/mwEntity' },
2154 ...' b ',
2155 {
2156 type: 'mwEntity',
2157 attributes: { character: 'Â¥' }
2158 },
2159 { type: '/mwEntity' },
2160 '\t',
2161 {
2162 type: 'mwEntity',
2163 attributes: { character: 'â„¢' }
2164 },
2165 { type: '/mwEntity' },
2166 { type: '/paragraph' },
2167 { type: 'internalList' },
2168 { type: '/internalList' }
2169 ]
2170 },
2171 'category default sort key': {
2172 body: '<span typeof="mw:Transclusion" data-mw=\'{"parts":[{"template":{"target":{"wt":"DEFAULTSORT:foo","function":"defaultsort"}}}]}\'></span>',
2173 data: [
2174 {
2175 type: 'mwDefaultSort',
2176 attributes: {
2177 prefix: 'DEFAULTSORT',
2178 sortkey: 'foo'
2179 }
2180 },
2181 { type: '/mwDefaultSort' },
2182 { type: 'paragraph', internal: { generated: 'empty' } },
2183 { type: '/paragraph' },
2184 { type: 'internalList' },
2185 { type: '/internalList' }
2186 ]
2187 },
2188 'thumb image': {
2189 body: ve.dm.mwExample.MWBlockImage.html,
2190 data: [
2191 ...ve.dm.mwExample.MWBlockImage.data,
2192 { type: 'internalList' },
2193 { type: '/internalList' }
2194 ],
2195 storeItems: ve.dm.mwExample.MWBlockImage.storeItems
2196 },
2197 'broken block image': {
2198 body: ve.dm.example.singleLine`
2199 <figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'>
2200 <a href="./Special:FilePath/Missing_image.jpg">
2201 <span resource="./File:Missing_image.jpg" class="mw-file-element mw-broken-media" data-width="220">File:Missing image.jpg</span>
2202 </a>
2203 <figcaption>abc</figcaption>
2204 </figure>
2205 `,
2206 data: [
2207 {
2208 type: 'mwBlockImage',
2209 attributes: {
2210 type: 'thumb',
2211 align: 'default',
2212 href: './Special:FilePath/Missing_image.jpg',
2213 imageClassAttr: 'mw-file-element mw-broken-media',
2214 imgWrapperClassAttr: null,
2215 mediaClass: 'Image',
2216 mediaTag: 'span',
2217 src: null,
2218 defaultSize: true,
2219 width: 220,
2220 height: null,
2221 originalWidth: 220,
2222 originalHeight: null,
2223 alt: null,
2224 isError: true,
2225 errorText: 'File:Missing image.jpg',
2226 resource: './File:Missing_image.jpg',
2227 mw: {
2228 errors: [ {
2229 key: 'apierror-filedoesnotexist',
2230 message: 'This image does not exist.'
2231 } ]
2232 },
2233 originalClasses: 'mw-default-size',
2234 unrecognizedClasses: []
2235 }
2236 },
2237 { type: 'mwImageCaption' },
2238 { type: 'paragraph', internal: { generated: 'wrapper' } },
2239 ...'abc',
2240 { type: '/paragraph' },
2241 { type: '/mwImageCaption' },
2242 { type: '/mwBlockImage' },
2243 { type: 'internalList' },
2244 { type: '/internalList' }
2245 ],
2246 previewBody: ve.dm.example.singleLine`
2247 <figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'>
2248 <a href="./Special:FilePath/Missing_image.jpg" class="new">
2249 <span resource="./File:Missing_image.jpg" class="mw-file-element mw-broken-media" data-width="220">File:Missing image.jpg</span>
2250 </a>
2251 <figcaption>abc</figcaption>
2252 </figure>
2253 `
2254 },
2255 'broken inline image': {
2256 body: ve.dm.example.singleLine`
2257 <p>
2258 <span typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'>
2259 <a href="./Special:FilePath/Missing_image.jpg">
2260 <span resource="./File:Missing_image.jpg" class="mw-file-element mw-broken-media" data-width="200">File:Missing image.jpg</span>
2261 </a>
2262 </span>
2263 </p>
2264 `,
2265 data: [
2266 { type: 'paragraph' },
2267 {
2268 type: 'mwInlineImage',
2269 attributes: {
2270 type: 'none',
2271 href: './Special:FilePath/Missing_image.jpg',
2272 imageClassAttr: 'mw-file-element mw-broken-media',
2273 imgWrapperClassAttr: null,
2274 mediaClass: 'Image',
2275 mediaTag: 'span',
2276 src: null,
2277 width: 200,
2278 height: null,
2279 valign: 'default',
2280 alt: null,
2281 isError: true,
2282 errorText: 'File:Missing image.jpg',
2283 resource: './File:Missing_image.jpg',
2284 mw: {
2285 errors: [ {
2286 key: 'apierror-filedoesnotexist',
2287 message: 'This image does not exist.'
2288 } ]
2289 },
2290 originalClasses: null,
2291 unrecognizedClasses: []
2292 }
2293 },
2294 { type: '/mwInlineImage' },
2295 { type: '/paragraph' },
2296 { type: 'internalList' },
2297 { type: '/internalList' }
2298 ],
2299 previewBody: ve.dm.example.singleLine`
2300 <p>
2301 <span typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'>
2302 <a href="./Special:FilePath/Missing_image.jpg" class="new">
2303 <span resource="./File:Missing_image.jpg" class="mw-file-element mw-broken-media" data-width="200">File:Missing image.jpg</span>
2304 </a>
2305 </span>
2306 </p>
2307 `
2308 },
2309 'attribute preservation does not crash due to text node split': {
2310 body: ve.dm.example.singleLine`
2311 <figure typeof="mw:Image/Thumb" data-parsoid="{}">
2312 <a href="./Foo" data-parsoid="{}" class="mw-file-description">
2313 <img src="${ ve.ce.minImgDataUri }" class="mw-file-element" width="1" height="2" resource="./FooBar" data-parsoid="{}">
2314 </a>
2315 <figcaption data-parsoid="{}">
2316 foo <a rel="mw:WikiLink" href="./Bar" data-parsoid="{}">bar</a> baz
2317 </figcaption>
2318 </figure>
2319 `,
2320 fromDataBody: ve.dm.example.singleLine`
2321 <figure typeof="mw:Image/Thumb">
2322 <a href="./Foo" class="mw-file-description">
2323 <img src="${ ve.ce.minImgDataUri }" class="mw-file-element" width="1" height="2" resource="./FooBar">
2324 </a>
2325 <figcaption>
2326 foo <a rel="mw:WikiLink" href="./Bar">bar</a> baz
2327 </figcaption>
2328 </figure>
2329 `,
2330 base: ve.dm.mwExample.baseUri,
2331 data: [
2332 {
2333 type: 'mwBlockImage',
2334 attributes: {
2335 type: 'thumb',
2336 align: 'default',
2337 href: './Foo',
2338 imageClassAttr: 'mw-file-element',
2339 imgWrapperClassAttr: 'mw-file-description',
2340 mediaClass: 'Image',
2341 mediaTag: 'img',
2342 src: ve.ce.minImgDataUri,
2343 width: 1,
2344 height: 2,
2345 alt: null,
2346 mw: {},
2347 isError: false,
2348 errorText: null,
2349 resource: './FooBar'
2350 }
2351 },
2352 { type: 'mwImageCaption', internal: { whitespace: [ undefined, ' ' ] } },
2353 { type: 'paragraph', internal: { generated: 'wrapper', whitespace: [ ' ' ] } },
2354 ...'foo ',
2355 [
2356 'b',
2357 [ {
2358 type: 'link/mwInternal',
2359 attributes: {
2360 title: 'Bar',
2361 normalizedTitle: 'Bar',
2362 lookupTitle: 'Bar'
2363 }
2364 } ]
2365 ],
2366 [
2367 'a',
2368 [ {
2369 type: 'link/mwInternal',
2370 attributes: {
2371 title: 'Bar',
2372 normalizedTitle: 'Bar',
2373 lookupTitle: 'Bar'
2374 }
2375 } ]
2376 ],
2377 [
2378 'r',
2379 [ {
2380 type: 'link/mwInternal',
2381 attributes: {
2382 title: 'Bar',
2383 normalizedTitle: 'Bar',
2384 lookupTitle: 'Bar'
2385 }
2386 } ]
2387 ],
2388 ...' baz',
2389 { type: '/paragraph' },
2390 { type: '/mwImageCaption' },
2391 { type: '/mwBlockImage' },
2392 { type: 'internalList' },
2393 { type: '/internalList' }
2394 ]
2395 },
2396 'mw:Nowiki': {
2397 body: ve.dm.mwExample.mwNowikiHtml,
2398 data: ve.dm.mwExample.mwNowiki,
2399 fromDataBody: ve.dm.mwExample.mwNowikiHtmlFromData
2400 },
2401 'mw:Nowiki unwraps when text modified': {
2402 data: ve.dm.mwExample.mwNowiki,
2403 modify: ( model ) => {
2404 model.data.modifyData( 7, ( item ) => {
2405 item[ 0 ] = 'z';
2406 } );
2407 },
2408 normalizedBody: '<p>Foo[[Bzr]]Baz</p>'
2409 },
2410 'mw:Nowiki unwraps when annotations modified': {
2411 data: ve.dm.mwExample.mwNowiki,
2412 modify: ( model ) => {
2413 model.data.modifyData( 7, ( item ) => {
2414 item[ 1 ].push( model.getStore().hash( ve.dm.example.createAnnotation( ve.dm.example.bold ) ) );
2415 } );
2416 },
2417 normalizedBody: '<p>Foo[[B<b>a</b>r]]Baz</p>'
2418 },
2419 'plain external links when pasted are converted to link/mwExternal': {
2420 fromClipboard: true,
2421 body: '<a href="https://www.mediawiki.org/">ab</a>',
2422 data: [
2423 {
2424 type: 'paragraph',
2425 internal: {
2426 generated: 'wrapper'
2427 }
2428 },
2429 [
2430 'a',
2431 [ {
2432 type: 'link/mwExternal',
2433 attributes: {
2434 href: 'https://www.mediawiki.org/'
2435 }
2436 } ]
2437 ],
2438 [
2439 'b',
2440 [ {
2441 type: 'link/mwExternal',
2442 attributes: {
2443 href: 'https://www.mediawiki.org/'
2444 }
2445 } ]
2446 ],
2447 {
2448 type: '/paragraph'
2449 },
2450 {
2451 type: 'internalList'
2452 },
2453 {
2454 type: '/internalList'
2455 }
2456 ],
2457 normalizedBody: '<a href="https://www.mediawiki.org/" rel="mw:ExtLink">ab</a>',
2458 previewBody: '<a href="https://www.mediawiki.org/" class="external" rel="mw:ExtLink">ab</a>'
2459 },
2460 'plain internal links when pasted are converted to link/mwInternal': {
2461 fromClipboard: true,
2462 body: '<a href="' + ve.dm.mwExample.MWInternalLink.absoluteHref + '">ab</a>',
2463 base: ve.dm.mwExample.baseUri,
2464 data: [
2465 {
2466 type: 'paragraph',
2467 internal: {
2468 generated: 'wrapper'
2469 }
2470 },
2471 [
2472 'a',
2473 [ {
2474 type: 'link/mwInternal',
2475 attributes: {
2476 title: 'Foo/Bar',
2477 normalizedTitle: 'Foo/Bar',
2478 lookupTitle: 'Foo/Bar'
2479 }
2480 } ]
2481 ],
2482 [
2483 'b',
2484 [ {
2485 type: 'link/mwInternal',
2486 attributes: {
2487 title: 'Foo/Bar',
2488 normalizedTitle: 'Foo/Bar',
2489 lookupTitle: 'Foo/Bar'
2490 }
2491 } ]
2492 ],
2493 {
2494 type: '/paragraph'
2495 },
2496 {
2497 type: 'internalList'
2498 },
2499 {
2500 type: '/internalList'
2501 }
2502 ],
2503 normalizedBody: '<a href="./Foo/Bar" rel="mw:WikiLink">ab</a>',
2504 mwConfig: {
2505 wgArticlePath: '/wiki/$1'
2506 }
2507 },
2508 'plain href-less anchors when pasted are converted to spans': {
2509 fromClipboard: true,
2510 body: '<a name="foo">ab</a>',
2511 data: [
2512 {
2513 type: 'paragraph',
2514 internal: {
2515 generated: 'wrapper'
2516 }
2517 },
2518 [
2519 'a',
2520 [ {
2521 type: 'textStyle/span',
2522 attributes: { nodeName: 'span' }
2523 } ]
2524 ],
2525 [
2526 'b',
2527 [ {
2528 type: 'textStyle/span',
2529 attributes: { nodeName: 'span' }
2530 } ]
2531 ],
2532 {
2533 type: '/paragraph'
2534 },
2535 {
2536 type: 'internalList'
2537 },
2538 {
2539 type: '/internalList'
2540 }
2541 ],
2542 normalizedBody: '<span name="foo">ab</span>',
2543 fromDataBody: '<span>ab</span>'
2544 }
2545 };