llmasaservice-ui 0.3.7 → 0.3.8

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/index.js CHANGED
@@ -132,9 +132,9 @@ var ChatPanel = ({
132
132
  } else if (action.type === "markdown") {
133
133
  html = (_a = action.markdown) != null ? _a : "";
134
134
  }
135
- html = html.replace("$match", match);
135
+ html = html.replace(new RegExp("\\$match", "g"), match);
136
136
  groups.forEach((group, index2) => {
137
- html = html.replace(`$${index2 + 1}`, group);
137
+ html = html.replace(new RegExp(`\\$${index2 + 1}`, "g"), group);
138
138
  });
139
139
  setTimeout(() => {
140
140
  const button = document.getElementById(buttonId);
@@ -339,6 +339,10 @@ var ChatPanel = ({
339
339
  String(children).replace(/\n$/, "")
340
340
  )) : /* @__PURE__ */ import_react.default.createElement("code", __spreadValues({ className: className ? className : "" }, props), children);
341
341
  };
342
+ const CustomLink = (_c) => {
343
+ var _d = _c, { href, children } = _d, props = __objRest(_d, ["href", "children"]);
344
+ return /* @__PURE__ */ import_react.default.createElement("a", __spreadValues({ href, target: "_blank", rel: "noopener noreferrer" }, props), children);
345
+ };
342
346
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
343
347
  "div",
344
348
  {
@@ -360,7 +364,7 @@ var ChatPanel = ({
360
364
  className: markdownClass,
361
365
  remarkPlugins: [import_remark_gfm.default],
362
366
  rehypePlugins: [import_rehype_raw.default],
363
- components: { code: CodeBlock }
367
+ components: { a: CustomLink, code: CodeBlock }
364
368
  },
365
369
  response2.content
366
370
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: "button-container" }, /* @__PURE__ */ import_react.default.createElement(
package/dist/index.mjs CHANGED
@@ -99,9 +99,9 @@ var ChatPanel = ({
99
99
  } else if (action.type === "markdown") {
100
100
  html = (_a = action.markdown) != null ? _a : "";
101
101
  }
102
- html = html.replace("$match", match);
102
+ html = html.replace(new RegExp("\\$match", "g"), match);
103
103
  groups.forEach((group, index2) => {
104
- html = html.replace(`$${index2 + 1}`, group);
104
+ html = html.replace(new RegExp(`\\$${index2 + 1}`, "g"), group);
105
105
  });
106
106
  setTimeout(() => {
107
107
  const button = document.getElementById(buttonId);
@@ -306,6 +306,10 @@ var ChatPanel = ({
306
306
  String(children).replace(/\n$/, "")
307
307
  )) : /* @__PURE__ */ React.createElement("code", __spreadValues({ className: className ? className : "" }, props), children);
308
308
  };
309
+ const CustomLink = (_c) => {
310
+ var _d = _c, { href, children } = _d, props = __objRest(_d, ["href", "children"]);
311
+ return /* @__PURE__ */ React.createElement("a", __spreadValues({ href, target: "_blank", rel: "noopener noreferrer" }, props), children);
312
+ };
309
313
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
310
314
  "div",
311
315
  {
@@ -327,7 +331,7 @@ var ChatPanel = ({
327
331
  className: markdownClass,
328
332
  remarkPlugins: [remarkGfm],
329
333
  rehypePlugins: [rehypeRaw],
330
- components: { code: CodeBlock }
334
+ components: { a: CustomLink, code: CodeBlock }
331
335
  },
332
336
  response2.content
333
337
  ), /* @__PURE__ */ React.createElement("div", { className: "button-container" }, /* @__PURE__ */ React.createElement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/ChatPanel.tsx CHANGED
@@ -138,9 +138,9 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
138
138
  html = action.markdown ?? "";
139
139
  }
140
140
 
141
- html = html.replace("$match", match);
141
+ html = html.replace(new RegExp("\\$match", "g"), match);
142
142
  groups.forEach((group, index) => {
143
- html = html.replace(`$${index + 1}`, group);
143
+ html = html.replace(new RegExp(`\\$${index + 1}`, 'g'), group);
144
144
  });
145
145
 
146
146
  setTimeout(() => {
@@ -382,6 +382,15 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
382
382
  );
383
383
  };
384
384
 
385
+ // links should always open in a new tab
386
+ const CustomLink = ({ href, children, ...props }: any) => {
387
+ return (
388
+ <a href={href} target="_blank" rel="noopener noreferrer" {...props}>
389
+ {children}
390
+ </a>
391
+ );
392
+ };
393
+
385
394
  return (
386
395
  <>
387
396
  <div
@@ -417,7 +426,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
417
426
  className={markdownClass}
418
427
  remarkPlugins={[remarkGfm]}
419
428
  rehypePlugins={[rehypeRaw]}
420
- components={{ code: CodeBlock }}
429
+ components={{ a: CustomLink, code: CodeBlock }}
421
430
  >
422
431
  {response.content}
423
432
  </ReactMarkdown>