|
|
@@ -115,6 +115,89 @@ describe( 'Pasting – integration', () => {
|
|
|
} );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'white spaces', () => {
|
|
|
+ // See https://github.com/ckeditor/ckeditor5-clipboard/issues/2#issuecomment-310417731.
|
|
|
+ it( 'keeps spaces around inline styles (Chrome)', () => {
|
|
|
+ return ClassicTestEditor
|
|
|
+ .create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
|
|
|
+ .then( editor => {
|
|
|
+ setData( editor.document, '<paragraph>x[]y</paragraph>' );
|
|
|
+
|
|
|
+ pasteHtml( editor,
|
|
|
+ '<meta charset=\'utf-8\'>' +
|
|
|
+ '<span style="color: rgb(0, 0, 0); font-family: Times;">This is the<span>\u00a0</span></span>' +
|
|
|
+ '<a href="url" style="font-family: Times; font-size: medium;">third developer preview</a>' +
|
|
|
+ '<span style="color: rgb(0, 0, 0); font-family: Times;"><span>\u00a0</span>of<span>\u00a0</span></span>' +
|
|
|
+ '<strong style="color: rgb(0, 0, 0); font-family: Times;">CKEditor\u00a05</strong>' +
|
|
|
+ '<span style="color: rgb(0, 0, 0); font-family: Times;">.</span>'
|
|
|
+ );
|
|
|
+
|
|
|
+ expect( getData( editor.document ) ).to.equal(
|
|
|
+ '<paragraph>' +
|
|
|
+ 'xThis is the ' +
|
|
|
+ '<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
|
|
|
+ '.[]y' +
|
|
|
+ '</paragraph>'
|
|
|
+ );
|
|
|
+
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ // See https://github.com/ckeditor/ckeditor5-clipboard/issues/2#issuecomment-310417731.
|
|
|
+ it( 'keeps spaces around inline styles (Safari)', () => {
|
|
|
+ return ClassicTestEditor
|
|
|
+ .create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
|
|
|
+ .then( editor => {
|
|
|
+ setData( editor.document, '<paragraph>x[]y</paragraph>' );
|
|
|
+
|
|
|
+ /* eslint-disable max-len */
|
|
|
+ pasteHtml( editor,
|
|
|
+ '<span style="color: rgb(0, 0, 0); font-family: -webkit-standard;">This is the<span class="Apple-converted-space">\u00a0</span></span>' +
|
|
|
+ '<a href="url" style="font-family: -webkit-standard; font-style: normal;">third developer preview</a>' +
|
|
|
+ '<span style="color: rgb(0, 0, 0); font-family: -webkit-standard;"><span class="Apple-converted-space">\u00a0</span>of<span class="Apple-converted-space">\u00a0</span></span>' +
|
|
|
+ '<strong style="color: rgb(0, 0, 0); font-family: -webkit-standard;">CKEditor\u00a05</strong>' +
|
|
|
+ '<span style="color: rgb(0, 0, 0); font-family: -webkit-standard;">.</span>'
|
|
|
+ );
|
|
|
+ /* eslint-enable max-len */
|
|
|
+
|
|
|
+ expect( getData( editor.document ) ).to.equal(
|
|
|
+ '<paragraph>' +
|
|
|
+ 'xThis is the ' +
|
|
|
+ '<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
|
|
|
+ '.[]y' +
|
|
|
+ '</paragraph>'
|
|
|
+ );
|
|
|
+
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'keeps spaces around inline styles (Firefox)', () => {
|
|
|
+ return ClassicTestEditor
|
|
|
+ .create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
|
|
|
+ .then( editor => {
|
|
|
+ setData( editor.document, '<paragraph>x[]y</paragraph>' );
|
|
|
+
|
|
|
+ // Note, when copying the HTML from Firefox's console you'll see only normal spaces,
|
|
|
+ // but when you check it later in the model it's still an nbsp.
|
|
|
+ pasteHtml( editor,
|
|
|
+ 'This is the <a href="url">third developer preview</a> of <strong>CKEditor\u00a05</strong>.'
|
|
|
+ );
|
|
|
+
|
|
|
+ expect( getData( editor.document ) ).to.equal(
|
|
|
+ '<paragraph>' +
|
|
|
+ 'xThis is the ' +
|
|
|
+ '<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
|
|
|
+ '.[]y' +
|
|
|
+ '</paragraph>'
|
|
|
+ );
|
|
|
+
|
|
|
+ return editor.destroy();
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
function pasteHtml( editor, html ) {
|