@gendive/chatllm 0.17.13 → 0.17.15
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 +42 -10
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +42 -10
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -1346,6 +1346,7 @@ var useProject = (options) => {
|
|
|
1346
1346
|
var generateId2 = () => {
|
|
1347
1347
|
return Math.random().toString(36).substring(2, 11);
|
|
1348
1348
|
};
|
|
1349
|
+
var stripInlineMarkdown = (text) => text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
|
|
1349
1350
|
var parsePollFromContent = (content) => {
|
|
1350
1351
|
const pollRegex = /<poll([^>]*)>([\s\S]*?)<\/poll>/gi;
|
|
1351
1352
|
const polls = [];
|
|
@@ -1380,12 +1381,12 @@ var parsePollFromContent = (content) => {
|
|
|
1380
1381
|
let optionMatch;
|
|
1381
1382
|
while ((optionMatch = optionTagRegex.exec(innerContent)) !== null) {
|
|
1382
1383
|
const optionAttrs = optionMatch[1];
|
|
1383
|
-
const optionLabel = optionMatch[2].trim();
|
|
1384
|
+
const optionLabel = stripInlineMarkdown(optionMatch[2].trim());
|
|
1384
1385
|
const descMatch = optionAttrs.match(/description=["']([^"']+)["']/i);
|
|
1385
1386
|
options.push({
|
|
1386
1387
|
id: generateId2(),
|
|
1387
1388
|
label: optionLabel,
|
|
1388
|
-
description: descMatch?.[1]
|
|
1389
|
+
description: descMatch?.[1] ? stripInlineMarkdown(descMatch[1]) : void 0
|
|
1389
1390
|
});
|
|
1390
1391
|
}
|
|
1391
1392
|
if (options.length === 0) {
|
|
@@ -1395,8 +1396,8 @@ var parsePollFromContent = (content) => {
|
|
|
1395
1396
|
const fullText = listMatch[1].trim();
|
|
1396
1397
|
const colonIndex = fullText.indexOf(":");
|
|
1397
1398
|
if (colonIndex > 0) {
|
|
1398
|
-
const label = fullText.substring(0, colonIndex).trim();
|
|
1399
|
-
const description = fullText.substring(colonIndex + 1).trim();
|
|
1399
|
+
const label = stripInlineMarkdown(fullText.substring(0, colonIndex).trim());
|
|
1400
|
+
const description = stripInlineMarkdown(fullText.substring(colonIndex + 1).trim());
|
|
1400
1401
|
options.push({
|
|
1401
1402
|
id: generateId2(),
|
|
1402
1403
|
label,
|
|
@@ -1405,7 +1406,7 @@ var parsePollFromContent = (content) => {
|
|
|
1405
1406
|
} else {
|
|
1406
1407
|
options.push({
|
|
1407
1408
|
id: generateId2(),
|
|
1408
|
-
label: fullText
|
|
1409
|
+
label: stripInlineMarkdown(fullText)
|
|
1409
1410
|
});
|
|
1410
1411
|
}
|
|
1411
1412
|
}
|
|
@@ -1416,14 +1417,14 @@ var parsePollFromContent = (content) => {
|
|
|
1416
1417
|
while ((numMatch = numberedRegex.exec(innerContent)) !== null) {
|
|
1417
1418
|
options.push({
|
|
1418
1419
|
id: generateId2(),
|
|
1419
|
-
label: numMatch[1].trim()
|
|
1420
|
+
label: stripInlineMarkdown(numMatch[1].trim())
|
|
1420
1421
|
});
|
|
1421
1422
|
}
|
|
1422
1423
|
}
|
|
1423
1424
|
if (questionText && options.length >= 2) {
|
|
1424
1425
|
const pollQuestion = {
|
|
1425
1426
|
id: generateId2(),
|
|
1426
|
-
question: questionText,
|
|
1427
|
+
question: stripInlineMarkdown(questionText),
|
|
1427
1428
|
options,
|
|
1428
1429
|
multiSelect,
|
|
1429
1430
|
allowOther,
|
|
@@ -7038,6 +7039,37 @@ var DeepResearchProgressUI = ({ progress }) => {
|
|
|
7038
7039
|
// src/react/components/PollCard.tsx
|
|
7039
7040
|
import { useState as useState11, useCallback as useCallback6, useEffect as useEffect7 } from "react";
|
|
7040
7041
|
import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
7042
|
+
var renderInlineMarkdown = (text) => {
|
|
7043
|
+
const parts = [];
|
|
7044
|
+
let remaining = text;
|
|
7045
|
+
let key = 0;
|
|
7046
|
+
while (remaining.length > 0) {
|
|
7047
|
+
const match = remaining.match(
|
|
7048
|
+
/(\*\*(.+?)\*\*|__(.+?)__|`(.+?)`|~~(.+?)~~|\*(.+?)\*|_(.+?)_)/
|
|
7049
|
+
);
|
|
7050
|
+
if (!match || match.index === void 0) {
|
|
7051
|
+
parts.push(remaining);
|
|
7052
|
+
break;
|
|
7053
|
+
}
|
|
7054
|
+
if (match.index > 0) {
|
|
7055
|
+
parts.push(remaining.slice(0, match.index));
|
|
7056
|
+
}
|
|
7057
|
+
const fullMatch = match[0];
|
|
7058
|
+
if (match[2] || match[3]) {
|
|
7059
|
+
parts.push(/* @__PURE__ */ jsx9("strong", { children: match[2] || match[3] }, key++));
|
|
7060
|
+
} else if (match[4]) {
|
|
7061
|
+
parts.push(
|
|
7062
|
+
/* @__PURE__ */ jsx9("code", { style: { backgroundColor: "var(--chatllm-bg-tertiary, #f1f5f9)", padding: "1px 4px", borderRadius: "3px", fontSize: "0.9em" }, children: match[4] }, key++)
|
|
7063
|
+
);
|
|
7064
|
+
} else if (match[5]) {
|
|
7065
|
+
parts.push(/* @__PURE__ */ jsx9("s", { children: match[5] }, key++));
|
|
7066
|
+
} else if (match[6] || match[7]) {
|
|
7067
|
+
parts.push(/* @__PURE__ */ jsx9("em", { children: match[6] || match[7] }, key++));
|
|
7068
|
+
}
|
|
7069
|
+
remaining = remaining.slice(match.index + fullMatch.length);
|
|
7070
|
+
}
|
|
7071
|
+
return parts.length === 1 && typeof parts[0] === "string" ? parts[0] : /* @__PURE__ */ jsx9(Fragment5, { children: parts });
|
|
7072
|
+
};
|
|
7041
7073
|
var stripMarkdown = (text) => text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
|
|
7042
7074
|
var PollCard = ({
|
|
7043
7075
|
questions,
|
|
@@ -7196,7 +7228,7 @@ var PollCard = ({
|
|
|
7196
7228
|
fontWeight: 600,
|
|
7197
7229
|
color: "var(--chatllm-text, #1e293b)"
|
|
7198
7230
|
},
|
|
7199
|
-
children:
|
|
7231
|
+
children: renderInlineMarkdown(currentQuestion.question)
|
|
7200
7232
|
}
|
|
7201
7233
|
),
|
|
7202
7234
|
currentQuestion.multiSelect && /* @__PURE__ */ jsx9(
|
|
@@ -7264,7 +7296,7 @@ var PollCard = ({
|
|
|
7264
7296
|
color: "var(--chatllm-text, #1e293b)",
|
|
7265
7297
|
lineHeight: "1.4"
|
|
7266
7298
|
},
|
|
7267
|
-
children:
|
|
7299
|
+
children: renderInlineMarkdown(option.label)
|
|
7268
7300
|
}
|
|
7269
7301
|
),
|
|
7270
7302
|
option.description && /* @__PURE__ */ jsx9(
|
|
@@ -7276,7 +7308,7 @@ var PollCard = ({
|
|
|
7276
7308
|
marginTop: "2px",
|
|
7277
7309
|
lineHeight: "1.3"
|
|
7278
7310
|
},
|
|
7279
|
-
children:
|
|
7311
|
+
children: renderInlineMarkdown(option.description)
|
|
7280
7312
|
}
|
|
7281
7313
|
)
|
|
7282
7314
|
] })
|