tablepropertiesediting-integration.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  7. import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  8. import TableEditing from '../../src/tableediting';
  9. import TablePropertiesEditing from '../../src/tableproperties/tablepropertiesediting';
  10. import AlignmentEditing from '@ckeditor/ckeditor5-alignment/src/alignmentediting';
  11. import { assertTableStyle } from '../_utils/utils';
  12. describe( 'table properties', () => {
  13. describe( 'TablePropertiesEditing integration', () => {
  14. let editor, model;
  15. afterEach( async () => {
  16. await editor.destroy();
  17. } );
  18. describe( 'Alignment', () => {
  19. let table;
  20. beforeEach( async () => {
  21. editor = await createEditorWithAdditionalPlugins( [ AlignmentEditing ] );
  22. model = editor.model;
  23. table = createEmptyTable();
  24. } );
  25. it( 'should properly downcast table with Alignment plugin enabled', () => {
  26. model.change( writer => writer.setAttribute( 'alignment', 'right', table ) );
  27. assertTableStyle( editor, null, 'float:right;' );
  28. } );
  29. } );
  30. function createEmptyTable() {
  31. setModelData(
  32. model,
  33. '<table headingRows="0" headingColumns="0">' +
  34. '<tableRow>' +
  35. '<tableCell>' +
  36. '<paragraph>foo</paragraph>' +
  37. '</tableCell>' +
  38. '</tableRow>' +
  39. '</table>'
  40. );
  41. return model.document.getRoot().getNodeByPath( [ 0 ] );
  42. }
  43. } );
  44. function createEditorWithAdditionalPlugins( plugins ) {
  45. return VirtualTestEditor.create( {
  46. plugins: [ ...plugins, TablePropertiesEditing, Paragraph, TableEditing ]
  47. } );
  48. }
  49. } );