lisichatbot 1.3.4 → 1.3.6
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 +39 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -23,7 +23,8 @@ let chatState = {
|
|
|
23
23
|
let elements = {
|
|
24
24
|
container: null,
|
|
25
25
|
messages: null,
|
|
26
|
-
nextBtn: null
|
|
26
|
+
nextBtn: null,
|
|
27
|
+
originalNextBtnText: null // Store original button text
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
let config = {
|
|
@@ -1630,6 +1631,10 @@ async function showNextStep() {
|
|
|
1630
1631
|
}
|
|
1631
1632
|
} else {
|
|
1632
1633
|
// No input - always auto-advance (nextButtonDisplay only controls button visibility)
|
|
1634
|
+
// Use step-level autoAdvanceDelay if provided, otherwise use global config
|
|
1635
|
+
const delay = nextStep.autoAdvanceDelay !== undefined ? nextStep.autoAdvanceDelay : config.autoAdvanceDelay;
|
|
1636
|
+
console.log(` ⏱️ Auto-advance delay: ${delay}ms ${nextStep.autoAdvanceDelay !== undefined ? '(step-level)' : '(global)'}`);
|
|
1637
|
+
|
|
1633
1638
|
setTimeout(() => {
|
|
1634
1639
|
chatState.step++;
|
|
1635
1640
|
|
|
@@ -1641,7 +1646,7 @@ async function showNextStep() {
|
|
|
1641
1646
|
} else {
|
|
1642
1647
|
handleCompletion();
|
|
1643
1648
|
}
|
|
1644
|
-
},
|
|
1649
|
+
}, delay);
|
|
1645
1650
|
}
|
|
1646
1651
|
|
|
1647
1652
|
// Handle nextButtonDisplay - default is true
|
|
@@ -1656,6 +1661,26 @@ async function showNextStep() {
|
|
|
1656
1661
|
}
|
|
1657
1662
|
}
|
|
1658
1663
|
|
|
1664
|
+
// Handle nextButtonText - update button text if specified at step level
|
|
1665
|
+
if (elements.nextBtn) {
|
|
1666
|
+
const nextBtnTextElement = elements.nextBtn.querySelector('[data-chat-element="next-button-text"]');
|
|
1667
|
+
|
|
1668
|
+
if (nextBtnTextElement) {
|
|
1669
|
+
if (nextStep.nextButtonText) {
|
|
1670
|
+
nextBtnTextElement.textContent = nextStep.nextButtonText;
|
|
1671
|
+
console.log(` 📝 Next button text: "${nextStep.nextButtonText}" (step-level)`);
|
|
1672
|
+
} else {
|
|
1673
|
+
// Restore original text
|
|
1674
|
+
nextBtnTextElement.textContent = elements.originalNextBtnText;
|
|
1675
|
+
console.log(` 📝 Next button text: "${elements.originalNextBtnText}" (original)`);
|
|
1676
|
+
}
|
|
1677
|
+
} else if (nextStep.nextButtonText) {
|
|
1678
|
+
// Fallback: warn user if they're trying to set custom text but element doesn't exist
|
|
1679
|
+
console.warn(` ⚠️ nextButtonText specified ("${nextStep.nextButtonText}") but next-button-text element not found`);
|
|
1680
|
+
console.warn(' Add <span data-chat-element="next-button-text">Next</span> inside your next-button');
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1659
1684
|
// Always update edit icons at the end to ensure correct state
|
|
1660
1685
|
// Use setTimeout to ensure it runs after any DOM updates
|
|
1661
1686
|
setTimeout(() => {
|
|
@@ -1757,6 +1782,18 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
1757
1782
|
console.error('next-button not found. Please add <button data-chat-element="next-button"></button>');
|
|
1758
1783
|
return null;
|
|
1759
1784
|
}
|
|
1785
|
+
|
|
1786
|
+
// Find the text element inside the button
|
|
1787
|
+
const nextBtnTextElement = elements.nextBtn.querySelector('[data-chat-element="next-button-text"]');
|
|
1788
|
+
if (nextBtnTextElement) {
|
|
1789
|
+
// Store original button text from the text element
|
|
1790
|
+
elements.originalNextBtnText = nextBtnTextElement.textContent || nextBtnTextElement.innerText || 'Next';
|
|
1791
|
+
console.log(`💾 Stored original button text: "${elements.originalNextBtnText}" (from next-button-text element)`);
|
|
1792
|
+
} else {
|
|
1793
|
+
console.warn('⚠️ Element with data-chat-element="next-button-text" not found inside next-button');
|
|
1794
|
+
console.warn(' Button text customization will not work. Please add <span data-chat-element="next-button-text">Next</span> inside your button');
|
|
1795
|
+
elements.originalNextBtnText = 'Next';
|
|
1796
|
+
}
|
|
1760
1797
|
|
|
1761
1798
|
// Clear ONLY messages container (not entire chat-wrapper)
|
|
1762
1799
|
elements.messages.innerHTML = '';
|