ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Missing line-shift when tables are aligned to the left

Open jensen-lin opened this issue 5 years ago • 3 comments

Add a table
align table to left
Add a new table
align table to left
Expected: Tables are below each other same way as if the tables where aligned to center
Actual: Tables are aligned close up

EDIT: We have introduced non-float alignment for images - https://ckeditor.com/docs/ckeditor5/latest/features/images/images-styles.html#presentational-styles - we could introduce same type of extra alignment for tables.

jensen-lin avatar Jun 29 '21 13:06 jensen-lin

Hi thanks for the report. I'll add some visuals here, so anyone reading this ticket doesn't need to reproduce this themselves.

Current state ( I'm using editor.execute( 'tableAlignment', { value: 'left' } ); ) :

https://user-images.githubusercontent.com/34380544/124435241-13523980-dd75-11eb-881d-b4d406b54d9b.mp4

Expected state: table1

I'll convert this into a feature request, so please add 👍 to bumps its popularity.

FilipTokarski avatar Jul 05 '21 07:07 FilipTokarski

We have introduced non-float alignment for images - https://ckeditor.com/docs/ckeditor5/latest/features/images/images-styles.html#presentational-styles - we could introduce same type of extra alignment for tables.

For those who can’t wait until this feature is ready simple plugin which overwrites default behaviour and instead of float styles, it uses margins just like the image plugin does: tableAlign.zip

In order to use this plugin you need to build CKEditor from source: https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/builds/guides/integration/advanced-setup.html#scenario-2-building-from-source

In order to use the plugin in your code you need to set it up as follows:

import TableAlign from './_your_plugins_folder/tableAlign/tableAlign.js';

ClassicEditor.create( document.querySelector( '#editor' ), {
        plugins: [ ...,TableAlign, ...		],
...

obraz

NOTE: If you are using default alignment for tables, you will have to use matching styles as well e.g. Table feature configuration

table: {
    tableProperties: {
	// The default styles for tables in the editor.
	// They should be synchronized with the content styles.
		defaultProperties: {
			alignment: 'left'
		}	
	}
}

Matching CSS styles for HTML page where editor is used

.ck-content .table {
	margin-left: 0 !important;
	margin-right: auto !important;
	display: table;
}

jswiderski avatar Jul 12 '21 07:07 jswiderski

Just a quick update regarding this request.

Starting from CKEditor 5 v47.3.0, new experimental table block-alignment options are available. These options introduce left and right table alignment without text wrapping, effectively covering the main needs described in this issue.

To try them out:

  • Enable:
    config.experimentalFlags.useExtendedTableBlockAlignment
  • Load the experimental UI plugins:
    TablePropertiesUIExperimental and TableCellPropertiesUIExperimental

Details: https://ckeditor.com/docs/ckeditor5/latest/updating/guides/update-to-47.html#new-experimental-options

These improvements resolve the table-style limitations mentioned here (and other issues). The new behavior is planned to become the default in version 48.0.0 (~April).

Witoso avatar Dec 08 '25 14:12 Witoso