Merge branch 'feat/dev' of github.com:toeverything/AFFiNE into feat/dev

This commit is contained in:
QiShaoXuan
2022-12-09 22:00:49 +08:00
5 changed files with 22 additions and 11 deletions
@@ -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<EditorContextValue>({
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 (