lisichatbot 2.1.0 → 2.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +26 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -231,10 +231,11 @@ function updateEditIcons() {
231
231
  // ✅ FIX: In edit mode, show edit icons for all completed steps (not just previous)
232
232
  const shouldShowInEditMode = chatState.chatMode === 'edit' && chatState.completed && isLatest;
233
233
  const shouldShowNormally = stepNumber < chatState.step && isLatest;
234
- // ✅ In editSteps mode, show edit icons for steps already visited in the editSteps list
235
- const shouldShowInEditSteps = chatState.editSteps && chatState.editSteps.length > 0 &&
236
- chatState.editSteps.includes(stepNumber) &&
237
- chatState.editSteps.indexOf(stepNumber) < chatState.editStepsIndex && isLatest;
234
+ // ✅ In editSteps mode, show for visited steps (not the current one being shown)
235
+ const isInEditStepsMode = chatState.editSteps && chatState.editSteps.length > 0;
236
+ const editStepPosition = isInEditStepsMode ? chatState.editSteps.indexOf(stepNumber) : -1;
237
+ const shouldShowInEditSteps = isInEditStepsMode && isLatest &&
238
+ editStepPosition !== -1 && editStepPosition < chatState.editStepsIndex;
238
239
 
239
240
  if ((hasInput || forceShowEdit) && (shouldShowInEditMode || shouldShowNormally || shouldShowInEditSteps)) {
240
241
  editIcon.onclick = (e) => {
@@ -2610,6 +2611,27 @@ async function handleNext() {
2610
2611
  const historyCopy = [...chatState.history];
2611
2612
  const callback = chatState.onEditComplete;
2612
2613
 
2614
+ // ✅ Show loader on next button while onEditComplete executes
2615
+ const nextBtnText = elements.nextBtn ? elements.nextBtn.querySelector('[data-chat-element="next-button-text"]') : null;
2616
+ const nextBtnLoader = elements.nextBtn ? elements.nextBtn.querySelector('[data-chat-element="next-button-loader"]') : null;
2617
+
2618
+ if (nextBtnText) nextBtnText.style.display = 'none';
2619
+ if (nextBtnLoader) nextBtnLoader.style.display = 'block';
2620
+
2621
+ // Call onEditComplete callback (await if async)
2622
+ if (callback) {
2623
+ console.log('📞 Calling onEditComplete with data:', dataCopy);
2624
+ try {
2625
+ await callback(dataCopy);
2626
+ } catch (error) {
2627
+ console.error('Error in onEditComplete callback:', error);
2628
+ }
2629
+ }
2630
+
2631
+ // ✅ Hide loader and restore button text after callback completes
2632
+ if (nextBtnText) nextBtnText.style.display = '';
2633
+ if (nextBtnLoader) nextBtnLoader.style.display = 'none';
2634
+
2613
2635
  // Clean up edit-steps state
2614
2636
  chatState.editSteps = null;
2615
2637
  chatState.editStepsIndex = 0;
@@ -2643,16 +2665,6 @@ async function handleNext() {
2643
2665
  window.dispatchEvent(event);
2644
2666
  }
2645
2667
 
2646
- // Call onEditComplete callback with updated data
2647
- if (callback) {
2648
- console.log('📞 Calling onEditComplete with data:', dataCopy);
2649
- try {
2650
- callback(dataCopy);
2651
- } catch (error) {
2652
- console.error('Error in onEditComplete callback:', error);
2653
- }
2654
- }
2655
-
2656
2668
  return;
2657
2669
  }
2658
2670
  }