@ixo/editor 3.0.0-beta.3 → 3.0.0-beta.4
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.
|
@@ -28225,6 +28225,49 @@ var FormSubmitConfig = ({ inputs, onInputsChange }) => {
|
|
|
28225
28225
|
import React251, { useCallback as useCallback83, useEffect as useEffect83, useMemo as useMemo97, useState as useState101 } from "react";
|
|
28226
28226
|
import { Alert as Alert46, Loader as Loader45, Stack as Stack169, Text as Text143 } from "@mantine/core";
|
|
28227
28227
|
import { Survey as Survey12, SurveyModel as SurveyModel12 } from "@ixo/surveys";
|
|
28228
|
+
function parsePrimarySkill(rawSkill) {
|
|
28229
|
+
const coerce = (candidate) => {
|
|
28230
|
+
if (!candidate || typeof candidate !== "object") return null;
|
|
28231
|
+
const cid = String(candidate.cid || "").trim();
|
|
28232
|
+
const name = String(candidate.name || "").trim();
|
|
28233
|
+
if (!cid) return null;
|
|
28234
|
+
return name ? { cid, name } : { cid };
|
|
28235
|
+
};
|
|
28236
|
+
if (!rawSkill) return null;
|
|
28237
|
+
if (typeof rawSkill === "object") {
|
|
28238
|
+
if (Array.isArray(rawSkill)) {
|
|
28239
|
+
for (const entry of rawSkill) {
|
|
28240
|
+
const skill = coerce(entry);
|
|
28241
|
+
if (skill) return skill;
|
|
28242
|
+
}
|
|
28243
|
+
return null;
|
|
28244
|
+
}
|
|
28245
|
+
return coerce(rawSkill);
|
|
28246
|
+
}
|
|
28247
|
+
if (typeof rawSkill === "string") {
|
|
28248
|
+
const trimmed = rawSkill.trim();
|
|
28249
|
+
if (!trimmed) return null;
|
|
28250
|
+
try {
|
|
28251
|
+
const parsed = JSON.parse(trimmed);
|
|
28252
|
+
return parsePrimarySkill(parsed);
|
|
28253
|
+
} catch {
|
|
28254
|
+
return null;
|
|
28255
|
+
}
|
|
28256
|
+
}
|
|
28257
|
+
return null;
|
|
28258
|
+
}
|
|
28259
|
+
function buildCompanionPrompt(params) {
|
|
28260
|
+
const answersJson = JSON.stringify(params.answers || {}, null, 2);
|
|
28261
|
+
return [
|
|
28262
|
+
"Use the skill with this form context.",
|
|
28263
|
+
`Skill name: ${params.skill.name || "(not provided)"}`,
|
|
28264
|
+
`Skill CID: ${params.skill.cid}`,
|
|
28265
|
+
`Action block title: ${params.blockTitle || "Form Submit Action"}`,
|
|
28266
|
+
`Action block description: ${params.blockDescription || "Complete the form to execute this action."}`,
|
|
28267
|
+
`Form answers JSON:
|
|
28268
|
+
${answersJson}`
|
|
28269
|
+
].join("\n");
|
|
28270
|
+
}
|
|
28228
28271
|
var FormSubmitFlowDetail = ({ inputs, editor, block, runtime, updateRuntime, isDisabled }) => {
|
|
28229
28272
|
const handlers = useBlocknoteHandlers();
|
|
28230
28273
|
const services = useMemo97(() => buildServicesFromHandlers(handlers), [handlers]);
|
|
@@ -28293,6 +28336,18 @@ var FormSubmitFlowDetail = ({ inputs, editor, block, runtime, updateRuntime, isD
|
|
|
28293
28336
|
setError(null);
|
|
28294
28337
|
updateRuntime({ state: "running", error: void 0 });
|
|
28295
28338
|
try {
|
|
28339
|
+
const skill = parsePrimarySkill(block?.props?.skill);
|
|
28340
|
+
if (skill && typeof handlers?.askCompanion === "function") {
|
|
28341
|
+
const prompt = buildCompanionPrompt({
|
|
28342
|
+
skill,
|
|
28343
|
+
blockTitle: String(block?.props?.title || ""),
|
|
28344
|
+
blockDescription: String(block?.props?.description || ""),
|
|
28345
|
+
answers: sender.data || {}
|
|
28346
|
+
});
|
|
28347
|
+
handlers.askCompanion(prompt).catch((askError) => {
|
|
28348
|
+
console.error("askCompanion failed during form submit execution", askError);
|
|
28349
|
+
});
|
|
28350
|
+
}
|
|
28296
28351
|
const outcome = await executeNode({
|
|
28297
28352
|
node: flowNode,
|
|
28298
28353
|
actorDid,
|
|
@@ -32263,4 +32318,4 @@ export {
|
|
|
32263
32318
|
getExtraSlashMenuItems,
|
|
32264
32319
|
useCreateIxoEditor
|
|
32265
32320
|
};
|
|
32266
|
-
//# sourceMappingURL=chunk-
|
|
32321
|
+
//# sourceMappingURL=chunk-36GMPLM6.mjs.map
|