fix: fix quick search

This commit is contained in:
JimmFly
2022-12-20 12:50:11 +08:00
parent d5832b1093
commit 45766b6b46
5 changed files with 48 additions and 29 deletions
@@ -7,6 +7,7 @@ import type {
Workspace as StoreWorkspace,
} from '@blocksuite/store';
import type { EditorContainer } from '@blocksuite/editor';
import { QueryContent } from '@blocksuite/store/dist/workspace/search';
export interface AppStateValue {
user: AccessTokenMessage | null;
@@ -32,6 +33,7 @@ export interface AppStateContext extends AppStateValue {
getPageMeta: (pageId: string) => PageMeta | null;
toggleFavoritePage: (pageId: string) => void;
toggleDeletePage: (pageId: string) => void;
search: (query: QueryContent) => Map<string, string | undefined>;
}
export const AppState = createContext<AppStateContext>({
@@ -54,6 +56,7 @@ export const AppState = createContext<AppStateContext>({
getPageMeta: () => null,
toggleFavoritePage: () => {},
toggleDeletePage: () => {},
search: () => new Map<string, string>(),
});
export const useAppState = () => {
@@ -8,6 +8,7 @@ import {
} from '@pathfinder/data-services';
import { AppState } from './context';
import type { AppStateValue, AppStateContext } from './context';
import { QueryContent } from '@blocksuite/store/dist/workspace/search';
const DynamicBlocksuite = dynamic(() => import('./dynamic-blocksuite'), {
ssr: false,
@@ -150,6 +151,10 @@ export const AppStateProvider = ({ children }: { children?: ReactNode }) => {
});
}
},
search: (query: QueryContent) => {
const { currentWorkspace } = state;
return currentWorkspace!.search(query);
},
}),
[state, setState, loadWorkspaceHandler, createEditorHandler]
);