File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed
packages/react-notion-x/src Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,14 @@ export const Search: React.FC<{
87
87
search ?: SearchNotionFn
88
88
title ?: React . ReactNode
89
89
} > = ( { block, search, title = 'Search' } ) => {
90
- const { searchNotion, rootPageId } = useNotionContext ( )
90
+ const { searchNotion, rootPageId, isShowingSearch } = useNotionContext ( )
91
91
const onSearchNotion = search || searchNotion
92
92
93
- const [ isSearchOpen , setIsSearchOpen ] = React . useState ( false )
93
+ const [ isSearchOpen , setIsSearchOpen ] = React . useState ( isShowingSearch )
94
+ React . useEffect ( ( ) => {
95
+ setIsSearchOpen ( isShowingSearch )
96
+ } , [ isShowingSearch ] )
97
+
94
98
const onOpenSearch = React . useCallback ( ( ) => {
95
99
setIsSearchOpen ( true )
96
100
} , [ ] )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export interface NotionContext {
20
20
mapPageUrl : MapPageUrlFn
21
21
mapImageUrl : MapImageUrlFn
22
22
searchNotion ?: SearchNotionFn
23
+ isShowingSearch ?: boolean
23
24
24
25
rootPageId ?: string
25
26
rootDomain ?: string
@@ -47,6 +48,7 @@ export interface PartialNotionContext {
47
48
mapPageUrl ?: MapPageUrlFn
48
49
mapImageUrl ?: MapImageUrlFn
49
50
searchNotion ?: SearchNotionFn
51
+ isShowingSearch ?: boolean
50
52
51
53
rootPageId ?: string
52
54
rootDomain ?: string
@@ -148,6 +150,7 @@ const defaultNotionContext: NotionContext = {
148
150
mapPageUrl : defaultMapPageUrl ( ) ,
149
151
mapImageUrl : defaultMapImageUrl ,
150
152
searchNotion : null ,
153
+ isShowingSearch : false ,
151
154
152
155
fullPage : false ,
153
156
darkMode : false ,
Original file line number Diff line number Diff line change @@ -6,4 +6,3 @@ export * from './context'
6
6
export * from './components/text'
7
7
export * from './components/header'
8
8
export * from './components/page-icon'
9
- export * from './components/search-dialog'
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export const NotionRenderer: React.FC<{
18
18
mapPageUrl ?: MapPageUrlFn
19
19
mapImageUrl ?: MapImageUrlFn
20
20
searchNotion ?: SearchNotionFn
21
+ isShowingSearch ?: boolean
21
22
22
23
rootPageId ?: string
23
24
rootDomain ?: string
@@ -60,6 +61,7 @@ export const NotionRenderer: React.FC<{
60
61
mapPageUrl,
61
62
mapImageUrl,
62
63
searchNotion,
64
+ isShowingSearch,
63
65
fullPage,
64
66
rootPageId,
65
67
rootDomain,
@@ -94,6 +96,7 @@ export const NotionRenderer: React.FC<{
94
96
mapPageUrl = { mapPageUrl }
95
97
mapImageUrl = { mapImageUrl }
96
98
searchNotion = { searchNotion }
99
+ isShowingSearch = { isShowingSearch }
97
100
fullPage = { fullPage }
98
101
rootPageId = { rootPageId }
99
102
rootDomain = { rootDomain }
You can’t perform that action at this time.
0 commit comments