lisichatbot 1.9.7 → 1.9.9
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 +21 -7
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -115,7 +115,9 @@ function addMessage(content, type = 'bot', hasInput = false, stepNumber = null)
|
|
|
115
115
|
|
|
116
116
|
const textElement = clone.querySelector(`[data-chat-element="${type}-message-text"]`);
|
|
117
117
|
if (textElement) {
|
|
118
|
-
|
|
118
|
+
// ✅ Convert \n to <br> tags for multi-line messages
|
|
119
|
+
const formattedContent = content.replace(/\n/g, '<br>');
|
|
120
|
+
textElement.innerHTML = formattedContent;
|
|
119
121
|
} else {
|
|
120
122
|
console.error(`Element with data-chat-element="${type}-message-text" not found in wrapper`);
|
|
121
123
|
}
|
|
@@ -3180,15 +3182,26 @@ async function showNextStep() {
|
|
|
3180
3182
|
const nextBtnTextElement = elements.nextBtn.querySelector('[data-chat-element="next-button-text"]');
|
|
3181
3183
|
|
|
3182
3184
|
if (nextBtnTextElement) {
|
|
3185
|
+
// ✅ Priority: step-level > global config > original
|
|
3186
|
+
let buttonText;
|
|
3187
|
+
|
|
3183
3188
|
if (nextStep.nextButtonText) {
|
|
3184
|
-
|
|
3185
|
-
|
|
3189
|
+
// Step-level override takes highest priority
|
|
3190
|
+
buttonText = nextStep.nextButtonText;
|
|
3191
|
+
console.log(` 📝 Next button text: "${buttonText}" (step-level)`);
|
|
3192
|
+
} else if (flowData.nextButtonText) {
|
|
3193
|
+
// Global config nextButtonText
|
|
3194
|
+
buttonText = flowData.nextButtonText;
|
|
3195
|
+
console.log(` 📝 Next button text: "${buttonText}" (global config)`);
|
|
3186
3196
|
} else {
|
|
3187
|
-
|
|
3188
|
-
|
|
3197
|
+
// Fall back to original
|
|
3198
|
+
buttonText = elements.originalNextBtnText;
|
|
3199
|
+
console.log(` 📝 Next button text: "${buttonText}" (original)`);
|
|
3189
3200
|
}
|
|
3190
|
-
|
|
3191
|
-
|
|
3201
|
+
|
|
3202
|
+
nextBtnTextElement.textContent = buttonText;
|
|
3203
|
+
} else if (nextStep.nextButtonText || flowData.nextButtonText) {
|
|
3204
|
+
console.warn(` ⚠️ nextButtonText specified but next-button-text element not found`);
|
|
3192
3205
|
console.warn(' Add <span data-chat-element="next-button-text">Next</span> inside your next-button');
|
|
3193
3206
|
}
|
|
3194
3207
|
}
|
|
@@ -3309,6 +3322,7 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3309
3322
|
selectedBackground: config.selectedBackground,
|
|
3310
3323
|
autoAdvanceDelay: config.autoAdvanceDelay,
|
|
3311
3324
|
showCancelButton: config.showCancelButton,
|
|
3325
|
+
nextButtonText: flowConfig.nextButtonText || 'not set',
|
|
3312
3326
|
customRangeErrors: config.customRangeErrors
|
|
3313
3327
|
});
|
|
3314
3328
|
|