Skip to content

Commit 3ad2718

Browse files
committed
feat: add table, row, and cell borders for improved layout clarit
1 parent 329341e commit 3ad2718

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

src/extensions/Table/Table.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import TiptapTable from '@tiptap/extension-table';
2-
import { TableCell } from '@tiptap/extension-table-cell';
32
import type { TableCellOptions } from '@tiptap/extension-table-cell';
43
import { TableHeader } from '@tiptap/extension-table-header';
54
import type { TableHeaderOptions } from '@tiptap/extension-table-header';
6-
import { TableRow } from '@tiptap/extension-table-row';
75
import type { TableRowOptions } from '@tiptap/extension-table-row';
8-
96
import TableActionButton from '@/extensions/Table/components/TableActionButton';
107
import type { GeneralOptions } from '@/types';
11-
128
import type { TableCellBackgroundOptions } from './cell-background';
139
import { TableCellBackground } from './cell-background';
10+
import { TableRow } from './components/TableRow';
11+
import {TableCell} from "./components/TableCell"
1412

1513
export interface TableOptions extends GeneralOptions<TableOptions> {
1614
HTMLAttributes: Record<string, any>
@@ -32,9 +30,17 @@ export const Table = /* @__PURE__ */ TiptapTable.extend<TableOptions>({
3230
addOptions() {
3331
return {
3432
...this.parent?.(),
33+
HTMLAttributes: {
34+
style: `
35+
border: 1px solid #000;
36+
border-collapse: collapse;
37+
width: 100%;
38+
`,
39+
},
3540
resizable: true,
3641
lastColumnResizable: true,
3742
allowTableNodeSelection: false,
43+
3844
button: ({ editor, t }: any) => ({
3945
component: TableActionButton,
4046
componentProps: {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { TableCell as TBCell } from '@tiptap/extension-table-cell';
2+
3+
export const TableCell = TBCell.extend({
4+
addOptions() {
5+
return {
6+
...this.parent?.(),
7+
HTMLAttributes: {
8+
style: `
9+
border-right: 1px solid #000;
10+
padding: 8px 12px;
11+
&:last-child {
12+
border-right: none;
13+
}
14+
`,
15+
},
16+
};
17+
},
18+
});
19+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { TableRow as TBRow } from "@tiptap/extension-table-row";
2+
3+
export const TableRow = TBRow.extend({
4+
addOptions() {
5+
return {
6+
...this.parent?.(),
7+
HTMLAttributes: {
8+
style: "border-bottom: 1px solid #000;", /* Row borders */
9+
},
10+
};
11+
},
12+
});

0 commit comments

Comments
 (0)