Skip to content

Commit

Permalink
fix: incorrect column's width after cell merging (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Apr 8, 2024
1 parent d0db4e4 commit 3f58640
Show file tree
Hide file tree
Showing 6 changed files with 25 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 @@ -29,8 +29,10 @@ export const defaultEditorExtensions = [
import(`@tinkoff/tui-editor/extensions/table`).then(({TuiTable}) =>
TuiTable.configure({resizable: true}),
),
import(`@tinkoff/tui-editor/extensions/table-cell`).then(
({TuiTableCell}) => TuiTableCell,
),
import(`@tiptap/extension-table-row`).then(({default: TableRow}) => TableRow),
import(`@tiptap/extension-table-cell`).then(({default: TableCell}) => TableCell),
import(`@tiptap/extension-table-header`).then(({TableHeader}) => TableHeader),
import(`@tinkoff/tui-editor/extensions/indent-outdent`).then(
({TuiTabExtension}) => TuiTabExtension,
Expand Down
1 change: 1 addition & 0 deletions projects/tui-editor/extensions/table-cell/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './table';
5 changes: 5 additions & 0 deletions projects/tui-editor/extensions/table-cell/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "index.ts"
}
}
14 changes: 14 additions & 0 deletions projects/tui-editor/extensions/table-cell/table.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];
},
});
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@taiga-ui/core": ["./taiga-ui/dist/core/index"],
"@taiga-ui/core/*": ["./taiga-ui/dist/core/*"],
"@taiga-ui/i18n": ["./taiga-ui/dist/i18n/index"],
"@taiga-ui/i18n/*": ["./taiga-ui/dist/i18n/*"],
"@taiga-ui/i18n/*": ["./taiga-ui/dist/i18n/*"]
}
}
}

0 comments on commit 3f58640

Please sign in to comment.