spacing.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals document */
  6. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  7. import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
  8. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  9. import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
  10. import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
  11. import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
  12. import PasteFromOffice from '../../../src/pastefromoffice';
  13. import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  14. import { getFixtures } from '../../_utils/fixtures';
  15. import { expectModel } from '../../_utils/utils';
  16. describe( 'Spacing – integration', () => {
  17. let element, editor, input;
  18. before( () => {
  19. input = getFixtures( 'spacing' ).input;
  20. element = document.createElement( 'div' );
  21. document.body.appendChild( element );
  22. return ClassicTestEditor
  23. .create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Underline, PasteFromOffice ] } )
  24. .then( editorInstance => {
  25. editor = editorInstance;
  26. } );
  27. } );
  28. beforeEach( () => {
  29. setData( editor.model, '<paragraph>[]</paragraph>' );
  30. } );
  31. after( () => {
  32. editor.destroy();
  33. element.remove();
  34. } );
  35. // Pastes (after cleaning up garbage markup):
  36. //
  37. // <p><span>Foo Bar </span></p>
  38. //
  39. // which should result in the same output as pasting:
  40. //
  41. // <p>Foo Bar </p>
  42. it( 'pastes line with single space', () => {
  43. const expected = '<paragraph>Foo Bar </paragraph>';
  44. expectModel( editor, input.simple, expected );
  45. } );
  46. // Pastes (after cleaning up garbage markup):
  47. //
  48. // <p><span>
  49. // <span style='mso-spacerun:yes'> </span>
  50. // 2Foo <span style='mso-spacerun:yes'> </span>
  51. // 3Bar4 <span style='mso-spacerun:yes'> </span><o:p></o:p>
  52. // </span></p>
  53. //
  54. // which should result in the same output as pasting:
  55. //
  56. // <p> 2Foo 3Bar4 </p>
  57. it( 'pastes single line with multiple spaces', () => {
  58. const expected = '<paragraph> 2Foo 3Bar4 </paragraph>';
  59. expectModel( editor, input.singleLine, expected );
  60. } );
  61. // Pastes (after cleaning up garbage markup):
  62. //
  63. // <p><span>2Foo 3Bar4 <o:p></o:p></span></p>
  64. // <p><span>03 <o:p></o:p></span></p>
  65. // <p><span> 21 <o:p></o:p></span></p>
  66. //
  67. // which should result in the same output as pasting:
  68. //
  69. // <p>2Foo 3Bar4 </p>
  70. // <p>03 </p>
  71. // <p> 21 </p>
  72. it( 'pastes multiple lines with multiple spaces', () => {
  73. const expected = '<paragraph>2Foo 3Bar4 </paragraph>' +
  74. '<paragraph>03 </paragraph>' +
  75. '<paragraph> 21 </paragraph>';
  76. expectModel( editor, input.multiLine, expected );
  77. } );
  78. } );