|
@@ -63,7 +63,7 @@ describe( 'Paragraph feature', () => {
|
|
|
expect( editor.getData() ).to.equal( '<p>foo</p><p>baz</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>foo</p><p>baz</p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- describe( 'generic block converter (autoparagraphing)', () => {
|
|
|
|
|
|
|
+ describe( 'generic text converter (text autoparagraphing)', () => {
|
|
|
it( 'should autoparagraph text', () => {
|
|
it( 'should autoparagraph text', () => {
|
|
|
editor.setData( 'foo' );
|
|
editor.setData( 'foo' );
|
|
|
|
|
|
|
@@ -71,6 +71,13 @@ describe( 'Paragraph feature', () => {
|
|
|
expect( editor.getData() ).to.equal( '<p>foo</p>' );
|
|
expect( editor.getData() ).to.equal( '<p>foo</p>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should not autoparagraph text (in clipboard holder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( 'foo', '$clipboardHolder' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( 'foo' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'should autoparagraph text next to allowed element', () => {
|
|
it( 'should autoparagraph text next to allowed element', () => {
|
|
|
doc.schema.registerItem( 'heading1', '$block' );
|
|
doc.schema.registerItem( 'heading1', '$block' );
|
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
|
|
@@ -81,56 +88,37 @@ describe( 'Paragraph feature', () => {
|
|
|
.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph><paragraph>bom</paragraph>' );
|
|
.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph><paragraph>bom</paragraph>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should autoparagraph 3 inline things into one paragraph', () => {
|
|
|
|
|
|
|
+ it( 'should autoparagraph 3 inline inline nodes into one paragraph', () => {
|
|
|
const modelFragment = editor.data.parse( 'foo<b>bar</b>bom' );
|
|
const modelFragment = editor.data.parse( 'foo<b>bar</b>bom' );
|
|
|
|
|
|
|
|
expect( stringifyModel( modelFragment ) )
|
|
expect( stringifyModel( modelFragment ) )
|
|
|
.to.equal( '<paragraph>foobarbom</paragraph>' );
|
|
.to.equal( '<paragraph>foobarbom</paragraph>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should autoparagraph h1, h2...', () => {
|
|
|
|
|
- const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>' );
|
|
|
|
|
-
|
|
|
|
|
- expect( stringifyModel( modelFragment ) )
|
|
|
|
|
- .to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should autoparagraph ul > li', () => {
|
|
|
|
|
- const modelFragment = editor.data.parse( '<ul><li>foo</li><li>bar</li></ul>' );
|
|
|
|
|
-
|
|
|
|
|
- expect( stringifyModel( modelFragment ) )
|
|
|
|
|
- .to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should autoparagraph tr', () => {
|
|
|
|
|
- const modelFragment = editor.data.parse( '<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>' );
|
|
|
|
|
|
|
+ it( 'should not autoparagraph 3 inline inline nodes (in clipboardHolder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( 'foo<b>bar</b>bom', '$clipboardHolder' );
|
|
|
|
|
|
|
|
expect( stringifyModel( modelFragment ) )
|
|
expect( stringifyModel( modelFragment ) )
|
|
|
- .to.equal( '<paragraph>ab</paragraph><paragraph>cd</paragraph>' );
|
|
|
|
|
|
|
+ .to.equal( 'foobarbom' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should autoparagraph inside some container', () => {
|
|
|
|
|
|
|
+ it( 'should autoparagraph text inside converted container', () => {
|
|
|
doc.schema.registerItem( 'div' );
|
|
doc.schema.registerItem( 'div' );
|
|
|
- doc.schema.allow( { name: '$inline', attributes: [ 'bold' ] } );
|
|
|
|
|
doc.schema.allow( { name: 'div', inside: '$root' } );
|
|
doc.schema.allow( { name: 'div', inside: '$root' } );
|
|
|
doc.schema.allow( { name: 'paragraph', inside: 'div' } );
|
|
doc.schema.allow( { name: 'paragraph', inside: 'div' } );
|
|
|
|
|
|
|
|
- buildViewConverter().for( editor.data.viewToModel )
|
|
|
|
|
- .fromElement( 'b' )
|
|
|
|
|
- .toAttribute( 'bold', true );
|
|
|
|
|
-
|
|
|
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
|
|
|
|
|
|
|
|
- const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>' );
|
|
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<div>foo</div><div>bom<p>bim</p></div>' );
|
|
|
|
|
|
|
|
expect( stringifyModel( modelFragment ) )
|
|
expect( stringifyModel( modelFragment ) )
|
|
|
.to.equal(
|
|
.to.equal(
|
|
|
- '<div><paragraph>foo</paragraph><paragraph>bar</paragraph></div>' +
|
|
|
|
|
|
|
+ '<div><paragraph>foo</paragraph></div>' +
|
|
|
'<div><paragraph>bom</paragraph><paragraph>bim</paragraph></div>'
|
|
'<div><paragraph>bom</paragraph><paragraph>bim</paragraph></div>'
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should not autopargraph when disallowed element contains allowed element', () => {
|
|
|
|
|
|
|
+ it( 'should autoparagraph text inside disallowed element next to allowed element', () => {
|
|
|
doc.schema.registerItem( 'heading1', '$block' );
|
|
doc.schema.registerItem( 'heading1', '$block' );
|
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
|
|
|
|
|
|
|
@@ -140,7 +128,7 @@ describe( 'Paragraph feature', () => {
|
|
|
.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph>' );
|
|
.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph>' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should not autopargraph when allowed element contains disallowed element', () => {
|
|
|
|
|
|
|
+ it( 'should not autoparagraph text in disallowed element', () => {
|
|
|
doc.schema.registerItem( 'heading1', '$block' );
|
|
doc.schema.registerItem( 'heading1', '$block' );
|
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
|
|
buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
|
|
|
|
|
|
|
@@ -150,6 +138,111 @@ describe( 'Paragraph feature', () => {
|
|
|
.to.equal( '<heading1>foobar</heading1>' );
|
|
.to.equal( '<heading1>foobar</heading1>' );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ describe( 'generic block converter (paragraph-like element handling)', () => {
|
|
|
|
|
+ it( 'should convert h1+h2', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert h1+h2 (in clipboard holder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>', '$clipboardHolder' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert ul,ol>li', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<ul><li>a</li><li>b</li></ul><ol><li>c</li></ol>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert ul,ol>li (in clipboard holder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<ul><li>a</li><li>b</li></ul><ol><li>c</li></ol>', '$clipboardHolder' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert ul>li>ul>li+li', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<ul><li>a<ul><li>b</li><li>c</li></ul></li></ul>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ // "b" is not autoparagraphed because clipboard holder allows text nodes.
|
|
|
|
|
+ // There's a similar integrational test what's going to happen when pasting in paragraph-integration.js.
|
|
|
|
|
+ it( 'should convert ul>li>ul>li+li (in clipboard holder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<ul><li>a<ul><li>b</li><li>c</li></ul></li></ul>', '$clipboardHolder' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( 'a<paragraph>b</paragraph><paragraph>c</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert ul>li>p,text', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<ul><li><p>a</p>b</li></ul>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ // "b" is not autoparagraphed because clipboard holder allows text nodes.
|
|
|
|
|
+ // There's a similar integrational test what's going to happen when pasting in paragraph-integration.js.
|
|
|
|
|
+ it( 'should convert ul>li>p,text (in clipboard holder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<ul><li><p>a</p>b</li></ul>', '$clipboardHolder' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph>b' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert td', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph><paragraph>d</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert td (in clipboardHolder)', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse(
|
|
|
|
|
+ '<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>',
|
|
|
|
|
+ '$clipboardHolder'
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph><paragraph>d</paragraph>' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert li inside converted container', () => {
|
|
|
|
|
+ doc.schema.registerItem( 'div' );
|
|
|
|
|
+ doc.schema.allow( { name: 'div', inside: '$root' } );
|
|
|
|
|
+ doc.schema.allow( { name: 'paragraph', inside: 'div' } );
|
|
|
|
|
+
|
|
|
|
|
+ buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
|
|
|
|
|
+
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal(
|
|
|
|
|
+ '<div><paragraph>foo</paragraph><paragraph>bar</paragraph></div>' +
|
|
|
|
|
+ '<div><paragraph>bom</paragraph><paragraph>bim</paragraph></div>'
|
|
|
|
|
+ );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should convert li inside disallowed container', () => {
|
|
|
|
|
+ const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( stringifyModel( modelFragment ) )
|
|
|
|
|
+ .to.equal(
|
|
|
|
|
+ '<paragraph>foo</paragraph><paragraph>bar</paragraph>' +
|
|
|
|
|
+ '<paragraph>bom</paragraph><paragraph>bim</paragraph>'
|
|
|
|
|
+ );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'editing pipeline conversion', () => {
|
|
describe( 'editing pipeline conversion', () => {
|