diff --git a/node_modules/@ai-stack/payloadcms/.bun-tag-e130c3bcd4cfe50c b/.bun-tag-e130c3bcd4cfe50c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dist/endpoints/index.js b/dist/endpoints/index.js index f80e469821efbc3f256c7ef8ba29f549d065e1f8..8113c5fdda9411f19d654110464b2a6b72fcc615 100644 --- a/dist/endpoints/index.js +++ b/dist/endpoints/index.js @@ -158,7 +158,7 @@ export const endpoints = (pluginConfig)=>({ // Check authentication and authorization first await checkAccess(req, pluginConfig); const data = await req.json?.(); - const { allowedEditorNodes = [], locale = 'en', options } = data; + const { allowedEditorNodes = [], locale = 'en', options, activeFieldPath = '' } = data; const { action, actionParams, instructionId } = options; const contextData = data.doc; if (!instructionId) { @@ -192,6 +192,16 @@ export const endpoints = (pluginConfig)=>({ const collectionName = parts[0]; const fieldPath = parts.slice(1).join('.'); const fieldName = parts.length > 1 ? parts[parts.length - 1] : ''; + // Array-nested richText: handlebars paths like "briefing.details" cannot traverse + // arrays, so the action prompt renders empty. Substitute the active field's real + // path (sent by the client, e.g. "briefing.0.details") when it indexes an array. + let promptFieldPath = fieldPath || fieldName || ''; + if (String(instructions['field-type']) === 'richText' && activeFieldPath) { + const relPath = activeFieldPath.startsWith(`${collectionName}.`) ? activeFieldPath.slice(collectionName.length + 1) : activeFieldPath; + if (relPath !== promptFieldPath && /(^|\.)\d+(\.|$)/.test(relPath)) { + promptFieldPath = relPath; + } + } registerEditorHelper(req.payload, schemaPath); let localeInfo = locale; if (localeData && defaultLocale && localeData.label && typeof localeData.label === 'object' && defaultLocale in localeData.label) { @@ -212,7 +222,7 @@ export const endpoints = (pluginConfig)=>({ actionParams, collection: collectionName, context: contextData, - field: fieldPath || fieldName || '', + field: promptFieldPath, layout: instructions.layout, locale: localeInfo, pluginConfig, diff --git a/dist/ui/Compose/hooks/useGenerate.js b/dist/ui/Compose/hooks/useGenerate.js index e0d1f16706f214349921391a2850d7a878143dfc..f1591067cdc9c340871c656b0a383e8584d8d8a1 100644 --- a/dist/ui/Compose/hooks/useGenerate.js +++ b/dist/ui/Compose/hooks/useGenerate.js @@ -327,6 +327,7 @@ export const useGenerate = ({ instructionId })=>{ // Snapshot the editor state exactly once, before any streamed updates can mutate it. originalRootRef.current = editor?.getEditorState ? editor.getEditorState().toJSON()?.root ?? null : null; submit({ + activeFieldPath: editorConfigContext.fieldProps?.path ?? pathFromContext ?? '', allowedEditorNodes: Array.from(editor?._nodes?.keys() || []), doc: { ...doc, @@ -340,7 +341,9 @@ export const useGenerate = ({ instructionId })=>{ instructionIdRef, documentId, editor, - cancelPendingApply + cancelPendingApply, + pathFromContext, + editorConfigContext.fieldProps?.path ]); const generateUpload = useCallback(async ()=>{ const doc = getData();