lisichatbot 1.1.9 β†’ 1.2.0

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 +48 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -166,6 +166,41 @@ function addMessage(content, type = 'bot', hasInput = false, stepNumber = null)
166
166
  scrollToBottom();
167
167
  }
168
168
 
169
+ // =============================================================================
170
+ // UPDATE EDIT ICONS FOR PREVIOUS STEPS
171
+ // =============================================================================
172
+
173
+ function updateEditIcons() {
174
+ // Find all rendered bot message wrappers
175
+ const allBotMessages = elements.messages.querySelectorAll('[data-chat-element="bot-message-wrapper"]');
176
+
177
+ console.log(`\nπŸ”„ Updating edit icons - Current step: ${chatState.step}`);
178
+
179
+ allBotMessages.forEach(wrapper => {
180
+ const stepNumber = parseInt(wrapper.getAttribute('data-chat-step'));
181
+ const editIcon = wrapper.querySelector('[data-chat-element="bot-edit-icon"]');
182
+
183
+ if (editIcon && !isNaN(stepNumber)) {
184
+ // Check if this step has input by looking at the flow
185
+ const stepData = flowData.flow[stepNumber];
186
+ const hasInput = stepData && !!stepData.input;
187
+
188
+ // Show icon if: has input AND is previous step
189
+ if (hasInput && stepNumber < chatState.step) {
190
+ editIcon.style.setProperty('display', 'block', 'important');
191
+ console.log(` ✏️ Step ${stepNumber}: Icon SHOWN (previous step)`);
192
+ } else {
193
+ editIcon.style.setProperty('display', 'none', 'important');
194
+ if (stepNumber === chatState.step) {
195
+ console.log(` ⏸️ Step ${stepNumber}: Icon HIDDEN (current step)`);
196
+ } else if (!hasInput) {
197
+ console.log(` βšͺ Step ${stepNumber}: Icon HIDDEN (no input)`);
198
+ }
199
+ }
200
+ }
201
+ });
202
+ }
203
+
169
204
  // =============================================================================
170
205
  // OPTIONS RENDERING WITH CUSTOM ATTRIBUTES
171
206
  // =============================================================================
@@ -502,6 +537,9 @@ async function handleNext() {
502
537
 
503
538
  // Move to next step
504
539
  chatState.step++;
540
+
541
+ // Update edit icons for all previous steps
542
+ updateEditIcons();
505
543
 
506
544
  // Check if finished
507
545
  if (chatState.step >= flowData.flow.length) {
@@ -575,6 +613,10 @@ async function showNextStep() {
575
613
  // Auto-advance for steps without input
576
614
  setTimeout(() => {
577
615
  chatState.step++;
616
+
617
+ // Update edit icons after auto-advance
618
+ updateEditIcons();
619
+
578
620
  if (chatState.step < flowData.flow.length) {
579
621
  showNextStep();
580
622
  } else {
@@ -582,6 +624,12 @@ async function showNextStep() {
582
624
  }
583
625
  }, config.autoAdvanceDelay);
584
626
  }
627
+
628
+ // Always update edit icons at the end to ensure correct state
629
+ // Use setTimeout to ensure it runs after any DOM updates
630
+ setTimeout(() => {
631
+ updateEditIcons();
632
+ }, 10);
585
633
  }
586
634
 
587
635
  function handleCompletion() {