lisichatbot 1.6.9 ā 1.7.1
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 +111 -18
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -17,7 +17,8 @@ let chatState = {
|
|
|
17
17
|
history: [],
|
|
18
18
|
currentSelection: null,
|
|
19
19
|
returnToStep: null,
|
|
20
|
-
completed: false
|
|
20
|
+
completed: false,
|
|
21
|
+
editPath: [] // ā
NEW: Array of step names/numbers to edit in sequence
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
let elements = {
|
|
@@ -238,8 +239,15 @@ function updateEditIcons() {
|
|
|
238
239
|
e.preventDefault();
|
|
239
240
|
console.log(`\nš±ļø EDIT ICON CLICKED (from updateEditIcons) - Step ${stepNumber}`);
|
|
240
241
|
console.log(` Current step: ${chatState.step}`);
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
|
|
243
|
+
// ā
NEW: Check if this step has an editSteps path
|
|
244
|
+
if (stepData.editSteps && Array.isArray(stepData.editSteps) && stepData.editSteps.length > 0) {
|
|
245
|
+
console.log(` š¤ļø Step has editSteps path:`, stepData.editSteps);
|
|
246
|
+
startEditPath(stepData.editSteps);
|
|
247
|
+
} else {
|
|
248
|
+
console.log(` Calling editStep(${stepNumber})...`);
|
|
249
|
+
editStep(stepNumber);
|
|
250
|
+
}
|
|
243
251
|
};
|
|
244
252
|
editIcon.setAttribute('data-chat-step', stepNumber);
|
|
245
253
|
editIcon.style.setProperty('display', 'flex', 'important');
|
|
@@ -1103,6 +1111,7 @@ function renderMinMaxInputs(field, customConfig, existingData) {
|
|
|
1103
1111
|
rangeWrapper.appendChild(errorDiv);
|
|
1104
1112
|
|
|
1105
1113
|
elements.messages.appendChild(rangeWrapper);
|
|
1114
|
+
scrollToBottom(); // ā
Scroll after adding range inputs
|
|
1106
1115
|
|
|
1107
1116
|
if (minInput && maxInput) {
|
|
1108
1117
|
const updateVisualFeedback = () => {
|
|
@@ -1172,6 +1181,10 @@ function selectCustomOption(field) {
|
|
|
1172
1181
|
const rangeWrapper = document.querySelector(`[data-chat-element="range-wrapper"][data-field="${field}"]`);
|
|
1173
1182
|
if (rangeWrapper) {
|
|
1174
1183
|
rangeWrapper.style.display = 'flex';
|
|
1184
|
+
// ā
Scroll after showing range inputs
|
|
1185
|
+
setTimeout(() => {
|
|
1186
|
+
scrollToBottom();
|
|
1187
|
+
}, 100);
|
|
1175
1188
|
}
|
|
1176
1189
|
}
|
|
1177
1190
|
|
|
@@ -2368,19 +2381,42 @@ async function handleNext() {
|
|
|
2368
2381
|
await showNextStep();
|
|
2369
2382
|
return;
|
|
2370
2383
|
} else {
|
|
2371
|
-
// Reached or passed target
|
|
2372
|
-
console.log(` āļø Reached target
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
+
// Reached or passed target
|
|
2385
|
+
console.log(` āļø Reached target step`);
|
|
2386
|
+
|
|
2387
|
+
// ā
NEW: Check if there are more steps in the edit path
|
|
2388
|
+
if (chatState.editPath && chatState.editPath.length > 0) {
|
|
2389
|
+
const nextEditStep = chatState.editPath.shift();
|
|
2390
|
+
console.log(` š¤ļø Edit path continues - going to step ${nextEditStep}`);
|
|
2391
|
+
console.log(` š¤ļø Remaining edit path:`, chatState.editPath);
|
|
2392
|
+
|
|
2393
|
+
// Keep returnToStep for when edit path completes
|
|
2394
|
+
chatState.step = nextEditStep;
|
|
2395
|
+
|
|
2396
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
2397
|
+
allRangeWrappers.forEach(wrapper => {
|
|
2398
|
+
wrapper.style.display = 'none';
|
|
2399
|
+
});
|
|
2400
|
+
|
|
2401
|
+
updateEditIcons();
|
|
2402
|
+
await showNextStep();
|
|
2403
|
+
return;
|
|
2404
|
+
} else {
|
|
2405
|
+
// No more edit path, return to saved step
|
|
2406
|
+
console.log(` ā
Edit complete - returning to step ${targetStep}`);
|
|
2407
|
+
chatState.returnToStep = null;
|
|
2408
|
+
chatState.editPath = []; // Clear any remaining path
|
|
2409
|
+
chatState.step = targetStep;
|
|
2410
|
+
|
|
2411
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
2412
|
+
allRangeWrappers.forEach(wrapper => {
|
|
2413
|
+
wrapper.style.display = 'none';
|
|
2414
|
+
});
|
|
2415
|
+
|
|
2416
|
+
updateEditIcons();
|
|
2417
|
+
await showNextStep();
|
|
2418
|
+
return;
|
|
2419
|
+
}
|
|
2384
2420
|
}
|
|
2385
2421
|
}
|
|
2386
2422
|
|
|
@@ -2994,6 +3030,13 @@ function handleCompletion() {
|
|
|
2994
3030
|
chatState.completed = true;
|
|
2995
3031
|
console.log(' š Flow marked as completed');
|
|
2996
3032
|
|
|
3033
|
+
// ā
Hide all range wrappers (single-select-custom inputs)
|
|
3034
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
3035
|
+
allRangeWrappers.forEach(wrapper => {
|
|
3036
|
+
wrapper.style.display = 'none';
|
|
3037
|
+
});
|
|
3038
|
+
console.log(' š Hidden all range-wrappers on completion');
|
|
3039
|
+
|
|
2997
3040
|
updateEditIcons();
|
|
2998
3041
|
|
|
2999
3042
|
if (elements.nextBtn) {
|
|
@@ -3106,6 +3149,7 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3106
3149
|
|
|
3107
3150
|
if (typeof window !== 'undefined') {
|
|
3108
3151
|
window.editStep = editStep;
|
|
3152
|
+
window.startEditPath = startEditPath; // ā
NEW: Export to window
|
|
3109
3153
|
}
|
|
3110
3154
|
|
|
3111
3155
|
showNextStep();
|
|
@@ -3116,7 +3160,8 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3116
3160
|
getState,
|
|
3117
3161
|
reset,
|
|
3118
3162
|
goToStep,
|
|
3119
|
-
editStep
|
|
3163
|
+
editStep,
|
|
3164
|
+
startEditPath // ā
NEW: Export from init
|
|
3120
3165
|
};
|
|
3121
3166
|
}
|
|
3122
3167
|
|
|
@@ -3166,6 +3211,53 @@ function goToStep(stepNumber) {
|
|
|
3166
3211
|
showNextStep();
|
|
3167
3212
|
}
|
|
3168
3213
|
|
|
3214
|
+
// ā
NEW: Start editing through a path of steps
|
|
3215
|
+
function startEditPath(stepNamesOrNumbers) {
|
|
3216
|
+
console.log(`\nš¤ļø startEditPath() called with:`, stepNamesOrNumbers);
|
|
3217
|
+
|
|
3218
|
+
if (!Array.isArray(stepNamesOrNumbers) || stepNamesOrNumbers.length === 0) {
|
|
3219
|
+
console.error('editPath must be a non-empty array');
|
|
3220
|
+
return;
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
// Convert step names to step numbers
|
|
3224
|
+
const stepNumbers = stepNamesOrNumbers.map(nameOrNumber => {
|
|
3225
|
+
if (typeof nameOrNumber === 'number') {
|
|
3226
|
+
return nameOrNumber;
|
|
3227
|
+
} else if (typeof nameOrNumber === 'string') {
|
|
3228
|
+
// Find step by name
|
|
3229
|
+
const stepIndex = flowData.flow.findIndex(step => step.name === nameOrNumber);
|
|
3230
|
+
if (stepIndex === -1) {
|
|
3231
|
+
console.error(`Step with name "${nameOrNumber}" not found`);
|
|
3232
|
+
return null;
|
|
3233
|
+
}
|
|
3234
|
+
return stepIndex;
|
|
3235
|
+
}
|
|
3236
|
+
return null;
|
|
3237
|
+
}).filter(num => num !== null);
|
|
3238
|
+
|
|
3239
|
+
if (stepNumbers.length === 0) {
|
|
3240
|
+
console.error('No valid steps found in editPath');
|
|
3241
|
+
return;
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
console.log(` ā
Resolved to step numbers:`, stepNumbers);
|
|
3245
|
+
|
|
3246
|
+
// Save current step as return point
|
|
3247
|
+
chatState.returnToStep = chatState.step;
|
|
3248
|
+
console.log(` š¾ Saved return step: ${chatState.returnToStep}`);
|
|
3249
|
+
|
|
3250
|
+
// Save the edit path (remaining steps to edit)
|
|
3251
|
+
chatState.editPath = [...stepNumbers];
|
|
3252
|
+
console.log(` š¤ļø Edit path set:`, chatState.editPath);
|
|
3253
|
+
|
|
3254
|
+
// Start editing the first step in the path
|
|
3255
|
+
const firstStep = chatState.editPath.shift();
|
|
3256
|
+
console.log(` šÆ Starting with step ${firstStep}`);
|
|
3257
|
+
|
|
3258
|
+
editStep(firstStep);
|
|
3259
|
+
}
|
|
3260
|
+
|
|
3169
3261
|
function editStep(stepNumber) {
|
|
3170
3262
|
console.log(`\nš editStep() called with stepNumber: ${stepNumber}`);
|
|
3171
3263
|
console.log(` Current step before edit: ${chatState.step}`);
|
|
@@ -3307,5 +3399,6 @@ module.exports = {
|
|
|
3307
3399
|
reset,
|
|
3308
3400
|
goToStep,
|
|
3309
3401
|
editStep,
|
|
3310
|
-
displayMessage
|
|
3402
|
+
displayMessage,
|
|
3403
|
+
startEditPath // ā
NEW: Export edit path function
|
|
3311
3404
|
};
|