lisichatbot 1.6.9 ā 1.7.0
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 +99 -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');
|
|
@@ -2368,19 +2376,42 @@ async function handleNext() {
|
|
|
2368
2376
|
await showNextStep();
|
|
2369
2377
|
return;
|
|
2370
2378
|
} else {
|
|
2371
|
-
// Reached or passed target
|
|
2372
|
-
console.log(` āļø Reached target
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2379
|
+
// Reached or passed target
|
|
2380
|
+
console.log(` āļø Reached target step`);
|
|
2381
|
+
|
|
2382
|
+
// ā
NEW: Check if there are more steps in the edit path
|
|
2383
|
+
if (chatState.editPath && chatState.editPath.length > 0) {
|
|
2384
|
+
const nextEditStep = chatState.editPath.shift();
|
|
2385
|
+
console.log(` š¤ļø Edit path continues - going to step ${nextEditStep}`);
|
|
2386
|
+
console.log(` š¤ļø Remaining edit path:`, chatState.editPath);
|
|
2387
|
+
|
|
2388
|
+
// Keep returnToStep for when edit path completes
|
|
2389
|
+
chatState.step = nextEditStep;
|
|
2390
|
+
|
|
2391
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
2392
|
+
allRangeWrappers.forEach(wrapper => {
|
|
2393
|
+
wrapper.style.display = 'none';
|
|
2394
|
+
});
|
|
2395
|
+
|
|
2396
|
+
updateEditIcons();
|
|
2397
|
+
await showNextStep();
|
|
2398
|
+
return;
|
|
2399
|
+
} else {
|
|
2400
|
+
// No more edit path, return to saved step
|
|
2401
|
+
console.log(` ā
Edit complete - returning to step ${targetStep}`);
|
|
2402
|
+
chatState.returnToStep = null;
|
|
2403
|
+
chatState.editPath = []; // Clear any remaining path
|
|
2404
|
+
chatState.step = targetStep;
|
|
2405
|
+
|
|
2406
|
+
const allRangeWrappers = document.querySelectorAll('[data-chat-element="range-wrapper"]');
|
|
2407
|
+
allRangeWrappers.forEach(wrapper => {
|
|
2408
|
+
wrapper.style.display = 'none';
|
|
2409
|
+
});
|
|
2410
|
+
|
|
2411
|
+
updateEditIcons();
|
|
2412
|
+
await showNextStep();
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2384
2415
|
}
|
|
2385
2416
|
}
|
|
2386
2417
|
|
|
@@ -3106,6 +3137,7 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3106
3137
|
|
|
3107
3138
|
if (typeof window !== 'undefined') {
|
|
3108
3139
|
window.editStep = editStep;
|
|
3140
|
+
window.startEditPath = startEditPath; // ā
NEW: Export to window
|
|
3109
3141
|
}
|
|
3110
3142
|
|
|
3111
3143
|
showNextStep();
|
|
@@ -3116,7 +3148,8 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3116
3148
|
getState,
|
|
3117
3149
|
reset,
|
|
3118
3150
|
goToStep,
|
|
3119
|
-
editStep
|
|
3151
|
+
editStep,
|
|
3152
|
+
startEditPath // ā
NEW: Export from init
|
|
3120
3153
|
};
|
|
3121
3154
|
}
|
|
3122
3155
|
|
|
@@ -3166,6 +3199,53 @@ function goToStep(stepNumber) {
|
|
|
3166
3199
|
showNextStep();
|
|
3167
3200
|
}
|
|
3168
3201
|
|
|
3202
|
+
// ā
NEW: Start editing through a path of steps
|
|
3203
|
+
function startEditPath(stepNamesOrNumbers) {
|
|
3204
|
+
console.log(`\nš¤ļø startEditPath() called with:`, stepNamesOrNumbers);
|
|
3205
|
+
|
|
3206
|
+
if (!Array.isArray(stepNamesOrNumbers) || stepNamesOrNumbers.length === 0) {
|
|
3207
|
+
console.error('editPath must be a non-empty array');
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
// Convert step names to step numbers
|
|
3212
|
+
const stepNumbers = stepNamesOrNumbers.map(nameOrNumber => {
|
|
3213
|
+
if (typeof nameOrNumber === 'number') {
|
|
3214
|
+
return nameOrNumber;
|
|
3215
|
+
} else if (typeof nameOrNumber === 'string') {
|
|
3216
|
+
// Find step by name
|
|
3217
|
+
const stepIndex = flowData.flow.findIndex(step => step.name === nameOrNumber);
|
|
3218
|
+
if (stepIndex === -1) {
|
|
3219
|
+
console.error(`Step with name "${nameOrNumber}" not found`);
|
|
3220
|
+
return null;
|
|
3221
|
+
}
|
|
3222
|
+
return stepIndex;
|
|
3223
|
+
}
|
|
3224
|
+
return null;
|
|
3225
|
+
}).filter(num => num !== null);
|
|
3226
|
+
|
|
3227
|
+
if (stepNumbers.length === 0) {
|
|
3228
|
+
console.error('No valid steps found in editPath');
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
console.log(` ā
Resolved to step numbers:`, stepNumbers);
|
|
3233
|
+
|
|
3234
|
+
// Save current step as return point
|
|
3235
|
+
chatState.returnToStep = chatState.step;
|
|
3236
|
+
console.log(` š¾ Saved return step: ${chatState.returnToStep}`);
|
|
3237
|
+
|
|
3238
|
+
// Save the edit path (remaining steps to edit)
|
|
3239
|
+
chatState.editPath = [...stepNumbers];
|
|
3240
|
+
console.log(` š¤ļø Edit path set:`, chatState.editPath);
|
|
3241
|
+
|
|
3242
|
+
// Start editing the first step in the path
|
|
3243
|
+
const firstStep = chatState.editPath.shift();
|
|
3244
|
+
console.log(` šÆ Starting with step ${firstStep}`);
|
|
3245
|
+
|
|
3246
|
+
editStep(firstStep);
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3169
3249
|
function editStep(stepNumber) {
|
|
3170
3250
|
console.log(`\nš editStep() called with stepNumber: ${stepNumber}`);
|
|
3171
3251
|
console.log(` Current step before edit: ${chatState.step}`);
|
|
@@ -3307,5 +3387,6 @@ module.exports = {
|
|
|
3307
3387
|
reset,
|
|
3308
3388
|
goToStep,
|
|
3309
3389
|
editStep,
|
|
3310
|
-
displayMessage
|
|
3390
|
+
displayMessage,
|
|
3391
|
+
startEditPath // ā
NEW: Export edit path function
|
|
3311
3392
|
};
|