chore: add pretty

This commit is contained in:
lencx
2023-01-22 18:18:36 +08:00
parent 1ba356a91f
commit bc39dcdd72
56 changed files with 776 additions and 535 deletions

View File

@@ -22,15 +22,20 @@ const FilePath: FC<FilePathProps> = ({ className, label = 'PATH', paths = '', ur
setPath(url);
return;
}
setPath(await path.join(await chatRoot(), ...paths.split('/').filter(i => !!i)));
})()
}, [url, paths])
setPath(await path.join(await chatRoot(), ...paths.split('/').filter((i) => !!i)));
})();
}, [url, paths]);
return (
<div className={clsx(className, 'chat-file-path')}>
<div>{label}: <a onClick={() => shell.open(filePath)} title={filePath}>{content ? content : filePath}</a></div>
<div>
{label}:{' '}
<a onClick={() => shell.open(filePath)} title={filePath}>
{content ? content : filePath}
</a>
</div>
</div>
);
}
};
export default FilePath;
export default FilePath;

View File

@@ -1,5 +1,5 @@
import { FC, useEffect, useState } from 'react';
import Editor from "@monaco-editor/react";
import Editor from '@monaco-editor/react';
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
import Markdown from '@/components/Markdown';
@@ -17,12 +17,12 @@ const MarkdownEditor: FC<MarkdownEditorProps> = ({ value = '', onChange, mode =
useEffect(() => {
setContent(value);
onChange && onChange(value);
}, [value])
}, [value]);
const handleEdit = (e: any) => {
setContent(e);
onChange && onChange(e);
}
};
const isSplit = mode === 'split';
@@ -31,11 +31,7 @@ const MarkdownEditor: FC<MarkdownEditorProps> = ({ value = '', onChange, mode =
<PanelGroup direction="horizontal">
{['md', 'split'].includes(mode) && (
<Panel>
<Editor
language="markdown"
value={content}
onChange={handleEdit}
/>
<Editor language="markdown" value={content} onChange={handleEdit} />
</Panel>
)}
{isSplit && <PanelResizeHandle className="resize-handle" />}
@@ -44,9 +40,9 @@ const MarkdownEditor: FC<MarkdownEditorProps> = ({ value = '', onChange, mode =
<Markdown className="edit-preview">{content}</Markdown>
</Panel>
)}
</PanelGroup>
</PanelGroup>
</div>
)
);
};
export default MarkdownEditor;
export default MarkdownEditor;

View File

@@ -1,15 +1,16 @@
.markdown-body {
height: 100%;
overflow: auto;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial,
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
&.edit-preview {
padding: 10px;
font-size: 14px;
}
pre, code {
pre,
code {
font-family: monospace, monospace;
}
}

View File

@@ -13,7 +13,6 @@ interface MarkdownProps {
}
const Markdown: FC<MarkdownProps> = ({ children, className }) => {
return (
<div className={clsx(className, 'markdown-body')}>
<div>
@@ -22,8 +21,8 @@ const Markdown: FC<MarkdownProps> = ({ children, className }) => {
linkTarget="_blank"
remarkPlugins={[remarkGfm]}
components={{
code({node, inline, className, children, ...props}) {
const match = /language-(\w+)/.exec(className || '')
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '');
return !inline && match ? (
<SyntaxHighlighter
children={String(children).replace(/\n$/, '')}
@@ -38,13 +37,13 @@ const Markdown: FC<MarkdownProps> = ({ children, className }) => {
<code className={className} {...props}>
{children}
</code>
)
}
);
},
}}
/>
</div>
</div>
)
}
);
};
export default Markdown;
export default Markdown;

View File

@@ -20,7 +20,7 @@ const Tags: FC<TagsProps> = ({ max = 99, value = [], onChange, addTxt = 'New Tag
useEffect(() => {
setTags(value);
}, [value])
}, [value]);
useEffect(() => {
if (inputVisible) {
@@ -97,4 +97,4 @@ const Tags: FC<TagsProps> = ({ max = 99, value = [], onChange, addTxt = 'New Tag
);
};
export default Tags;
export default Tags;