diff --git a/packages/app/src/components/quick-search/content/index.tsx b/packages/app/src/components/quick-search/content/index.tsx
index 610056f3f3..136d4fb222 100644
--- a/packages/app/src/components/quick-search/content/index.tsx
+++ b/packages/app/src/components/quick-search/content/index.tsx
@@ -3,9 +3,9 @@ import JumpTo from './JumpTo';
import { Command } from 'cmdk';
import SearchResult from './searchResult';
-const Result = (props: { search: string }) => {
+const Result = (props: { result: string }) => {
return (
- {props.search ? : }
+ {props.result ? : }
);
};
diff --git a/packages/app/src/components/quick-search/content/searchResult/index.tsx b/packages/app/src/components/quick-search/content/searchResult/index.tsx
index 2848bb2142..33f14b08d2 100644
--- a/packages/app/src/components/quick-search/content/searchResult/index.tsx
+++ b/packages/app/src/components/quick-search/content/searchResult/index.tsx
@@ -1,7 +1,6 @@
import React from 'react';
import NoResult from './NotFound';
import { Command } from 'cmdk';
-import Store from '@blocksuite/store';
const SearchResult = () => {
return (
@@ -10,7 +9,6 @@ const SearchResult = () => {
a
b
-
c
Apple
diff --git a/packages/app/src/components/quick-search/index.tsx b/packages/app/src/components/quick-search/index.tsx
index 455ff88020..05853b9ad2 100644
--- a/packages/app/src/components/quick-search/index.tsx
+++ b/packages/app/src/components/quick-search/index.tsx
@@ -11,6 +11,7 @@ import Result from './content';
import QuickSearchFooter from './Footer';
import { Command } from 'cmdk';
import { useState } from 'react';
+import { useEditor } from '@/providers/editor-provider';
type TransitionsModalProps = {
open: boolean;
onClose: () => void;
@@ -19,7 +20,11 @@ const isMac = () => {
return /macintosh|mac os x/i.test(navigator.userAgent);
};
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
- const [search, setSearch] = useState('');
+ const [query, setQuery] = useState('');
+ const [result, setResult] = useState({});
+ const { search } = useEditor();
+ const { pageList } = useEditor();
+
return (
{
>
-
+
{isMac() ? '⌘+K' : 'Ctrl+K'}
-
+
diff --git a/packages/app/src/components/quick-search/input.tsx b/packages/app/src/components/quick-search/input.tsx
index cba2814260..69e89927a5 100644
--- a/packages/app/src/components/quick-search/input.tsx
+++ b/packages/app/src/components/quick-search/input.tsx
@@ -3,8 +3,8 @@ import { MiddleSearchIcon } from '@blocksuite/icons';
import { StyledInputContent, StyledLabel } from './style';
import { Command } from 'cmdk';
const Input = (props: {
- search: string;
- setSearch: Dispatch>;
+ query: string;
+ setQuery: Dispatch>;
}) => {
return (
@@ -12,8 +12,8 @@ const Input = (props: {
diff --git a/packages/app/src/providers/editor-provider/editor-provider.tsx b/packages/app/src/providers/editor-provider/editor-provider.tsx
index b22b14622e..8d1931e967 100644
--- a/packages/app/src/providers/editor-provider/editor-provider.tsx
+++ b/packages/app/src/providers/editor-provider/editor-provider.tsx
@@ -6,6 +6,7 @@ import Loading from './loading';
import { Page, Workspace } from '@blocksuite/store';
import { BlockSchema } from '@blocksuite/editor/dist/block-loader';
import { useRouter } from 'next/router';
+import { QueryContent } from '@blocksuite/store/dist/workspace/search';
export interface PageMeta {
id: string;
title: string;
@@ -40,6 +41,7 @@ type EditorHandlers = {
unFavoritePage: (pageId: string) => void;
toggleFavoritePage: (pageId: string) => void;
permanentlyDeletePage: (pageId: string) => void;
+ search: (query: QueryContent) => any;
};
type EditorContextProps = PropsWithChildren<{}>;
@@ -61,6 +63,7 @@ export const EditorContext = createContext({
unFavoritePage: () => {},
toggleFavoritePage: () => {},
permanentlyDeletePage: () => {},
+ search: () => {},
});
export const useEditor = () => useContext(EditorContext);
@@ -137,6 +140,11 @@ export const EditorProvider = ({
workspace?.setPageMeta(pageId, { favorite: !pageMeta.favorite });
}
},
+ search: (query: QueryContent) => {
+ if (query) {
+ return workspace?.search(query);
+ }
+ },
};
return (