@gendive/chatllm 0.17.14 → 0.17.16
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 +149 -72
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +149 -72
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -1412,6 +1412,7 @@ var useProject = (options) => {
|
|
|
1412
1412
|
var generateId2 = () => {
|
|
1413
1413
|
return Math.random().toString(36).substring(2, 11);
|
|
1414
1414
|
};
|
|
1415
|
+
var stripInlineMarkdown = (text) => text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
|
|
1415
1416
|
var parsePollFromContent = (content) => {
|
|
1416
1417
|
const pollRegex = /<poll([^>]*)>([\s\S]*?)<\/poll>/gi;
|
|
1417
1418
|
const polls = [];
|
|
@@ -1446,12 +1447,12 @@ var parsePollFromContent = (content) => {
|
|
|
1446
1447
|
let optionMatch;
|
|
1447
1448
|
while ((optionMatch = optionTagRegex.exec(innerContent)) !== null) {
|
|
1448
1449
|
const optionAttrs = optionMatch[1];
|
|
1449
|
-
const optionLabel = optionMatch[2].trim();
|
|
1450
|
+
const optionLabel = stripInlineMarkdown(optionMatch[2].trim());
|
|
1450
1451
|
const descMatch = optionAttrs.match(/description=["']([^"']+)["']/i);
|
|
1451
1452
|
options.push({
|
|
1452
1453
|
id: generateId2(),
|
|
1453
1454
|
label: optionLabel,
|
|
1454
|
-
description: descMatch?.[1]
|
|
1455
|
+
description: descMatch?.[1] ? stripInlineMarkdown(descMatch[1]) : void 0
|
|
1455
1456
|
});
|
|
1456
1457
|
}
|
|
1457
1458
|
if (options.length === 0) {
|
|
@@ -1461,8 +1462,8 @@ var parsePollFromContent = (content) => {
|
|
|
1461
1462
|
const fullText = listMatch[1].trim();
|
|
1462
1463
|
const colonIndex = fullText.indexOf(":");
|
|
1463
1464
|
if (colonIndex > 0) {
|
|
1464
|
-
const label = fullText.substring(0, colonIndex).trim();
|
|
1465
|
-
const description = fullText.substring(colonIndex + 1).trim();
|
|
1465
|
+
const label = stripInlineMarkdown(fullText.substring(0, colonIndex).trim());
|
|
1466
|
+
const description = stripInlineMarkdown(fullText.substring(colonIndex + 1).trim());
|
|
1466
1467
|
options.push({
|
|
1467
1468
|
id: generateId2(),
|
|
1468
1469
|
label,
|
|
@@ -1471,7 +1472,7 @@ var parsePollFromContent = (content) => {
|
|
|
1471
1472
|
} else {
|
|
1472
1473
|
options.push({
|
|
1473
1474
|
id: generateId2(),
|
|
1474
|
-
label: fullText
|
|
1475
|
+
label: stripInlineMarkdown(fullText)
|
|
1475
1476
|
});
|
|
1476
1477
|
}
|
|
1477
1478
|
}
|
|
@@ -1482,14 +1483,14 @@ var parsePollFromContent = (content) => {
|
|
|
1482
1483
|
while ((numMatch = numberedRegex.exec(innerContent)) !== null) {
|
|
1483
1484
|
options.push({
|
|
1484
1485
|
id: generateId2(),
|
|
1485
|
-
label: numMatch[1].trim()
|
|
1486
|
+
label: stripInlineMarkdown(numMatch[1].trim())
|
|
1486
1487
|
});
|
|
1487
1488
|
}
|
|
1488
1489
|
}
|
|
1489
1490
|
if (questionText && options.length >= 2) {
|
|
1490
1491
|
const pollQuestion = {
|
|
1491
1492
|
id: generateId2(),
|
|
1492
|
-
question: questionText,
|
|
1493
|
+
question: stripInlineMarkdown(questionText),
|
|
1493
1494
|
options,
|
|
1494
1495
|
multiSelect,
|
|
1495
1496
|
allowOther,
|
|
@@ -6511,7 +6512,12 @@ var MarkdownRenderer = ({
|
|
|
6511
6512
|
processedContent = processedContent.replace(UNCLOSED_THINKING_TAG_REGEX, "");
|
|
6512
6513
|
}
|
|
6513
6514
|
processedContent = processedContent.replace(/<poll[^>]*>[\s\S]*?<\/poll>/gi, "");
|
|
6515
|
+
const hasUnfinishedPoll = UNCLOSED_POLL_TAG_REGEX.test(processedContent);
|
|
6516
|
+
UNCLOSED_POLL_TAG_REGEX.lastIndex = 0;
|
|
6514
6517
|
processedContent = processedContent.replace(UNCLOSED_POLL_TAG_REGEX, "");
|
|
6518
|
+
if (hasUnfinishedPoll) {
|
|
6519
|
+
processedContent += "\n\xA7POLL_LOADING\xA7";
|
|
6520
|
+
}
|
|
6515
6521
|
processedContent = processedContent.replace(UNCLOSED_SKILL_TAG_REGEX, "");
|
|
6516
6522
|
const codeBlocks = [];
|
|
6517
6523
|
processedContent = processedContent.replace(CODE_BLOCK_REGEX, (match, lang, code) => {
|
|
@@ -6647,6 +6653,46 @@ var MarkdownRenderer = ({
|
|
|
6647
6653
|
);
|
|
6648
6654
|
return;
|
|
6649
6655
|
}
|
|
6656
|
+
if (line.trim() === "\xA7POLL_LOADING\xA7") {
|
|
6657
|
+
flushList();
|
|
6658
|
+
flushBlockquote();
|
|
6659
|
+
elements.push(
|
|
6660
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
6661
|
+
"div",
|
|
6662
|
+
{
|
|
6663
|
+
style: {
|
|
6664
|
+
display: "flex",
|
|
6665
|
+
alignItems: "center",
|
|
6666
|
+
gap: "8px",
|
|
6667
|
+
padding: "14px 16px",
|
|
6668
|
+
backgroundColor: "var(--chatllm-bg-secondary, #f9fafb)",
|
|
6669
|
+
borderRadius: "10px",
|
|
6670
|
+
border: "1px solid var(--chatllm-border, #e5e7eb)",
|
|
6671
|
+
marginTop: "12px",
|
|
6672
|
+
animation: "chatllm-pulse 1.5s ease-in-out infinite"
|
|
6673
|
+
},
|
|
6674
|
+
children: [
|
|
6675
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
6676
|
+
"div",
|
|
6677
|
+
{
|
|
6678
|
+
style: {
|
|
6679
|
+
width: "18px",
|
|
6680
|
+
height: "18px",
|
|
6681
|
+
borderRadius: "50%",
|
|
6682
|
+
border: "2px solid var(--chatllm-primary, #4A90E2)",
|
|
6683
|
+
borderTopColor: "transparent",
|
|
6684
|
+
animation: "chatllm-spin 0.8s linear infinite"
|
|
6685
|
+
}
|
|
6686
|
+
}
|
|
6687
|
+
),
|
|
6688
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: { fontSize: "13px", color: "var(--chatllm-text-muted, #64748b)" }, children: "\uC120\uD0DD\uC9C0\uB97C \uC900\uBE44\uD558\uACE0 \uC788\uC5B4\uC694..." })
|
|
6689
|
+
]
|
|
6690
|
+
},
|
|
6691
|
+
`poll-loading-${lineIndex}`
|
|
6692
|
+
)
|
|
6693
|
+
);
|
|
6694
|
+
return;
|
|
6695
|
+
}
|
|
6650
6696
|
const codeBlockMatch = line.match(/§CODEBLOCK§(\d+)§\/CODEBLOCK§/);
|
|
6651
6697
|
if (codeBlockMatch) {
|
|
6652
6698
|
flushList();
|
|
@@ -7214,6 +7260,26 @@ var PollCard = ({
|
|
|
7214
7260
|
const currentHasSelection = getSelectionCount(currentQuestion.id) > 0;
|
|
7215
7261
|
const isLastTab = activeTab === questions.length - 1;
|
|
7216
7262
|
const totalSelected = questions.reduce((sum, q) => sum + getSelectionCount(q.id), 0);
|
|
7263
|
+
const [visibleCount, setVisibleCount] = (0, import_react13.useState)(0);
|
|
7264
|
+
const [cardVisible, setCardVisible] = (0, import_react13.useState)(false);
|
|
7265
|
+
(0, import_react13.useEffect)(() => {
|
|
7266
|
+
const fadeTimer = setTimeout(() => setCardVisible(true), 50);
|
|
7267
|
+
const totalItems = currentQuestion.options.length + 1;
|
|
7268
|
+
const timers = [fadeTimer];
|
|
7269
|
+
for (let i = 1; i <= totalItems; i++) {
|
|
7270
|
+
timers.push(setTimeout(() => setVisibleCount(i), 150 + i * 80));
|
|
7271
|
+
}
|
|
7272
|
+
return () => timers.forEach(clearTimeout);
|
|
7273
|
+
}, [currentQuestion.options.length]);
|
|
7274
|
+
(0, import_react13.useEffect)(() => {
|
|
7275
|
+
setVisibleCount(0);
|
|
7276
|
+
const totalItems = currentQuestion.options.length + 1;
|
|
7277
|
+
const timers = [];
|
|
7278
|
+
for (let i = 1; i <= totalItems; i++) {
|
|
7279
|
+
timers.push(setTimeout(() => setVisibleCount(i), i * 80));
|
|
7280
|
+
}
|
|
7281
|
+
return () => timers.forEach(clearTimeout);
|
|
7282
|
+
}, [activeTab, currentQuestion.options.length]);
|
|
7217
7283
|
const handleNext = (0, import_react13.useCallback)(() => {
|
|
7218
7284
|
if (!isLastTab) {
|
|
7219
7285
|
setActiveTab((prev) => prev + 1);
|
|
@@ -7230,6 +7296,9 @@ var PollCard = ({
|
|
|
7230
7296
|
borderRadius: "12px",
|
|
7231
7297
|
border: "1px solid var(--chatllm-border, #e5e7eb)",
|
|
7232
7298
|
overflow: "hidden",
|
|
7299
|
+
opacity: cardVisible ? 1 : 0,
|
|
7300
|
+
transform: cardVisible ? "translateY(0)" : "translateY(8px)",
|
|
7301
|
+
transition: "opacity 0.3s ease, transform 0.3s ease",
|
|
7233
7302
|
marginTop: "12px"
|
|
7234
7303
|
},
|
|
7235
7304
|
children: [
|
|
@@ -7311,8 +7380,9 @@ var PollCard = ({
|
|
|
7311
7380
|
}
|
|
7312
7381
|
),
|
|
7313
7382
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { padding: "8px" }, children: [
|
|
7314
|
-
currentQuestion.options.map((option) => {
|
|
7383
|
+
currentQuestion.options.map((option, optIdx) => {
|
|
7315
7384
|
const isSelected = selections[currentQuestion.id]?.has(option.id) || false;
|
|
7385
|
+
const isVisible = optIdx < visibleCount;
|
|
7316
7386
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
7317
7387
|
"button",
|
|
7318
7388
|
{
|
|
@@ -7328,8 +7398,10 @@ var PollCard = ({
|
|
|
7328
7398
|
borderRadius: "8px",
|
|
7329
7399
|
cursor: "pointer",
|
|
7330
7400
|
textAlign: "left",
|
|
7331
|
-
transition: "all 0.
|
|
7332
|
-
marginBottom: "6px"
|
|
7401
|
+
transition: "all 0.2s ease",
|
|
7402
|
+
marginBottom: "6px",
|
|
7403
|
+
opacity: isVisible ? 1 : 0,
|
|
7404
|
+
transform: isVisible ? "translateY(0)" : "translateY(6px)"
|
|
7333
7405
|
},
|
|
7334
7406
|
children: [
|
|
7335
7407
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -7382,68 +7454,73 @@ var PollCard = ({
|
|
|
7382
7454
|
option.id
|
|
7383
7455
|
);
|
|
7384
7456
|
}),
|
|
7385
|
-
currentQuestion.allowOther !== false &&
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
"
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7457
|
+
currentQuestion.allowOther !== false && (() => {
|
|
7458
|
+
const otherVisible = currentQuestion.options.length < visibleCount;
|
|
7459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7460
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
7461
|
+
"button",
|
|
7462
|
+
{
|
|
7463
|
+
onClick: () => handleOtherToggle(currentQuestion.id, currentQuestion.multiSelect ?? false),
|
|
7464
|
+
style: {
|
|
7465
|
+
width: "100%",
|
|
7466
|
+
display: "flex",
|
|
7467
|
+
alignItems: "center",
|
|
7468
|
+
gap: "12px",
|
|
7469
|
+
padding: "12px 14px",
|
|
7470
|
+
backgroundColor: otherSelected[currentQuestion.id] ? "var(--chatllm-primary-light, rgba(74, 144, 226, 0.08))" : "transparent",
|
|
7471
|
+
border: otherSelected[currentQuestion.id] ? "1px solid var(--chatllm-primary, #4A90E2)" : "1px solid var(--chatllm-border, #e5e7eb)",
|
|
7472
|
+
borderRadius: "8px",
|
|
7473
|
+
cursor: "pointer",
|
|
7474
|
+
textAlign: "left",
|
|
7475
|
+
transition: "all 0.2s ease",
|
|
7476
|
+
opacity: otherVisible ? 1 : 0,
|
|
7477
|
+
transform: otherVisible ? "translateY(0)" : "translateY(6px)"
|
|
7478
|
+
},
|
|
7479
|
+
children: [
|
|
7480
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7481
|
+
"div",
|
|
7482
|
+
{
|
|
7483
|
+
style: {
|
|
7484
|
+
width: "20px",
|
|
7485
|
+
height: "20px",
|
|
7486
|
+
borderRadius: currentQuestion.multiSelect ? "4px" : "50%",
|
|
7487
|
+
border: `2px solid ${otherSelected[currentQuestion.id] ? "var(--chatllm-primary, #4A90E2)" : "var(--chatllm-border, #d1d5db)"}`,
|
|
7488
|
+
backgroundColor: otherSelected[currentQuestion.id] ? "var(--chatllm-primary, #4A90E2)" : "transparent",
|
|
7489
|
+
display: "flex",
|
|
7490
|
+
alignItems: "center",
|
|
7491
|
+
justifyContent: "center",
|
|
7492
|
+
flexShrink: 0,
|
|
7493
|
+
transition: "all 0.15s ease"
|
|
7494
|
+
},
|
|
7495
|
+
children: otherSelected[currentQuestion.id] && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(IconSvg, { name: "check-line", size: 14, color: "#fff" })
|
|
7496
|
+
}
|
|
7497
|
+
),
|
|
7498
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { fontSize: "14px", color: "var(--chatllm-text-muted, #64748b)" }, children: "\uAE30\uD0C0" })
|
|
7499
|
+
]
|
|
7500
|
+
}
|
|
7501
|
+
),
|
|
7502
|
+
otherSelected[currentQuestion.id] && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { padding: "8px 0 4px 32px" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7503
|
+
"input",
|
|
7504
|
+
{
|
|
7505
|
+
type: "text",
|
|
7506
|
+
value: otherTexts[currentQuestion.id] || "",
|
|
7507
|
+
onChange: (e) => setOtherTexts((prev) => ({ ...prev, [currentQuestion.id]: e.target.value })),
|
|
7508
|
+
placeholder: "\uC9C1\uC811 \uC785\uB825...",
|
|
7509
|
+
style: {
|
|
7510
|
+
width: "100%",
|
|
7511
|
+
padding: "10px 12px",
|
|
7512
|
+
backgroundColor: "var(--chatllm-bg-secondary, #f9fafb)",
|
|
7513
|
+
border: "1px solid var(--chatllm-border, #e5e7eb)",
|
|
7514
|
+
borderRadius: "6px",
|
|
7515
|
+
color: "var(--chatllm-text, #1e293b)",
|
|
7516
|
+
fontSize: "13px",
|
|
7517
|
+
outline: "none"
|
|
7518
|
+
},
|
|
7519
|
+
autoFocus: true
|
|
7520
|
+
}
|
|
7521
|
+
) })
|
|
7522
|
+
] });
|
|
7523
|
+
})()
|
|
7447
7524
|
] }),
|
|
7448
7525
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
7449
7526
|
"div",
|