mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: awesome
This commit is contained in:
31
src/components/Markdown/Editor.tsx
vendored
31
src/components/Markdown/Editor.tsx
vendored
@@ -8,9 +8,10 @@ import './index.scss';
|
||||
interface MarkdownEditorProps {
|
||||
value?: string;
|
||||
onChange?: (v: string) => void;
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
const MarkdownEditor: FC<MarkdownEditorProps> = ({ value = '', onChange }) => {
|
||||
const MarkdownEditor: FC<MarkdownEditorProps> = ({ value = '', onChange, mode = 'split' }) => {
|
||||
const [content, setContent] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -23,20 +24,26 @@ const MarkdownEditor: FC<MarkdownEditorProps> = ({ value = '', onChange }) => {
|
||||
onChange && onChange(e);
|
||||
}
|
||||
|
||||
const isSplit = mode === 'split';
|
||||
|
||||
return (
|
||||
<div className="md-main">
|
||||
<PanelGroup direction="horizontal">
|
||||
<Panel>
|
||||
<Editor
|
||||
language="markdown"
|
||||
value={content}
|
||||
onChange={handleEdit}
|
||||
/>
|
||||
</Panel>
|
||||
<PanelResizeHandle className="resize-handle" />
|
||||
<Panel collapsible={true}>
|
||||
<Markdown className="edit-preview">{content}</Markdown>
|
||||
</Panel>
|
||||
{['md', 'split'].includes(mode) && (
|
||||
<Panel>
|
||||
<Editor
|
||||
language="markdown"
|
||||
value={content}
|
||||
onChange={handleEdit}
|
||||
/>
|
||||
</Panel>
|
||||
)}
|
||||
{isSplit && <PanelResizeHandle className="resize-handle" />}
|
||||
{['doc', 'split'].includes(mode) && (
|
||||
<Panel>
|
||||
<Markdown className="edit-preview">{content}</Markdown>
|
||||
</Panel>
|
||||
)}
|
||||
</PanelGroup>
|
||||
</div>
|
||||
)
|
||||
|
||||
8
src/components/Tags/index.tsx
vendored
8
src/components/Tags/index.tsx
vendored
@@ -8,9 +8,11 @@ import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
interface TagsProps {
|
||||
value?: string[];
|
||||
onChange?: (v: string[]) => void;
|
||||
addTxt?: string;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
const Tags: FC<TagsProps> = ({ value = [], onChange }) => {
|
||||
const Tags: FC<TagsProps> = ({ max = 99, value = [], onChange, addTxt = 'New Tag' }) => {
|
||||
const [tags, setTags] = useState<string[]>(value);
|
||||
const [inputVisible, setInputVisible] = useState<boolean>(false);
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
@@ -86,9 +88,9 @@ const Tags: FC<TagsProps> = ({ value = [], onChange }) => {
|
||||
{...DISABLE_AUTO_COMPLETE}
|
||||
/>
|
||||
)}
|
||||
{!inputVisible && (
|
||||
{!inputVisible && tags.length < max && (
|
||||
<Tag onClick={showInput} className="chat-tag-new">
|
||||
<PlusOutlined /> New Tag
|
||||
<PlusOutlined /> {addTxt}
|
||||
</Tag>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user