Compare commits
7 Commits
master
..
ee514f10ff
| Author | SHA1 | Date | |
|---|---|---|---|
| ee514f10ff | |||
| 45b35e4eab | |||
| fd677e978b | |||
| 738e34f02c | |||
| 987415eafd | |||
| e3a2734f03 | |||
| a038e7eaae |
@@ -35,7 +35,7 @@ const config: Config = {
|
|||||||
markdown: {
|
markdown: {
|
||||||
mermaid: true,
|
mermaid: true,
|
||||||
},
|
},
|
||||||
plugins: [docuservix()],
|
plugins: [docuservix],
|
||||||
themes: ['@docusaurus/theme-mermaid'],
|
themes: ['@docusaurus/theme-mermaid'],
|
||||||
|
|
||||||
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
|
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
.MD p:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD p:first-child {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD code {
|
|
||||||
padding: 0.15em 0.4em;
|
|
||||||
border-radius: 4px;
|
|
||||||
background: var(--ifm-color-emphasis-200);
|
|
||||||
font-size: 0.85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD pre {
|
|
||||||
margin: 0.5em 0;
|
|
||||||
padding: 0.75em;
|
|
||||||
overflow-x: auto;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: var(--ifm-color-emphasis-100);
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD pre code {
|
|
||||||
padding: 0;
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD ul,
|
|
||||||
.MD ol {
|
|
||||||
padding-left: 1.5em;
|
|
||||||
margin: 0.5em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD table {
|
|
||||||
width: 100%;
|
|
||||||
margin: 0.5em 0;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD th,
|
|
||||||
.MD td {
|
|
||||||
padding: 0.4em 0.75em;
|
|
||||||
border: 1px solid var(--ifm-color-emphasis-300);
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD th {
|
|
||||||
background: var(--ifm-color-emphasis-100);
|
|
||||||
font-weight: var(--ifm-font-weight-semibold);
|
|
||||||
}
|
|
||||||
|
|
||||||
.MD blockquote {
|
|
||||||
margin: 0.5em 0;
|
|
||||||
padding: 0.25em 1em;
|
|
||||||
border-left: 3px solid var(--ifm-color-emphasis-300);
|
|
||||||
color: var(--ifm-color-emphasis-700);
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import React, { ReactNode } from 'react';
|
|
||||||
import Markdown from 'react-markdown';
|
|
||||||
import remarkGfm from 'remark-gfm';
|
|
||||||
|
|
||||||
import styles from './MD.module.css';
|
|
||||||
|
|
||||||
interface MDProps {
|
|
||||||
children: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MD({ children }: MDProps): ReactNode {
|
|
||||||
return (
|
|
||||||
<div className={styles.MD}>
|
|
||||||
<Markdown remarkPlugins={[remarkGfm]}>{children}</Markdown>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { MD } from './MD';
|
|
||||||
@@ -2,8 +2,7 @@ import path from 'path';
|
|||||||
|
|
||||||
import type { LoadContext, Plugin } from '@docusaurus/types';
|
import type { LoadContext, Plugin } from '@docusaurus/types';
|
||||||
|
|
||||||
export default function docuservix() {
|
function pluginDocuservix(_context: LoadContext): Plugin {
|
||||||
return function pluginDocuservix(_context: LoadContext): Plugin {
|
|
||||||
return {
|
return {
|
||||||
name: 'docuservix',
|
name: 'docuservix',
|
||||||
|
|
||||||
@@ -27,5 +26,6 @@ export default function docuservix() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default pluginDocuservix;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export function Chat({ dialog, typing, statusMessage, onSend }: ChatProps): Reac
|
|||||||
/>
|
/>
|
||||||
{statusMessage && <div className={b('statusMessage')}>{statusMessage}</div>}
|
{statusMessage && <div className={b('statusMessage')}>{statusMessage}</div>}
|
||||||
<Input
|
<Input
|
||||||
disabled={typing}
|
loading={typing}
|
||||||
onSend={onSend}
|
onSend={onSend}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,17 +7,17 @@ import styles from './Input.module.css';
|
|||||||
const b = block(styles, 'Input');
|
const b = block(styles, 'Input');
|
||||||
|
|
||||||
interface InputProps {
|
interface InputProps {
|
||||||
disabled?: boolean;
|
loading?: boolean;
|
||||||
onSend?: (text: string) => void;
|
onSend?: (text: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Input({ disabled, onSend }: InputProps): ReactNode {
|
export function Input({ loading, onSend }: InputProps): ReactNode {
|
||||||
const [input, setInput] = useState('');
|
const [input, setInput] = useState('');
|
||||||
|
|
||||||
const handleSend = () => {
|
const handleSend = () => {
|
||||||
const text = input.trim();
|
const text = input.trim();
|
||||||
|
|
||||||
if (!text || disabled) {
|
if (!text || loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@ export function Input({ disabled, onSend }: InputProps): ReactNode {
|
|||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
placeholder="Type your message here..."
|
placeholder="Type your message here..."
|
||||||
rows={1}
|
rows={1}
|
||||||
disabled={disabled}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
className={b('send')}
|
className={b('send')}
|
||||||
onClick={handleSend}
|
onClick={handleSend}
|
||||||
disabled={disabled || !input.trim()}
|
disabled={loading || !input.trim()}
|
||||||
>
|
>
|
||||||
<PaperPlaneIcon />
|
<PaperPlaneIcon />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.Message {
|
.Message {
|
||||||
max-width: 90%;
|
max-width: 85%;
|
||||||
animation: slideIn 0.3s ease-out;
|
animation: slideIn 0.3s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,8 +34,94 @@
|
|||||||
border-bottom-right-radius: 0.25rem;
|
border-bottom-right-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
/* Markdown typography */
|
||||||
|
|
||||||
|
.Message__content p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content p:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content code {
|
||||||
|
padding: 0.15em 0.4em;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--ifm-color-emphasis-200);
|
||||||
|
font-size: 0.85em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content pre {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
padding: 0.75em;
|
||||||
|
overflow-x: auto;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--ifm-color-emphasis-100);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content pre code {
|
||||||
|
padding: 0;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content ul,
|
||||||
|
.Message__content ol {
|
||||||
|
padding-left: 1.5em;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content table {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content th,
|
||||||
|
.Message__content td {
|
||||||
|
padding: 0.4em 0.75em;
|
||||||
|
border: 1px solid var(--ifm-color-emphasis-300);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content th {
|
||||||
|
background: var(--ifm-color-emphasis-100);
|
||||||
|
font-weight: var(--ifm-font-weight-semibold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message__content blockquote {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
padding: 0.25em 1em;
|
||||||
|
border-left: 3px solid var(--ifm-color-emphasis-300);
|
||||||
|
color: var(--ifm-color-emphasis-700);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* User role overrides for light-on-dark text */
|
||||||
|
|
||||||
|
.Message_role_user .Message__content code {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message_role_user .Message__content pre {
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message_role_user .Message__content th,
|
||||||
|
.Message_role_user .Message__content td {
|
||||||
|
border-color: rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message_role_user .Message__content th {
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Message_role_user .Message__content blockquote {
|
||||||
|
border-left-color: rgba(255, 255, 255, 0.4);
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 576px) {
|
||||||
.Message {
|
.Message {
|
||||||
max-width: 100%;
|
max-width: 75%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import block from 'bem-css-modules';
|
import block from 'bem-css-modules';
|
||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
|
import Markdown from 'react-markdown';
|
||||||
import { MD } from '@docuservix/entities/markdown';
|
import remarkGfm from 'remark-gfm';
|
||||||
|
|
||||||
import styles from './Message.module.css';
|
import styles from './Message.module.css';
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ export function Message({ role, content }: MessageProps): ReactNode {
|
|||||||
return (
|
return (
|
||||||
<div className={b({ role })}>
|
<div className={b({ role })}>
|
||||||
<div className={b('content')}>
|
<div className={b('content')}>
|
||||||
<MD>{content}</MD>
|
<Markdown remarkPlugins={[remarkGfm]}>{content}</Markdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user