lisichatbot 1.1.8 → 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.
- package/package.json +1 -1
- package/src/index.js +59 -8
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -110,15 +110,18 @@ function addMessage(content, type = 'bot', hasInput = false, stepNumber = null)
|
|
|
110
110
|
editIcon.style.setProperty('display', 'none', 'important');
|
|
111
111
|
console.log(' ✓ Edit icon hidden (display: none !important)');
|
|
112
112
|
|
|
113
|
-
// Only show if this step has input
|
|
114
|
-
if (hasInput && stepNumber !== null) {
|
|
113
|
+
// Only show if this step has input AND it's a PREVIOUS step (not current)
|
|
114
|
+
if (hasInput && stepNumber !== null && stepNumber < chatState.step) {
|
|
115
115
|
editIcon.setAttribute('data-chat-step', stepNumber);
|
|
116
116
|
editIcon.onclick = (e) => {
|
|
117
117
|
e.stopPropagation();
|
|
118
118
|
editStep(stepNumber);
|
|
119
119
|
};
|
|
120
120
|
editIcon.style.setProperty('display', 'block', 'important');
|
|
121
|
-
|
|
121
|
+
editIcon.style.setProperty('margin-left', '8px', 'important');
|
|
122
|
+
console.log(` ✏️ Edit icon SHOWN (step ${stepNumber} is previous step with input)`);
|
|
123
|
+
} else if (hasInput && stepNumber === chatState.step) {
|
|
124
|
+
console.log(` ⏸️ Edit icon HIDDEN (step ${stepNumber} is CURRENT step)`);
|
|
122
125
|
} else {
|
|
123
126
|
console.log(` ⚪ Edit icon HIDDEN (step ${stepNumber || 'N/A'} has no input)`);
|
|
124
127
|
}
|
|
@@ -146,15 +149,15 @@ function addMessage(content, type = 'bot', hasInput = false, stepNumber = null)
|
|
|
146
149
|
editIconAfterAppend.style.setProperty('display', 'none', 'important');
|
|
147
150
|
editIconAfterAppend.style.setProperty('margin-left', '8px', 'important');
|
|
148
151
|
|
|
149
|
-
// Only show if has input
|
|
150
|
-
if (hasInput && stepNumber !== null) {
|
|
151
|
-
editIconAfterAppend.style.setProperty('display', '
|
|
152
|
+
// Only show if has input AND it's a previous step
|
|
153
|
+
if (hasInput && stepNumber !== null && stepNumber < chatState.step) {
|
|
154
|
+
editIconAfterAppend.style.setProperty('display', 'block', 'important');
|
|
152
155
|
|
|
153
156
|
// Debug: Check spacing
|
|
154
157
|
setTimeout(() => {
|
|
155
158
|
const computedMargin = window.getComputedStyle(editIconAfterAppend).marginLeft;
|
|
156
|
-
const
|
|
157
|
-
console.log(` 📏
|
|
159
|
+
const computedDisplay = window.getComputedStyle(editIconAfterAppend).display;
|
|
160
|
+
console.log(` 📏 Edit icon - Display: ${computedDisplay}, Margin: ${computedMargin}`);
|
|
158
161
|
}, 100);
|
|
159
162
|
}
|
|
160
163
|
}
|
|
@@ -163,6 +166,41 @@ function addMessage(content, type = 'bot', hasInput = false, stepNumber = null)
|
|
|
163
166
|
scrollToBottom();
|
|
164
167
|
}
|
|
165
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
|
+
|
|
166
204
|
// =============================================================================
|
|
167
205
|
// OPTIONS RENDERING WITH CUSTOM ATTRIBUTES
|
|
168
206
|
// =============================================================================
|
|
@@ -499,6 +537,9 @@ async function handleNext() {
|
|
|
499
537
|
|
|
500
538
|
// Move to next step
|
|
501
539
|
chatState.step++;
|
|
540
|
+
|
|
541
|
+
// Update edit icons for all previous steps
|
|
542
|
+
updateEditIcons();
|
|
502
543
|
|
|
503
544
|
// Check if finished
|
|
504
545
|
if (chatState.step >= flowData.flow.length) {
|
|
@@ -572,6 +613,10 @@ async function showNextStep() {
|
|
|
572
613
|
// Auto-advance for steps without input
|
|
573
614
|
setTimeout(() => {
|
|
574
615
|
chatState.step++;
|
|
616
|
+
|
|
617
|
+
// Update edit icons after auto-advance
|
|
618
|
+
updateEditIcons();
|
|
619
|
+
|
|
575
620
|
if (chatState.step < flowData.flow.length) {
|
|
576
621
|
showNextStep();
|
|
577
622
|
} else {
|
|
@@ -579,6 +624,12 @@ async function showNextStep() {
|
|
|
579
624
|
}
|
|
580
625
|
}, config.autoAdvanceDelay);
|
|
581
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);
|
|
582
633
|
}
|
|
583
634
|
|
|
584
635
|
function handleCompletion() {
|