Provides table column resizing for CKEditor 5 in Drupal 11 by integrating the
official CKEditor 5 TableColumnResize plugin bundled with Drupal core.
Column widths are persisted in the formatted HTML of text fields. No separate
database storage is used.
Requirements
- Drupal 11
- CKEditor 5 (provided by Drupal core)
- The core Table CKEditor 5 plugin enabled on the target text format
- CKEditor 5 47.x or later (as bundled with Drupal 11.4+)
Installation
This module is not yet published on Drupal.org. Install it manually or via
Composer path repository until a project page exists.
Manual installation:
- Place the module in
modules/contrib/table_column_resizeor
modules/custom_modules/table_column_resize. - Enable the module:
drush <span class="hljs-keyword">en</span> table_column_resize -<span class="hljs-built_in">y</span> drush cr
After the module is published on Drupal.org, installation via Composer will be:
composer <span class="hljs-built_in">require</span> drupal/table_column_resize drush en table_column_resize -y drush <span class="hljs-literal">cr</span>
Configuration
- Go to Configuration → Content authoring → Text formats and editors.
- Edit the desired text format.
- Ensure Table is enabled under CKEditor 5 plugins.
- Enable Table column resize.
- Under Enabled filters, enable:
- Encode table column widths for storage
- Restore table column width styles
- Save the text format.
The Limit allowed HTML tags field is managed automatically by CKEditor 5 and
will include the required colgroup, col, and data-column-width elements
when the plugin is enabled.
Usage
- Create or edit content that uses a CKEditor 5 formatted text field.
- Insert a table with multiple columns.
- Drag a column boundary to resize a column.
- Save the content.
- Re-open the content in edit mode and confirm the same column widths appear.
- View the content on the frontend and confirm the same widths are rendered.
Technical implementation
CKEditor 5 integration
The module registers CKEditor 5 plugin table.TableColumnResize from Drupal
core's bundled core/ckeditor5.table library. Resizing is handled entirely
by CKEditor 5; this module does not implement a custom resize engine.
The plugin requires the core Table plugin (ckeditor5_table) to be enabled.
HTML representation
CKEditor 5 emits column widths using <colgroup> and <col> elements, for
example:
<table <span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"ck-table-resized"</span>> <span class="xml"><span class="hljs-tag"><<span class="hljs-name">colgroup</span>></span> <span class="hljs-tag"><<span class="hljs-name">col</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 30%;"</span>></span> <span class="hljs-tag"><<span class="hljs-name">col</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 70%;"</span>></span> <span class="hljs-tag"></<span class="hljs-name">colgroup</span>></span> <span class="hljs-tag"><<span class="hljs-name">tbody</span>></span> <span class="hljs-tag"><<span class="hljs-name">tr</span>></span> <span class="hljs-tag"><<span class="hljs-name">td</span>></span>Column 1<span class="hljs-tag"></<span class="hljs-name">td</span>></span> <span class="hljs-tag"><<span class="hljs-name">td</span>></span>Column 2<span class="hljs-tag"></<span class="hljs-name">td</span>></span> <span class="hljs-tag"></<span class="hljs-name">tr</span>></span> <span class="hljs-tag"></<span class="hljs-name">tbody</span>></span> <span class="hljs-tag"></<span class="hljs-name">table</span>></span></span>
Drupal filtering
Drupal's filter_html does not allow arbitrary style attributes. To persist
widths securely, the module converts validated width values to a
data-column-width attribute before filtering:
<<span class="hljs-built_in">col</span> data-column-<span class="hljs-built_in">width</span>=<span class="hljs-string">"30%"</span>>
Two filters implement the encode/restore pipeline:
Filter Weight Purpose Encode table column widths for storage -20 Converts inline styles todata-column-width before filter_html
Restore table column width styles
0
Restores validated inline styles after filter_html for display
Entity presave normalization ensures stored field values use the safe
data-column-width representation.
Frontend rendering
The restore filter re-applies validated inline width styles and attaches a
small frontend library that sets table-layout: fixed on resized tables.
Security
- All editor HTML is treated as untrusted input.
- Width values are validated to allow only
%,px, andptnumeric values. - Values containing
javascript:,expression(, URLs, or other unsafe
content are rejected. filter_htmlremains enabled; this module does not bypass XSS protections.
Testing
Automated tests
.<span class="hljs-regexp">/vendor/</span>bin<span class="hljs-regexp">/phpunit web/m</span>odules<span class="hljs-regexp">/custom_modules/</span>table_column_resize<span class="hljs-regexp">/tests</span>
Test suites:
tests/src/Unit— width validation and markup conversiontests/src/Kernel— plugin discovery and filter pipelinetests/src/Functional— module installation UI
Manual testing
- Enable the module and configure a text format as described above.
- Create a table with at least three columns.
- Drag multiple column boundaries.
- Save, reload the edit form, and inspect stored/rendered HTML.
- Confirm widths match in the editor and on the frontend.
Development
Run PHP syntax checks:
php -l web<span class="hljs-regexp">/modules/</span>custom_modules<span class="hljs-regexp">/table_column_resize/</span>src<span class="hljs-regexp">/Plugin/</span>CKEditor5Plugin<span class="hljs-regexp">/TableColumnResize.php</span>
If Drupal Coder is available in the project:
phpcs <span class="hljs-comment">--standard=Drupal web/modules/custom_modules/table_column_resize</span>
Limitations
TableColumnResizeis marked as a premium CKEditor plugin upstream, but is
bundled in Drupal core's OSS CKEditor build. Verify resize behavior after
major Drupal core upgrades.- Both encode and restore filters must be enabled on each text format.
- CKEditor's native upcast accepts
%andptwidths;pxwidths are
preserved through the Drupal filtering layer when present in editor output.
License
This project is licensed under the GNU General Public License version 2 or later.
Ask your assistant about Table Column Resize
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.x-dev | Dev | 11 | Nov 15, 2026 |