lisichatbot 1.6.8 → 1.6.9
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/package.json +1 -1
- package/src/index.js +38 -13
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -229,7 +229,10 @@ function updateEditIcons() {
|
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
if
|
|
232
|
+
// ✅ NEW: Check if edit icon should be forced to show (even without input)
|
|
233
|
+
const forceShowEdit = stepData && stepData.showEditIcon === true;
|
|
234
|
+
|
|
235
|
+
if ((hasInput || forceShowEdit) && stepNumber < chatState.step && isLatest) {
|
|
233
236
|
editIcon.onclick = (e) => {
|
|
234
237
|
e.stopPropagation();
|
|
235
238
|
e.preventDefault();
|
|
@@ -2424,6 +2427,16 @@ function findNextAccessibleStep(currentStep) {
|
|
|
2424
2427
|
async function showNextStep() {
|
|
2425
2428
|
const nextStep = flowData.flow[chatState.step];
|
|
2426
2429
|
|
|
2430
|
+
// ✅ NEW: Clean up any previously injected elements (from addElements)
|
|
2431
|
+
// BUT: If this step has addElements, we'll re-inject them below
|
|
2432
|
+
if (elements.messages) {
|
|
2433
|
+
const injectedElements = elements.messages.querySelectorAll('[data-chat-injected="true"]');
|
|
2434
|
+
if (injectedElements.length > 0) {
|
|
2435
|
+
console.log(` 🧹 Removing ${injectedElements.length} previously injected element(s)`);
|
|
2436
|
+
injectedElements.forEach(el => el.remove());
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2427
2440
|
// ✅ NEW: Check if step should be displayed based on condition
|
|
2428
2441
|
if (nextStep.shouldDisplay) {
|
|
2429
2442
|
let shouldShow = false;
|
|
@@ -2793,6 +2806,9 @@ async function showNextStep() {
|
|
|
2793
2806
|
// Make it visible (in case it was hidden)
|
|
2794
2807
|
clonedElement.style.display = '';
|
|
2795
2808
|
|
|
2809
|
+
// ✅ Mark as injected for cleanup
|
|
2810
|
+
clonedElement.setAttribute('data-chat-injected', 'true');
|
|
2811
|
+
|
|
2796
2812
|
// Add to messages container
|
|
2797
2813
|
elements.messages.appendChild(clonedElement);
|
|
2798
2814
|
|
|
@@ -2888,20 +2904,29 @@ async function showNextStep() {
|
|
|
2888
2904
|
// If hasPreFill, renderOptions already handled it
|
|
2889
2905
|
}
|
|
2890
2906
|
} else {
|
|
2891
|
-
|
|
2892
|
-
|
|
2907
|
+
// ✅ FIXED: Only auto-advance if explicitly enabled OR if step has autoAdvance
|
|
2908
|
+
const shouldAutoAdvance = nextStep.autoAdvance === true;
|
|
2893
2909
|
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
updateEditIcons();
|
|
2910
|
+
if (shouldAutoAdvance) {
|
|
2911
|
+
const delay = nextStep.autoAdvanceDelay !== undefined ? nextStep.autoAdvanceDelay : config.autoAdvanceDelay;
|
|
2912
|
+
console.log(` ⏱️ Auto-advance delay: ${delay}ms ${nextStep.autoAdvanceDelay !== undefined ? '(step-level)' : '(global)'}`);
|
|
2898
2913
|
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2914
|
+
setTimeout(() => {
|
|
2915
|
+
// ✅ NEW: Find next accessible step
|
|
2916
|
+
chatState.step = findNextAccessibleStep(chatState.step);
|
|
2917
|
+
updateEditIcons();
|
|
2918
|
+
|
|
2919
|
+
if (chatState.step < flowData.flow.length) {
|
|
2920
|
+
showNextStep();
|
|
2921
|
+
} else {
|
|
2922
|
+
handleCompletion();
|
|
2923
|
+
}
|
|
2924
|
+
}, delay);
|
|
2925
|
+
} else {
|
|
2926
|
+
// ✅ No input and no auto-advance - just enable Next button
|
|
2927
|
+
enableNextButton();
|
|
2928
|
+
console.log(' 🔓 No input field - Next button enabled for manual progression');
|
|
2929
|
+
}
|
|
2905
2930
|
}
|
|
2906
2931
|
|
|
2907
2932
|
const showNextButton = nextStep.nextButtonDisplay !== false;
|