|
@@ -37,7 +37,7 @@ describe( 'DowncastWriter', () => {
|
|
|
* @param {String} wrapAttribute
|
|
* @param {String} wrapAttribute
|
|
|
* @param {String} expected
|
|
* @param {String} expected
|
|
|
*/
|
|
*/
|
|
|
- function test( input, wrapAttribute, expected ) {
|
|
|
|
|
|
|
+ function testWrap( input, wrapAttribute, expected ) {
|
|
|
const { view, selection } = parse( input );
|
|
const { view, selection } = parse( input );
|
|
|
const newRange = writer.wrap( selection.getFirstRange(), parse( wrapAttribute ) );
|
|
const newRange = writer.wrap( selection.getFirstRange(), parse( wrapAttribute ) );
|
|
|
|
|
|
|
@@ -46,7 +46,7 @@ describe( 'DowncastWriter', () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
it( 'wraps single text node', () => {
|
|
it( 'wraps single text node', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[foobar]</container:p>',
|
|
'<container:p>[foobar]</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>'
|
|
'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>'
|
|
@@ -54,7 +54,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'wraps single text node in document fragment', () => {
|
|
it( 'wraps single text node in document fragment', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'{foobar}',
|
|
'{foobar}',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'[<attribute:b view-priority="1">foobar</attribute:b>]'
|
|
'[<attribute:b view-priority="1">foobar</attribute:b>]'
|
|
@@ -98,7 +98,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'wraps part of a single text node #1', () => {
|
|
it( 'wraps part of a single text node #1', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[foo}bar</container:p>',
|
|
'<container:p>[foo}bar</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="1">foo</attribute:b>]bar</container:p>'
|
|
'<container:p>[<attribute:b view-priority="1">foo</attribute:b>]bar</container:p>'
|
|
@@ -106,7 +106,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'wraps part of a single text node #2', () => {
|
|
it( 'wraps part of a single text node #2', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>{foo}bar</container:p>',
|
|
'<container:p>{foo}bar</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="1">foo</attribute:b>]bar</container:p>'
|
|
'<container:p>[<attribute:b view-priority="1">foo</attribute:b>]bar</container:p>'
|
|
@@ -114,7 +114,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should support unicode', () => {
|
|
it( 'should support unicode', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>நி{லை}க்கு</container:p>',
|
|
'<container:p>நி{லை}க்கு</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>நி[<attribute:b view-priority="1">லை</attribute:b>]க்கு</container:p>'
|
|
'<container:p>நி[<attribute:b view-priority="1">லை</attribute:b>]க்கு</container:p>'
|
|
@@ -122,7 +122,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should join wrapping element with a nested attribute element', () => {
|
|
it( 'should join wrapping element with a nested attribute element', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'<attribute:u view-priority="1">' +
|
|
'<attribute:u view-priority="1">' +
|
|
|
'<attribute:b view-priority="2" class="bar">{foo}</attribute:b>' +
|
|
'<attribute:b view-priority="2" class="bar">{foo}</attribute:b>' +
|
|
@@ -140,7 +140,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should join wrapping element with a part of a nested attribute element', () => {
|
|
it( 'should join wrapping element with a part of a nested attribute element', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'<attribute:i view-priority="1">' +
|
|
'<attribute:i view-priority="1">' +
|
|
|
'<attribute:b view-priority="2" class="bar">fo{ob}ar</attribute:b>' +
|
|
'<attribute:b view-priority="2" class="bar">fo{ob}ar</attribute:b>' +
|
|
@@ -160,7 +160,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'wraps part of a single text node #3', () => {
|
|
it( 'wraps part of a single text node #3', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>foo{bar}</container:p>',
|
|
'<container:p>foo{bar}</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>foo[<attribute:b view-priority="1">bar</attribute:b>]</container:p>'
|
|
'<container:p>foo[<attribute:b view-priority="1">bar</attribute:b>]</container:p>'
|
|
@@ -168,7 +168,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not wrap inside nested containers', () => {
|
|
it( 'should not wrap inside nested containers', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:div>[foobar<container:p>baz</container:p>]</container:div>',
|
|
'<container:div>[foobar<container:p>baz</container:p>]</container:div>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:div>[<attribute:b view-priority="1">foobar</attribute:b><container:p>baz</container:p>]</container:div>'
|
|
'<container:div>[<attribute:b view-priority="1">foobar</attribute:b><container:p>baz</container:p>]</container:div>'
|
|
@@ -176,7 +176,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'wraps according to priorities', () => {
|
|
it( 'wraps according to priorities', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:u view-priority="1">foobar</attribute:u>]</container:p>',
|
|
'<container:p>[<attribute:u view-priority="1">foobar</attribute:u>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="2"></attribute:b>',
|
|
'<attribute:b view-priority="2"></attribute:b>',
|
|
@@ -188,7 +188,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'merges wrapped nodes #1', () => {
|
|
it( 'merges wrapped nodes #1', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'[<attribute:b view-priority="1">foo</attribute:b>bar<attribute:b view-priority="1">baz</attribute:b>]' +
|
|
'[<attribute:b view-priority="1">foo</attribute:b>bar<attribute:b view-priority="1">baz</attribute:b>]' +
|
|
|
'</container:p>',
|
|
'</container:p>',
|
|
@@ -200,7 +200,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'merges wrapped nodes #2', () => {
|
|
it( 'merges wrapped nodes #2', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p><attribute:b view-priority="1">foo</attribute:b>[bar}baz</container:p>',
|
|
'<container:p><attribute:b view-priority="1">foo</attribute:b>[bar}baz</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p><attribute:b view-priority="1">foo{bar</attribute:b>]baz</container:p>'
|
|
'<container:p><attribute:b view-priority="1">foo{bar</attribute:b>]baz</container:p>'
|
|
@@ -208,7 +208,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'merges wrapped nodes #3', () => {
|
|
it( 'merges wrapped nodes #3', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p><attribute:b view-priority="1">foobar</attribute:b>[baz]</container:p>',
|
|
'<container:p><attribute:b view-priority="1">foobar</attribute:b>[baz]</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p><attribute:b view-priority="1">foobar{baz</attribute:b>]</container:p>'
|
|
'<container:p><attribute:b view-priority="1">foobar{baz</attribute:b>]</container:p>'
|
|
@@ -216,7 +216,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'merges wrapped nodes #4', () => {
|
|
it( 'merges wrapped nodes #4', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[foo<attribute:i view-priority="1">bar</attribute:i>]baz</container:p>',
|
|
'<container:p>[foo<attribute:i view-priority="1">bar</attribute:i>]baz</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
@@ -228,7 +228,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'merges wrapped nodes #5', () => {
|
|
it( 'merges wrapped nodes #5', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[foo<attribute:i view-priority="1">bar</attribute:i>baz]</container:p>',
|
|
'<container:p>[foo<attribute:i view-priority="1">bar</attribute:i>baz]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="2"></attribute:b>',
|
|
'<attribute:b view-priority="2"></attribute:b>',
|
|
@@ -246,7 +246,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'merges wrapped nodes #6', () => {
|
|
it( 'merges wrapped nodes #6', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:div>f{o<attribute:strong>ob</attribute:strong>a}r</container:div>',
|
|
'<container:div>f{o<attribute:strong>ob</attribute:strong>a}r</container:div>',
|
|
|
|
|
|
|
|
'<attribute:span view-priority="1"></attribute:span>',
|
|
'<attribute:span view-priority="1"></attribute:span>',
|
|
@@ -260,7 +260,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap single element by merging attributes', () => {
|
|
it( 'should wrap single element by merging attributes', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:b view-priority="1" foo="bar" one="two"></attribute:b>]</container:p>',
|
|
'<container:p>[<attribute:b view-priority="1" foo="bar" one="two"></attribute:b>]</container:p>',
|
|
|
'<attribute:b view-priority="1" baz="qux" one="two"></attribute:b>',
|
|
'<attribute:b view-priority="1" baz="qux" one="two"></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="1" baz="qux" foo="bar" one="two"></attribute:b>]</container:p>'
|
|
'<container:p>[<attribute:b view-priority="1" baz="qux" foo="bar" one="two"></attribute:b>]</container:p>'
|
|
@@ -268,7 +268,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not merge attributes when they differ', () => {
|
|
it( 'should not merge attributes when they differ', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:b view-priority="1" foo="bar">text</attribute:b>]</container:p>',
|
|
'<container:p>[<attribute:b view-priority="1" foo="bar">text</attribute:b>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="1" foo="baz"></attribute:b>',
|
|
'<attribute:b view-priority="1" foo="baz"></attribute:b>',
|
|
@@ -282,7 +282,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap single element by merging classes', () => {
|
|
it( 'should wrap single element by merging classes', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:b view-priority="1" class="foo bar baz"></attribute:b>]</container:p>',
|
|
'<container:p>[<attribute:b view-priority="1" class="foo bar baz"></attribute:b>]</container:p>',
|
|
|
'<attribute:b view-priority="1" class="foo bar qux jax"></attribute:b>',
|
|
'<attribute:b view-priority="1" class="foo bar qux jax"></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="1" class="bar baz foo jax qux"></attribute:b>]</container:p>'
|
|
'<container:p>[<attribute:b view-priority="1" class="bar baz foo jax qux"></attribute:b>]</container:p>'
|
|
@@ -290,7 +290,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap single element by merging styles', () => {
|
|
it( 'should wrap single element by merging styles', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'[<attribute:b view-priority="1" style="color:red; position: absolute"></attribute:b>]' +
|
|
'[<attribute:b view-priority="1" style="color:red; position: absolute"></attribute:b>]' +
|
|
|
'</container:p>',
|
|
'</container:p>',
|
|
@@ -304,7 +304,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not merge styles when they differ', () => {
|
|
it( 'should not merge styles when they differ', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:b view-priority="1" style="color:red"></attribute:b>]</container:p>',
|
|
'<container:p>[<attribute:b view-priority="1" style="color:red"></attribute:b>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="1" style="color:black"></attribute:b>',
|
|
'<attribute:b view-priority="1" style="color:black"></attribute:b>',
|
|
@@ -320,7 +320,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not merge single elements when they have different priority', () => {
|
|
it( 'should not merge single elements when they have different priority', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:b view-priority="2" style="color:red"></attribute:b>]</container:p>',
|
|
'<container:p>[<attribute:b view-priority="2" style="color:red"></attribute:b>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="1" style="color:red"></attribute:b>',
|
|
'<attribute:b view-priority="1" style="color:red"></attribute:b>',
|
|
@@ -336,7 +336,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should be merged with outside element when wrapping all children', () => {
|
|
it( 'should be merged with outside element when wrapping all children', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'<attribute:b view-priority="1" foo="bar">[foobar<attribute:i view-priority="1">baz</attribute:i>]</attribute:b>' +
|
|
'<attribute:b view-priority="1" foo="bar">[foobar<attribute:i view-priority="1">baz</attribute:i>]</attribute:b>' +
|
|
|
'</container:p>',
|
|
'</container:p>',
|
|
@@ -355,7 +355,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should be merged with broken element', () => {
|
|
it( 'should be merged with broken element', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'[<attribute:b view-priority="1" foo="bar">foo}bar</attribute:b>' +
|
|
'[<attribute:b view-priority="1" foo="bar">foo}bar</attribute:b>' +
|
|
|
'</container:p>',
|
|
'</container:p>',
|
|
@@ -370,7 +370,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should be merged with broken element and merged with siblings', () => {
|
|
it( 'should be merged with broken element and merged with siblings', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'<attribute:b view-priority="1" baz="qux" foo="bar">xyz</attribute:b>' +
|
|
'<attribute:b view-priority="1" baz="qux" foo="bar">xyz</attribute:b>' +
|
|
|
'[<attribute:b view-priority="1" foo="bar">foo}bar</attribute:b>' +
|
|
'[<attribute:b view-priority="1" foo="bar">foo}bar</attribute:b>' +
|
|
@@ -386,7 +386,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap EmptyElement', () => {
|
|
it( 'should wrap EmptyElement', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<empty:img></empty:img>]</container:p>',
|
|
'<container:p>[<empty:img></empty:img>]</container:p>',
|
|
|
'<attribute:b></attribute:b>',
|
|
'<attribute:b></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="10"><empty:img></empty:img></attribute:b>]</container:p>'
|
|
'<container:p>[<attribute:b view-priority="10"><empty:img></empty:img></attribute:b>]</container:p>'
|
|
@@ -404,7 +404,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap UIElement', () => {
|
|
it( 'should wrap UIElement', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<ui:span></ui:span>]</container:p>',
|
|
'<container:p>[<ui:span></ui:span>]</container:p>',
|
|
|
'<attribute:b></attribute:b>',
|
|
'<attribute:b></attribute:b>',
|
|
|
'<container:p>[<attribute:b view-priority="10"><ui:span></ui:span></attribute:b>]</container:p>'
|
|
'<container:p>[<attribute:b view-priority="10"><ui:span></ui:span></attribute:b>]</container:p>'
|
|
@@ -422,7 +422,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should keep stable hierarchy when wrapping with attribute with same priority', () => {
|
|
it( 'should keep stable hierarchy when wrapping with attribute with same priority', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:span>foo</attribute:span>]</container:p>',
|
|
'<container:p>[<attribute:span>foo</attribute:span>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:b></attribute:b>',
|
|
'<attribute:b></attribute:b>',
|
|
@@ -434,7 +434,7 @@ describe( 'DowncastWriter', () => {
|
|
|
'</container:p>'
|
|
'</container:p>'
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:b>foo</attribute:b>]</container:p>',
|
|
'<container:p>[<attribute:b>foo</attribute:b>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:span></attribute:span>',
|
|
'<attribute:span></attribute:span>',
|
|
@@ -448,7 +448,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should keep stable hierarchy when wrapping with attribute with same priority that can\'t be merged', () => {
|
|
it( 'should keep stable hierarchy when wrapping with attribute with same priority that can\'t be merged', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:span name="foo">foo</attribute:span>]</container:p>',
|
|
'<container:p>[<attribute:span name="foo">foo</attribute:span>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:span name="bar"></attribute:span>',
|
|
'<attribute:span name="bar"></attribute:span>',
|
|
@@ -460,7 +460,7 @@ describe( 'DowncastWriter', () => {
|
|
|
'</container:p>'
|
|
'</container:p>'
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:span name="bar">foo</attribute:span>]</container:p>',
|
|
'<container:p>[<attribute:span name="bar">foo</attribute:span>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:span name="foo"></attribute:span>',
|
|
'<attribute:span name="foo"></attribute:span>',
|
|
@@ -474,7 +474,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not join elements if element to wrap has id', () => {
|
|
it( 'should not join elements if element to wrap has id', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:span foo="foo" view-id="foo">xyz</attribute:span>]</container:p>',
|
|
'<container:p>[<attribute:span foo="foo" view-id="foo">xyz</attribute:span>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:span bar="bar"></attribute:span>',
|
|
'<attribute:span bar="bar"></attribute:span>',
|
|
@@ -488,7 +488,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not join elements if wrapper element has id', () => {
|
|
it( 'should not join elements if wrapper element has id', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:span foo="foo">xyz</attribute:span>]</container:p>',
|
|
'<container:p>[<attribute:span foo="foo">xyz</attribute:span>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:span bar="bar" view-id="foo"></attribute:span>',
|
|
'<attribute:span bar="bar" view-id="foo"></attribute:span>',
|
|
@@ -502,7 +502,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not join elements if they have different ids', () => {
|
|
it( 'should not join elements if they have different ids', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[<attribute:span foo="foo" view-id="foo">xyz</attribute:span>]</container:p>',
|
|
'<container:p>[<attribute:span foo="foo" view-id="foo">xyz</attribute:span>]</container:p>',
|
|
|
|
|
|
|
|
'<attribute:span bar="bar" view-id="bar"></attribute:span>',
|
|
'<attribute:span bar="bar" view-id="bar"></attribute:span>',
|
|
@@ -536,7 +536,7 @@ describe( 'DowncastWriter', () => {
|
|
|
* @param {String} wrapAttribute
|
|
* @param {String} wrapAttribute
|
|
|
* @param {String} expected
|
|
* @param {String} expected
|
|
|
*/
|
|
*/
|
|
|
- function test( input, wrapAttribute, expected ) {
|
|
|
|
|
|
|
+ function testWrap( input, wrapAttribute, expected ) {
|
|
|
const { view, selection } = parse( input, { rootElement: viewRoot } );
|
|
const { view, selection } = parse( input, { rootElement: viewRoot } );
|
|
|
viewDocument.selection._setTo( selection );
|
|
viewDocument.selection._setTo( selection );
|
|
|
|
|
|
|
@@ -559,7 +559,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap position at the beginning of text node', () => {
|
|
it( 'should wrap position at the beginning of text node', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>{}foobar</container:p>',
|
|
'<container:p>{}foobar</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p><attribute:b view-priority="1">[]</attribute:b>foobar</container:p>'
|
|
'<container:p><attribute:b view-priority="1">[]</attribute:b>foobar</container:p>'
|
|
@@ -567,7 +567,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap position inside text node', () => {
|
|
it( 'should wrap position inside text node', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>foo{}bar</container:p>',
|
|
'<container:p>foo{}bar</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>foo<attribute:b view-priority="1">[]</attribute:b>bar</container:p>'
|
|
'<container:p>foo<attribute:b view-priority="1">[]</attribute:b>bar</container:p>'
|
|
@@ -575,7 +575,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should support unicode', () => {
|
|
it( 'should support unicode', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>நிலை{}க்கு</container:p>',
|
|
'<container:p>நிலை{}க்கு</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>நிலை<attribute:b view-priority="1">[]</attribute:b>க்கு</container:p>'
|
|
'<container:p>நிலை<attribute:b view-priority="1">[]</attribute:b>க்கு</container:p>'
|
|
@@ -583,7 +583,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap position inside document fragment', () => {
|
|
it( 'should wrap position inside document fragment', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="3">bar</attribute:b>',
|
|
'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="3">bar</attribute:b>',
|
|
|
|
|
|
|
|
'<attribute:b view-priority="2"></attribute:b>',
|
|
'<attribute:b view-priority="2"></attribute:b>',
|
|
@@ -595,7 +595,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap position at the end of text node', () => {
|
|
it( 'should wrap position at the end of text node', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>foobar{}</container:p>',
|
|
'<container:p>foobar{}</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p>foobar<attribute:b view-priority="1">[]</attribute:b></container:p>'
|
|
'<container:p>foobar<attribute:b view-priority="1">[]</attribute:b></container:p>'
|
|
@@ -603,7 +603,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should merge with existing attributes #1', () => {
|
|
it( 'should merge with existing attributes #1', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p><attribute:b view-priority="1">foo</attribute:b>[]</container:p>',
|
|
'<container:p><attribute:b view-priority="1">foo</attribute:b>[]</container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p><attribute:b view-priority="1">foo{}</attribute:b></container:p>'
|
|
'<container:p><attribute:b view-priority="1">foo{}</attribute:b></container:p>'
|
|
@@ -611,7 +611,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should merge with existing attributes #2', () => {
|
|
it( 'should merge with existing attributes #2', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>[]<attribute:b view-priority="1">foo</attribute:b></container:p>',
|
|
'<container:p>[]<attribute:b view-priority="1">foo</attribute:b></container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p><attribute:b view-priority="1">{}foo</attribute:b></container:p>'
|
|
'<container:p><attribute:b view-priority="1">{}foo</attribute:b></container:p>'
|
|
@@ -619,7 +619,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should wrap when inside nested attributes', () => {
|
|
it( 'should wrap when inside nested attributes', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p><attribute:b view-priority="1">foo{}bar</attribute:b></container:p>',
|
|
'<container:p><attribute:b view-priority="1">foo{}bar</attribute:b></container:p>',
|
|
|
|
|
|
|
|
'<attribute:u view-priority="1"></attribute:u>',
|
|
'<attribute:u view-priority="1"></attribute:u>',
|
|
@@ -635,7 +635,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should merge when wrapping between same attribute', () => {
|
|
it( 'should merge when wrapping between same attribute', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p>' +
|
|
'<container:p>' +
|
|
|
'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="1">bar</attribute:b>' +
|
|
'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="1">bar</attribute:b>' +
|
|
|
'</container:p>',
|
|
'</container:p>',
|
|
@@ -647,7 +647,7 @@ describe( 'DowncastWriter', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should move position to text node if in same attribute', () => {
|
|
it( 'should move position to text node if in same attribute', () => {
|
|
|
- test(
|
|
|
|
|
|
|
+ testWrap(
|
|
|
'<container:p><attribute:b view-priority="1">foobar[]</attribute:b></container:p>',
|
|
'<container:p><attribute:b view-priority="1">foobar[]</attribute:b></container:p>',
|
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
'<attribute:b view-priority="1"></attribute:b>',
|
|
|
'<container:p><attribute:b view-priority="1">foobar{}</attribute:b></container:p>'
|
|
'<container:p><attribute:b view-priority="1">foobar{}</attribute:b></container:p>'
|