reachat 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Markdown/Markdown.d.ts +2 -2
- package/dist/Markdown/index.d.ts +1 -0
- package/dist/Markdown/types.d.ts +21 -0
- package/dist/index.css +12 -0
- package/dist/index.js +27 -32
- package/dist/index.js.map +1 -1
- package/dist/stories/Markdown.stories.tsx +92 -0
- package/dist/theme.d.ts +2 -21
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { Components } from 'react-markdown';
|
|
3
3
|
import { Plugin } from 'unified';
|
|
4
|
-
import {
|
|
4
|
+
import { MarkdownTheme } from './types';
|
|
5
5
|
interface MarkdownWrapperProps extends PropsWithChildren {
|
|
6
6
|
/**
|
|
7
7
|
* Remark plugins to apply to the markdown content.
|
|
@@ -15,7 +15,7 @@ interface MarkdownWrapperProps extends PropsWithChildren {
|
|
|
15
15
|
/**
|
|
16
16
|
* Theme to apply to the markdown content.
|
|
17
17
|
*/
|
|
18
|
-
theme
|
|
18
|
+
theme: MarkdownTheme;
|
|
19
19
|
/**
|
|
20
20
|
* Custom components to override default markdown rendering.
|
|
21
21
|
* These will be merged with the default components.
|
package/dist/Markdown/index.d.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface MarkdownTheme {
|
|
2
|
+
hr: string;
|
|
3
|
+
p: string;
|
|
4
|
+
a: string;
|
|
5
|
+
table: string;
|
|
6
|
+
th: string;
|
|
7
|
+
td: string;
|
|
8
|
+
code: string;
|
|
9
|
+
inlineCode: string;
|
|
10
|
+
toolbar: string;
|
|
11
|
+
li: string;
|
|
12
|
+
ul: string;
|
|
13
|
+
ol: string;
|
|
14
|
+
copy: string;
|
|
15
|
+
h1: string;
|
|
16
|
+
h2: string;
|
|
17
|
+
h3: string;
|
|
18
|
+
h4: string;
|
|
19
|
+
h5: string;
|
|
20
|
+
h6: string;
|
|
21
|
+
}
|
package/dist/index.css
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
--color-green-600: oklch(62.7% 0.194 149.214);
|
|
36
36
|
--color-green-800: oklch(44.8% 0.119 151.328);
|
|
37
37
|
--color-green-950: oklch(26.6% 0.065 152.934);
|
|
38
|
+
--color-cyan-300: oklch(86.5% 0.127 207.078);
|
|
38
39
|
--color-cyan-500: oklch(71.5% 0.143 215.221);
|
|
39
40
|
--color-blue-100: oklch(93.2% 0.032 255.585);
|
|
40
41
|
--color-blue-200: oklch(88.2% 0.059 254.128);
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
--color-blue-700: oklch(48.8% 0.243 264.376);
|
|
46
47
|
--color-blue-900: oklch(37.9% 0.146 265.522);
|
|
47
48
|
--color-blue-950: oklch(28.2% 0.091 267.935);
|
|
49
|
+
--color-indigo-300: oklch(78.5% 0.115 274.713);
|
|
48
50
|
--color-indigo-600: oklch(51.1% 0.262 276.966);
|
|
49
51
|
--color-indigo-700: oklch(45.7% 0.24 277.023);
|
|
50
52
|
--color-violet-500: oklch(60.6% 0.25 292.717);
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
--spacing: 0.25rem;
|
|
75
77
|
--container-sm: 24rem;
|
|
76
78
|
--container-2xl: 42rem;
|
|
79
|
+
--container-4xl: 56rem;
|
|
77
80
|
--text-xs: 0.75rem;
|
|
78
81
|
--text-xs--line-height: calc(1 / 0.75);
|
|
79
82
|
--text-sm: 0.875rem;
|
|
@@ -1011,6 +1014,9 @@
|
|
|
1011
1014
|
.max-w-2xl {
|
|
1012
1015
|
max-width: var(--container-2xl);
|
|
1013
1016
|
}
|
|
1017
|
+
.max-w-4xl {
|
|
1018
|
+
max-width: var(--container-4xl);
|
|
1019
|
+
}
|
|
1014
1020
|
.max-w-10 {
|
|
1015
1021
|
max-width: calc(var(--spacing) * 10);
|
|
1016
1022
|
}
|
|
@@ -2307,6 +2313,9 @@
|
|
|
2307
2313
|
.text-blue-700 {
|
|
2308
2314
|
color: var(--color-blue-700);
|
|
2309
2315
|
}
|
|
2316
|
+
.text-cyan-300 {
|
|
2317
|
+
color: var(--color-cyan-300);
|
|
2318
|
+
}
|
|
2310
2319
|
.text-gray-100 {
|
|
2311
2320
|
color: var(--color-gray-100);
|
|
2312
2321
|
}
|
|
@@ -2331,6 +2340,9 @@
|
|
|
2331
2340
|
.text-green-500 {
|
|
2332
2341
|
color: var(--color-green-500);
|
|
2333
2342
|
}
|
|
2343
|
+
.text-indigo-300 {
|
|
2344
|
+
color: var(--color-indigo-300);
|
|
2345
|
+
}
|
|
2334
2346
|
.text-inherit {
|
|
2335
2347
|
color: inherit;
|
|
2336
2348
|
}
|
package/dist/index.js
CHANGED
|
@@ -1413,9 +1413,7 @@ var TableDataCell = ({ children, ...props }) => /* @__PURE__ */ jsx("td", {
|
|
|
1413
1413
|
});
|
|
1414
1414
|
//#endregion
|
|
1415
1415
|
//#region src/Markdown/Markdown.tsx
|
|
1416
|
-
var Markdown = ({ children, remarkPlugins, rehypePlugins = [rehypeRaw, rehypeKatex], theme
|
|
1417
|
-
const { theme: contextTheme, markdownComponents } = useContext(ChatContext);
|
|
1418
|
-
const theme = themeProp || contextTheme;
|
|
1416
|
+
var Markdown = ({ children, remarkPlugins, rehypePlugins = [rehypeRaw, rehypeKatex], theme, customComponents }) => {
|
|
1419
1417
|
return /* @__PURE__ */ jsx(ReactMarkdown, {
|
|
1420
1418
|
remarkPlugins,
|
|
1421
1419
|
rehypePlugins,
|
|
@@ -1424,85 +1422,80 @@ var Markdown = ({ children, remarkPlugins, rehypePlugins = [rehypeRaw, rehypeKat
|
|
|
1424
1422
|
code: ({ className, children, ...props }) => /* @__PURE__ */ jsx(CodeHighlighter, {
|
|
1425
1423
|
...props,
|
|
1426
1424
|
language: cn(className),
|
|
1427
|
-
inlineClassName: cn(theme.
|
|
1428
|
-
className: cn(theme.
|
|
1429
|
-
copyClassName: cn(theme.
|
|
1430
|
-
toolbarClassName: cn(theme.
|
|
1425
|
+
inlineClassName: cn(theme.inlineCode),
|
|
1426
|
+
className: cn(theme.code, className),
|
|
1427
|
+
copyClassName: cn(theme.copy),
|
|
1428
|
+
toolbarClassName: cn(theme.toolbar),
|
|
1431
1429
|
children
|
|
1432
1430
|
}),
|
|
1433
1431
|
table: (props) => /* @__PURE__ */ jsx(TableComponent, {
|
|
1434
1432
|
...props,
|
|
1435
|
-
className: cn(theme.
|
|
1433
|
+
className: cn(theme.table)
|
|
1436
1434
|
}),
|
|
1437
1435
|
th: (props) => /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1438
1436
|
...props,
|
|
1439
|
-
className: cn(theme.
|
|
1437
|
+
className: cn(theme.th)
|
|
1440
1438
|
}),
|
|
1441
1439
|
td: (props) => /* @__PURE__ */ jsx(TableDataCell, {
|
|
1442
1440
|
...props,
|
|
1443
|
-
className: cn(theme.
|
|
1441
|
+
className: cn(theme.td)
|
|
1444
1442
|
}),
|
|
1445
1443
|
a: (props) => /* @__PURE__ */ jsx("a", {
|
|
1446
1444
|
...props,
|
|
1447
|
-
className: cn(theme.
|
|
1445
|
+
className: cn(theme.a)
|
|
1448
1446
|
}),
|
|
1449
1447
|
hr: (props) => /* @__PURE__ */ jsx("hr", {
|
|
1450
1448
|
...props,
|
|
1451
|
-
className: cn(theme.
|
|
1449
|
+
className: cn(theme.hr)
|
|
1452
1450
|
}),
|
|
1453
1451
|
p: (props) => /* @__PURE__ */ jsx("p", {
|
|
1454
1452
|
...props,
|
|
1455
|
-
className: cn(theme.
|
|
1453
|
+
className: cn(theme.p)
|
|
1456
1454
|
}),
|
|
1457
1455
|
li: (props) => /* @__PURE__ */ jsx("li", {
|
|
1458
1456
|
...props,
|
|
1459
|
-
className: cn(theme.
|
|
1457
|
+
className: cn(theme.li)
|
|
1460
1458
|
}),
|
|
1461
1459
|
ul: (props) => /* @__PURE__ */ jsx("ul", {
|
|
1462
1460
|
...props,
|
|
1463
|
-
className: cn(theme.
|
|
1461
|
+
className: cn(theme.ul)
|
|
1464
1462
|
}),
|
|
1465
1463
|
ol: (props) => /* @__PURE__ */ jsx("ol", {
|
|
1466
1464
|
...props,
|
|
1467
|
-
className: cn(theme.
|
|
1465
|
+
className: cn(theme.ol)
|
|
1468
1466
|
}),
|
|
1469
1467
|
h1: (props) => /* @__PURE__ */ jsx("h1", {
|
|
1470
1468
|
...props,
|
|
1471
|
-
className: cn(theme.
|
|
1469
|
+
className: cn(theme.h1)
|
|
1472
1470
|
}),
|
|
1473
1471
|
h2: (props) => /* @__PURE__ */ jsx("h2", {
|
|
1474
1472
|
...props,
|
|
1475
|
-
className: cn(theme.
|
|
1473
|
+
className: cn(theme.h2)
|
|
1476
1474
|
}),
|
|
1477
1475
|
h3: (props) => /* @__PURE__ */ jsx("h3", {
|
|
1478
1476
|
...props,
|
|
1479
|
-
className: cn(theme.
|
|
1477
|
+
className: cn(theme.h3)
|
|
1480
1478
|
}),
|
|
1481
1479
|
h4: (props) => /* @__PURE__ */ jsx("h4", {
|
|
1482
1480
|
...props,
|
|
1483
|
-
className: cn(theme.
|
|
1481
|
+
className: cn(theme.h4)
|
|
1484
1482
|
}),
|
|
1485
1483
|
h5: (props) => /* @__PURE__ */ jsx("h5", {
|
|
1486
1484
|
...props,
|
|
1487
|
-
className: cn(theme.
|
|
1485
|
+
className: cn(theme.h5)
|
|
1488
1486
|
}),
|
|
1489
1487
|
h6: (props) => /* @__PURE__ */ jsx("h6", {
|
|
1490
1488
|
...props,
|
|
1491
|
-
className: cn(theme.
|
|
1489
|
+
className: cn(theme.h6)
|
|
1492
1490
|
}),
|
|
1493
1491
|
redact: ((props) => /* @__PURE__ */ jsx(Redact, {
|
|
1494
1492
|
value: props["data-redact-value"] || props.children,
|
|
1495
1493
|
allowToggle: true,
|
|
1496
1494
|
tooltipText: `${props["data-redact-name"] || "Sensitive"} information - Click to toggle`
|
|
1497
1495
|
})),
|
|
1498
|
-
...markdownComponents,
|
|
1499
1496
|
...customComponents
|
|
1500
1497
|
};
|
|
1501
|
-
}, [
|
|
1502
|
-
theme,
|
|
1503
|
-
markdownComponents,
|
|
1504
|
-
customComponents
|
|
1505
|
-
]),
|
|
1498
|
+
}, [theme, customComponents]),
|
|
1506
1499
|
children
|
|
1507
1500
|
});
|
|
1508
1501
|
};
|
|
@@ -2032,7 +2025,7 @@ MessageFiles.displayName = "MessageFiles";
|
|
|
2032
2025
|
//#endregion
|
|
2033
2026
|
//#region src/SessionMessages/SessionMessage/MessageQuestion.tsx
|
|
2034
2027
|
var MessageQuestion = memo(({ children, ...props }) => {
|
|
2035
|
-
const { theme, remarkPlugins } = useContext(ChatContext);
|
|
2028
|
+
const { theme, remarkPlugins, markdownComponents } = useContext(ChatContext);
|
|
2036
2029
|
const { question, files } = props;
|
|
2037
2030
|
const Comp = children ? Slot : "div";
|
|
2038
2031
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -2044,7 +2037,8 @@ var MessageQuestion = memo(({ children, ...props }) => {
|
|
|
2044
2037
|
/* @__PURE__ */ jsx(MessageFiles, { files }),
|
|
2045
2038
|
/* @__PURE__ */ jsx(Markdown, {
|
|
2046
2039
|
remarkPlugins,
|
|
2047
|
-
theme,
|
|
2040
|
+
theme: theme.messages.message.markdown,
|
|
2041
|
+
customComponents: markdownComponents,
|
|
2048
2042
|
children: question
|
|
2049
2043
|
}),
|
|
2050
2044
|
isLong && !expanded && /* @__PURE__ */ jsx(Button, {
|
|
@@ -2061,13 +2055,14 @@ MessageQuestion.displayName = "MessageQuestion";
|
|
|
2061
2055
|
//#endregion
|
|
2062
2056
|
//#region src/SessionMessages/SessionMessage/MessageResponse.tsx
|
|
2063
2057
|
var MessageResponse = memo(({ response, isLoading, children }) => {
|
|
2064
|
-
const { theme, isCompact, remarkPlugins } = useContext(ChatContext);
|
|
2058
|
+
const { theme, isCompact, remarkPlugins, markdownComponents } = useContext(ChatContext);
|
|
2065
2059
|
return /* @__PURE__ */ jsx(children ? Slot : "div", {
|
|
2066
2060
|
"data-compact": isCompact,
|
|
2067
2061
|
className: cn(theme.messages.message.response),
|
|
2068
2062
|
children: children || /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Markdown, {
|
|
2069
2063
|
remarkPlugins,
|
|
2070
|
-
theme,
|
|
2064
|
+
theme: theme.messages.message.markdown,
|
|
2065
|
+
customComponents: markdownComponents,
|
|
2071
2066
|
children: response
|
|
2072
2067
|
}), isLoading && /* @__PURE__ */ jsx(motion.div, {
|
|
2073
2068
|
className: cn(theme.messages.message.cursor),
|