lisichatbot 1.9.6 → 1.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +13 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.9.6",
3
+ "version": "1.9.8",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
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
- textElement.textContent = content;
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
  }
@@ -2818,16 +2820,16 @@ async function showNextStep() {
2818
2820
  console.log(` ✅ Updating current step autoAdvanceDelay:`, result.autoAdvanceDelay);
2819
2821
  currentStep.autoAdvanceDelay = result.autoAdvanceDelay;
2820
2822
  }
2821
-
2822
- // ✅ NEW: Support updating chatState.data from onStart
2823
- if (result.data && typeof result.data === 'object') {
2824
- console.log(` 📝 onStart returned data to update chatState.data:`, result.data);
2825
- // Merge returned data into chatState.data
2826
- Object.keys(result.data).forEach(key => {
2827
- chatState.data[key] = result.data[key];
2828
- console.log(` → chatState.data.${key} = ${JSON.stringify(result.data[key])}`);
2829
- });
2830
- }
2823
+ }
2824
+
2825
+ // NEW: Support updating chatState.data from onStart (moved outside updateCurrentStep block)
2826
+ if (result && typeof result === 'object' && result.data && typeof result.data === 'object') {
2827
+ console.log(` 📝 onStart returned data to update chatState.data:`, result.data);
2828
+ // Merge returned data into chatState.data
2829
+ Object.keys(result.data).forEach(key => {
2830
+ chatState.data[key] = result.data[key];
2831
+ console.log(` → chatState.data.${key} = ${JSON.stringify(result.data[key])}`);
2832
+ });
2831
2833
  }
2832
2834
 
2833
2835
  // ✅ NEW: Check if onStart wants to jump to step by name