Skip to content

Commit 16fbfcb

Browse files
bdbchCopilot
andauthored
add new option to control table rendering for wrapper (#7141)
* add new option to control table rendering for wrapper * Update packages/extension-table/src/table/table.ts Co-authored-by: Copilot <[email protected]> * Update packages/extension-table/src/table/table.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent f74ce9f commit 16fbfcb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tiptap/extension-table": patch
3+
---
4+
5+
Add a `renderWrapper` option to the Table extension so consumers can customize whether the table wrapper for the resizable node view should be rendered in non-editable mode as well.

packages/extension-table/src/table/table.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ export interface TableOptions {
5757
*/
5858
resizable: boolean
5959

60+
/**
61+
* Controls whether the table should be wrapped in a div with class "tableWrapper" when rendered.
62+
* In editable mode with resizable tables, this wrapper is always present via TableView.
63+
* @default false
64+
* @example true
65+
*/
66+
renderWrapper: boolean
67+
6068
/**
6169
* The width of the resize handle.
6270
* @default 5
@@ -247,6 +255,7 @@ export const Table = Node.create<TableOptions>({
247255
return {
248256
HTMLAttributes: {},
249257
resizable: false,
258+
renderWrapper: false,
250259
handleWidth: 5,
251260
cellMinWidth: 25,
252261
// TODO: fix
@@ -280,7 +289,7 @@ export const Table = Node.create<TableOptions>({
280289
['tbody', 0],
281290
]
282291

283-
return table
292+
return this.options.renderWrapper ? ['div', { class: 'tableWrapper' }, table] : table
284293
},
285294

286295
parseMarkdown: (token: MarkdownTableToken, h) => {

0 commit comments

Comments
 (0)