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

Fix block equation display issue #491

Open
wants to merge 4 commits 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
6 changes: 3 additions & 3 deletions examples/cra/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-x-example-cra",
"version": "6.16.0",
"version": "6.16.1",
"private": true,
"scripts": {
"dev": "GENERATE_SOURCEMAP=false react-scripts start",
Expand All @@ -12,10 +12,10 @@
"@types/node": "^16.11.26",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"notion-types": "^6.15.6",
"notion-types": "^6.16.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-notion-x": "^6.16.0",
"react-notion-x": "^6.16.1",
"react-scripts": "5.0.0",
"typescript": "^4.6.3"
},
Expand Down
10 changes: 5 additions & 5 deletions examples/full/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-x-example-full",
"version": "6.16.0",
"version": "6.16.1",
"private": true,
"type": "commonjs",
"scripts": {
Expand All @@ -18,14 +18,14 @@
"got": "^12.0.2",
"lqip-modern": "^1.2.0",
"next": "^12.1.0",
"notion-client": "^6.16.0",
"notion-compat": "^6.16.0",
"notion-utils": "^6.16.0",
"notion-client": "^6.16.1",
"notion-compat": "^6.16.1",
"notion-utils": "^6.16.1",
"p-map": "^5.3.0",
"p-memoize": "^6.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-notion-x": "^6.16.0",
"react-notion-x": "^6.16.1",
"react-tweet-embed": "^2.0.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions examples/minimal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-x-example-minimal",
"version": "6.16.0",
"version": "6.16.1",
"private": true,
"type": "commonjs",
"scripts": {
Expand All @@ -11,11 +11,11 @@
},
"dependencies": {
"next": "^12.1.0",
"notion-client": "^6.16.0",
"notion-utils": "^6.16.0",
"notion-client": "^6.16.1",
"notion-utils": "^6.16.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-notion-x": "^6.16.0"
"react-notion-x": "^6.16.1"
},
"devDependencies": {
"@types/node": "^16.11.2",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "6.16.0",
"version": "6.16.1",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
Expand Down
6 changes: 3 additions & 3 deletions packages/notion-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-client",
"version": "6.16.0",
"version": "6.16.1",
"type": "module",
"description": "Robust TypeScript client for the unofficial Notion API.",
"repository": "NotionX/react-notion-x",
Expand All @@ -23,8 +23,8 @@
},
"dependencies": {
"got": "^11.8.1",
"notion-types": "^6.16.0",
"notion-utils": "^6.16.0",
"notion-types": "^6.16.1",
"notion-utils": "^6.16.1",
"p-map": "^5.3.0"
},
"ava": {
Expand Down
8 changes: 4 additions & 4 deletions packages/notion-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-compat",
"version": "6.16.0",
"version": "6.16.1",
"type": "module",
"description": "Compatibility layer between the official Notion API and unofficial private API.",
"repository": "NotionX/react-notion-x",
Expand All @@ -22,13 +22,13 @@
"test": "ava"
},
"dependencies": {
"notion-types": "^6.16.0",
"notion-utils": "^6.16.0",
"notion-types": "^6.16.1",
"notion-utils": "^6.16.1",
"p-queue": "^7.2.0"
},
"devDependencies": {
"@notionhq/client": "^1.0.4",
"notion-client": "^6.16.0"
"notion-client": "^6.16.1"
},
"peerDependencies": {
"@notionhq/client": "^1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/notion-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-types",
"version": "6.16.0",
"version": "6.16.1",
"type": "module",
"description": "TypeScript types for core Notion data structures.",
"repository": "NotionX/react-notion-x",
Expand Down
4 changes: 2 additions & 2 deletions packages/notion-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-utils",
"version": "6.16.0",
"version": "6.16.1",
"type": "module",
"description": "Useful utilities for working with Notion data. Isomorphic.",
"repository": "NotionX/react-notion-x",
Expand Down Expand Up @@ -31,7 +31,7 @@
"is-url-superb": "^6.1.0",
"mem": "^9.0.2",
"normalize-url": "^7.0.3",
"notion-types": "^6.16.0",
"notion-types": "^6.16.1",
"p-queue": "^7.2.0"
},
"ava": {
Expand Down
19 changes: 17 additions & 2 deletions packages/notion-utils/src/get-page-table-of-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,31 @@ const indentLevels = {
* H1, H2, and H3 elements.
*/
export const getPageTableOfContents = (
page: types.PageBlock,
page: types.PageBlock | types.ColumnBlock,
recordMap: types.ExtendedRecordMap
): Array<TableOfContentsEntry> => {
const toc = (page.content ?? [])
.map((blockId: string) => {
const block = recordMap.block[blockId]?.value

if (block) {
const { type } = block

if (type === 'column_list') {
// loop through its children column
const subToc = (block.content ?? [])
.map((blockId: string) => {
const subBlock = recordMap.block[blockId].value
if (subBlock.type === 'column') {
return getPageTableOfContents(subBlock, recordMap)
}
return null
})
.filter(Boolean)
.flat() as Array<TableOfContentsEntry>

return subToc
}

if (
type === 'header' ||
type === 'sub_header' ||
Expand Down
6 changes: 3 additions & 3 deletions packages/react-notion-x/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-notion-x",
"version": "6.16.0",
"version": "6.16.1",
"type": "module",
"description": "Fast and accurate React renderer for Notion.",
"repository": "NotionX/react-notion-x",
Expand All @@ -25,8 +25,8 @@
"@fisch0920/medium-zoom": "^1.0.7",
"@matejmazur/react-katex": "^3.1.3",
"katex": "^0.15.3",
"notion-types": "^6.16.0",
"notion-utils": "^6.16.0",
"notion-types": "^6.16.1",
"notion-utils": "^6.16.1",
"prismjs": "^1.27.0",
"react-fast-compare": "^3.2.0",
"react-hotkeys-hook": "^3.0.3",
Expand Down
8 changes: 6 additions & 2 deletions packages/react-notion-x/src/third-party/equation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const Equation: React.FC<{
math?: string
inline?: boolean
className?: string
}> = ({ block, math, inline = false, className, ...rest }) => {
}> = ({ block, math, inline, className, ...rest }) => {
const { recordMap } = useNotionContext()
math = math || getBlockTitle(block, recordMap)
if (!math) return null
Expand All @@ -32,7 +32,11 @@ export const Equation: React.FC<{
className
)}
>
<Katex math={math} settings={katexSettings} {...rest} />
{inline ? (
<Katex math={math} settings={katexSettings} {...rest} />
) : (
<Katex math={math} settings={katexSettings} {...rest} block />
)}
</span>
)
}
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9602,11 +9602,6 @@ normalize-url@^7.0.3:
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-7.0.3.tgz"
integrity sha512-RiCOdwdPnzvwcBFJE4iI1ss3dMVRIrEzFpn8ftje6iBfzBInqlnRrNhxcLwBEKjPPXQKzm1Ptlxtaiv9wdcj5w==

notion-types@^6.15.6:
version "6.15.6"
resolved "https://registry.yarnpkg.com/notion-types/-/notion-types-6.15.6.tgz#eabbb28e1c514f421f0ffbf06ecdecd90e8ec8e3"
integrity sha512-JgLWDN4oHg/1sNdHDCeKUfdPl1AYsjOTnYkq+Zn7vITPykxbhw7nIxbAJ7owWUTro1cYTPh+GVmdX0mPiZGujg==

npm-bundled@^1.1.1:
version "1.1.2"
resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz"
Expand Down