@tiptap/extension-table 3.23.5 → 3.24.0
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/cell/index.cjs.map +1 -1
- package/dist/cell/index.js.map +1 -1
- package/dist/header/index.cjs.map +1 -1
- package/dist/header/index.js.map +1 -1
- package/dist/index.cjs +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/kit/index.cjs +19 -7
- package/dist/kit/index.cjs.map +1 -1
- package/dist/kit/index.js +19 -7
- package/dist/kit/index.js.map +1 -1
- package/dist/table/index.cjs +19 -7
- package/dist/table/index.cjs.map +1 -1
- package/dist/table/index.js +19 -7
- package/dist/table/index.js.map +1 -1
- package/package.json +19 -20
- package/src/table/TableView.ts +11 -3
- package/src/table/table.ts +13 -3
- package/src/table/utilities/colStyle.ts +4 -1
- package/src/table/utilities/createColGroup.ts +2 -1
- package/src/table/utilities/markdown.ts +14 -8
- package/src/utilities/parseAlign.ts +5 -1
package/dist/table/index.js
CHANGED
|
@@ -254,7 +254,9 @@ function renderTableToMarkdown(node, h, options = {}) {
|
|
|
254
254
|
rowNode.content.forEach((cellNode) => {
|
|
255
255
|
let raw = "";
|
|
256
256
|
if (cellNode.content && Array.isArray(cellNode.content) && cellNode.content.length > 1) {
|
|
257
|
-
const parts = cellNode.content.map(
|
|
257
|
+
const parts = cellNode.content.map(
|
|
258
|
+
(child) => h.renderChildren(child)
|
|
259
|
+
);
|
|
258
260
|
raw = parts.join(cellSep);
|
|
259
261
|
} else {
|
|
260
262
|
raw = cellNode.content ? h.renderChildren(cellNode.content) : "";
|
|
@@ -271,7 +273,7 @@ function renderTableToMarkdown(node, h, options = {}) {
|
|
|
271
273
|
if (columnCount === 0) {
|
|
272
274
|
return "";
|
|
273
275
|
}
|
|
274
|
-
const colWidths =
|
|
276
|
+
const colWidths = Array.from({ length: columnCount }).fill(0);
|
|
275
277
|
rows.forEach((r) => {
|
|
276
278
|
var _a2;
|
|
277
279
|
for (let i = 0; i < columnCount; i += 1) {
|
|
@@ -288,7 +290,9 @@ function renderTableToMarkdown(node, h, options = {}) {
|
|
|
288
290
|
const pad = (s, width) => s + " ".repeat(Math.max(0, width - s.length));
|
|
289
291
|
const headerRow = rows[0];
|
|
290
292
|
const hasHeader = headerRow.some((c) => c.isHeader);
|
|
291
|
-
const colAlignments =
|
|
293
|
+
const colAlignments = Array.from({
|
|
294
|
+
length: columnCount
|
|
295
|
+
}).fill(null);
|
|
292
296
|
rows.forEach((r) => {
|
|
293
297
|
var _a2;
|
|
294
298
|
for (let i = 0; i < columnCount; i += 1) {
|
|
@@ -298,7 +302,9 @@ function renderTableToMarkdown(node, h, options = {}) {
|
|
|
298
302
|
}
|
|
299
303
|
});
|
|
300
304
|
let out = "\n";
|
|
301
|
-
const headerTexts =
|
|
305
|
+
const headerTexts = Array.from({ length: columnCount }).map(
|
|
306
|
+
(_, i) => hasHeader ? headerRow[i] && headerRow[i].text || "" : ""
|
|
307
|
+
);
|
|
302
308
|
out += `| ${headerTexts.map((t, i) => pad(t, colWidths[i])).join(" | ")} |
|
|
303
309
|
`;
|
|
304
310
|
out += `| ${colWidths.map((w, index) => {
|
|
@@ -318,7 +324,7 @@ function renderTableToMarkdown(node, h, options = {}) {
|
|
|
318
324
|
`;
|
|
319
325
|
const body = hasHeader ? rows.slice(1) : rows;
|
|
320
326
|
body.forEach((r) => {
|
|
321
|
-
out += `| ${
|
|
327
|
+
out += `| ${Array.from({ length: columnCount }).fill(0).map((_, i) => pad(r[i] && r[i].text || "", colWidths[i])).join(" | ")} |
|
|
322
328
|
`;
|
|
323
329
|
});
|
|
324
330
|
return out;
|
|
@@ -378,7 +384,9 @@ var Table = Node.create({
|
|
|
378
384
|
const align = normalizeTableCellAlign((_a = alignments[index]) != null ? _a : cell.align);
|
|
379
385
|
const attrs = align ? { align } : {};
|
|
380
386
|
headerCells.push(
|
|
381
|
-
h.createNode("tableHeader", attrs, [
|
|
387
|
+
h.createNode("tableHeader", attrs, [
|
|
388
|
+
{ type: "paragraph", content: h.parseInline(cell.tokens) }
|
|
389
|
+
])
|
|
382
390
|
);
|
|
383
391
|
});
|
|
384
392
|
rows.push(h.createNode("tableRow", {}, headerCells));
|
|
@@ -390,7 +398,11 @@ var Table = Node.create({
|
|
|
390
398
|
var _a;
|
|
391
399
|
const align = normalizeTableCellAlign((_a = alignments[index]) != null ? _a : cell.align);
|
|
392
400
|
const attrs = align ? { align } : {};
|
|
393
|
-
bodyCells.push(
|
|
401
|
+
bodyCells.push(
|
|
402
|
+
h.createNode("tableCell", attrs, [
|
|
403
|
+
{ type: "paragraph", content: h.parseInline(cell.tokens) }
|
|
404
|
+
])
|
|
405
|
+
);
|
|
394
406
|
});
|
|
395
407
|
rows.push(h.createNode("tableRow", {}, bodyCells));
|
|
396
408
|
});
|
package/dist/table/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/table.ts","../../src/utilities/parseAlign.ts","../../src/table/utilities/colStyle.ts","../../src/table/TableView.ts","../../src/table/utilities/createColGroup.ts","../../src/table/utilities/createCell.ts","../../src/table/utilities/getTableNodeTypes.ts","../../src/table/utilities/createTable.ts","../../src/table/utilities/deleteTableWhenAllCellsSelected.ts","../../src/table/utilities/isCellSelection.ts","../../src/table/utilities/markdown.ts"],"sourcesContent":["import '../types.js'\n\nimport {\n type JSONContent,\n type MarkdownToken,\n callOrReturn,\n getExtensionField,\n mergeAttributes,\n Node,\n} from '@tiptap/core'\nimport type { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { TextSelection } from '@tiptap/pm/state'\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n CellSelection,\n columnResizing,\n deleteColumn,\n deleteRow,\n deleteTable,\n fixTables,\n goToNextCell,\n mergeCells,\n setCellAttr,\n splitCell,\n tableEditing,\n toggleHeader,\n toggleHeaderCell,\n} from '@tiptap/pm/tables'\nimport type { EditorView, NodeView } from '@tiptap/pm/view'\n\nimport { type TableCellAlign, normalizeTableCellAlign } from '../utilities/parseAlign.js'\nimport { TableView } from './TableView.js'\nimport { createColGroup } from './utilities/createColGroup.js'\nimport { createTable } from './utilities/createTable.js'\nimport { deleteTableWhenAllCellsSelected } from './utilities/deleteTableWhenAllCellsSelected.js'\nimport renderTableToMarkdown from './utilities/markdown.js'\n\ntype MarkdownTableToken = {\n align?: Array<TableCellAlign | null>\n header?: { tokens: MarkdownToken[]; align?: TableCellAlign | null }[]\n rows?: { tokens: MarkdownToken[]; align?: TableCellAlign | null }[][]\n} & MarkdownToken\n\nexport interface TableOptions {\n /**\n * HTML attributes for the table element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Enables the resizing of tables.\n * @default false\n * @example true\n */\n resizable: boolean\n\n /**\n * Controls whether the table should be wrapped in a div with class \"tableWrapper\" when rendered.\n * In editable mode with resizable tables, this wrapper is always present via TableView.\n * @default false\n * @example true\n */\n renderWrapper: boolean\n\n /**\n * The width of the resize handle.\n * @default 5\n * @example 10\n */\n handleWidth: number\n\n /**\n * The minimum width of a cell.\n * @default 25\n * @example 50\n */\n cellMinWidth: number\n\n /**\n * The node view to render the table.\n * @default TableView\n */\n View: (new (node: ProseMirrorNode, cellMinWidth: number, view: EditorView) => NodeView) | null\n\n /**\n * Enables the resizing of the last column.\n * @default true\n * @example false\n */\n lastColumnResizable: boolean\n\n /**\n * Allow table node selection.\n * @default false\n * @example true\n */\n allowTableNodeSelection: boolean\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n table: {\n /**\n * Insert a table\n * @param options The table attributes\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.insertTable({ rows: 3, cols: 3, withHeaderRow: true })\n */\n insertTable: (options?: { rows?: number; cols?: number; withHeaderRow?: boolean }) => ReturnType\n\n /**\n * Add a column before the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addColumnBefore()\n */\n addColumnBefore: () => ReturnType\n\n /**\n * Add a column after the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addColumnAfter()\n */\n addColumnAfter: () => ReturnType\n\n /**\n * Delete the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteColumn()\n */\n deleteColumn: () => ReturnType\n\n /**\n * Add a row before the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addRowBefore()\n */\n addRowBefore: () => ReturnType\n\n /**\n * Add a row after the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addRowAfter()\n */\n addRowAfter: () => ReturnType\n\n /**\n * Delete the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteRow()\n */\n deleteRow: () => ReturnType\n\n /**\n * Delete the current table\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteTable()\n */\n deleteTable: () => ReturnType\n\n /**\n * Merge the currently selected cells\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.mergeCells()\n */\n mergeCells: () => ReturnType\n\n /**\n * Split the currently selected cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.splitCell()\n */\n splitCell: () => ReturnType\n\n /**\n * Toggle the header column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderColumn()\n */\n toggleHeaderColumn: () => ReturnType\n\n /**\n * Toggle the header row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderRow()\n */\n toggleHeaderRow: () => ReturnType\n\n /**\n * Toggle the header cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderCell()\n */\n toggleHeaderCell: () => ReturnType\n\n /**\n * Merge or split the currently selected cells\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.mergeOrSplit()\n */\n mergeOrSplit: () => ReturnType\n\n /**\n * Set a cell attribute\n * @param name The attribute name\n * @param value The attribute value\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.setCellAttribute('align', 'right')\n */\n setCellAttribute: (name: string, value: any) => ReturnType\n\n /**\n * Moves the selection to the next cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.goToNextCell()\n */\n goToNextCell: () => ReturnType\n\n /**\n * Moves the selection to the previous cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.goToPreviousCell()\n */\n goToPreviousCell: () => ReturnType\n\n /**\n * Try to fix the table structure if necessary\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.fixTables()\n */\n fixTables: () => ReturnType\n\n /**\n * Set a cell selection inside the current table\n * @param position The cell position\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.setCellSelection({ anchorCell: 1, headCell: 2 })\n */\n setCellSelection: (position: { anchorCell: number; headCell?: number }) => ReturnType\n }\n }\n}\n\n/**\n * This extension allows you to create tables.\n * @see https://www.tiptap.dev/api/nodes/table\n */\nexport const Table = Node.create<TableOptions>({\n name: 'table',\n\n // @ts-ignore\n addOptions() {\n return {\n HTMLAttributes: {},\n resizable: false,\n renderWrapper: false,\n handleWidth: 5,\n cellMinWidth: 25,\n // TODO: fix\n View: TableView,\n lastColumnResizable: true,\n allowTableNodeSelection: false,\n }\n },\n\n content: 'tableRow+',\n\n tableRole: 'table',\n\n isolating: true,\n\n group: 'block',\n\n parseHTML() {\n return [{ tag: 'table' }]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth)\n\n const userStyles = HTMLAttributes.style as string | undefined\n\n function getTableStyle() {\n if (userStyles) {\n return userStyles\n }\n\n return tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`\n }\n\n const table: DOMOutputSpec = [\n 'table',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n style: getTableStyle(),\n }),\n colgroup,\n ['tbody', 0],\n ]\n\n return this.options.renderWrapper ? ['div', { class: 'tableWrapper' }, table] : table\n },\n\n parseMarkdown: (token: MarkdownTableToken, h) => {\n const rows = []\n const alignments = Array.isArray(token.align) ? token.align : []\n\n if (token.header) {\n const headerCells: JSONContent[] = []\n\n token.header.forEach((cell, index) => {\n const align = normalizeTableCellAlign(alignments[index] ?? cell.align)\n const attrs = align ? { align } : {}\n\n headerCells.push(\n h.createNode('tableHeader', attrs, [{ type: 'paragraph', content: h.parseInline(cell.tokens) }]),\n )\n })\n\n rows.push(h.createNode('tableRow', {}, headerCells))\n }\n\n if (token.rows) {\n token.rows.forEach(row => {\n const bodyCells: JSONContent[] = []\n row.forEach((cell, index) => {\n const align = normalizeTableCellAlign(alignments[index] ?? cell.align)\n const attrs = align ? { align } : {}\n\n bodyCells.push(h.createNode('tableCell', attrs, [{ type: 'paragraph', content: h.parseInline(cell.tokens) }]))\n })\n rows.push(h.createNode('tableRow', {}, bodyCells))\n })\n }\n\n return h.createNode('table', undefined, rows)\n },\n\n renderMarkdown: (node, h) => {\n return renderTableToMarkdown(node, h)\n },\n\n addCommands() {\n return {\n insertTable:\n ({ rows = 3, cols = 3, withHeaderRow = true } = {}) =>\n ({ tr, dispatch, editor }) => {\n const node = createTable(editor.schema, rows, cols, withHeaderRow)\n\n if (dispatch) {\n const offset = tr.selection.from + 1\n\n tr.replaceSelectionWith(node)\n .scrollIntoView()\n .setSelection(TextSelection.near(tr.doc.resolve(offset)))\n }\n\n return true\n },\n addColumnBefore:\n () =>\n ({ state, dispatch }) => {\n return addColumnBefore(state, dispatch)\n },\n addColumnAfter:\n () =>\n ({ state, dispatch }) => {\n return addColumnAfter(state, dispatch)\n },\n deleteColumn:\n () =>\n ({ state, dispatch }) => {\n return deleteColumn(state, dispatch)\n },\n addRowBefore:\n () =>\n ({ state, dispatch }) => {\n return addRowBefore(state, dispatch)\n },\n addRowAfter:\n () =>\n ({ state, dispatch }) => {\n return addRowAfter(state, dispatch)\n },\n deleteRow:\n () =>\n ({ state, dispatch }) => {\n return deleteRow(state, dispatch)\n },\n deleteTable:\n () =>\n ({ state, dispatch }) => {\n return deleteTable(state, dispatch)\n },\n mergeCells:\n () =>\n ({ state, dispatch }) => {\n return mergeCells(state, dispatch)\n },\n splitCell:\n () =>\n ({ state, dispatch }) => {\n return splitCell(state, dispatch)\n },\n toggleHeaderColumn:\n () =>\n ({ state, dispatch }) => {\n return toggleHeader('column')(state, dispatch)\n },\n toggleHeaderRow:\n () =>\n ({ state, dispatch }) => {\n return toggleHeader('row')(state, dispatch)\n },\n toggleHeaderCell:\n () =>\n ({ state, dispatch }) => {\n return toggleHeaderCell(state, dispatch)\n },\n mergeOrSplit:\n () =>\n ({ state, dispatch }) => {\n if (mergeCells(state, dispatch)) {\n return true\n }\n\n return splitCell(state, dispatch)\n },\n setCellAttribute:\n (name, value) =>\n ({ state, dispatch }) => {\n return setCellAttr(name, value)(state, dispatch)\n },\n goToNextCell:\n () =>\n ({ state, dispatch }) => {\n return goToNextCell(1)(state, dispatch)\n },\n goToPreviousCell:\n () =>\n ({ state, dispatch }) => {\n return goToNextCell(-1)(state, dispatch)\n },\n fixTables:\n () =>\n ({ state, dispatch }) => {\n if (dispatch) {\n fixTables(state)\n }\n\n return true\n },\n setCellSelection:\n position =>\n ({ tr, dispatch }) => {\n if (dispatch) {\n const selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell)\n\n // @ts-ignore\n tr.setSelection(selection)\n }\n\n return true\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Tab: () => {\n if (this.editor.commands.goToNextCell()) {\n return true\n }\n\n if (!this.editor.can().addRowAfter()) {\n return false\n }\n\n return this.editor.chain().addRowAfter().goToNextCell().run()\n },\n 'Shift-Tab': () => this.editor.commands.goToPreviousCell(),\n Backspace: deleteTableWhenAllCellsSelected,\n 'Mod-Backspace': deleteTableWhenAllCellsSelected,\n Delete: deleteTableWhenAllCellsSelected,\n 'Mod-Delete': deleteTableWhenAllCellsSelected,\n }\n },\n\n addProseMirrorPlugins() {\n const isResizable = this.options.resizable && this.editor.isEditable\n\n return [\n ...(isResizable\n ? [\n columnResizing({\n handleWidth: this.options.handleWidth,\n cellMinWidth: this.options.cellMinWidth,\n defaultCellMinWidth: this.options.cellMinWidth,\n View: this.options.View,\n lastColumnResizable: this.options.lastColumnResizable,\n }),\n ]\n : []),\n tableEditing({\n allowTableNodeSelection: this.options.allowTableNodeSelection,\n }),\n ]\n },\n\n addNodeView() {\n // When resizable, the columnResizing plugin registers its own NodeView.\n // We only register one here for the non-resizable case so that\n // <colgroup> stays in sync with column changes (issue #7015).\n const isResizable = this.options.resizable && this.editor.isEditable\n const View = this.options.View\n\n if (isResizable || !View) {\n return null\n }\n\n return ({ node, view }) => new View(node, this.options.cellMinWidth, view)\n },\n\n extendNodeSchema(extension) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n }\n\n return {\n tableRole: callOrReturn(getExtensionField(extension, 'tableRole', context)),\n }\n },\n})\n","import type { Attribute } from '@tiptap/core'\n\n/**\n * Supported table cell alignment values\n */\nexport enum TableCellAlign {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\n/**\n * Normalize unknown input into a supported table alignment\n *\n * @param value - A potential alignment value\n * @returns A valid TableCellAlign value or null\n */\nexport function normalizeTableCellAlign(value: unknown): TableCellAlign | null {\n if (value === TableCellAlign.Left || value === TableCellAlign.Right || value === TableCellAlign.Center) {\n return value\n }\n\n return null\n}\n\n/**\n * Parse table cell alignment from an HTML element\n *\n * Prefers inline style (${\"`\"}text-align${\"`\"}) and falls back to the legacy\n * ${\"`\"}align${\"`\"} attribute.\n *\n * @param element - The table cell/header DOM element\n * @returns A valid TableCellAlign value or null\n */\nexport function parseAlign(element: HTMLElement): TableCellAlign | null {\n const styleAlign = (element.style.textAlign || '').trim().toLowerCase()\n const attrAlign = (element.getAttribute('align') || '').trim().toLowerCase()\n const align = styleAlign || attrAlign\n\n return normalizeTableCellAlign(align)\n}\n\n/**\n * Normalize alignment from a generic attrs object that may include an align field\n *\n * @param attributes - A node attrs-like object with an optional align field\n * @returns A valid TableCellAlign value or null.\n */\nexport function normalizeTableCellAlignFromAttributes(\n attributes: { align?: TableCellAlign } | null | undefined,\n): TableCellAlign | null {\n return normalizeTableCellAlign(attributes?.align)\n}\n\n/**\n * Create a reusable Tiptap attribute config for table alignment\n *\n * @returns A Tiptap Attribute definition that parses and renders table alignment\n */\nexport function createAlignAttribute(): Attribute {\n return {\n default: null,\n parseHTML: (element: HTMLElement) => parseAlign(element),\n renderHTML: (attributes: { align?: TableCellAlign | null }) => {\n if (!attributes.align) {\n return {}\n }\n\n return {\n style: `text-align: ${attributes.align}`,\n }\n },\n }\n}\n","export function getColStyleDeclaration(minWidth: number, width: number | undefined): [string, string] {\n if (width) {\n // apply the stored width unless it is below the configured minimum cell width\n return ['width', `${Math.max(width, minWidth)}px`]\n }\n\n // set the minimum with on the column if it has no stored width\n return ['min-width', `${minWidth}px`]\n}\n","import type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { NodeView, ViewMutationRecord } from '@tiptap/pm/view'\n\nimport { getColStyleDeclaration } from './utilities/colStyle.js'\n\nexport function updateColumns(\n node: ProseMirrorNode,\n colgroup: HTMLTableColElement, // <colgroup> has the same prototype as <col>\n table: HTMLTableElement,\n cellMinWidth: number,\n overrideCol?: number,\n overrideValue?: number,\n) {\n let totalWidth = 0\n let fixedWidth = true\n let nextDOM = colgroup.firstChild\n const row = node.firstChild\n\n if (row !== null) {\n for (let i = 0, col = 0; i < row.childCount; i += 1) {\n const { colspan, colwidth } = row.child(i).attrs\n\n for (let j = 0; j < colspan; j += 1, col += 1) {\n const hasWidth = overrideCol === col ? overrideValue : ((colwidth && colwidth[j]) as number | undefined)\n const cssWidth = hasWidth ? `${hasWidth}px` : ''\n\n totalWidth += hasWidth || cellMinWidth\n\n if (!hasWidth) {\n fixedWidth = false\n }\n\n if (!nextDOM) {\n const colElement = document.createElement('col')\n\n const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth)\n\n colElement.style.setProperty(propertyKey, propertyValue)\n\n colgroup.appendChild(colElement)\n } else {\n if ((nextDOM as HTMLTableColElement).style.width !== cssWidth) {\n const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth)\n\n ;(nextDOM as HTMLTableColElement).style.setProperty(propertyKey, propertyValue)\n }\n\n nextDOM = nextDOM.nextSibling\n }\n }\n }\n }\n\n while (nextDOM) {\n const after = nextDOM.nextSibling\n\n nextDOM.parentNode?.removeChild(nextDOM)\n nextDOM = after\n }\n\n // Check if user has set a width style on the table node\n const hasUserWidth = node.attrs.style && typeof node.attrs.style === 'string' && /\\bwidth\\s*:/i.test(node.attrs.style)\n\n if (fixedWidth && !hasUserWidth) {\n table.style.width = `${totalWidth}px`\n table.style.minWidth = ''\n } else {\n table.style.width = ''\n table.style.minWidth = `${totalWidth}px`\n }\n}\n\nexport class TableView implements NodeView {\n node: ProseMirrorNode\n\n cellMinWidth: number\n\n dom: HTMLDivElement\n\n table: HTMLTableElement\n\n colgroup: HTMLTableColElement\n\n contentDOM: HTMLTableSectionElement\n\n constructor(node: ProseMirrorNode, cellMinWidth: number) {\n this.node = node\n this.cellMinWidth = cellMinWidth\n this.dom = document.createElement('div')\n this.dom.className = 'tableWrapper'\n this.table = this.dom.appendChild(document.createElement('table'))\n\n // Apply user styles to the table element\n if (node.attrs.style) {\n this.table.style.cssText = node.attrs.style\n }\n\n this.colgroup = this.table.appendChild(document.createElement('colgroup'))\n updateColumns(node, this.colgroup, this.table, cellMinWidth)\n this.contentDOM = this.table.appendChild(document.createElement('tbody'))\n }\n\n update(node: ProseMirrorNode) {\n if (node.type !== this.node.type) {\n return false\n }\n\n this.node = node\n updateColumns(node, this.colgroup, this.table, this.cellMinWidth)\n\n return true\n }\n\n ignoreMutation(mutation: ViewMutationRecord) {\n const target = mutation.target as Node\n const isInsideWrapper = this.dom.contains(target)\n const isInsideContent = this.contentDOM.contains(target)\n\n if (isInsideWrapper && !isInsideContent) {\n if (mutation.type === 'attributes' || mutation.type === 'childList' || mutation.type === 'characterData') {\n return true\n }\n }\n\n return false\n }\n}\n","import type { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nimport { getColStyleDeclaration } from './colStyle.js'\n\nexport type ColGroup =\n | {\n colgroup: DOMOutputSpec\n tableWidth: string\n tableMinWidth: string\n }\n | Record<string, never>\n\n/**\n * Creates a colgroup element for a table node in ProseMirror.\n *\n * @param node - The ProseMirror node representing the table.\n * @param cellMinWidth - The minimum width of a cell in the table.\n * @param overrideCol - (Optional) The index of the column to override the width of.\n * @param overrideValue - (Optional) The width value to use for the overridden column.\n * @returns An object containing the colgroup element, the total width of the table, and the minimum width of the table.\n */\nexport function createColGroup(node: ProseMirrorNode, cellMinWidth: number): ColGroup\nexport function createColGroup(\n node: ProseMirrorNode,\n cellMinWidth: number,\n overrideCol: number,\n overrideValue: number,\n): ColGroup\nexport function createColGroup(\n node: ProseMirrorNode,\n cellMinWidth: number,\n overrideCol?: number,\n overrideValue?: number,\n): ColGroup {\n let totalWidth = 0\n let fixedWidth = true\n const cols: DOMOutputSpec[] = []\n const row = node.firstChild\n\n if (!row) {\n return {}\n }\n\n for (let i = 0, col = 0; i < row.childCount; i += 1) {\n const { colspan, colwidth } = row.child(i).attrs\n\n for (let j = 0; j < colspan; j += 1, col += 1) {\n const hasWidth = overrideCol === col ? overrideValue : colwidth && (colwidth[j] as number | undefined)\n\n totalWidth += hasWidth || cellMinWidth\n\n if (!hasWidth) {\n fixedWidth = false\n }\n\n const [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth)\n\n cols.push(['col', { style: `${property}: ${value}` }])\n }\n }\n\n const tableWidth = fixedWidth ? `${totalWidth}px` : ''\n const tableMinWidth = fixedWidth ? '' : `${totalWidth}px`\n\n const colgroup: DOMOutputSpec = ['colgroup', {}, ...cols]\n\n return { colgroup, tableWidth, tableMinWidth }\n}\n","import type { Fragment, Node as ProsemirrorNode, NodeType } from '@tiptap/pm/model'\n\nexport function createCell(\n cellType: NodeType,\n cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,\n): ProsemirrorNode | null | undefined {\n if (cellContent) {\n return cellType.createChecked(null, cellContent)\n }\n\n return cellType.createAndFill()\n}\n","import type { NodeType, Schema } from '@tiptap/pm/model'\n\nexport function getTableNodeTypes(schema: Schema): { [key: string]: NodeType } {\n if (schema.cached.tableNodeTypes) {\n return schema.cached.tableNodeTypes\n }\n\n const roles: { [key: string]: NodeType } = {}\n\n Object.keys(schema.nodes).forEach(type => {\n const nodeType = schema.nodes[type]\n\n if (nodeType.spec.tableRole) {\n roles[nodeType.spec.tableRole] = nodeType\n }\n })\n\n schema.cached.tableNodeTypes = roles\n\n return roles\n}\n","import type { Fragment, Node as ProsemirrorNode, Schema } from '@tiptap/pm/model'\n\nimport { createCell } from './createCell.js'\nimport { getTableNodeTypes } from './getTableNodeTypes.js'\n\nexport function createTable(\n schema: Schema,\n rowsCount: number,\n colsCount: number,\n withHeaderRow: boolean,\n cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,\n): ProsemirrorNode {\n const types = getTableNodeTypes(schema)\n const headerCells: ProsemirrorNode[] = []\n const cells: ProsemirrorNode[] = []\n\n for (let index = 0; index < colsCount; index += 1) {\n const cell = createCell(types.cell, cellContent)\n\n if (cell) {\n cells.push(cell)\n }\n\n if (withHeaderRow) {\n const headerCell = createCell(types.header_cell, cellContent)\n\n if (headerCell) {\n headerCells.push(headerCell)\n }\n }\n }\n\n const rows: ProsemirrorNode[] = []\n\n for (let index = 0; index < rowsCount; index += 1) {\n rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells))\n }\n\n return types.table.createChecked(null, rows)\n}\n","import type { KeyboardShortcutCommand } from '@tiptap/core'\nimport { findParentNodeClosestToPos } from '@tiptap/core'\n\nimport { isCellSelection } from './isCellSelection.js'\n\nexport const deleteTableWhenAllCellsSelected: KeyboardShortcutCommand = ({ editor }) => {\n const { selection } = editor.state\n\n if (!isCellSelection(selection)) {\n return false\n }\n\n let cellCount = 0\n const table = findParentNodeClosestToPos(selection.ranges[0].$from, node => {\n return node.type.name === 'table'\n })\n\n table?.node.descendants(node => {\n if (node.type.name === 'table') {\n return false\n }\n\n if (['tableCell', 'tableHeader'].includes(node.type.name)) {\n cellCount += 1\n }\n })\n\n const allCellsSelected = cellCount === selection.ranges.length\n\n if (!allCellsSelected) {\n return false\n }\n\n editor.commands.deleteTable()\n\n return true\n}\n","import { CellSelection } from '@tiptap/pm/tables'\n\nexport function isCellSelection(value: unknown): value is CellSelection {\n return value instanceof CellSelection\n}\n","import type { JSONContent, MarkdownRendererHelpers } from '@tiptap/core'\n\nimport {\n type TableCellAlign as TableCellAlignType,\n normalizeTableCellAlignFromAttributes,\n TableCellAlign,\n} from '../../utilities/parseAlign.js'\n\nexport const DEFAULT_CELL_LINE_SEPARATOR = '\\u001F'\n\nfunction collapseWhitespace(s: string) {\n return (s || '').replace(/\\s+/g, ' ').trim()\n}\n\nexport function renderTableToMarkdown(\n node: JSONContent,\n h: MarkdownRendererHelpers,\n options: { cellLineSeparator?: string } = {},\n) {\n const cellSep = options.cellLineSeparator ?? DEFAULT_CELL_LINE_SEPARATOR\n\n if (!node || !node.content || node.content.length === 0) {\n return ''\n }\n\n // Build rows: each cell is { text, isHeader, align }\n const rows: { text: string; isHeader: boolean; align: TableCellAlignType | null }[][] = []\n\n node.content.forEach(rowNode => {\n const cells: { text: string; isHeader: boolean; align: TableCellAlignType | null }[] = []\n\n if (rowNode.content) {\n rowNode.content.forEach(cellNode => {\n let raw = ''\n\n if (cellNode.content && Array.isArray(cellNode.content) && cellNode.content.length > 1) {\n // Render each direct child separately and join with separator so we can split again later\n const parts = cellNode.content.map(child => h.renderChildren(child as unknown as JSONContent))\n raw = parts.join(cellSep)\n } else {\n raw = cellNode.content ? h.renderChildren(cellNode.content as unknown as JSONContent[]) : ''\n }\n\n const text = collapseWhitespace(raw)\n const isHeader = cellNode.type === 'tableHeader'\n const align = normalizeTableCellAlignFromAttributes(cellNode.attrs)\n\n cells.push({ text, isHeader, align })\n })\n }\n\n rows.push(cells)\n })\n\n const columnCount = rows.reduce((max, r) => Math.max(max, r.length), 0)\n\n if (columnCount === 0) {\n return ''\n }\n\n // Compute max width for each column\n const colWidths = new Array(columnCount).fill(0)\n\n rows.forEach(r => {\n for (let i = 0; i < columnCount; i += 1) {\n const cell = r[i]?.text || ''\n const len = cell.length\n if (len > colWidths[i]) {\n colWidths[i] = len\n }\n\n if (colWidths[i] < 3) {\n colWidths[i] = 3\n }\n }\n })\n\n const pad = (s: string, width: number) => s + ' '.repeat(Math.max(0, width - s.length))\n\n const headerRow = rows[0]\n const hasHeader = headerRow.some(c => c.isHeader)\n const colAlignments: Array<TableCellAlignType | null> = new Array(columnCount).fill(null)\n\n rows.forEach(r => {\n for (let i = 0; i < columnCount; i += 1) {\n if (!colAlignments[i] && r[i]?.align) {\n colAlignments[i] = r[i].align\n }\n }\n })\n\n let out = '\\n'\n\n // Render header: if the document has a header row (tableHeader cells) use it,\n // otherwise emit an empty header row so most Markdown parsers will recognize\n // the table (this makes roundtripping to Markdown -> JSON more reliable).\n const headerTexts = new Array(columnCount)\n .fill(0)\n .map((_, i) => (hasHeader ? (headerRow[i] && headerRow[i].text) || '' : ''))\n\n out += `| ${headerTexts.map((t, i) => pad(t, colWidths[i])).join(' | ')} |\\n`\n\n // Separator (use at least 3 dashes per column and include alignment markers)\n out += `| ${colWidths\n .map((w, index) => {\n const dashCount = Math.max(3, w)\n const alignment = colAlignments[index]\n\n if (alignment === TableCellAlign.Left) {\n return `:${'-'.repeat(dashCount)}`\n }\n\n if (alignment === TableCellAlign.Right) {\n return `${'-'.repeat(dashCount)}:`\n }\n\n if (alignment === TableCellAlign.Center) {\n return `:${'-'.repeat(dashCount)}:`\n }\n\n return '-'.repeat(dashCount)\n })\n .join(' | ')} |\\n`\n\n // Body rows: if we had a header, skip the first row; otherwise render all rows\n const body = hasHeader ? rows.slice(1) : rows\n body.forEach(r => {\n out += `| ${new Array(columnCount)\n .fill(0)\n .map((_, i) => pad((r[i] && r[i].text) || '', colWidths[i]))\n .join(' | ')} |\\n`\n })\n\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a,MAAM,KAAK,OAAO,SAAS,iBAAiB;AAAA,MACzD,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,cAAc;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,UAAM,cAAc,KAAK,QAAQ,aAAa,KAAK,OAAO;AAE1D,WAAO;AAAA,MACL,GAAI,cACA;AAAA,QACE,eAAe;AAAA,UACb,aAAa,KAAK,QAAQ;AAAA,UAC1B,cAAc,KAAK,QAAQ;AAAA,UAC3B,qBAAqB,KAAK,QAAQ;AAAA,UAClC,MAAM,KAAK,QAAQ;AAAA,UACnB,qBAAqB,KAAK,QAAQ;AAAA,QACpC,CAAC;AAAA,MACH,IACA,CAAC;AAAA,MACL,aAAa;AAAA,QACX,yBAAyB,KAAK,QAAQ;AAAA,MACxC,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,cAAc;AAIZ,UAAM,cAAc,KAAK,QAAQ,aAAa,KAAK,OAAO;AAC1D,UAAM,OAAO,KAAK,QAAQ;AAE1B,QAAI,eAAe,CAAC,MAAM;AACxB,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,EAAE,MAAM,KAAK,MAAM,IAAI,KAAK,MAAM,KAAK,QAAQ,cAAc,IAAI;AAAA,EAC3E;AAAA,EAEA,iBAAiB,WAAW;AAC1B,UAAM,UAAU;AAAA,MACd,MAAM,UAAU;AAAA,MAChB,SAAS,UAAU;AAAA,MACnB,SAAS,UAAU;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,WAAW,aAAa,kBAAkB,WAAW,aAAa,OAAO,CAAC;AAAA,IAC5E;AAAA,EACF;AACF,CAAC;","names":["CellSelection","_a","CellSelection"]}
|
|
1
|
+
{"version":3,"sources":["../../src/table/table.ts","../../src/utilities/parseAlign.ts","../../src/table/utilities/colStyle.ts","../../src/table/TableView.ts","../../src/table/utilities/createColGroup.ts","../../src/table/utilities/createCell.ts","../../src/table/utilities/getTableNodeTypes.ts","../../src/table/utilities/createTable.ts","../../src/table/utilities/deleteTableWhenAllCellsSelected.ts","../../src/table/utilities/isCellSelection.ts","../../src/table/utilities/markdown.ts"],"sourcesContent":["import '../types.js'\n\nimport {\n type JSONContent,\n type MarkdownToken,\n callOrReturn,\n getExtensionField,\n mergeAttributes,\n Node,\n} from '@tiptap/core'\nimport type { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { TextSelection } from '@tiptap/pm/state'\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n CellSelection,\n columnResizing,\n deleteColumn,\n deleteRow,\n deleteTable,\n fixTables,\n goToNextCell,\n mergeCells,\n setCellAttr,\n splitCell,\n tableEditing,\n toggleHeader,\n toggleHeaderCell,\n} from '@tiptap/pm/tables'\nimport type { EditorView, NodeView } from '@tiptap/pm/view'\n\nimport { type TableCellAlign, normalizeTableCellAlign } from '../utilities/parseAlign.js'\nimport { TableView } from './TableView.js'\nimport { createColGroup } from './utilities/createColGroup.js'\nimport { createTable } from './utilities/createTable.js'\nimport { deleteTableWhenAllCellsSelected } from './utilities/deleteTableWhenAllCellsSelected.js'\nimport renderTableToMarkdown from './utilities/markdown.js'\n\ntype MarkdownTableToken = {\n align?: Array<TableCellAlign | null>\n header?: { tokens: MarkdownToken[]; align?: TableCellAlign | null }[]\n rows?: { tokens: MarkdownToken[]; align?: TableCellAlign | null }[][]\n} & MarkdownToken\n\nexport interface TableOptions {\n /**\n * HTML attributes for the table element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Enables the resizing of tables.\n * @default false\n * @example true\n */\n resizable: boolean\n\n /**\n * Controls whether the table should be wrapped in a div with class \"tableWrapper\" when rendered.\n * In editable mode with resizable tables, this wrapper is always present via TableView.\n * @default false\n * @example true\n */\n renderWrapper: boolean\n\n /**\n * The width of the resize handle.\n * @default 5\n * @example 10\n */\n handleWidth: number\n\n /**\n * The minimum width of a cell.\n * @default 25\n * @example 50\n */\n cellMinWidth: number\n\n /**\n * The node view to render the table.\n * @default TableView\n */\n View: (new (node: ProseMirrorNode, cellMinWidth: number, view: EditorView) => NodeView) | null\n\n /**\n * Enables the resizing of the last column.\n * @default true\n * @example false\n */\n lastColumnResizable: boolean\n\n /**\n * Allow table node selection.\n * @default false\n * @example true\n */\n allowTableNodeSelection: boolean\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n table: {\n /**\n * Insert a table\n * @param options The table attributes\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.insertTable({ rows: 3, cols: 3, withHeaderRow: true })\n */\n insertTable: (options?: {\n rows?: number\n cols?: number\n withHeaderRow?: boolean\n }) => ReturnType\n\n /**\n * Add a column before the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addColumnBefore()\n */\n addColumnBefore: () => ReturnType\n\n /**\n * Add a column after the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addColumnAfter()\n */\n addColumnAfter: () => ReturnType\n\n /**\n * Delete the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteColumn()\n */\n deleteColumn: () => ReturnType\n\n /**\n * Add a row before the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addRowBefore()\n */\n addRowBefore: () => ReturnType\n\n /**\n * Add a row after the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addRowAfter()\n */\n addRowAfter: () => ReturnType\n\n /**\n * Delete the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteRow()\n */\n deleteRow: () => ReturnType\n\n /**\n * Delete the current table\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteTable()\n */\n deleteTable: () => ReturnType\n\n /**\n * Merge the currently selected cells\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.mergeCells()\n */\n mergeCells: () => ReturnType\n\n /**\n * Split the currently selected cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.splitCell()\n */\n splitCell: () => ReturnType\n\n /**\n * Toggle the header column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderColumn()\n */\n toggleHeaderColumn: () => ReturnType\n\n /**\n * Toggle the header row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderRow()\n */\n toggleHeaderRow: () => ReturnType\n\n /**\n * Toggle the header cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderCell()\n */\n toggleHeaderCell: () => ReturnType\n\n /**\n * Merge or split the currently selected cells\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.mergeOrSplit()\n */\n mergeOrSplit: () => ReturnType\n\n /**\n * Set a cell attribute\n * @param name The attribute name\n * @param value The attribute value\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.setCellAttribute('align', 'right')\n */\n setCellAttribute: (name: string, value: any) => ReturnType\n\n /**\n * Moves the selection to the next cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.goToNextCell()\n */\n goToNextCell: () => ReturnType\n\n /**\n * Moves the selection to the previous cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.goToPreviousCell()\n */\n goToPreviousCell: () => ReturnType\n\n /**\n * Try to fix the table structure if necessary\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.fixTables()\n */\n fixTables: () => ReturnType\n\n /**\n * Set a cell selection inside the current table\n * @param position The cell position\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.setCellSelection({ anchorCell: 1, headCell: 2 })\n */\n setCellSelection: (position: { anchorCell: number; headCell?: number }) => ReturnType\n }\n }\n}\n\n/**\n * This extension allows you to create tables.\n * @see https://www.tiptap.dev/api/nodes/table\n */\nexport const Table = Node.create<TableOptions>({\n name: 'table',\n\n // @ts-ignore\n addOptions() {\n return {\n HTMLAttributes: {},\n resizable: false,\n renderWrapper: false,\n handleWidth: 5,\n cellMinWidth: 25,\n // TODO: fix\n View: TableView,\n lastColumnResizable: true,\n allowTableNodeSelection: false,\n }\n },\n\n content: 'tableRow+',\n\n tableRole: 'table',\n\n isolating: true,\n\n group: 'block',\n\n parseHTML() {\n return [{ tag: 'table' }]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth)\n\n const userStyles = HTMLAttributes.style as string | undefined\n\n function getTableStyle() {\n if (userStyles) {\n return userStyles\n }\n\n return tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`\n }\n\n const table: DOMOutputSpec = [\n 'table',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n style: getTableStyle(),\n }),\n colgroup,\n ['tbody', 0],\n ]\n\n return this.options.renderWrapper ? ['div', { class: 'tableWrapper' }, table] : table\n },\n\n parseMarkdown: (token: MarkdownTableToken, h) => {\n const rows = []\n const alignments = Array.isArray(token.align) ? token.align : []\n\n if (token.header) {\n const headerCells: JSONContent[] = []\n\n token.header.forEach((cell, index) => {\n const align = normalizeTableCellAlign(alignments[index] ?? cell.align)\n const attrs = align ? { align } : {}\n\n headerCells.push(\n h.createNode('tableHeader', attrs, [\n { type: 'paragraph', content: h.parseInline(cell.tokens) },\n ]),\n )\n })\n\n rows.push(h.createNode('tableRow', {}, headerCells))\n }\n\n if (token.rows) {\n token.rows.forEach(row => {\n const bodyCells: JSONContent[] = []\n row.forEach((cell, index) => {\n const align = normalizeTableCellAlign(alignments[index] ?? cell.align)\n const attrs = align ? { align } : {}\n\n bodyCells.push(\n h.createNode('tableCell', attrs, [\n { type: 'paragraph', content: h.parseInline(cell.tokens) },\n ]),\n )\n })\n rows.push(h.createNode('tableRow', {}, bodyCells))\n })\n }\n\n return h.createNode('table', undefined, rows)\n },\n\n renderMarkdown: (node, h) => {\n return renderTableToMarkdown(node, h)\n },\n\n addCommands() {\n return {\n insertTable:\n ({ rows = 3, cols = 3, withHeaderRow = true } = {}) =>\n ({ tr, dispatch, editor }) => {\n const node = createTable(editor.schema, rows, cols, withHeaderRow)\n\n if (dispatch) {\n const offset = tr.selection.from + 1\n\n tr.replaceSelectionWith(node)\n .scrollIntoView()\n .setSelection(TextSelection.near(tr.doc.resolve(offset)))\n }\n\n return true\n },\n addColumnBefore:\n () =>\n ({ state, dispatch }) => {\n return addColumnBefore(state, dispatch)\n },\n addColumnAfter:\n () =>\n ({ state, dispatch }) => {\n return addColumnAfter(state, dispatch)\n },\n deleteColumn:\n () =>\n ({ state, dispatch }) => {\n return deleteColumn(state, dispatch)\n },\n addRowBefore:\n () =>\n ({ state, dispatch }) => {\n return addRowBefore(state, dispatch)\n },\n addRowAfter:\n () =>\n ({ state, dispatch }) => {\n return addRowAfter(state, dispatch)\n },\n deleteRow:\n () =>\n ({ state, dispatch }) => {\n return deleteRow(state, dispatch)\n },\n deleteTable:\n () =>\n ({ state, dispatch }) => {\n return deleteTable(state, dispatch)\n },\n mergeCells:\n () =>\n ({ state, dispatch }) => {\n return mergeCells(state, dispatch)\n },\n splitCell:\n () =>\n ({ state, dispatch }) => {\n return splitCell(state, dispatch)\n },\n toggleHeaderColumn:\n () =>\n ({ state, dispatch }) => {\n return toggleHeader('column')(state, dispatch)\n },\n toggleHeaderRow:\n () =>\n ({ state, dispatch }) => {\n return toggleHeader('row')(state, dispatch)\n },\n toggleHeaderCell:\n () =>\n ({ state, dispatch }) => {\n return toggleHeaderCell(state, dispatch)\n },\n mergeOrSplit:\n () =>\n ({ state, dispatch }) => {\n if (mergeCells(state, dispatch)) {\n return true\n }\n\n return splitCell(state, dispatch)\n },\n setCellAttribute:\n (name, value) =>\n ({ state, dispatch }) => {\n return setCellAttr(name, value)(state, dispatch)\n },\n goToNextCell:\n () =>\n ({ state, dispatch }) => {\n return goToNextCell(1)(state, dispatch)\n },\n goToPreviousCell:\n () =>\n ({ state, dispatch }) => {\n return goToNextCell(-1)(state, dispatch)\n },\n fixTables:\n () =>\n ({ state, dispatch }) => {\n if (dispatch) {\n fixTables(state)\n }\n\n return true\n },\n setCellSelection:\n position =>\n ({ tr, dispatch }) => {\n if (dispatch) {\n const selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell)\n\n // @ts-ignore\n tr.setSelection(selection)\n }\n\n return true\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Tab: () => {\n if (this.editor.commands.goToNextCell()) {\n return true\n }\n\n if (!this.editor.can().addRowAfter()) {\n return false\n }\n\n return this.editor.chain().addRowAfter().goToNextCell().run()\n },\n 'Shift-Tab': () => this.editor.commands.goToPreviousCell(),\n Backspace: deleteTableWhenAllCellsSelected,\n 'Mod-Backspace': deleteTableWhenAllCellsSelected,\n Delete: deleteTableWhenAllCellsSelected,\n 'Mod-Delete': deleteTableWhenAllCellsSelected,\n }\n },\n\n addProseMirrorPlugins() {\n const isResizable = this.options.resizable && this.editor.isEditable\n\n return [\n ...(isResizable\n ? [\n columnResizing({\n handleWidth: this.options.handleWidth,\n cellMinWidth: this.options.cellMinWidth,\n defaultCellMinWidth: this.options.cellMinWidth,\n View: this.options.View,\n lastColumnResizable: this.options.lastColumnResizable,\n }),\n ]\n : []),\n tableEditing({\n allowTableNodeSelection: this.options.allowTableNodeSelection,\n }),\n ]\n },\n\n addNodeView() {\n // When resizable, the columnResizing plugin registers its own NodeView.\n // We only register one here for the non-resizable case so that\n // <colgroup> stays in sync with column changes (issue #7015).\n const isResizable = this.options.resizable && this.editor.isEditable\n const View = this.options.View\n\n if (isResizable || !View) {\n return null\n }\n\n return ({ node, view }) => new View(node, this.options.cellMinWidth, view)\n },\n\n extendNodeSchema(extension) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n }\n\n return {\n tableRole: callOrReturn(getExtensionField(extension, 'tableRole', context)),\n }\n },\n})\n","import type { Attribute } from '@tiptap/core'\n\n/**\n * Supported table cell alignment values\n */\nexport enum TableCellAlign {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\n/**\n * Normalize unknown input into a supported table alignment\n *\n * @param value - A potential alignment value\n * @returns A valid TableCellAlign value or null\n */\nexport function normalizeTableCellAlign(value: unknown): TableCellAlign | null {\n if (\n value === TableCellAlign.Left ||\n value === TableCellAlign.Right ||\n value === TableCellAlign.Center\n ) {\n return value\n }\n\n return null\n}\n\n/**\n * Parse table cell alignment from an HTML element\n *\n * Prefers inline style (${\"`\"}text-align${\"`\"}) and falls back to the legacy\n * ${\"`\"}align${\"`\"} attribute.\n *\n * @param element - The table cell/header DOM element\n * @returns A valid TableCellAlign value or null\n */\nexport function parseAlign(element: HTMLElement): TableCellAlign | null {\n const styleAlign = (element.style.textAlign || '').trim().toLowerCase()\n const attrAlign = (element.getAttribute('align') || '').trim().toLowerCase()\n const align = styleAlign || attrAlign\n\n return normalizeTableCellAlign(align)\n}\n\n/**\n * Normalize alignment from a generic attrs object that may include an align field\n *\n * @param attributes - A node attrs-like object with an optional align field\n * @returns A valid TableCellAlign value or null.\n */\nexport function normalizeTableCellAlignFromAttributes(\n attributes: { align?: TableCellAlign } | null | undefined,\n): TableCellAlign | null {\n return normalizeTableCellAlign(attributes?.align)\n}\n\n/**\n * Create a reusable Tiptap attribute config for table alignment\n *\n * @returns A Tiptap Attribute definition that parses and renders table alignment\n */\nexport function createAlignAttribute(): Attribute {\n return {\n default: null,\n parseHTML: (element: HTMLElement) => parseAlign(element),\n renderHTML: (attributes: { align?: TableCellAlign | null }) => {\n if (!attributes.align) {\n return {}\n }\n\n return {\n style: `text-align: ${attributes.align}`,\n }\n },\n }\n}\n","export function getColStyleDeclaration(\n minWidth: number,\n width: number | undefined,\n): [string, string] {\n if (width) {\n // apply the stored width unless it is below the configured minimum cell width\n return ['width', `${Math.max(width, minWidth)}px`]\n }\n\n // set the minimum with on the column if it has no stored width\n return ['min-width', `${minWidth}px`]\n}\n","import type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { NodeView, ViewMutationRecord } from '@tiptap/pm/view'\n\nimport { getColStyleDeclaration } from './utilities/colStyle.js'\n\nexport function updateColumns(\n node: ProseMirrorNode,\n colgroup: HTMLTableColElement, // <colgroup> has the same prototype as <col>\n table: HTMLTableElement,\n cellMinWidth: number,\n overrideCol?: number,\n overrideValue?: number,\n) {\n let totalWidth = 0\n let fixedWidth = true\n let nextDOM = colgroup.firstChild\n const row = node.firstChild\n\n if (row !== null) {\n for (let i = 0, col = 0; i < row.childCount; i += 1) {\n const { colspan, colwidth } = row.child(i).attrs\n\n for (let j = 0; j < colspan; j += 1, col += 1) {\n const hasWidth =\n overrideCol === col ? overrideValue : ((colwidth && colwidth[j]) as number | undefined)\n const cssWidth = hasWidth ? `${hasWidth}px` : ''\n\n totalWidth += hasWidth || cellMinWidth\n\n if (!hasWidth) {\n fixedWidth = false\n }\n\n if (!nextDOM) {\n const colElement = document.createElement('col')\n\n const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth)\n\n colElement.style.setProperty(propertyKey, propertyValue)\n\n colgroup.appendChild(colElement)\n } else {\n if ((nextDOM as HTMLTableColElement).style.width !== cssWidth) {\n const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth)\n\n ;(nextDOM as HTMLTableColElement).style.setProperty(propertyKey, propertyValue)\n }\n\n nextDOM = nextDOM.nextSibling\n }\n }\n }\n }\n\n while (nextDOM) {\n const after = nextDOM.nextSibling\n\n nextDOM.parentNode?.removeChild(nextDOM)\n nextDOM = after\n }\n\n // Check if user has set a width style on the table node\n const hasUserWidth =\n node.attrs.style &&\n typeof node.attrs.style === 'string' &&\n /\\bwidth\\s*:/i.test(node.attrs.style)\n\n if (fixedWidth && !hasUserWidth) {\n table.style.width = `${totalWidth}px`\n table.style.minWidth = ''\n } else {\n table.style.width = ''\n table.style.minWidth = `${totalWidth}px`\n }\n}\n\nexport class TableView implements NodeView {\n node: ProseMirrorNode\n\n cellMinWidth: number\n\n dom: HTMLDivElement\n\n table: HTMLTableElement\n\n colgroup: HTMLTableColElement\n\n contentDOM: HTMLTableSectionElement\n\n constructor(node: ProseMirrorNode, cellMinWidth: number) {\n this.node = node\n this.cellMinWidth = cellMinWidth\n this.dom = document.createElement('div')\n this.dom.className = 'tableWrapper'\n this.table = this.dom.appendChild(document.createElement('table'))\n\n // Apply user styles to the table element\n if (node.attrs.style) {\n this.table.style.cssText = node.attrs.style\n }\n\n this.colgroup = this.table.appendChild(document.createElement('colgroup'))\n updateColumns(node, this.colgroup, this.table, cellMinWidth)\n this.contentDOM = this.table.appendChild(document.createElement('tbody'))\n }\n\n update(node: ProseMirrorNode) {\n if (node.type !== this.node.type) {\n return false\n }\n\n this.node = node\n updateColumns(node, this.colgroup, this.table, this.cellMinWidth)\n\n return true\n }\n\n ignoreMutation(mutation: ViewMutationRecord) {\n const target = mutation.target as Node\n const isInsideWrapper = this.dom.contains(target)\n const isInsideContent = this.contentDOM.contains(target)\n\n if (isInsideWrapper && !isInsideContent) {\n if (\n mutation.type === 'attributes' ||\n mutation.type === 'childList' ||\n mutation.type === 'characterData'\n ) {\n return true\n }\n }\n\n return false\n }\n}\n","import type { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nimport { getColStyleDeclaration } from './colStyle.js'\n\nexport type ColGroup =\n | {\n colgroup: DOMOutputSpec\n tableWidth: string\n tableMinWidth: string\n }\n | Record<string, never>\n\n/**\n * Creates a colgroup element for a table node in ProseMirror.\n *\n * @param node - The ProseMirror node representing the table.\n * @param cellMinWidth - The minimum width of a cell in the table.\n * @param overrideCol - (Optional) The index of the column to override the width of.\n * @param overrideValue - (Optional) The width value to use for the overridden column.\n * @returns An object containing the colgroup element, the total width of the table, and the minimum width of the table.\n */\nexport function createColGroup(node: ProseMirrorNode, cellMinWidth: number): ColGroup\nexport function createColGroup(\n node: ProseMirrorNode,\n cellMinWidth: number,\n overrideCol: number,\n overrideValue: number,\n): ColGroup\nexport function createColGroup(\n node: ProseMirrorNode,\n cellMinWidth: number,\n overrideCol?: number,\n overrideValue?: number,\n): ColGroup {\n let totalWidth = 0\n let fixedWidth = true\n const cols: DOMOutputSpec[] = []\n const row = node.firstChild\n\n if (!row) {\n return {}\n }\n\n for (let i = 0, col = 0; i < row.childCount; i += 1) {\n const { colspan, colwidth } = row.child(i).attrs\n\n for (let j = 0; j < colspan; j += 1, col += 1) {\n const hasWidth =\n overrideCol === col ? overrideValue : colwidth && (colwidth[j] as number | undefined)\n\n totalWidth += hasWidth || cellMinWidth\n\n if (!hasWidth) {\n fixedWidth = false\n }\n\n const [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth)\n\n cols.push(['col', { style: `${property}: ${value}` }])\n }\n }\n\n const tableWidth = fixedWidth ? `${totalWidth}px` : ''\n const tableMinWidth = fixedWidth ? '' : `${totalWidth}px`\n\n const colgroup: DOMOutputSpec = ['colgroup', {}, ...cols]\n\n return { colgroup, tableWidth, tableMinWidth }\n}\n","import type { Fragment, Node as ProsemirrorNode, NodeType } from '@tiptap/pm/model'\n\nexport function createCell(\n cellType: NodeType,\n cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,\n): ProsemirrorNode | null | undefined {\n if (cellContent) {\n return cellType.createChecked(null, cellContent)\n }\n\n return cellType.createAndFill()\n}\n","import type { NodeType, Schema } from '@tiptap/pm/model'\n\nexport function getTableNodeTypes(schema: Schema): { [key: string]: NodeType } {\n if (schema.cached.tableNodeTypes) {\n return schema.cached.tableNodeTypes\n }\n\n const roles: { [key: string]: NodeType } = {}\n\n Object.keys(schema.nodes).forEach(type => {\n const nodeType = schema.nodes[type]\n\n if (nodeType.spec.tableRole) {\n roles[nodeType.spec.tableRole] = nodeType\n }\n })\n\n schema.cached.tableNodeTypes = roles\n\n return roles\n}\n","import type { Fragment, Node as ProsemirrorNode, Schema } from '@tiptap/pm/model'\n\nimport { createCell } from './createCell.js'\nimport { getTableNodeTypes } from './getTableNodeTypes.js'\n\nexport function createTable(\n schema: Schema,\n rowsCount: number,\n colsCount: number,\n withHeaderRow: boolean,\n cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,\n): ProsemirrorNode {\n const types = getTableNodeTypes(schema)\n const headerCells: ProsemirrorNode[] = []\n const cells: ProsemirrorNode[] = []\n\n for (let index = 0; index < colsCount; index += 1) {\n const cell = createCell(types.cell, cellContent)\n\n if (cell) {\n cells.push(cell)\n }\n\n if (withHeaderRow) {\n const headerCell = createCell(types.header_cell, cellContent)\n\n if (headerCell) {\n headerCells.push(headerCell)\n }\n }\n }\n\n const rows: ProsemirrorNode[] = []\n\n for (let index = 0; index < rowsCount; index += 1) {\n rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells))\n }\n\n return types.table.createChecked(null, rows)\n}\n","import type { KeyboardShortcutCommand } from '@tiptap/core'\nimport { findParentNodeClosestToPos } from '@tiptap/core'\n\nimport { isCellSelection } from './isCellSelection.js'\n\nexport const deleteTableWhenAllCellsSelected: KeyboardShortcutCommand = ({ editor }) => {\n const { selection } = editor.state\n\n if (!isCellSelection(selection)) {\n return false\n }\n\n let cellCount = 0\n const table = findParentNodeClosestToPos(selection.ranges[0].$from, node => {\n return node.type.name === 'table'\n })\n\n table?.node.descendants(node => {\n if (node.type.name === 'table') {\n return false\n }\n\n if (['tableCell', 'tableHeader'].includes(node.type.name)) {\n cellCount += 1\n }\n })\n\n const allCellsSelected = cellCount === selection.ranges.length\n\n if (!allCellsSelected) {\n return false\n }\n\n editor.commands.deleteTable()\n\n return true\n}\n","import { CellSelection } from '@tiptap/pm/tables'\n\nexport function isCellSelection(value: unknown): value is CellSelection {\n return value instanceof CellSelection\n}\n","import type { JSONContent, MarkdownRendererHelpers } from '@tiptap/core'\n\nimport {\n type TableCellAlign as TableCellAlignType,\n normalizeTableCellAlignFromAttributes,\n TableCellAlign,\n} from '../../utilities/parseAlign.js'\n\nexport const DEFAULT_CELL_LINE_SEPARATOR = '\\u001F'\n\nfunction collapseWhitespace(s: string) {\n return (s || '').replace(/\\s+/g, ' ').trim()\n}\n\nexport function renderTableToMarkdown(\n node: JSONContent,\n h: MarkdownRendererHelpers,\n options: { cellLineSeparator?: string } = {},\n) {\n const cellSep = options.cellLineSeparator ?? DEFAULT_CELL_LINE_SEPARATOR\n\n if (!node || !node.content || node.content.length === 0) {\n return ''\n }\n\n // Build rows: each cell is { text, isHeader, align }\n const rows: { text: string; isHeader: boolean; align: TableCellAlignType | null }[][] = []\n\n node.content.forEach(rowNode => {\n const cells: { text: string; isHeader: boolean; align: TableCellAlignType | null }[] = []\n\n if (rowNode.content) {\n rowNode.content.forEach(cellNode => {\n let raw = ''\n\n if (cellNode.content && Array.isArray(cellNode.content) && cellNode.content.length > 1) {\n // Render each direct child separately and join with separator so we can split again later\n const parts = cellNode.content.map(child =>\n h.renderChildren(child as unknown as JSONContent),\n )\n raw = parts.join(cellSep)\n } else {\n raw = cellNode.content\n ? h.renderChildren(cellNode.content as unknown as JSONContent[])\n : ''\n }\n\n const text = collapseWhitespace(raw)\n const isHeader = cellNode.type === 'tableHeader'\n const align = normalizeTableCellAlignFromAttributes(cellNode.attrs)\n\n cells.push({ text, isHeader, align })\n })\n }\n\n rows.push(cells)\n })\n\n const columnCount = rows.reduce((max, r) => Math.max(max, r.length), 0)\n\n if (columnCount === 0) {\n return ''\n }\n\n // Compute max width for each column\n const colWidths = Array.from<number>({ length: columnCount }).fill(0)\n\n rows.forEach(r => {\n for (let i = 0; i < columnCount; i += 1) {\n const cell = r[i]?.text || ''\n const len = cell.length\n if (len > colWidths[i]) {\n colWidths[i] = len\n }\n\n if (colWidths[i] < 3) {\n colWidths[i] = 3\n }\n }\n })\n\n const pad = (s: string, width: number) => s + ' '.repeat(Math.max(0, width - s.length))\n\n const headerRow = rows[0]\n const hasHeader = headerRow.some(c => c.isHeader)\n const colAlignments: Array<TableCellAlignType | null> = Array.from<TableCellAlignType | null>({\n length: columnCount,\n }).fill(null)\n\n rows.forEach(r => {\n for (let i = 0; i < columnCount; i += 1) {\n if (!colAlignments[i] && r[i]?.align) {\n colAlignments[i] = r[i].align\n }\n }\n })\n\n let out = '\\n'\n\n // Render header: if the document has a header row (tableHeader cells) use it,\n // otherwise emit an empty header row so most Markdown parsers will recognize\n // the table (this makes roundtripping to Markdown -> JSON more reliable).\n const headerTexts = Array.from<number>({ length: columnCount }).map((_, i) =>\n hasHeader ? (headerRow[i] && headerRow[i].text) || '' : '',\n )\n\n out += `| ${headerTexts.map((t, i) => pad(t, colWidths[i])).join(' | ')} |\\n`\n\n // Separator (use at least 3 dashes per column and include alignment markers)\n out += `| ${colWidths\n .map((w, index) => {\n const dashCount = Math.max(3, w)\n const alignment = colAlignments[index]\n\n if (alignment === TableCellAlign.Left) {\n return `:${'-'.repeat(dashCount)}`\n }\n\n if (alignment === TableCellAlign.Right) {\n return `${'-'.repeat(dashCount)}:`\n }\n\n if (alignment === TableCellAlign.Center) {\n return `:${'-'.repeat(dashCount)}:`\n }\n\n return '-'.repeat(dashCount)\n })\n .join(' | ')} |\\n`\n\n // Body rows: if we had a header, skip the first row; otherwise render all rows\n const body = hasHeader ? rows.slice(1) : rows\n body.forEach(r => {\n out += `| ${Array.from<number>({ length: columnCount })\n .fill(0)\n .map((_, i) => pad((r[i] && r[i].text) || '', colWidths[i]))\n .join(' | ')} |\\n`\n })\n\n return out\n}\n\nexport default renderTableToMarkdown\n"],"mappings":";AAEA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACbA,SAAS,wBAAwB,OAAuC;AAC7E,MACE,UAAU,qBACV,UAAU,uBACV,UAAU,uBACV;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAyBO,SAAS,sCACd,YACuB;AACvB,SAAO,wBAAwB,yCAAY,KAAK;AAClD;;;ACxDO,SAAS,uBACd,UACA,OACkB;AAClB,MAAI,OAAO;AAET,WAAO,CAAC,SAAS,GAAG,KAAK,IAAI,OAAO,QAAQ,CAAC,IAAI;A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,IACH;AAAA,EACF;AAAA,EAEA,cAAc;AAIZ,UAAM,cAAc,KAAK,QAAQ,aAAa,KAAK,OAAO;AAC1D,UAAM,OAAO,KAAK,QAAQ;AAE1B,QAAI,eAAe,CAAC,MAAM;AACxB,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,EAAE,MAAM,KAAK,MAAM,IAAI,KAAK,MAAM,KAAK,QAAQ,cAAc,IAAI;AAAA,EAC3E;AAAA,EAEA,iBAAiB,WAAW;AAC1B,UAAM,UAAU;AAAA,MACd,MAAM,UAAU;AAAA,MAChB,SAAS,UAAU;AAAA,MACnB,SAAS,UAAU;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,WAAW,aAAa,kBAAkB,WAAW,aAAa,OAAO,CAAC;AAAA,IAC5E;AAAA,EACF;AACF,CAAC;","names":["CellSelection","_a","CellSelection"]}
|
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-table",
|
|
3
|
+
"version": "3.24.0",
|
|
3
4
|
"description": "table extension for tiptap",
|
|
4
|
-
"version": "3.23.5",
|
|
5
|
-
"homepage": "https://tiptap.dev",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"tiptap",
|
|
8
7
|
"tiptap extension"
|
|
9
8
|
],
|
|
9
|
+
"homepage": "https://tiptap.dev",
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
14
|
+
"directory": "packages/extension-table"
|
|
15
|
+
},
|
|
11
16
|
"funding": {
|
|
12
17
|
"type": "github",
|
|
13
18
|
"url": "https://github.com/sponsors/ueberdosis"
|
|
14
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
15
24
|
"type": "module",
|
|
25
|
+
"main": "dist/index.cjs",
|
|
26
|
+
"module": "dist/index.js",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
16
28
|
"exports": {
|
|
17
29
|
".": {
|
|
18
30
|
"types": {
|
|
@@ -63,28 +75,15 @@
|
|
|
63
75
|
"require": "./dist/row/index.cjs"
|
|
64
76
|
}
|
|
65
77
|
},
|
|
66
|
-
"main": "dist/index.cjs",
|
|
67
|
-
"module": "dist/index.js",
|
|
68
|
-
"types": "dist/index.d.ts",
|
|
69
|
-
"files": [
|
|
70
|
-
"src",
|
|
71
|
-
"dist"
|
|
72
|
-
],
|
|
73
78
|
"devDependencies": {
|
|
74
|
-
"@tiptap/core": "^3.
|
|
75
|
-
"@tiptap/pm": "^3.
|
|
79
|
+
"@tiptap/core": "^3.24.0",
|
|
80
|
+
"@tiptap/pm": "^3.24.0"
|
|
76
81
|
},
|
|
77
82
|
"peerDependencies": {
|
|
78
|
-
"@tiptap/core": "3.
|
|
79
|
-
"@tiptap/pm": "3.
|
|
80
|
-
},
|
|
81
|
-
"repository": {
|
|
82
|
-
"type": "git",
|
|
83
|
-
"url": "https://github.com/ueberdosis/tiptap",
|
|
84
|
-
"directory": "packages/extension-table"
|
|
83
|
+
"@tiptap/core": "3.24.0",
|
|
84
|
+
"@tiptap/pm": "3.24.0"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
|
-
"build": "tsup"
|
|
88
|
-
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
|
|
87
|
+
"build": "tsup"
|
|
89
88
|
}
|
|
90
89
|
}
|
package/src/table/TableView.ts
CHANGED
|
@@ -21,7 +21,8 @@ export function updateColumns(
|
|
|
21
21
|
const { colspan, colwidth } = row.child(i).attrs
|
|
22
22
|
|
|
23
23
|
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
24
|
-
const hasWidth =
|
|
24
|
+
const hasWidth =
|
|
25
|
+
overrideCol === col ? overrideValue : ((colwidth && colwidth[j]) as number | undefined)
|
|
25
26
|
const cssWidth = hasWidth ? `${hasWidth}px` : ''
|
|
26
27
|
|
|
27
28
|
totalWidth += hasWidth || cellMinWidth
|
|
@@ -59,7 +60,10 @@ export function updateColumns(
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
// Check if user has set a width style on the table node
|
|
62
|
-
const hasUserWidth =
|
|
63
|
+
const hasUserWidth =
|
|
64
|
+
node.attrs.style &&
|
|
65
|
+
typeof node.attrs.style === 'string' &&
|
|
66
|
+
/\bwidth\s*:/i.test(node.attrs.style)
|
|
63
67
|
|
|
64
68
|
if (fixedWidth && !hasUserWidth) {
|
|
65
69
|
table.style.width = `${totalWidth}px`
|
|
@@ -117,7 +121,11 @@ export class TableView implements NodeView {
|
|
|
117
121
|
const isInsideContent = this.contentDOM.contains(target)
|
|
118
122
|
|
|
119
123
|
if (isInsideWrapper && !isInsideContent) {
|
|
120
|
-
if (
|
|
124
|
+
if (
|
|
125
|
+
mutation.type === 'attributes' ||
|
|
126
|
+
mutation.type === 'childList' ||
|
|
127
|
+
mutation.type === 'characterData'
|
|
128
|
+
) {
|
|
121
129
|
return true
|
|
122
130
|
}
|
|
123
131
|
}
|
package/src/table/table.ts
CHANGED
|
@@ -111,7 +111,11 @@ declare module '@tiptap/core' {
|
|
|
111
111
|
* @returns True if the command was successful, otherwise false
|
|
112
112
|
* @example editor.commands.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
|
113
113
|
*/
|
|
114
|
-
insertTable: (options?: {
|
|
114
|
+
insertTable: (options?: {
|
|
115
|
+
rows?: number
|
|
116
|
+
cols?: number
|
|
117
|
+
withHeaderRow?: boolean
|
|
118
|
+
}) => ReturnType
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
121
|
* Add a column before the current column
|
|
@@ -316,7 +320,9 @@ export const Table = Node.create<TableOptions>({
|
|
|
316
320
|
const attrs = align ? { align } : {}
|
|
317
321
|
|
|
318
322
|
headerCells.push(
|
|
319
|
-
h.createNode('tableHeader', attrs, [
|
|
323
|
+
h.createNode('tableHeader', attrs, [
|
|
324
|
+
{ type: 'paragraph', content: h.parseInline(cell.tokens) },
|
|
325
|
+
]),
|
|
320
326
|
)
|
|
321
327
|
})
|
|
322
328
|
|
|
@@ -330,7 +336,11 @@ export const Table = Node.create<TableOptions>({
|
|
|
330
336
|
const align = normalizeTableCellAlign(alignments[index] ?? cell.align)
|
|
331
337
|
const attrs = align ? { align } : {}
|
|
332
338
|
|
|
333
|
-
bodyCells.push(
|
|
339
|
+
bodyCells.push(
|
|
340
|
+
h.createNode('tableCell', attrs, [
|
|
341
|
+
{ type: 'paragraph', content: h.parseInline(cell.tokens) },
|
|
342
|
+
]),
|
|
343
|
+
)
|
|
334
344
|
})
|
|
335
345
|
rows.push(h.createNode('tableRow', {}, bodyCells))
|
|
336
346
|
})
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export function getColStyleDeclaration(
|
|
1
|
+
export function getColStyleDeclaration(
|
|
2
|
+
minWidth: number,
|
|
3
|
+
width: number | undefined,
|
|
4
|
+
): [string, string] {
|
|
2
5
|
if (width) {
|
|
3
6
|
// apply the stored width unless it is below the configured minimum cell width
|
|
4
7
|
return ['width', `${Math.max(width, minWidth)}px`]
|
|
@@ -45,7 +45,8 @@ export function createColGroup(
|
|
|
45
45
|
const { colspan, colwidth } = row.child(i).attrs
|
|
46
46
|
|
|
47
47
|
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
48
|
-
const hasWidth =
|
|
48
|
+
const hasWidth =
|
|
49
|
+
overrideCol === col ? overrideValue : colwidth && (colwidth[j] as number | undefined)
|
|
49
50
|
|
|
50
51
|
totalWidth += hasWidth || cellMinWidth
|
|
51
52
|
|
|
@@ -35,10 +35,14 @@ export function renderTableToMarkdown(
|
|
|
35
35
|
|
|
36
36
|
if (cellNode.content && Array.isArray(cellNode.content) && cellNode.content.length > 1) {
|
|
37
37
|
// Render each direct child separately and join with separator so we can split again later
|
|
38
|
-
const parts = cellNode.content.map(child =>
|
|
38
|
+
const parts = cellNode.content.map(child =>
|
|
39
|
+
h.renderChildren(child as unknown as JSONContent),
|
|
40
|
+
)
|
|
39
41
|
raw = parts.join(cellSep)
|
|
40
42
|
} else {
|
|
41
|
-
raw = cellNode.content
|
|
43
|
+
raw = cellNode.content
|
|
44
|
+
? h.renderChildren(cellNode.content as unknown as JSONContent[])
|
|
45
|
+
: ''
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
const text = collapseWhitespace(raw)
|
|
@@ -59,7 +63,7 @@ export function renderTableToMarkdown(
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
// Compute max width for each column
|
|
62
|
-
const colWidths =
|
|
66
|
+
const colWidths = Array.from<number>({ length: columnCount }).fill(0)
|
|
63
67
|
|
|
64
68
|
rows.forEach(r => {
|
|
65
69
|
for (let i = 0; i < columnCount; i += 1) {
|
|
@@ -79,7 +83,9 @@ export function renderTableToMarkdown(
|
|
|
79
83
|
|
|
80
84
|
const headerRow = rows[0]
|
|
81
85
|
const hasHeader = headerRow.some(c => c.isHeader)
|
|
82
|
-
const colAlignments: Array<TableCellAlignType | null> =
|
|
86
|
+
const colAlignments: Array<TableCellAlignType | null> = Array.from<TableCellAlignType | null>({
|
|
87
|
+
length: columnCount,
|
|
88
|
+
}).fill(null)
|
|
83
89
|
|
|
84
90
|
rows.forEach(r => {
|
|
85
91
|
for (let i = 0; i < columnCount; i += 1) {
|
|
@@ -94,9 +100,9 @@ export function renderTableToMarkdown(
|
|
|
94
100
|
// Render header: if the document has a header row (tableHeader cells) use it,
|
|
95
101
|
// otherwise emit an empty header row so most Markdown parsers will recognize
|
|
96
102
|
// the table (this makes roundtripping to Markdown -> JSON more reliable).
|
|
97
|
-
const headerTexts =
|
|
98
|
-
.
|
|
99
|
-
|
|
103
|
+
const headerTexts = Array.from<number>({ length: columnCount }).map((_, i) =>
|
|
104
|
+
hasHeader ? (headerRow[i] && headerRow[i].text) || '' : '',
|
|
105
|
+
)
|
|
100
106
|
|
|
101
107
|
out += `| ${headerTexts.map((t, i) => pad(t, colWidths[i])).join(' | ')} |\n`
|
|
102
108
|
|
|
@@ -125,7 +131,7 @@ export function renderTableToMarkdown(
|
|
|
125
131
|
// Body rows: if we had a header, skip the first row; otherwise render all rows
|
|
126
132
|
const body = hasHeader ? rows.slice(1) : rows
|
|
127
133
|
body.forEach(r => {
|
|
128
|
-
out += `| ${
|
|
134
|
+
out += `| ${Array.from<number>({ length: columnCount })
|
|
129
135
|
.fill(0)
|
|
130
136
|
.map((_, i) => pad((r[i] && r[i].text) || '', colWidths[i]))
|
|
131
137
|
.join(' | ')} |\n`
|
|
@@ -16,7 +16,11 @@ export enum TableCellAlign {
|
|
|
16
16
|
* @returns A valid TableCellAlign value or null
|
|
17
17
|
*/
|
|
18
18
|
export function normalizeTableCellAlign(value: unknown): TableCellAlign | null {
|
|
19
|
-
if (
|
|
19
|
+
if (
|
|
20
|
+
value === TableCellAlign.Left ||
|
|
21
|
+
value === TableCellAlign.Right ||
|
|
22
|
+
value === TableCellAlign.Center
|
|
23
|
+
) {
|
|
20
24
|
return value
|
|
21
25
|
}
|
|
22
26
|
|