@tiptap/extension-table 3.20.1 → 3.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts DELETED
@@ -1,317 +0,0 @@
1
- import { ParentConfig, Node, JSONContent, MarkdownRendererHelpers, Extension } from '@tiptap/core';
2
- import { Node as Node$1, DOMOutputSpec, Schema, Fragment } from '@tiptap/pm/model';
3
- import { EditorView, NodeView, ViewMutationRecord } from '@tiptap/pm/view';
4
-
5
- declare module '@tiptap/core' {
6
- interface NodeConfig<Options, Storage> {
7
- /**
8
- * A string or function to determine the role of the table.
9
- * @default 'table'
10
- * @example () => 'table'
11
- */
12
- tableRole?: string | ((this: {
13
- name: string;
14
- options: Options;
15
- storage: Storage;
16
- parent: ParentConfig<NodeConfig<Options>>['tableRole'];
17
- }) => string);
18
- }
19
- }
20
-
21
- interface TableCellOptions {
22
- /**
23
- * The HTML attributes for a table cell node.
24
- * @default {}
25
- * @example { class: 'foo' }
26
- */
27
- HTMLAttributes: Record<string, any>;
28
- }
29
- /**
30
- * This extension allows you to create table cells.
31
- * @see https://www.tiptap.dev/api/nodes/table-cell
32
- */
33
- declare const TableCell: Node<TableCellOptions, any>;
34
-
35
- interface TableHeaderOptions {
36
- /**
37
- * The HTML attributes for a table header node.
38
- * @default {}
39
- * @example { class: 'foo' }
40
- */
41
- HTMLAttributes: Record<string, any>;
42
- }
43
- /**
44
- * This extension allows you to create table headers.
45
- * @see https://www.tiptap.dev/api/nodes/table-header
46
- */
47
- declare const TableHeader: Node<TableHeaderOptions, any>;
48
-
49
- interface TableRowOptions {
50
- /**
51
- * The HTML attributes for a table row node.
52
- * @default {}
53
- * @example { class: 'foo' }
54
- */
55
- HTMLAttributes: Record<string, any>;
56
- }
57
- /**
58
- * This extension allows you to create table rows.
59
- * @see https://www.tiptap.dev/api/nodes/table-row
60
- */
61
- declare const TableRow: Node<TableRowOptions, any>;
62
-
63
- interface TableOptions {
64
- /**
65
- * HTML attributes for the table element.
66
- * @default {}
67
- * @example { class: 'foo' }
68
- */
69
- HTMLAttributes: Record<string, any>;
70
- /**
71
- * Enables the resizing of tables.
72
- * @default false
73
- * @example true
74
- */
75
- resizable: boolean;
76
- /**
77
- * Controls whether the table should be wrapped in a div with class "tableWrapper" when rendered.
78
- * In editable mode with resizable tables, this wrapper is always present via TableView.
79
- * @default false
80
- * @example true
81
- */
82
- renderWrapper: boolean;
83
- /**
84
- * The width of the resize handle.
85
- * @default 5
86
- * @example 10
87
- */
88
- handleWidth: number;
89
- /**
90
- * The minimum width of a cell.
91
- * @default 25
92
- * @example 50
93
- */
94
- cellMinWidth: number;
95
- /**
96
- * The node view to render the table.
97
- * @default TableView
98
- */
99
- View: (new (node: Node$1, cellMinWidth: number, view: EditorView) => NodeView) | null;
100
- /**
101
- * Enables the resizing of the last column.
102
- * @default true
103
- * @example false
104
- */
105
- lastColumnResizable: boolean;
106
- /**
107
- * Allow table node selection.
108
- * @default false
109
- * @example true
110
- */
111
- allowTableNodeSelection: boolean;
112
- }
113
- declare module '@tiptap/core' {
114
- interface Commands<ReturnType> {
115
- table: {
116
- /**
117
- * Insert a table
118
- * @param options The table attributes
119
- * @returns True if the command was successful, otherwise false
120
- * @example editor.commands.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
121
- */
122
- insertTable: (options?: {
123
- rows?: number;
124
- cols?: number;
125
- withHeaderRow?: boolean;
126
- }) => ReturnType;
127
- /**
128
- * Add a column before the current column
129
- * @returns True if the command was successful, otherwise false
130
- * @example editor.commands.addColumnBefore()
131
- */
132
- addColumnBefore: () => ReturnType;
133
- /**
134
- * Add a column after the current column
135
- * @returns True if the command was successful, otherwise false
136
- * @example editor.commands.addColumnAfter()
137
- */
138
- addColumnAfter: () => ReturnType;
139
- /**
140
- * Delete the current column
141
- * @returns True if the command was successful, otherwise false
142
- * @example editor.commands.deleteColumn()
143
- */
144
- deleteColumn: () => ReturnType;
145
- /**
146
- * Add a row before the current row
147
- * @returns True if the command was successful, otherwise false
148
- * @example editor.commands.addRowBefore()
149
- */
150
- addRowBefore: () => ReturnType;
151
- /**
152
- * Add a row after the current row
153
- * @returns True if the command was successful, otherwise false
154
- * @example editor.commands.addRowAfter()
155
- */
156
- addRowAfter: () => ReturnType;
157
- /**
158
- * Delete the current row
159
- * @returns True if the command was successful, otherwise false
160
- * @example editor.commands.deleteRow()
161
- */
162
- deleteRow: () => ReturnType;
163
- /**
164
- * Delete the current table
165
- * @returns True if the command was successful, otherwise false
166
- * @example editor.commands.deleteTable()
167
- */
168
- deleteTable: () => ReturnType;
169
- /**
170
- * Merge the currently selected cells
171
- * @returns True if the command was successful, otherwise false
172
- * @example editor.commands.mergeCells()
173
- */
174
- mergeCells: () => ReturnType;
175
- /**
176
- * Split the currently selected cell
177
- * @returns True if the command was successful, otherwise false
178
- * @example editor.commands.splitCell()
179
- */
180
- splitCell: () => ReturnType;
181
- /**
182
- * Toggle the header column
183
- * @returns True if the command was successful, otherwise false
184
- * @example editor.commands.toggleHeaderColumn()
185
- */
186
- toggleHeaderColumn: () => ReturnType;
187
- /**
188
- * Toggle the header row
189
- * @returns True if the command was successful, otherwise false
190
- * @example editor.commands.toggleHeaderRow()
191
- */
192
- toggleHeaderRow: () => ReturnType;
193
- /**
194
- * Toggle the header cell
195
- * @returns True if the command was successful, otherwise false
196
- * @example editor.commands.toggleHeaderCell()
197
- */
198
- toggleHeaderCell: () => ReturnType;
199
- /**
200
- * Merge or split the currently selected cells
201
- * @returns True if the command was successful, otherwise false
202
- * @example editor.commands.mergeOrSplit()
203
- */
204
- mergeOrSplit: () => ReturnType;
205
- /**
206
- * Set a cell attribute
207
- * @param name The attribute name
208
- * @param value The attribute value
209
- * @returns True if the command was successful, otherwise false
210
- * @example editor.commands.setCellAttribute('align', 'right')
211
- */
212
- setCellAttribute: (name: string, value: any) => ReturnType;
213
- /**
214
- * Moves the selection to the next cell
215
- * @returns True if the command was successful, otherwise false
216
- * @example editor.commands.goToNextCell()
217
- */
218
- goToNextCell: () => ReturnType;
219
- /**
220
- * Moves the selection to the previous cell
221
- * @returns True if the command was successful, otherwise false
222
- * @example editor.commands.goToPreviousCell()
223
- */
224
- goToPreviousCell: () => ReturnType;
225
- /**
226
- * Try to fix the table structure if necessary
227
- * @returns True if the command was successful, otherwise false
228
- * @example editor.commands.fixTables()
229
- */
230
- fixTables: () => ReturnType;
231
- /**
232
- * Set a cell selection inside the current table
233
- * @param position The cell position
234
- * @returns True if the command was successful, otherwise false
235
- * @example editor.commands.setCellSelection({ anchorCell: 1, headCell: 2 })
236
- */
237
- setCellSelection: (position: {
238
- anchorCell: number;
239
- headCell?: number;
240
- }) => ReturnType;
241
- };
242
- }
243
- }
244
- /**
245
- * This extension allows you to create tables.
246
- * @see https://www.tiptap.dev/api/nodes/table
247
- */
248
- declare const Table: Node<TableOptions, any>;
249
-
250
- type ColGroup = {
251
- colgroup: DOMOutputSpec;
252
- tableWidth: string;
253
- tableMinWidth: string;
254
- } | Record<string, never>;
255
- /**
256
- * Creates a colgroup element for a table node in ProseMirror.
257
- *
258
- * @param node - The ProseMirror node representing the table.
259
- * @param cellMinWidth - The minimum width of a cell in the table.
260
- * @param overrideCol - (Optional) The index of the column to override the width of.
261
- * @param overrideValue - (Optional) The width value to use for the overridden column.
262
- * @returns An object containing the colgroup element, the total width of the table, and the minimum width of the table.
263
- */
264
- declare function createColGroup(node: Node$1, cellMinWidth: number): ColGroup;
265
- declare function createColGroup(node: Node$1, cellMinWidth: number, overrideCol: number, overrideValue: number): ColGroup;
266
-
267
- declare function createTable(schema: Schema, rowsCount: number, colsCount: number, withHeaderRow: boolean, cellContent?: Fragment | Node$1 | Array<Node$1>): Node$1;
268
-
269
- declare const DEFAULT_CELL_LINE_SEPARATOR = "\u001F";
270
- declare function renderTableToMarkdown(node: JSONContent, h: MarkdownRendererHelpers, options?: {
271
- cellLineSeparator?: string;
272
- }): string;
273
-
274
- interface TableKitOptions {
275
- /**
276
- * If set to false, the table extension will not be registered
277
- * @example table: false
278
- */
279
- table: Partial<TableOptions> | false;
280
- /**
281
- * If set to false, the table extension will not be registered
282
- * @example tableCell: false
283
- */
284
- tableCell: Partial<TableCellOptions> | false;
285
- /**
286
- * If set to false, the table extension will not be registered
287
- * @example tableHeader: false
288
- */
289
- tableHeader: Partial<TableHeaderOptions> | false;
290
- /**
291
- * If set to false, the table extension will not be registered
292
- * @example tableRow: false
293
- */
294
- tableRow: Partial<TableRowOptions> | false;
295
- }
296
- /**
297
- * The table kit is a collection of table editor extensions.
298
- *
299
- * It’s a good starting point for building your own table in Tiptap.
300
- */
301
- declare const TableKit: Extension<TableKitOptions, any>;
302
-
303
- declare function updateColumns(node: Node$1, colgroup: HTMLTableColElement, // <colgroup> has the same prototype as <col>
304
- table: HTMLTableElement, cellMinWidth: number, overrideCol?: number, overrideValue?: number): void;
305
- declare class TableView implements NodeView {
306
- node: Node$1;
307
- cellMinWidth: number;
308
- dom: HTMLDivElement;
309
- table: HTMLTableElement;
310
- colgroup: HTMLTableColElement;
311
- contentDOM: HTMLTableSectionElement;
312
- constructor(node: Node$1, cellMinWidth: number);
313
- update(node: Node$1): boolean;
314
- ignoreMutation(mutation: ViewMutationRecord): boolean;
315
- }
316
-
317
- export { type ColGroup, DEFAULT_CELL_LINE_SEPARATOR, Table, TableCell, type TableCellOptions, TableHeader, type TableHeaderOptions, TableKit, type TableKitOptions, type TableOptions, TableRow, type TableRowOptions, TableView, createColGroup, createTable, renderTableToMarkdown, updateColumns };