Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reintroducing table cell schema changes [TOL-2249] #622

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
14 changes: 14 additions & 0 deletions packages/rich-text-types/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# rich-text-types

Type definitions and constants for the Contentful rich text field type.

## Updating test snapshots

If you want to update the test snapshots simply run

```properties
npm run test:update-snapshots
```

or

```properties
yarn test:update-snapshots
```
3 changes: 2 additions & 1 deletion packages/rich-text-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"build": "yarn generate-json-schema && tsc --module commonjs && rollup -c --bundleConfigAsCjs rollup.config.js",
"start": "tsc && rollup -c --bundleConfigAsCjs rollup.config.js -w",
"generate-json-schema": "ts-node -O '{\"module\": \"commonjs\"}' ./tools/jsonSchemaGen",
"test": "jest"
"test": "jest",
"test:update-snapshots": "jest -u"
},
"devDependencies": {
"@cspotcode/source-map-consumer": "^0.8.0",
Expand Down
15 changes: 14 additions & 1 deletion packages/rich-text-types/src/nodeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ export interface ResourceHyperlink extends Inline {
content: Text[];
}

interface TableCellContent extends Block {
nodeType: BLOCKS.PARAGRAPH | BLOCKS.UL_LIST | BLOCKS.OL_LIST;
z0al marked this conversation as resolved.
Show resolved Hide resolved
}

export interface TableCell extends Block {
nodeType: BLOCKS.TABLE_HEADER_CELL | BLOCKS.TABLE_CELL;
data: {
Expand All @@ -207,11 +211,20 @@ export interface TableCell extends Block {
/**
* @minItems 1
*/
content: Paragraph[];
content: TableCellContent[];
}

// Notice that this is only exported and not reused anywhere else in this file
// this is because this we only want this interface to generate the schema
// if we end up decouping the header cell from the regular cell we
// end up with unwanted side effects when validating the schema
export interface TableHeaderCell extends TableCell {
aodhagan-cf marked this conversation as resolved.
Show resolved Hide resolved
nodeType: BLOCKS.TABLE_HEADER_CELL;

/**
* @minItems 1
*/
content: Paragraph[];
}

// An abstract table row can have both table cell types
Expand Down
Loading
Loading