2013-07-03 01:30:10 +00:00
|
|
|
/*!
|
2017-06-22 19:55:28 +00:00
|
|
|
* VisualEditor MediaWiki-specific ContentEditable ContentBranchNode tests.
|
2013-07-03 01:30:10 +00:00
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2013-07-03 01:30:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2021-08-25 08:31:34 +00:00
|
|
|
QUnit.module( 've.ce.ContentBranchNode (MW)' );
|
2013-07-03 01:30:10 +00:00
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
|
|
|
// FIXME runner copypasted from core, use data provider
|
2024-05-01 17:25:33 +00:00
|
|
|
QUnit.test.each( 'getRenderedContents', {
|
|
|
|
'Annotation spanning text and inline nodes': {
|
|
|
|
data: [
|
|
|
|
{ type: 'paragraph' },
|
|
|
|
'a',
|
|
|
|
[ 'b', [ { type: 'textStyle/bold' } ] ],
|
|
|
|
{
|
|
|
|
type: 'mwEntity',
|
|
|
|
attributes: { character: 'c' },
|
|
|
|
annotations: [ { type: 'textStyle/bold' } ]
|
|
|
|
},
|
|
|
|
{ type: '/mwEntity' },
|
|
|
|
[ 'd', [ { type: 'textStyle/bold' } ] ],
|
|
|
|
{
|
|
|
|
type: 'alienInline',
|
|
|
|
originalDomElements: $.parseHTML( '<span rel="ve:Alien">e</span>' ),
|
|
|
|
annotations: [ { type: 'textStyle/bold' } ]
|
|
|
|
},
|
|
|
|
{ type: '/alienInline' },
|
|
|
|
{ type: '/paragraph' }
|
|
|
|
],
|
|
|
|
html: ve.dm.example.singleLine`
|
|
|
|
a
|
|
|
|
<b>
|
|
|
|
b
|
|
|
|
<span class="ve-ce-leafNode ve-ce-mwEntityNode" contenteditable="false">c</span>
|
|
|
|
d
|
|
|
|
<span rel="ve:Alien" class="ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">e</span>
|
|
|
|
</b>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
}, ( assert, { data, html } ) => {
|
|
|
|
const doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( data ) );
|
|
|
|
const $wrapper = $( new ve.ce.ParagraphNode( doc.getDocumentNode().getChildren()[ 0 ] ).getRenderedContents() );
|
|
|
|
// HACK strip out all the class="ve-ce-textStyleAnnotation ve-ce-textStyleBoldAnnotation" crap
|
|
|
|
$wrapper.find( '.ve-ce-textStyleAnnotation' ).removeAttr( 'class' );
|
2017-04-28 15:48:52 +00:00
|
|
|
|
2024-05-01 17:25:33 +00:00
|
|
|
assert.equalDomElement( $wrapper[ 0 ], $( '<div>' ).html( html )[ 0 ] );
|
2013-07-03 01:30:10 +00:00
|
|
|
} );
|