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
@@ -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 (
<Command.List>{props.search ? <SearchResult /> : <JumpTo />}</Command.List>
<Command.List>{props.result ? <SearchResult /> : <JumpTo />}</Command.List>
);
};
@@ -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 = () => {
<Command.Group heading="Letters">
<Command.Item>a</Command.Item>
<Command.Item>b</Command.Item>
<Command.Separator />
<Command.Item>c</Command.Item>
</Command.Group>
<Command.Item>Apple</Command.Item>
@@ -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 (
<Modal open={open} onClose={onClose} wrapperPosition={['top', 'center']}>
<ModalWrapper
@@ -34,12 +39,12 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
>
<Command>
<StyledModalHeader>
<Input search={search} setSearch={setSearch} />
<Input query={query} setQuery={setQuery} />
<StyledShortcut>{isMac() ? '⌘+K' : 'Ctrl+K'}</StyledShortcut>
</StyledModalHeader>
<StyledModalDivider />
<StyledContent>
<Result search={search} />
<Result result={query} />
</StyledContent>
<StyledModalFooter>
@@ -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<SetStateAction<string>>;
query: string;
setQuery: Dispatch<SetStateAction<string>>;
}) => {
return (
<StyledInputContent>
@@ -12,8 +12,8 @@ const Input = (props: {
<MiddleSearchIcon />
</StyledLabel>
<Command.Input
value={props.search}
onValueChange={props.setSearch}
value={props.query}
onValueChange={props.setQuery}
placeholder="Quick Search..."
/>
</StyledInputContent>