mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: add pretty
This commit is contained in:
17
src/components/FilePath/index.tsx
vendored
17
src/components/FilePath/index.tsx
vendored
@@ -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;
|
||||
|
||||
18
src/components/Markdown/Editor.tsx
vendored
18
src/components/Markdown/Editor.tsx
vendored
@@ -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;
|
||||
|
||||
7
src/components/Markdown/index.scss
vendored
7
src/components/Markdown/index.scss
vendored
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
15
src/components/Markdown/index.tsx
vendored
15
src/components/Markdown/index.tsx
vendored
@@ -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;
|
||||
|
||||
4
src/components/Tags/index.tsx
vendored
4
src/components/Tags/index.tsx
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user