lisichatbot 1.0.1 → 1.0.2
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 +20 -24
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -388,11 +388,13 @@ function handleCompletion() {
|
|
|
388
388
|
// INITIALIZATION
|
|
389
389
|
// =============================================================================
|
|
390
390
|
|
|
391
|
-
function init(
|
|
392
|
-
//
|
|
393
|
-
elements.container = document.
|
|
391
|
+
function init(flowName, flowConfig) {
|
|
392
|
+
// Find container by data-chat-element="chat-wrapper"
|
|
393
|
+
elements.container = document.querySelector('[data-chat-element="chat-wrapper"]');
|
|
394
|
+
|
|
394
395
|
if (!elements.container) {
|
|
395
|
-
console.error('Container not found
|
|
396
|
+
console.error('Container with data-chat-element="chat-wrapper" not found');
|
|
397
|
+
console.error('Please add <div data-chat-element="chat-wrapper"></div> to your HTML');
|
|
396
398
|
return null;
|
|
397
399
|
}
|
|
398
400
|
|
|
@@ -410,28 +412,21 @@ function init(containerId, flowConfig) {
|
|
|
410
412
|
chatState.history = [];
|
|
411
413
|
chatState.currentSelection = null;
|
|
412
414
|
|
|
413
|
-
//
|
|
415
|
+
// Clear existing content and create structure
|
|
414
416
|
elements.container.innerHTML = `
|
|
415
|
-
<div
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
class="cf-next-btn"
|
|
423
|
-
data-chat-element="next-button"
|
|
424
|
-
style="opacity: 0.5; cursor: not-allowed;"
|
|
425
|
-
disabled>
|
|
426
|
-
Next →
|
|
427
|
-
</button>
|
|
428
|
-
</div>
|
|
417
|
+
<div data-chat-element="messages-container"></div>
|
|
418
|
+
<div data-chat-element="navigation-bottom">
|
|
419
|
+
<button data-chat-element="next-button"
|
|
420
|
+
style="opacity: 0.5; cursor: not-allowed;"
|
|
421
|
+
disabled>
|
|
422
|
+
Next →
|
|
423
|
+
</button>
|
|
429
424
|
</div>
|
|
430
425
|
`;
|
|
431
426
|
|
|
432
|
-
// Get elements
|
|
433
|
-
elements.messages =
|
|
434
|
-
elements.nextBtn =
|
|
427
|
+
// Get elements by data-chat-element
|
|
428
|
+
elements.messages = elements.container.querySelector('[data-chat-element="messages-container"]');
|
|
429
|
+
elements.nextBtn = elements.container.querySelector('[data-chat-element="next-button"]');
|
|
435
430
|
|
|
436
431
|
// Add event listener
|
|
437
432
|
if (elements.nextBtn) {
|
|
@@ -446,12 +441,13 @@ function init(containerId, flowConfig) {
|
|
|
446
441
|
// Start
|
|
447
442
|
showNextStep();
|
|
448
443
|
|
|
449
|
-
console.log(
|
|
444
|
+
console.log(`✅ Flow "${flowName}" initialized`);
|
|
450
445
|
|
|
451
446
|
return {
|
|
452
447
|
getState,
|
|
453
448
|
reset,
|
|
454
|
-
goToStep
|
|
449
|
+
goToStep,
|
|
450
|
+
editStep
|
|
455
451
|
};
|
|
456
452
|
}
|
|
457
453
|
|