@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.js
CHANGED
|
@@ -1819,7 +1819,8 @@ var LinkChip = ({
|
|
|
1819
1819
|
|
|
1820
1820
|
// src/react/components/MarkdownRenderer.tsx
|
|
1821
1821
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1822
|
-
var
|
|
1822
|
+
var IMAGE_REGEX = /!\[([^\]]*)\]\(([^)]+)\)/g;
|
|
1823
|
+
var LINK_REGEX = /(?<!!)\[([^\]]+)\]\(([^)]+)\)/g;
|
|
1823
1824
|
var SOURCE_LINKS_REGEX = /(\*{0,2}출처:?\*{0,2}\s*)?((?:\[`?[^\]]+`?\]\([^)]+\)\s*)+)/gi;
|
|
1824
1825
|
var CODE_BLOCK_REGEX = /```(\w*)\n?([\s\S]*?)```/g;
|
|
1825
1826
|
var INLINE_CODE_REGEX = /`([^`]+)`/g;
|
|
@@ -1847,8 +1848,9 @@ var parseInlineElements = (text, key) => {
|
|
|
1847
1848
|
currentText = currentText.replace(INLINE_CODE_REGEX, "\xA7CODE\xA7$1\xA7/CODE\xA7");
|
|
1848
1849
|
currentText = currentText.replace(BOLD_REGEX, "\xA7BOLD\xA7$1\xA7/BOLD\xA7");
|
|
1849
1850
|
currentText = currentText.replace(ITALIC_REGEX, "\xA7ITALIC\xA7$1\xA7/ITALIC\xA7");
|
|
1851
|
+
currentText = currentText.replace(IMAGE_REGEX, "\xA7IMAGE\xA7$1\xA7URL\xA7$2\xA7/IMAGE\xA7");
|
|
1850
1852
|
currentText = currentText.replace(LINK_REGEX, "\xA7LINK\xA7$1\xA7URL\xA7$2\xA7/LINK\xA7");
|
|
1851
|
-
const parts = currentText.split(/(§CODE§.*?§\/CODE§|§BOLD§.*?§\/BOLD§|§ITALIC§.*?§\/ITALIC§|§LINK§.*?§\/LINK§)/);
|
|
1853
|
+
const parts = currentText.split(/(§CODE§.*?§\/CODE§|§BOLD§.*?§\/BOLD§|§ITALIC§.*?§\/ITALIC§|§IMAGE§.*?§\/IMAGE§|§LINK§.*?§\/LINK§)/);
|
|
1852
1854
|
parts.forEach((part, index) => {
|
|
1853
1855
|
if (part.startsWith("\xA7CODE\xA7")) {
|
|
1854
1856
|
const content = part.replace("\xA7CODE\xA7", "").replace("\xA7/CODE\xA7", "");
|
|
@@ -1875,6 +1877,28 @@ var parseInlineElements = (text, key) => {
|
|
|
1875
1877
|
} else if (part.startsWith("\xA7ITALIC\xA7")) {
|
|
1876
1878
|
const content = part.replace("\xA7ITALIC\xA7", "").replace("\xA7/ITALIC\xA7", "");
|
|
1877
1879
|
elements.push(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: content }, `${key}-italic-${index}`));
|
|
1880
|
+
} else if (part.startsWith("\xA7IMAGE\xA7")) {
|
|
1881
|
+
const match = part.match(/§IMAGE§(.*)§URL§(.+?)§\/IMAGE§/);
|
|
1882
|
+
if (match) {
|
|
1883
|
+
elements.push(
|
|
1884
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1885
|
+
"img",
|
|
1886
|
+
{
|
|
1887
|
+
src: match[2],
|
|
1888
|
+
alt: match[1] || "",
|
|
1889
|
+
className: "chatllm-image",
|
|
1890
|
+
style: {
|
|
1891
|
+
maxWidth: "100%",
|
|
1892
|
+
borderRadius: "8px",
|
|
1893
|
+
margin: "8px 0",
|
|
1894
|
+
display: "block"
|
|
1895
|
+
},
|
|
1896
|
+
loading: "lazy"
|
|
1897
|
+
},
|
|
1898
|
+
`${key}-image-${index}`
|
|
1899
|
+
)
|
|
1900
|
+
);
|
|
1901
|
+
}
|
|
1878
1902
|
} else if (part.startsWith("\xA7LINK\xA7")) {
|
|
1879
1903
|
const match = part.match(/§LINK§(.+?)§URL§(.+?)§\/LINK§/);
|
|
1880
1904
|
if (match) {
|
|
@@ -4036,6 +4060,18 @@ var injectStyles = () => {
|
|
|
4036
4060
|
.chatllm-table tr:hover {
|
|
4037
4061
|
background-color: var(--chatllm-bg-hover, #f3f4f6);
|
|
4038
4062
|
}
|
|
4063
|
+
|
|
4064
|
+
.chatllm-image {
|
|
4065
|
+
max-width: 100%;
|
|
4066
|
+
border-radius: 8px;
|
|
4067
|
+
margin: 8px 0;
|
|
4068
|
+
display: block;
|
|
4069
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
4070
|
+
}
|
|
4071
|
+
|
|
4072
|
+
.chatllm-image:hover {
|
|
4073
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
4074
|
+
}
|
|
4039
4075
|
`;
|
|
4040
4076
|
document.head.appendChild(style);
|
|
4041
4077
|
};
|