Skip to content

Commit

Permalink
fix: incorrect column's width after cell merging
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Apr 8, 2024
1 parent 318c87d commit 681c885
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

table {
border-collapse: collapse;
table-layout: fixed;
table-layout: unset;
width: 100%;
margin: 0;
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const TUI_EDITOR_DEFAULT_EXTENSIONS: ReadonlyArray<
TuiJumpAnchor,
TuiFileLink,
TuiBackgroundColor,
TuiTable,
TuiTable.configure({resizable: true}),
import('@tiptap/extension-table-row').then(({TableRow}) => TableRow),
import('@tiptap/extension-table-cell').then(({TableCell}) => TableCell),
import('@tinkoff/tui-editor').then(({TuiTableCell}) => TuiTableCell),
import('@tiptap/extension-table-header').then(({TableHeader}) => TableHeader),
TuiTabExtension,
TableCellBackground,
Expand Down
14 changes: 14 additions & 0 deletions projects/tui-editor/src/extensions/table-cell/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {mergeAttributes} from '@tiptap/core';
import TableCell from '@tiptap/extension-table-cell';

export const TuiTableCell = TableCell.extend({
renderHTML({HTMLAttributes}) {
const attrs = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes);

if (attrs.colwidth) {
attrs.style = `width: ${attrs.colwidth}px`;
}

return ['td', attrs, 0];
},
});
1 change: 1 addition & 0 deletions projects/tui-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export * from './extensions/media';
export * from './extensions/mention';
export * from './extensions/starter-kit';
export * from './extensions/table';
export * from './extensions/table-cell';
export * from './extensions/table-cell-background';
export * from './extensions/tiptap-node-view';
export * from './extensions/youtube';
Expand Down

0 comments on commit 681c885

Please sign in to comment.