lisichatbot 1.6.7 → 1.6.8
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 +32 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2777,6 +2777,38 @@ async function showNextStep() {
|
|
|
2777
2777
|
|
|
2778
2778
|
addMessage(messageToDisplay, 'bot', hasInput, chatState.step);
|
|
2779
2779
|
|
|
2780
|
+
// ✅ NEW: Add custom elements if specified
|
|
2781
|
+
if (nextStep.addElements && Array.isArray(nextStep.addElements)) {
|
|
2782
|
+
console.log(` 🎨 Adding ${nextStep.addElements.length} custom element(s) to chat`);
|
|
2783
|
+
|
|
2784
|
+
nextStep.addElements.forEach((selector, index) => {
|
|
2785
|
+
try {
|
|
2786
|
+
// Find the element in the DOM
|
|
2787
|
+
const element = document.querySelector(selector);
|
|
2788
|
+
|
|
2789
|
+
if (element) {
|
|
2790
|
+
// Clone the element to avoid removing it from its original location
|
|
2791
|
+
const clonedElement = element.cloneNode(true);
|
|
2792
|
+
|
|
2793
|
+
// Make it visible (in case it was hidden)
|
|
2794
|
+
clonedElement.style.display = '';
|
|
2795
|
+
|
|
2796
|
+
// Add to messages container
|
|
2797
|
+
elements.messages.appendChild(clonedElement);
|
|
2798
|
+
|
|
2799
|
+
console.log(` ✅ Added element ${index + 1}: ${selector}`);
|
|
2800
|
+
} else {
|
|
2801
|
+
console.warn(` ⚠️ Element not found: ${selector}`);
|
|
2802
|
+
}
|
|
2803
|
+
} catch (error) {
|
|
2804
|
+
console.error(` ❌ Error adding element ${selector}:`, error);
|
|
2805
|
+
}
|
|
2806
|
+
});
|
|
2807
|
+
|
|
2808
|
+
// Scroll after adding elements
|
|
2809
|
+
scrollToBottom();
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2780
2812
|
const inputRequired = nextStep.inputRequired === true;
|
|
2781
2813
|
|
|
2782
2814
|
if (nextStep.input) {
|