@gendive/chatllm 0.6.2 → 0.6.3
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/react/index.js +38 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +38 -2
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -1770,7 +1770,8 @@ var LinkChip = ({
|
|
|
1770
1770
|
|
|
1771
1771
|
// src/react/components/MarkdownRenderer.tsx
|
|
1772
1772
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1773
|
-
var
|
|
1773
|
+
var IMAGE_REGEX = /!\[([^\]]*)\]\(([^)]+)\)/g;
|
|
1774
|
+
var LINK_REGEX = /(?<!!)\[([^\]]+)\]\(([^)]+)\)/g;
|
|
1774
1775
|
var SOURCE_LINKS_REGEX = /(\*{0,2}출처:?\*{0,2}\s*)?((?:\[`?[^\]]+`?\]\([^)]+\)\s*)+)/gi;
|
|
1775
1776
|
var CODE_BLOCK_REGEX = /```(\w*)\n?([\s\S]*?)```/g;
|
|
1776
1777
|
var INLINE_CODE_REGEX = /`([^`]+)`/g;
|
|
@@ -1798,8 +1799,9 @@ var parseInlineElements = (text, key) => {
|
|
|
1798
1799
|
currentText = currentText.replace(INLINE_CODE_REGEX, "\xA7CODE\xA7$1\xA7/CODE\xA7");
|
|
1799
1800
|
currentText = currentText.replace(BOLD_REGEX, "\xA7BOLD\xA7$1\xA7/BOLD\xA7");
|
|
1800
1801
|
currentText = currentText.replace(ITALIC_REGEX, "\xA7ITALIC\xA7$1\xA7/ITALIC\xA7");
|
|
1802
|
+
currentText = currentText.replace(IMAGE_REGEX, "\xA7IMAGE\xA7$1\xA7URL\xA7$2\xA7/IMAGE\xA7");
|
|
1801
1803
|
currentText = currentText.replace(LINK_REGEX, "\xA7LINK\xA7$1\xA7URL\xA7$2\xA7/LINK\xA7");
|
|
1802
|
-
const parts = currentText.split(/(§CODE§.*?§\/CODE§|§BOLD§.*?§\/BOLD§|§ITALIC§.*?§\/ITALIC§|§LINK§.*?§\/LINK§)/);
|
|
1804
|
+
const parts = currentText.split(/(§CODE§.*?§\/CODE§|§BOLD§.*?§\/BOLD§|§ITALIC§.*?§\/ITALIC§|§IMAGE§.*?§\/IMAGE§|§LINK§.*?§\/LINK§)/);
|
|
1803
1805
|
parts.forEach((part, index) => {
|
|
1804
1806
|
if (part.startsWith("\xA7CODE\xA7")) {
|
|
1805
1807
|
const content = part.replace("\xA7CODE\xA7", "").replace("\xA7/CODE\xA7", "");
|
|
@@ -1826,6 +1828,28 @@ var parseInlineElements = (text, key) => {
|
|
|
1826
1828
|
} else if (part.startsWith("\xA7ITALIC\xA7")) {
|
|
1827
1829
|
const content = part.replace("\xA7ITALIC\xA7", "").replace("\xA7/ITALIC\xA7", "");
|
|
1828
1830
|
elements.push(/* @__PURE__ */ jsx6("em", { children: content }, `${key}-italic-${index}`));
|
|
1831
|
+
} else if (part.startsWith("\xA7IMAGE\xA7")) {
|
|
1832
|
+
const match = part.match(/§IMAGE§(.*)§URL§(.+?)§\/IMAGE§/);
|
|
1833
|
+
if (match) {
|
|
1834
|
+
elements.push(
|
|
1835
|
+
/* @__PURE__ */ jsx6(
|
|
1836
|
+
"img",
|
|
1837
|
+
{
|
|
1838
|
+
src: match[2],
|
|
1839
|
+
alt: match[1] || "",
|
|
1840
|
+
className: "chatllm-image",
|
|
1841
|
+
style: {
|
|
1842
|
+
maxWidth: "100%",
|
|
1843
|
+
borderRadius: "8px",
|
|
1844
|
+
margin: "8px 0",
|
|
1845
|
+
display: "block"
|
|
1846
|
+
},
|
|
1847
|
+
loading: "lazy"
|
|
1848
|
+
},
|
|
1849
|
+
`${key}-image-${index}`
|
|
1850
|
+
)
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1829
1853
|
} else if (part.startsWith("\xA7LINK\xA7")) {
|
|
1830
1854
|
const match = part.match(/§LINK§(.+?)§URL§(.+?)§\/LINK§/);
|
|
1831
1855
|
if (match) {
|
|
@@ -3987,6 +4011,18 @@ var injectStyles = () => {
|
|
|
3987
4011
|
.chatllm-table tr:hover {
|
|
3988
4012
|
background-color: var(--chatllm-bg-hover, #f3f4f6);
|
|
3989
4013
|
}
|
|
4014
|
+
|
|
4015
|
+
.chatllm-image {
|
|
4016
|
+
max-width: 100%;
|
|
4017
|
+
border-radius: 8px;
|
|
4018
|
+
margin: 8px 0;
|
|
4019
|
+
display: block;
|
|
4020
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
.chatllm-image:hover {
|
|
4024
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
4025
|
+
}
|
|
3990
4026
|
`;
|
|
3991
4027
|
document.head.appendChild(style);
|
|
3992
4028
|
};
|