Skip to content

Commit fb17ed1

Browse files
🚵
1 parent e9629b6 commit fb17ed1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+315
-178
lines changed

.eslintrc.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"root": true,
33
"extends": ["@fisch0920/eslint-config"],
44
"rules": {
5-
"react/function-component-definition": "off",
65
"react/prop-types": "off",
76
"unicorn/no-array-reduce": "off",
87
"unicorn/filename-case": "off",

.vscode/launch.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Next.js: debug server-side",
6+
"type": "node-terminal",
7+
"request": "launch",
8+
"command": "./node_modules/.bin/next dev",
9+
"cwd": "${workspaceFolder}/examples/minimal"
10+
},
11+
{
12+
"name": "Next.js: debug client-side",
13+
"type": "chrome",
14+
"request": "launch",
15+
"url": "http://localhost:3000"
16+
},
17+
{
18+
"name": "Next.js: debug full stack",
19+
"type": "node",
20+
"request": "launch",
21+
"program": "${workspaceFolder}/examples/minimal/node_modules/.bin/next",
22+
"cwd": "${workspaceFolder}/examples/minimal",
23+
"runtimeArgs": ["--inspect"],
24+
"skipFiles": ["<node_internals>/**"],
25+
"serverReadyAction": {
26+
"action": "debugWithEdge",
27+
"killOnServerStop": true,
28+
"pattern": "- Local:.+(https?://.+)",
29+
"uriFormat": "%s",
30+
"webRoot": "${workspaceFolder}/examples/minimal"
31+
}
32+
}
33+
]
34+
}

examples/full/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "notion-x-example-full",
33
"version": "6.16.2",
44
"private": true,
5-
"type": "commonjs",
5+
"type": "module",
66
"scripts": {
77
"dev": "next dev",
88
"build": "next build",

examples/minimal/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "notion-x-example-minimal",
33
"version": "6.16.1",
44
"private": true,
5-
"type": "commonjs",
5+
"type": "module",
66
"scripts": {
77
"dev": "next dev",
88
"build": "next build",

packages/react-notion-x/src/block.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ const tocIndentLevelCache: {
5353

5454
const pageCoverStyleCache: Record<string, object> = {}
5555

56-
export const Block: React.FC<BlockProps> = (props: BlockProps) => {
56+
export function Block(props: BlockProps) {
57+
console.log('Block', {
58+
id: props.block.id,
59+
type: props.block.type,
60+
level: props.level
61+
})
62+
5763
const ctx = useNotionContext()
5864
const {
5965
components,
@@ -148,6 +154,16 @@ export const Block: React.FC<BlockProps> = (props: BlockProps) => {
148154
const hasAside = !!((hasToc || pageAside) && !page_full_width)
149155
const hasPageCover = !!(pageCover || page_cover)
150156

157+
console.log({
158+
disableHeader,
159+
header,
160+
pageCover,
161+
pageHeader,
162+
pageFooter,
163+
footer,
164+
components
165+
})
166+
151167
return (
152168
<div
153169
className={cs(

packages/react-notion-x/src/components/asset-wrapper.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import { Text } from './text'
99

1010
const urlStyle = { width: '100%' }
1111

12-
export const AssetWrapper: React.FC<{
12+
export function AssetWrapper({
13+
blockId,
14+
block
15+
}: {
1316
blockId: string
1417
block: Block
15-
}> = ({ blockId, block }) => {
18+
}) {
1619
const value = block as BaseContentBlock
1720
const { components, mapPageUrl, rootDomain, zoom } = useNotionContext()
1821

packages/react-notion-x/src/components/asset.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ const supportedAssetTypes = new Set([
2525
'drive'
2626
])
2727

28-
export const Asset: React.FC<{
28+
export function Asset({
29+
block,
30+
zoomable = true,
31+
children
32+
}: {
2933
block: BaseContentBlock
3034
children: any
3135
zoomable?: boolean
32-
}> = ({ block, zoomable = true, children }) => {
36+
}) {
3337
const { recordMap, mapImageUrl, components } = useNotionContext()
3438

3539
if (!block || !supportedAssetTypes.has(block.type)) {

packages/react-notion-x/src/components/audio.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { type AudioBlock } from 'notion-types'
44
import { useNotionContext } from '../context'
55
import { cs } from '../utils'
66

7-
export const Audio: React.FC<{
7+
export function Audio({
8+
block,
9+
className
10+
}: {
811
block: AudioBlock
912
className?: string
10-
}> = ({ block, className }) => {
13+
}) {
1114
const { recordMap } = useNotionContext()
1215
const source =
1316
recordMap.signed_urls[block.id] || block.properties?.source?.[0]?.[0]

packages/react-notion-x/src/components/checkbox.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import type * as React from 'react'
22

33
import CheckIcon from '../icons/check'
44

5-
export const Checkbox: React.FC<{
5+
export function Checkbox({
6+
isChecked
7+
}: {
68
isChecked: boolean
79
blockId?: string
8-
}> = ({ isChecked }) => {
10+
}) {
911
let content = null
1012

1113
if (isChecked) {

packages/react-notion-x/src/components/eoi.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ import { cs, formatNotionDateTime } from '../utils'
77
import { MentionPreviewCard } from './mention-preview-card'
88

99
// External Object Instance
10-
export const EOI: React.FC<{
10+
export function EOI({
11+
block,
12+
inline,
13+
className
14+
}: {
1115
block: Block
1216
inline?: boolean
1317
className?: string
14-
}> = ({ block, inline, className }) => {
18+
}) {
1519
const { components } = useNotionContext()
1620
const { original_url, attributes, domain } = block?.format || {}
1721
if (!original_url || !attributes) {

packages/react-notion-x/src/components/file.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ import { FileIcon } from '../icons/file-icon'
66
import { cs } from '../utils'
77
import { Text } from './text'
88

9-
export const File: React.FC<{
9+
export function File({
10+
block,
11+
className
12+
}: {
1013
block: FileBlock
1114
className?: string
12-
}> = ({ block, className }) => {
15+
}) {
1316
const { components, recordMap } = useNotionContext()
1417
const source =
1518
recordMap.signed_urls[block.id] || block.properties?.source?.[0]?.[0]

packages/react-notion-x/src/components/google-drive.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import { useNotionContext } from '../context'
55
import { cs } from '../utils'
66
import { GracefulImage } from './graceful-image'
77

8-
export const GoogleDrive: React.FC<{
8+
export function GoogleDrive({
9+
block,
10+
className
11+
}: {
912
block: GoogleDriveBlock
1013
className?: string
11-
}> = ({ block, className }) => {
14+
}) {
1215
const { components, mapImageUrl } = useNotionContext()
1316
const properties = block.format?.drive_properties
1417
if (!properties) return null

packages/react-notion-x/src/components/graceful-image.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Img, type ImgProps } from 'react-image'
33

44
import { isBrowser } from '../utils'
55

6-
export const GracefulImage = (props: ImgProps) => {
6+
export function GracefulImage(props: ImgProps) {
77
if (isBrowser) {
88
return <Img {...props} />
99
} else {

packages/react-notion-x/src/components/header.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import { cs } from '../utils'
1010
import { PageIcon } from './page-icon'
1111
import { SearchDialog } from './search-dialog'
1212

13-
export const Header: React.FC<{
13+
export function Header({
14+
block
15+
}: {
1416
block: types.CollectionViewPageBlock | types.PageBlock
15-
}> = ({ block }) => {
17+
}) {
1618
return (
1719
<header className='notion-header'>
1820
<div className='notion-nav-header'>
@@ -23,10 +25,13 @@ export const Header: React.FC<{
2325
)
2426
}
2527

26-
export const Breadcrumbs: React.FC<{
28+
export function Breadcrumbs({
29+
block,
30+
rootOnly = false
31+
}: {
2732
block: types.Block
2833
rootOnly?: boolean
29-
}> = ({ block, rootOnly = false }) => {
34+
}) {
3035
const { recordMap, mapPageUrl, components } = useNotionContext()
3136

3237
const breadcrumbs = React.useMemo(() => {
@@ -81,11 +86,15 @@ export const Breadcrumbs: React.FC<{
8186
)
8287
}
8388

84-
export const Search: React.FC<{
89+
export function Search({
90+
block,
91+
search,
92+
title = 'Search'
93+
}: {
8594
block: types.Block
8695
search?: SearchNotionFn
8796
title?: React.ReactNode
88-
}> = ({ block, search, title = 'Search' }) => {
97+
}) {
8998
const { searchNotion, rootPageId, isShowingSearch, onHideSearch } =
9099
useNotionContext()
91100
const onSearchNotion = search || searchNotion

packages/react-notion-x/src/components/lazy-image.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ import { cs } from '../utils'
88
/**
99
* Progressive, lazy images modeled after Medium's LQIP technique.
1010
*/
11-
export const LazyImage: React.FC<{
12-
src?: string
13-
alt?: string
14-
className?: string
15-
style?: React.CSSProperties
16-
height?: number
17-
zoomable?: boolean
18-
priority?: boolean
19-
}> = ({
11+
export function LazyImage({
2012
src,
2113
alt,
2214
className,
@@ -25,7 +17,15 @@ export const LazyImage: React.FC<{
2517
priority = false,
2618
height,
2719
...rest
28-
}) => {
20+
}: {
21+
src?: string
22+
alt?: string
23+
className?: string
24+
style?: React.CSSProperties
25+
height?: number
26+
zoomable?: boolean
27+
priority?: boolean
28+
}) {
2929
const { recordMap, zoom, previewImages, forceCustomImages, components } =
3030
useNotionContext()
3131
const zoomRef = React.useRef(zoom ? zoom.clone() : null)

packages/react-notion-x/src/components/lite-youtube-embed.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,7 @@ const qs = (params: Record<string, string>) => {
1010
.join('&')
1111
}
1212

13-
export const LiteYouTubeEmbed: React.FC<{
14-
id: string
15-
defaultPlay?: boolean
16-
mute?: boolean
17-
lazyImage?: boolean
18-
iframeTitle?: string
19-
alt?: string
20-
params?: Record<string, string>
21-
adLinksPreconnect?: boolean
22-
style?: React.CSSProperties
23-
className?: string
24-
}> = ({
13+
export function LiteYouTubeEmbed({
2514
id,
2615
defaultPlay = false,
2716
mute = false,
@@ -32,7 +21,18 @@ export const LiteYouTubeEmbed: React.FC<{
3221
adLinksPreconnect = true,
3322
style,
3423
className
35-
}) => {
24+
}: {
25+
id: string
26+
defaultPlay?: boolean
27+
mute?: boolean
28+
lazyImage?: boolean
29+
iframeTitle?: string
30+
alt?: string
31+
params?: Record<string, string>
32+
adLinksPreconnect?: boolean
33+
style?: React.CSSProperties
34+
className?: string
35+
}) {
3636
const muteParam = mute || defaultPlay ? '1' : '0' // Default play must be muted
3737
const queryString = React.useMemo(
3838
() => qs({ autoplay: '1', mute: muteParam, ...params }),

packages/react-notion-x/src/components/mention-preview-card.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ function capitalizeFirstLetter(str?: string) {
66
return str.charAt(0).toUpperCase() + str.slice(1)
77
}
88

9-
export const MentionPreviewCard: React.FC<{
9+
export function MentionPreviewCard({
10+
owner,
11+
lastUpdated,
12+
externalImage,
13+
title,
14+
domain
15+
}: {
1016
owner?: string
1117
lastUpdated?: string | null
1218
title: string
1319
domain: string
1420
externalImage?: React.ReactNode
15-
}> = ({ owner, lastUpdated, externalImage, title, domain }) => {
21+
}) {
1622
return (
1723
<div className='notion-external-subtitle'>
1824
{externalImage && (

packages/react-notion-x/src/components/page-aside.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import * as React from 'react'
44

55
import { cs } from '../utils'
66

7-
export const PageAside: React.FC<{
8-
toc: Array<TableOfContentsEntry>
9-
activeSection: string | null
10-
setActiveSection: (activeSection: string | null) => unknown
11-
hasToc: boolean
12-
hasAside: boolean
13-
pageAside?: React.ReactNode
14-
className?: string
15-
}> = ({
7+
export function PageAside({
168
toc,
179
activeSection,
1810
setActiveSection,
1911
pageAside,
2012
hasToc,
2113
hasAside,
2214
className
23-
}) => {
15+
}: {
16+
toc: Array<TableOfContentsEntry>
17+
activeSection: string | null
18+
setActiveSection: (activeSection: string | null) => unknown
19+
hasToc: boolean
20+
hasAside: boolean
21+
pageAside?: React.ReactNode
22+
className?: string
23+
}) {
2424
const throttleMs = 100
2525
const actionSectionScrollSpy = React.useMemo(
2626
() =>

0 commit comments

Comments
 (0)