lisichatbot 2.0.1 → 2.0.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/package.json +1 -1
- package/src/index.js +40 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -213,16 +213,21 @@ function updateEditIcons() {
|
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
// ✅ FIX: In edit mode, keep edit icons visible even after completion
|
|
217
|
+
if (chatState.completed && chatState.chatMode !== 'edit') {
|
|
217
218
|
editIcon.style.setProperty('display', 'none', 'important');
|
|
218
|
-
console.log(` 🏁 Step ${stepNumber}: Icon HIDDEN (flow completed)`);
|
|
219
|
+
console.log(` 🏁 Step ${stepNumber}: Icon HIDDEN (flow completed in create mode)`);
|
|
219
220
|
return;
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
// ✅ NEW: Check if edit icon should be forced to show (even without input)
|
|
223
224
|
const forceShowEdit = stepData && stepData.showEditIcon === true;
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
// ✅ FIX: In edit mode, show edit icons for all completed steps (not just previous)
|
|
227
|
+
const shouldShowInEditMode = chatState.chatMode === 'edit' && chatState.completed && isLatest;
|
|
228
|
+
const shouldShowNormally = stepNumber < chatState.step && isLatest;
|
|
229
|
+
|
|
230
|
+
if ((hasInput || forceShowEdit) && (shouldShowInEditMode || shouldShowNormally)) {
|
|
226
231
|
editIcon.onclick = (e) => {
|
|
227
232
|
e.stopPropagation();
|
|
228
233
|
e.preventDefault();
|
|
@@ -575,7 +580,19 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
575
580
|
// ✅ Initial tag render if pre-filled (edit mode)
|
|
576
581
|
if (selectedValues.size > 0) {
|
|
577
582
|
renderTags(field, options, tagsContainer, tagTemplateClone, optionsContainer);
|
|
583
|
+
|
|
584
|
+
// ✅ NEW: Set currentSelection for pre-filled data so user message shows
|
|
585
|
+
chatState.currentSelection = {
|
|
586
|
+
field,
|
|
587
|
+
value: existingData,
|
|
588
|
+
name: existingData.map(v => {
|
|
589
|
+
const opt = options.find(o => o.value === v);
|
|
590
|
+
return opt ? opt.name : v;
|
|
591
|
+
}).join(', ')
|
|
592
|
+
};
|
|
593
|
+
|
|
578
594
|
console.log(` ✅ Pre-filled ${selectedValues.size} selections, Next button enabled`);
|
|
595
|
+
console.log(` 📝 Set currentSelection.name: "${chatState.currentSelection.name}"`);
|
|
579
596
|
}
|
|
580
597
|
|
|
581
598
|
elements.messages.appendChild(clone);
|
|
@@ -3178,6 +3195,26 @@ async function showNextStep() {
|
|
|
3178
3195
|
console.log(` ⏱️ Auto-advance delay: ${delay}ms ${nextStep.autoAdvanceDelay !== undefined ? '(step-level)' : '(global)'}`);
|
|
3179
3196
|
|
|
3180
3197
|
setTimeout(() => {
|
|
3198
|
+
// ✅ NEW: Add user message if there's a currentSelection (pre-filled value)
|
|
3199
|
+
if (chatState.currentSelection && chatState.currentSelection.name) {
|
|
3200
|
+
const prefix = nextStep.input?.selectedInputPrefix || '';
|
|
3201
|
+
const suffix = nextStep.input?.selectedInputSuffix || '';
|
|
3202
|
+
let displayName = chatState.currentSelection.name;
|
|
3203
|
+
|
|
3204
|
+
if (prefix) displayName = `${prefix} ${displayName}`;
|
|
3205
|
+
if (suffix) displayName = `${displayName} ${suffix}`;
|
|
3206
|
+
|
|
3207
|
+
console.log(`📝 Adding user message for auto-advance: "${displayName}"`);
|
|
3208
|
+
addMessage(displayName, 'user', false, chatState.step);
|
|
3209
|
+
|
|
3210
|
+
chatState.history.push({
|
|
3211
|
+
step: chatState.step,
|
|
3212
|
+
field: chatState.currentSelection.field,
|
|
3213
|
+
value: chatState.currentSelection.value,
|
|
3214
|
+
displayName: displayName
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3181
3218
|
// ✅ NEW: Find next accessible step
|
|
3182
3219
|
chatState.step = findNextAccessibleStep(chatState.step);
|
|
3183
3220
|
updateEditIcons();
|