Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/pages/docs/editor-basics/document-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@ The `styles` property is explained below.

While most blocks use an array of `InlineContent` objects to describe their content (e.g.: paragraphs, headings, list items). Some blocks, like [images](/docs/editor-basics/default-schema#image), don't contain any rich text content, so their `content` fields will be `undefined`.

[Tables](/docs/editor-basics/default-schema#table) are also different, as they contain `TableContent`. Here, each table cell is represented as an array of `InlineContent` objects with a width:
[Tables](/docs/editor-basics/default-schema#table) are also different, as they contain `TableContent`. Here, each table cell is represented as an array of `InlineContent` objects with a width, colspan and rowspan:

```typescript
type TableContent = {
type: "tableContent";
rows: {
cells: {
content: InlineContent,
width?: number
width?: number,
colspan?: number,
rowspan?: number
}[][];
}[];
};
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/api/nodeConversions/nodeConversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ export function tableContentToNodes<
}

const cellNode = schema.nodes["tableCell"].create(
{ colwidth: [cell.width] || null },
{
colwidth: [cell.width] || null,
colspan: cell.colspan || 1,
rowspan: cell.rowspan || 1
},
pNode
);
columnNodes.push(cellNode);
Expand Down Expand Up @@ -299,6 +303,8 @@ function contentNodeToTableContent<
cellNode.attrs.colwidth !== null
? cellNode.attrs.colwidth[0]
: undefined,
colspan: cellNode.attrs.colspan || 1,
rowspan: cellNode.attrs.rowspan || 1
});
});

Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/schema/blocks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ export type CellContent<
> = {
content: InlineContent<I, T>[];
width?: number;
colspan?: number;
rowspan?: number;
};

// A BlockConfig has all the information to get the type of a Block (which is a specific instance of the BlockConfig.
Expand Down Expand Up @@ -241,6 +243,8 @@ export type PartialCellContent<
> = {
content: PartialInlineContent<I, T>;
width?: number;
colspan?: number;
rowspan?: number;
};

type PartialBlockFromConfigNoChildren<
Expand Down