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

Update @notionhq/client to v2.2.15 #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"author": "Richard Robinson",
"license": "ISC",
"dependencies": {
"@notionhq/client": "^1.0.4",
"@notionhq/client": "^2.2.15",
"remark-gfm": "^1.0.0",
"remark-math": "^4.0.0",
"remark-parse": "^9.0.0",
Expand Down
9 changes: 3 additions & 6 deletions src/notion/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {richText, supportedCodeLang} from './common';
import {richText, supportedCodeLang, TableRowBlock} from './common';
import {AppendBlockChildrenParameters} from '@notionhq/client/build/src/api-endpoints';

export type Block = AppendBlockChildrenParameters['children'][number];
Expand Down Expand Up @@ -155,10 +155,7 @@ export function toDo(
};
}

export function table(
children: BlockWithoutChildren[],
tableWidth: number
): Block {
export function table(children: TableRowBlock[], tableWidth: number): Block {
return {
object: 'block',
type: 'table',
Expand All @@ -170,7 +167,7 @@ export function table(
};
}

export function tableRow(cells: RichText[][] = []): BlockWithoutChildren {
export function tableRow(cells: RichText[][] = []): TableRowBlock {
return {
object: 'block',
type: 'table_row',
Expand Down
8 changes: 8 additions & 0 deletions src/notion/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,11 @@ export type supportedCodeLang = typeof SUPPORTED_CODE_BLOCK_LANGUAGES[number];
export function isSupportedCodeLang(lang: string): lang is supportedCodeLang {
return (SUPPORTED_CODE_BLOCK_LANGUAGES as readonly string[]).includes(lang);
}

export interface TableRowBlock {
type: 'table_row';
table_row: {
cells: Array<Array<RichText>>;
};
object?: 'block';
}
12 changes: 6 additions & 6 deletions src/parser/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ function parseList(element: md.List, options: BlocksOptions): notion.Block[] {
});
}

function parseTableCell(node: md.TableCell): notion.RichText[][] {
return [node.children.flatMap(child => parseInline(child))];
function parseTableCell(node: md.TableCell): notion.RichText[] {
return node.children.flatMap(child => parseInline(child));
}

function parseTableRow(node: md.TableRow): notion.BlockWithoutChildren[] {
const tableCells = node.children.flatMap(child => parseTableCell(child));
return [notion.tableRow(tableCells)];
function parseTableRow(node: md.TableRow): notion.TableRowBlock {
const cells = node.children.map(child => parseTableCell(child));
return notion.tableRow(cells);
}

function parseTable(node: md.Table): notion.Block[] {
Expand All @@ -206,7 +206,7 @@ function parseTable(node: md.Table): notion.Block[] {
? node.children[0].children.length
: 0;

const tableRows = node.children.flatMap(child => parseTableRow(child));
const tableRows = node.children.map(child => parseTableRow(child));
return [notion.table(tableRows, tableWidth)];
}

Expand Down