mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 04:51:49 +08:00
feat: placeholder adapts to the public state
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { AddIcon } from '@blocksuite/icons';
|
import { AddIcon } from '@blocksuite/icons';
|
||||||
import { StyledModalFooterContent } from './style';
|
import { StyledModalFooterContent } from './style';
|
||||||
import { useModal } from '@/providers/global-modal-provider';
|
import { useModal } from '@/providers/global-modal-provider';
|
||||||
import { useAppState } from '@/providers/app-state-provider/context';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
import { Command } from 'cmdk';
|
import { Command } from 'cmdk';
|
||||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { Command } from 'cmdk';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useModal } from '@/providers/global-modal-provider';
|
import { useModal } from '@/providers/global-modal-provider';
|
||||||
import { getUaHelper } from '@/utils';
|
import { getUaHelper } from '@/utils';
|
||||||
import { useAppState } from '@/providers/app-state-provider/context';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
type TransitionsModalProps = {
|
type TransitionsModalProps = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import React, {
|
|||||||
import { SearchIcon } from '@blocksuite/icons';
|
import { SearchIcon } from '@blocksuite/icons';
|
||||||
import { StyledInputContent, StyledLabel } from './style';
|
import { StyledInputContent, StyledLabel } from './style';
|
||||||
import { Command } from 'cmdk';
|
import { Command } from 'cmdk';
|
||||||
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
export const Input = (props: {
|
export const Input = (props: {
|
||||||
query: string;
|
query: string;
|
||||||
setQuery: Dispatch<SetStateAction<string>>;
|
setQuery: Dispatch<SetStateAction<string>>;
|
||||||
@@ -16,6 +17,11 @@ export const Input = (props: {
|
|||||||
const [isComposition, setIsComposition] = useState(false);
|
const [isComposition, setIsComposition] = useState(false);
|
||||||
const [inputValue, setInputValue] = useState('');
|
const [inputValue, setInputValue] = useState('');
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const { currentWorkspaceId, workspacesMeta, currentWorkspace } =
|
||||||
|
useAppState();
|
||||||
|
const isPublic = workspacesMeta.find(
|
||||||
|
meta => String(meta.id) === String(currentWorkspaceId)
|
||||||
|
)?.public;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
inputRef.current?.addEventListener(
|
inputRef.current?.addEventListener(
|
||||||
'blur',
|
'blur',
|
||||||
@@ -73,7 +79,7 @@ export const Input = (props: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="Quick Search..."
|
placeholder={isPublic ? currentWorkspace?.meta.name : 'Quick Search...'}
|
||||||
/>
|
/>
|
||||||
</StyledInputContent>
|
</StyledInputContent>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { StyledListItem, StyledNotFound } from './style';
|
|||||||
import { useModal } from '@/providers/global-modal-provider';
|
import { useModal } from '@/providers/global-modal-provider';
|
||||||
import { PaperIcon, EdgelessIcon } from '@blocksuite/icons';
|
import { PaperIcon, EdgelessIcon } from '@blocksuite/icons';
|
||||||
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
||||||
import { useAppState } from '@/providers/app-state-provider/context';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { config } from './config';
|
import { config } from './config';
|
||||||
import { NoResultSVG } from './noResultSVG';
|
import { NoResultSVG } from './noResultSVG';
|
||||||
|
|||||||
Reference in New Issue
Block a user