chore: awesome

This commit is contained in:
lencx
2023-01-20 21:28:57 +08:00
parent 1af173cb24
commit 5f1c33d750
18 changed files with 359 additions and 46 deletions

View File

@@ -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>
)

View File

@@ -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>
)}
</>