@ai-stack/payloadcms 3.0.0-beta.104.1 → 3.0.0-beta.104.3
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/README.md +14 -0
- package/dist/ai/prompts.d.ts +1 -1
- package/dist/ai/prompts.d.ts.map +1 -1
- package/dist/ai/prompts.js +6 -3
- package/dist/ai/prompts.js.map +1 -1
- package/dist/exports/fields.d.ts +1 -1
- package/dist/exports/fields.d.ts.map +1 -1
- package/dist/exports/fields.js +1 -1
- package/dist/exports/fields.js.map +1 -1
- package/dist/fields/ComposeField/ComposeField.d.ts +4 -0
- package/dist/fields/ComposeField/ComposeField.d.ts.map +1 -0
- package/dist/fields/{DescriptionField/DescriptionField.js → ComposeField/ComposeField.js} +4 -4
- package/dist/fields/ComposeField/ComposeField.js.map +1 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts +2 -0
- package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +1 -0
- package/dist/fields/LexicalEditor/{ActionsFeatureComponent.js → ComposeFeatureComponent.js} +4 -4
- package/dist/fields/LexicalEditor/{ActionsFeatureComponent.js.map → ComposeFeatureComponent.js.map} +1 -1
- package/dist/fields/LexicalEditor/feature.client.d.ts +1 -4
- package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -1
- package/dist/fields/LexicalEditor/feature.client.js +2 -2
- package/dist/fields/LexicalEditor/feature.client.js.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts +2 -2
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
- package/dist/fields/SelectField/SelectField.d.ts +2 -2
- package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
- package/dist/fields/SelectField/SelectField.js.map +1 -1
- package/dist/libraries/handlebars/asyncHandlebars.js +1 -1
- package/dist/libraries/handlebars/asyncHandlebars.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +13 -5
- package/dist/plugin.js.map +1 -1
- package/dist/ui/Compose/Compose.d.ts +9 -0
- package/dist/ui/Compose/Compose.d.ts.map +1 -0
- package/dist/ui/{Actions/Actions.js → Compose/Compose.js} +46 -38
- package/dist/ui/Compose/Compose.js.map +1 -0
- package/dist/ui/{Actions → Compose}/UndoRedoActions.d.ts.map +1 -1
- package/dist/ui/{Actions → Compose}/UndoRedoActions.js +15 -2
- package/dist/ui/Compose/UndoRedoActions.js.map +1 -0
- package/dist/ui/{Actions → Compose}/hooks/menu/Item.d.ts.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/Item.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +1 -0
- package/dist/ui/{Actions → Compose}/hooks/menu/TranslateMenu.js.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/items.d.ts.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/items.js.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.d.ts.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.js.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.d.ts.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/useGenerate.d.ts.map +1 -1
- package/dist/ui/{Actions → Compose}/hooks/useGenerate.js +1 -2
- package/dist/ui/{Actions → Compose}/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Compose/hooks/useHistory.d.ts.map +1 -0
- package/dist/ui/{Actions → Compose}/hooks/useHistory.js +3 -1
- package/dist/ui/Compose/hooks/useHistory.js.map +1 -0
- package/dist/utilities/setSafeLexicalState.d.ts +2 -2
- package/dist/utilities/setSafeLexicalState.d.ts.map +1 -1
- package/dist/utilities/setSafeLexicalState.js +5 -12
- package/dist/utilities/setSafeLexicalState.js.map +1 -1
- package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
- package/dist/utilities/updateFieldsConfig.js +4 -8
- package/dist/utilities/updateFieldsConfig.js.map +1 -1
- package/package.json +35 -59
- package/dist/fields/DescriptionField/DescriptionField.d.ts +0 -4
- package/dist/fields/DescriptionField/DescriptionField.d.ts.map +0 -1
- package/dist/fields/DescriptionField/DescriptionField.js.map +0 -1
- package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts +0 -2
- package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts.map +0 -1
- package/dist/ui/Actions/Actions.d.ts +0 -5
- package/dist/ui/Actions/Actions.d.ts.map +0 -1
- package/dist/ui/Actions/Actions.js.map +0 -1
- package/dist/ui/Actions/UndoRedoActions.js.map +0 -1
- package/dist/ui/Actions/hooks/menu/TranslateMenu.d.ts.map +0 -1
- package/dist/ui/Actions/hooks/useHistory.d.ts.map +0 -1
- package/dist/ui/Actions/hooks/useHistory.js.map +0 -1
- /package/dist/ui/{Actions → Compose}/UndoRedoActions.d.ts +0 -0
- /package/dist/ui/{Actions/actions.module.scss → Compose/compose.module.scss} +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/Item.d.ts +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/Item.js +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/TranslateMenu.d.ts +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/TranslateMenu.js +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/items.d.ts +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/items.js +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.d.ts +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.js +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/menu.module.scss +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.d.ts +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.js +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/useGenerate.d.ts +0 -0
- /package/dist/ui/{Actions → Compose}/hooks/useHistory.d.ts +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,11 @@ The Payload AI Plugin is an advanced extension that integrates modern AI capabil
|
|
|
12
12
|
>
|
|
13
13
|
> To give it a try, we recommend using [Payload's website template](https://github.com/payloadcms/payload/tree/v3.0.0-beta.104/templates/website).
|
|
14
14
|
|
|
15
|
+
---
|
|
16
|
+
|
|
15
17
|
### 🎥 [Watch the Magic in Action](https://youtu.be/qaYukeGpuu4)
|
|
18
|
+
Want to dive deeper?
|
|
19
|
+
### 🎥 [Explore More in Our Extended Demo](https://youtu.be/LEsuHbKalNY)
|
|
16
20
|
|
|
17
21
|
|
|
18
22
|
## ✨ Supported Fields and Features
|
|
@@ -38,6 +42,7 @@ The Payload AI Plugin is an advanced extension that integrates modern AI capabil
|
|
|
38
42
|
- ✅ **Fact Checking** (Coming Soon)
|
|
39
43
|
- 🔄 **Automated Content Workflows** (Coming Soon)
|
|
40
44
|
- 🌍 **Internationalization Support** (Coming Soon)
|
|
45
|
+
- 🌍 **Editor AI suggestions** (Coming Soon)
|
|
41
46
|
- 💬 **AI Chat Support** (Coming Soon)
|
|
42
47
|
|
|
43
48
|
## 📚 Table of Contents
|
|
@@ -109,6 +114,15 @@ ANTHROPIC_API_KEY=your-anthropic-api-key
|
|
|
109
114
|
ELEVENLABS_API_KEY=your-elevenlabs-api-key
|
|
110
115
|
```
|
|
111
116
|
|
|
117
|
+
### Enabling AI for Custom Components
|
|
118
|
+
|
|
119
|
+
> **⚠️ Note:** Custom fields don't fully adhere to the Payload schema, making it difficult to determine which components support injecting ComposeField as a Description.
|
|
120
|
+
> If AI enabled fields don't display Compose settings, please manually add the following component path:
|
|
121
|
+
>
|
|
122
|
+
> `@ai-stack/payloadcms/fields#ComposeField`
|
|
123
|
+
>
|
|
124
|
+
> To view AI enabled fields, enable the `debugging` flag in your plugin config or check your server startup logs.
|
|
125
|
+
|
|
112
126
|
|
|
113
127
|
## 👥 Contributing
|
|
114
128
|
|
package/dist/ai/prompts.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ type ActionPrompt = {
|
|
|
10
10
|
name: ActionMenuItems;
|
|
11
11
|
system: (options: ActionPromptOptions) => string;
|
|
12
12
|
};
|
|
13
|
-
export declare const defaultSystemPrompt = "
|
|
13
|
+
export declare const defaultSystemPrompt = "IMPORTANT INSTRUCTION:\nProduce only the requested output text.\nDo not add any explanations, comments, or engagement.\nDo not use quotation marks in the response.\nBEGIN OUTPUT:";
|
|
14
14
|
export declare const defaultPrompts: ActionPrompt[];
|
|
15
15
|
export declare const seedPrompts: ({ fieldLabel, fieldSchemaPaths, fieldType, path }: {
|
|
16
16
|
fieldLabel: any;
|
package/dist/ai/prompts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAClD,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACjD,CAAA;
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IAClD,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAA;CACjD,CAAA;AAGD,eAAO,MAAM,mBAAmB,uLAIlB,CAAA;AAEd,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA6GvB,CAAA"}
|
package/dist/ai/prompts.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//TODO: This is a temporary solution make use of structured object in API
|
|
2
|
+
export const defaultSystemPrompt = `IMPORTANT INSTRUCTION:
|
|
3
|
+
Produce only the requested output text.
|
|
4
|
+
Do not add any explanations, comments, or engagement.
|
|
5
|
+
Do not use quotation marks in the response.
|
|
6
|
+
BEGIN OUTPUT:`;
|
|
4
7
|
export const defaultPrompts = [
|
|
5
8
|
{
|
|
6
9
|
name: 'Rephrase',
|
package/dist/ai/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionMenuItems } from '../types.js'\n\ntype ActionPromptOptions = {\n layout?: string\n locale?: string\n prompt?: string\n systemPrompt?: string\n}\n\ntype ActionPrompt = {\n layout?: (options?: ActionPromptOptions) => string\n name: ActionMenuItems\n system: (options: ActionPromptOptions) => string\n}\n\nexport const defaultSystemPrompt = `\nIMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!\n`\n\nexport const defaultPrompts: ActionPrompt[] = [\n {\n name: 'Rephrase',\n system: ({\n prompt = '',\n systemPrompt = '',\n }) => `You are a skilled language expert. Rephrase the given text while maintaining its original meaning, tone, and emotional content. Use different words and sentence structures where possible, but preserve the overall style and sentiment of the original.\n \n -------------\n INSTRUCTIONS:\n - Rephrase the text according to the guidelines of the ORIGINAL SYSTEM PROMPT, if provided.\n - Retain the original meaning, tone, and emotional content.\n - Use different vocabulary and sentence structures where appropriate.\n - Ensure the rephrased text conveys the same message and feeling as the original.\n ${prompt ? '\\n\\nPrevious prompt:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n {\n name: 'Expand',\n system:\n () => `You are a creative writer and subject matter expert. Expand the given text by adding depth, detail, and relevant information while maintaining the original tone and style.\n \n -------------\n INSTRUCTIONS:\n - Understand the main ideas and tone of the text.\n - Add more details, examples, explanations, or context.\n - Maintain the original tone, style, and intent.\n - Ensure the expanded version flows naturally and coherently.\n - Do not contradict or alter the original meaning.\n -------------`,\n },\n {\n name: 'Proofread',\n system:\n () => `You are an English language expert. Proofread the given text, focusing on correcting grammar and spelling mistakes without altering the content, style, or tone.\n \n -------------\n INSTRUCTIONS:\n - Correct grammar and spelling errors.\n - Do not change the content, meaning, tone, or style.\n - Return the full text, whether corrections were made or not.\n - Do not provide additional comments or analysis.\n -------------`,\n },\n {\n name: 'Simplify',\n system: ({\n prompt = '',\n }) => `You are a skilled communicator specializing in clear and concise writing. Simplify the given text to make it easier to understand while retaining its core message.\n \n -------------\n INSTRUCTIONS:\n - Simplify the language, using more common words and shorter sentences.\n - Remove unnecessary details or jargon while keeping essential information.\n - Maintain the original meaning and key points.\n - Aim for clarity and readability for a general audience.\n - The simplified text should be more concise than the original.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n -------------`,\n },\n {\n name: 'Summarize',\n layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\n `,\n system: () =>\n `You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.\n\nINSTRUCTIONS:\n1. Carefully read and analyze the provided text.\n2. Identify and extract the main ideas and crucial supporting details.\n3. Condense the information into a clear and coherent summary that maintains the core message.\n4. Preserve the original tone and intent of the text.\n5. Ensure your summary is approximately 25-30% of the original text length.\n6. Use clear and precise language, avoiding unnecessary jargon or complexity.\n`,\n },\n {\n name: 'Tone',\n system: () =>\n `You are a tone adjustment specialist. Modify the tone of the given text as specified while keeping the original message and content intact.\n \n -------------\n INSTRUCTIONS:\n - Adjust the tone to match the specified style (e.g., formal, informal, professional, friendly).\n - Maintain the original content and meaning.\n - Ensure the adjusted text flows naturally with the new tone.\n -------------`,\n },\n {\n name: 'Translate',\n system: ({ locale, prompt = '', systemPrompt = '' }) =>\n `You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.\n \n -------------\n INSTRUCTIONS:\n - Accurately translate the text into ${locale}.\n - Preserve the original meaning, tone, and context.\n - Ensure the translation is culturally appropriate and natural in the target language.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n]\n\nexport const seedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path }) => {\n return {\n prompt: `field-type: ${fieldType}\nfield-name: ${fieldLabel}\nschema-path: ${path}\n\nGive me a prompt that relate to the given field type and schema path.\n\nGenerated prompt:\n`,\n system: `# AI Assistant for CMS Prompt Generation\n\nYour role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.\n\n## Key Guidelines:\n- Tailor prompts to specific field-type and purpose\n- Use schema-path for context\n- Include '{{ title }}' in every prompt\n- Be clear, concise, and instructive\n- Focus on content generation, not user perspective\n- For Image, Voice, or Banner fields, use provided example prompts verbatim\n- Image, Banner prompt MUST NOT CONTAIN ANY TYPOGRAPHY/TEXT DETAILS\n\n## Field Types and Prompts:\n\n1. richText:\n - Craft detailed, structured content\n - Include intro, sections, body, formatting, and conclusion\n - Aim for engaging, informative, and valuable content\n\n2. text:\n - For titles: Generate concise, engaging titles\n - For keywords: List relevant SEO terms\n\n3. textarea:\n - Provide comprehensive details (e.g., event information)\n\n4. upload:\n - Describe high-quality images or media\n\n## Schema-path Examples:\n- posts.title: Blog/article title\n- products.name: Product name\n\n## Must Follow:\n- Adapt prompts to schema-path context\n- Generate content directly, avoid personal pronouns\n- Use provided examples as guidelines\n\n### Examples for each field type along with generated prompt:\n\nFor richText:\n field-type: richText\n field-name: Content\n schema-path: posts.content\n Generated prompt: Craft compelling content for a blog post with the title \"{{ title }}\". Develop a well-structured narrative that captivates readers from start to finish. Incorporate the following elements to create a polished and engaging piece:\n\n- Engaging introduction that hooks the reader\n- Clearly defined sections with relevant subheadings\n- Well-researched and informative body paragraphs\n- Creative use of formatting to enhance readability (e.g., bullet points, blockquotes, italics, headings, bolds, other text formats)\n- Compelling conclusion that reinforces the main theme\n- Make the format easily digestible and clear for enhanced readability and improved CTR. \n- The user should be engaged, consistently interested, and feel that they’ve gained the knowledge they were seeking. \n\nInfuse the content with your expertise and a touch of personality to make it both informative and enjoyable to read. Aim to provide value to your target audience while maintaining a professional tone that aligns with the blog's overall style.\nFeel free to incorporate relevant anecdotes, statistics, or examples to support your points and add depth to the post. Remember, the goal is to create content that not only informs but also inspires and entertains your readers.\n\nFor text:\n field-type: text\n field-name: title\n schema-path: posts.title\n Generated prompt: Generate a captivating title for the blog post based on '{{ title }}' that effectively encapsulates the main theme and draws in readers. The title should be concise, engaging, and relevant to the content being presented. If no input is provided then generate creative title.\n\nFor text:\n field-type: text\n field-name: keywords\n schema-path: posts.keywords\n Generated prompt: Identify and list relevant keywords for the blog post titled \"{{ title }}\". Focus on terms that enhance search engine optimization and accurately reflect the main themes and topics of the content.\nkeywords will with comma separated.\n\n\nFor textarea:\n field-type: textarea:\n field-name: details\n schema-path: posts.details\n Generated prompt: Provide comprehensive details for the event '{{ title }}'. Include essential information such as date, time, location, and any specific instructions or requirements.\n\nFor upload:\n field-type: upload\n field-name: Featured Image\n schema-path: posts.image\n Generated prompt: Imagine {{ title }}\n\nFor upload:\n field-type: upload\n field-name: Voice\n schema-path: posts.upload\n Generated prompt: {{ title }} {{ toLexicalHTML [provide schema-path for richText] }}\n\n\nRemember to adapt the prompts based on the specific schema-path provided, considering the context and purpose of the field within the CMS structure. The prompts should directly instruct the AI model on what content to generate or describe, without assuming a user perspective.\n\nSchema Map Context:\n${JSON.stringify(fieldSchemaPaths)}\n\n${defaultSystemPrompt}\n`,\n }\n}\n"],"names":["defaultSystemPrompt","defaultPrompts","name","system","prompt","systemPrompt","layout","locale","seedPrompts","fieldLabel","fieldSchemaPaths","fieldType","path","JSON","stringify"],"mappings":"AAeA,OAAO,MAAMA,sBAAsB,CAAC;;AAEpC,CAAC,CAAA;AAED,OAAO,MAAMC,iBAAiC;IAC5C;QACEC,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACXC,eAAe,EAAE,EAClB,GAAK,CAAC;;;;;;;;MAQL,EAAED,SAAS,2BAA2BA,SAAS,GAAG;MAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;mBACxD,CAAC;IAClB;IACA;QACEH,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;;mBASM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;mBAQM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACZ,GAAK,CAAC;;;;;;;;;MASL,EAAEA,SAAS,2BAA2BA,SAAS,GAAG;mBACrC,CAAC;IAClB;IACA;QACEF,MAAM;QACNI,QAAQ,IAAM,CAAC;;;IAGf,CAAC;QACDH,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;IACC;IACA;QACED,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEI,MAAM,EAAEH,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAE,GACjD,CAAC,gEAAgE,EAAEE,OAAO;;;;yCAIvC,EAAEA,OAAO;;;IAG9C,EAAEH,SAAS,2BAA2BA,SAAS,GAAG;IAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;iBACxD,CAAC;IAChB;CACD,CAAA;AAED,OAAO,MAAMG,cAAc,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,IAAI,EAAE;IAC3E,OAAO;QACLR,QAAQ,CAAC,YAAY,EAAEO,UAAU;YACzB,EAAEF,WAAW;aACZ,EAAEG,KAAK;;;;;AAKpB,CAAC;QACGT,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACJ,kBAAkB;;AAEnC,EAAEV,oBAAoB;AACtB,CAAC;IACC;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionMenuItems } from '../types.js'\n\ntype ActionPromptOptions = {\n layout?: string\n locale?: string\n prompt?: string\n systemPrompt?: string\n}\n\ntype ActionPrompt = {\n layout?: (options?: ActionPromptOptions) => string\n name: ActionMenuItems\n system: (options: ActionPromptOptions) => string\n}\n\n//TODO: This is a temporary solution make use of structured object in API\nexport const defaultSystemPrompt = `IMPORTANT INSTRUCTION:\nProduce only the requested output text.\nDo not add any explanations, comments, or engagement.\nDo not use quotation marks in the response.\nBEGIN OUTPUT:`\n\nexport const defaultPrompts: ActionPrompt[] = [\n {\n name: 'Rephrase',\n system: ({\n prompt = '',\n systemPrompt = '',\n }) => `You are a skilled language expert. Rephrase the given text while maintaining its original meaning, tone, and emotional content. Use different words and sentence structures where possible, but preserve the overall style and sentiment of the original.\n \n -------------\n INSTRUCTIONS:\n - Rephrase the text according to the guidelines of the ORIGINAL SYSTEM PROMPT, if provided.\n - Retain the original meaning, tone, and emotional content.\n - Use different vocabulary and sentence structures where appropriate.\n - Ensure the rephrased text conveys the same message and feeling as the original.\n ${prompt ? '\\n\\nPrevious prompt:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n {\n name: 'Expand',\n system:\n () => `You are a creative writer and subject matter expert. Expand the given text by adding depth, detail, and relevant information while maintaining the original tone and style.\n \n -------------\n INSTRUCTIONS:\n - Understand the main ideas and tone of the text.\n - Add more details, examples, explanations, or context.\n - Maintain the original tone, style, and intent.\n - Ensure the expanded version flows naturally and coherently.\n - Do not contradict or alter the original meaning.\n -------------`,\n },\n {\n name: 'Proofread',\n system:\n () => `You are an English language expert. Proofread the given text, focusing on correcting grammar and spelling mistakes without altering the content, style, or tone.\n \n -------------\n INSTRUCTIONS:\n - Correct grammar and spelling errors.\n - Do not change the content, meaning, tone, or style.\n - Return the full text, whether corrections were made or not.\n - Do not provide additional comments or analysis.\n -------------`,\n },\n {\n name: 'Simplify',\n system: ({\n prompt = '',\n }) => `You are a skilled communicator specializing in clear and concise writing. Simplify the given text to make it easier to understand while retaining its core message.\n \n -------------\n INSTRUCTIONS:\n - Simplify the language, using more common words and shorter sentences.\n - Remove unnecessary details or jargon while keeping essential information.\n - Maintain the original meaning and key points.\n - Aim for clarity and readability for a general audience.\n - The simplified text should be more concise than the original.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n -------------`,\n },\n {\n name: 'Summarize',\n layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\n `,\n system: () =>\n `You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.\n\nINSTRUCTIONS:\n1. Carefully read and analyze the provided text.\n2. Identify and extract the main ideas and crucial supporting details.\n3. Condense the information into a clear and coherent summary that maintains the core message.\n4. Preserve the original tone and intent of the text.\n5. Ensure your summary is approximately 25-30% of the original text length.\n6. Use clear and precise language, avoiding unnecessary jargon or complexity.\n`,\n },\n {\n name: 'Tone',\n system: () =>\n `You are a tone adjustment specialist. Modify the tone of the given text as specified while keeping the original message and content intact.\n \n -------------\n INSTRUCTIONS:\n - Adjust the tone to match the specified style (e.g., formal, informal, professional, friendly).\n - Maintain the original content and meaning.\n - Ensure the adjusted text flows naturally with the new tone.\n -------------`,\n },\n {\n name: 'Translate',\n system: ({ locale, prompt = '', systemPrompt = '' }) =>\n `You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.\n \n -------------\n INSTRUCTIONS:\n - Accurately translate the text into ${locale}.\n - Preserve the original meaning, tone, and context.\n - Ensure the translation is culturally appropriate and natural in the target language.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n]\n\nexport const seedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path }) => {\n return {\n prompt: `field-type: ${fieldType}\nfield-name: ${fieldLabel}\nschema-path: ${path}\n\nGive me a prompt that relate to the given field type and schema path.\n\nGenerated prompt:\n`,\n system: `# AI Assistant for CMS Prompt Generation\n\nYour role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.\n\n## Key Guidelines:\n- Tailor prompts to specific field-type and purpose\n- Use schema-path for context\n- Include '{{ title }}' in every prompt\n- Be clear, concise, and instructive\n- Focus on content generation, not user perspective\n- For Image, Voice, or Banner fields, use provided example prompts verbatim\n- Image, Banner prompt MUST NOT CONTAIN ANY TYPOGRAPHY/TEXT DETAILS\n\n## Field Types and Prompts:\n\n1. richText:\n - Craft detailed, structured content\n - Include intro, sections, body, formatting, and conclusion\n - Aim for engaging, informative, and valuable content\n\n2. text:\n - For titles: Generate concise, engaging titles\n - For keywords: List relevant SEO terms\n\n3. textarea:\n - Provide comprehensive details (e.g., event information)\n\n4. upload:\n - Describe high-quality images or media\n\n## Schema-path Examples:\n- posts.title: Blog/article title\n- products.name: Product name\n\n## Must Follow:\n- Adapt prompts to schema-path context\n- Generate content directly, avoid personal pronouns\n- Use provided examples as guidelines\n\n### Examples for each field type along with generated prompt:\n\nFor richText:\n field-type: richText\n field-name: Content\n schema-path: posts.content\n Generated prompt: Craft compelling content for a blog post with the title \"{{ title }}\". Develop a well-structured narrative that captivates readers from start to finish. Incorporate the following elements to create a polished and engaging piece:\n\n- Engaging introduction that hooks the reader\n- Clearly defined sections with relevant subheadings\n- Well-researched and informative body paragraphs\n- Creative use of formatting to enhance readability (e.g., bullet points, blockquotes, italics, headings, bolds, other text formats)\n- Compelling conclusion that reinforces the main theme\n- Make the format easily digestible and clear for enhanced readability and improved CTR. \n- The user should be engaged, consistently interested, and feel that they’ve gained the knowledge they were seeking. \n\nInfuse the content with your expertise and a touch of personality to make it both informative and enjoyable to read. Aim to provide value to your target audience while maintaining a professional tone that aligns with the blog's overall style.\nFeel free to incorporate relevant anecdotes, statistics, or examples to support your points and add depth to the post. Remember, the goal is to create content that not only informs but also inspires and entertains your readers.\n\nFor text:\n field-type: text\n field-name: title\n schema-path: posts.title\n Generated prompt: Generate a captivating title for the blog post based on '{{ title }}' that effectively encapsulates the main theme and draws in readers. The title should be concise, engaging, and relevant to the content being presented. If no input is provided then generate creative title.\n\nFor text:\n field-type: text\n field-name: keywords\n schema-path: posts.keywords\n Generated prompt: Identify and list relevant keywords for the blog post titled \"{{ title }}\". Focus on terms that enhance search engine optimization and accurately reflect the main themes and topics of the content.\nkeywords will with comma separated.\n\n\nFor textarea:\n field-type: textarea:\n field-name: details\n schema-path: posts.details\n Generated prompt: Provide comprehensive details for the event '{{ title }}'. Include essential information such as date, time, location, and any specific instructions or requirements.\n\nFor upload:\n field-type: upload\n field-name: Featured Image\n schema-path: posts.image\n Generated prompt: Imagine {{ title }}\n\nFor upload:\n field-type: upload\n field-name: Voice\n schema-path: posts.upload\n Generated prompt: {{ title }} {{ toLexicalHTML [provide schema-path for richText] }}\n\n\nRemember to adapt the prompts based on the specific schema-path provided, considering the context and purpose of the field within the CMS structure. The prompts should directly instruct the AI model on what content to generate or describe, without assuming a user perspective.\n\nSchema Map Context:\n${JSON.stringify(fieldSchemaPaths)}\n\n${defaultSystemPrompt}\n`,\n }\n}\n"],"names":["defaultSystemPrompt","defaultPrompts","name","system","prompt","systemPrompt","layout","locale","seedPrompts","fieldLabel","fieldSchemaPaths","fieldType","path","JSON","stringify"],"mappings":"AAeA,yEAAyE;AACzE,OAAO,MAAMA,sBAAsB,CAAC;;;;aAIvB,CAAC,CAAA;AAEd,OAAO,MAAMC,iBAAiC;IAC5C;QACEC,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACXC,eAAe,EAAE,EAClB,GAAK,CAAC;;;;;;;;MAQL,EAAED,SAAS,2BAA2BA,SAAS,GAAG;MAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;mBACxD,CAAC;IAClB;IACA;QACEH,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;;mBASM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;mBAQM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACZ,GAAK,CAAC;;;;;;;;;MASL,EAAEA,SAAS,2BAA2BA,SAAS,GAAG;mBACrC,CAAC;IAClB;IACA;QACEF,MAAM;QACNI,QAAQ,IAAM,CAAC;;;IAGf,CAAC;QACDH,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;IACC;IACA;QACED,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEI,MAAM,EAAEH,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAE,GACjD,CAAC,gEAAgE,EAAEE,OAAO;;;;yCAIvC,EAAEA,OAAO;;;IAG9C,EAAEH,SAAS,2BAA2BA,SAAS,GAAG;IAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;iBACxD,CAAC;IAChB;CACD,CAAA;AAED,OAAO,MAAMG,cAAc,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,IAAI,EAAE;IAC3E,OAAO;QACLR,QAAQ,CAAC,YAAY,EAAEO,UAAU;YACzB,EAAEF,WAAW;aACZ,EAAEG,KAAK;;;;;AAKpB,CAAC;QACGT,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACJ,kBAAkB;;AAEnC,EAAEV,oBAAoB;AACtB,CAAC;IACC;AACF,EAAC"}
|
package/dist/exports/fields.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js';
|
|
2
2
|
export { SelectField } from '../fields/SelectField/SelectField.js';
|
|
3
|
-
export {
|
|
3
|
+
export { ComposeField } from '../fields/ComposeField/ComposeField.js';
|
|
4
4
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/exports/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAA;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/exports/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAA;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA"}
|
package/dist/exports/fields.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js';
|
|
2
2
|
export { SelectField } from '../fields/SelectField/SelectField.js';
|
|
3
|
-
export {
|
|
3
|
+
export { ComposeField } from '../fields/ComposeField/ComposeField.js';
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/fields.ts"],"sourcesContent":["export { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js'\nexport { SelectField } from '../fields/SelectField/SelectField.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/fields.ts"],"sourcesContent":["export { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js'\nexport { SelectField } from '../fields/SelectField/SelectField.js'\nexport { ComposeField } from '../fields/ComposeField/ComposeField.js'\n"],"names":["PromptEditorField","SelectField","ComposeField"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,mDAAkD;AACpF,SAASC,WAAW,QAAQ,uCAAsC;AAClE,SAASC,YAAY,QAAQ,yCAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposeField.d.ts","sourceRoot":"","sources":["../../../src/fields/ComposeField/ComposeField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAO9D,CAAA"}
|
|
@@ -3,16 +3,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useFieldProps } from '@payloadcms/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js';
|
|
6
|
-
import {
|
|
7
|
-
export const
|
|
6
|
+
import { Compose } from '../../ui/Compose/Compose.js';
|
|
7
|
+
export const ComposeField = (props)=>{
|
|
8
8
|
const { schemaPath } = useFieldProps();
|
|
9
9
|
const { id: instructionId } = useInstructions({
|
|
10
10
|
path: schemaPath
|
|
11
11
|
});
|
|
12
|
-
return /*#__PURE__*/ _jsx(
|
|
12
|
+
return /*#__PURE__*/ _jsx(Compose, {
|
|
13
13
|
descriptionProps: props,
|
|
14
14
|
instructionId: instructionId
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=ComposeField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/ComposeField/ComposeField.tsx"],"sourcesContent":["'use client'\n\nimport { useFieldProps } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js'\nimport { Compose } from '../../ui/Compose/Compose.js'\nimport { FieldDescriptionClientProps } from 'payload'\n\nexport const ComposeField: React.FC<FieldDescriptionClientProps> = (props) => {\n const { schemaPath } = useFieldProps()\n const { id: instructionId } = useInstructions({\n path: schemaPath,\n })\n\n return <Compose descriptionProps={props} instructionId={instructionId} />\n}\n"],"names":["useFieldProps","React","useInstructions","Compose","ComposeField","props","schemaPath","id","instructionId","path","descriptionProps"],"mappings":"AAAA;;AAEA,SAASA,aAAa,QAAQ,iBAAgB;AAC9C,OAAOC,WAAW,QAAO;AAEzB,SAASC,eAAe,QAAQ,0DAAyD;AACzF,SAASC,OAAO,QAAQ,8BAA6B;AAGrD,OAAO,MAAMC,eAAsD,CAACC;IAClE,MAAM,EAAEC,UAAU,EAAE,GAAGN;IACvB,MAAM,EAAEO,IAAIC,aAAa,EAAE,GAAGN,gBAAgB;QAC5CO,MAAMH;IACR;IAEA,qBAAO,KAACH;QAAQO,kBAAkBL;QAAOG,eAAeA;;AAC1D,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComposeFeatureComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/LexicalEditor/ComposeFeatureComponent.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,uBAAuB,+CAQnC,CAAA"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useFieldProps } from '@payloadcms/ui';
|
|
3
3
|
import { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js';
|
|
4
|
-
import {
|
|
5
|
-
export const
|
|
4
|
+
import { Compose } from '../../ui/Compose/Compose.js';
|
|
5
|
+
export const ComposeFeatureComponent = ()=>{
|
|
6
6
|
const { schemaPath } = useFieldProps();
|
|
7
7
|
const { id: instructionId } = useInstructions({
|
|
8
8
|
path: schemaPath
|
|
9
9
|
});
|
|
10
|
-
return /*#__PURE__*/ _jsx(
|
|
10
|
+
return /*#__PURE__*/ _jsx(Compose, {
|
|
11
11
|
instructionId: instructionId
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=ComposeFeatureComponent.js.map
|
package/dist/fields/LexicalEditor/{ActionsFeatureComponent.js.map → ComposeFeatureComponent.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/LexicalEditor/
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/LexicalEditor/ComposeFeatureComponent.tsx"],"sourcesContent":["import { useFieldProps } from '@payloadcms/ui'\n\nimport { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js'\nimport { Compose } from '../../ui/Compose/Compose.js'\n\nexport const ComposeFeatureComponent = () => {\n const { schemaPath } = useFieldProps()\n\n const { id: instructionId } = useInstructions({\n path: schemaPath,\n })\n\n return <Compose instructionId={instructionId} />\n}\n"],"names":["useFieldProps","useInstructions","Compose","ComposeFeatureComponent","schemaPath","id","instructionId","path"],"mappings":";AAAA,SAASA,aAAa,QAAQ,iBAAgB;AAE9C,SAASC,eAAe,QAAQ,0DAAyD;AACzF,SAASC,OAAO,QAAQ,8BAA6B;AAErD,OAAO,MAAMC,0BAA0B;IACrC,MAAM,EAAEC,UAAU,EAAE,GAAGJ;IAEvB,MAAM,EAAEK,IAAIC,aAAa,EAAE,GAAGL,gBAAgB;QAC5CM,MAAMH;IACR;IAEA,qBAAO,KAACF;QAAQI,eAAeA;;AACjC,EAAC"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export declare const LexicalEditorFeatureClient: import("
|
|
2
|
-
featureKey: string;
|
|
3
|
-
order: number;
|
|
4
|
-
}>;
|
|
1
|
+
export declare const LexicalEditorFeatureClient: import("@payloadcms/richtext-lexical").FeatureProviderProviderClient<undefined, undefined>;
|
|
5
2
|
//# sourceMappingURL=feature.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../src/fields/LexicalEditor/feature.client.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../src/fields/LexicalEditor/feature.client.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,0BAA0B,4FAOrC,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { createClientFeature } from '@payloadcms/richtext-lexical/client';
|
|
3
|
-
import {
|
|
3
|
+
import { ComposeFeatureComponent } from './ComposeFeatureComponent.js';
|
|
4
4
|
export const LexicalEditorFeatureClient = createClientFeature({
|
|
5
5
|
plugins: [
|
|
6
6
|
{
|
|
7
|
-
Component:
|
|
7
|
+
Component: ComposeFeatureComponent,
|
|
8
8
|
position: 'belowContainer'
|
|
9
9
|
}
|
|
10
10
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/LexicalEditor/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { createClientFeature } from '@payloadcms/richtext-lexical/client'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/LexicalEditor/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { createClientFeature } from '@payloadcms/richtext-lexical/client'\n\nimport { ComposeFeatureComponent } from './ComposeFeatureComponent.js'\n\nexport const LexicalEditorFeatureClient = createClientFeature({\n plugins: [\n {\n Component: ComposeFeatureComponent,\n position: 'belowContainer',\n },\n ],\n})\n"],"names":["createClientFeature","ComposeFeatureComponent","LexicalEditorFeatureClient","plugins","Component","position"],"mappings":"AAAA;AAEA,SAASA,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,uBAAuB,QAAQ,+BAA8B;AAEtE,OAAO,MAAMC,6BAA6BF,oBAAoB;IAC5DG,SAAS;QACP;YACEC,WAAWH;YACXI,UAAU;QACZ;KACD;AACH,GAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TextareaFieldProps } from 'payload';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
|
|
2
|
+
import { TextareaFieldClientProps } from 'payload';
|
|
3
|
+
export declare const PromptEditorField: React.FC<TextareaFieldClientProps>;
|
|
4
4
|
//# sourceMappingURL=PromptEditorField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptEditorField.d.ts","sourceRoot":"","sources":["../../../src/fields/PromptEditorField/PromptEditorField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PromptEditorField.d.ts","sourceRoot":"","sources":["../../../src/fields/PromptEditorField/PromptEditorField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAGlD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA4BhE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/PromptEditorField/PromptEditorField.tsx"],"sourcesContent":["'use client'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/PromptEditorField/PromptEditorField.tsx"],"sourcesContent":["'use client'\n\nimport { FieldLabel, useField, useFieldProps } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js'\nimport { AutocompleteTextField } from '../../libraries/autocomplete/AutocompleteTextArea.js'\nimport { TextareaFieldClientProps } from 'payload'\n\n//NOTE: HMR does not work for plugin components anymore, I think it has to do with importMap/ string path\nexport const PromptEditorField: React.FC<TextareaFieldClientProps> = (props) => {\n const { field } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { setValue, value } = useField<string>({\n path: pathFromContext,\n })\n\n const { promptEditorSuggestions } = useInstructions({\n path: pathFromContext,\n })\n\n return (\n <div className=\"field-type textarea\">\n <FieldLabel field={field} label={field.label} />\n <AutocompleteTextField\n changeOnSelect={(trigger, selected) => {\n return trigger + selected + ' }}'\n }}\n onChange={(val: string) => {\n setValue(val)\n }}\n options={promptEditorSuggestions}\n trigger={['{{ ']}\n value={value}\n />\n </div>\n )\n}\n"],"names":["FieldLabel","useField","useFieldProps","React","useInstructions","AutocompleteTextField","PromptEditorField","props","field","path","pathFromContext","setValue","value","promptEditorSuggestions","div","className","label","changeOnSelect","trigger","selected","onChange","val","options"],"mappings":"AAAA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACpE,OAAOC,WAAW,QAAO;AAEzB,SAASC,eAAe,QAAQ,0DAAyD;AACzF,SAASC,qBAAqB,QAAQ,uDAAsD;AAG5F,yGAAyG;AACzG,OAAO,MAAMC,oBAAwD,CAACC;IACpE,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,MAAM,EAAEE,MAAMC,eAAe,EAAE,GAAGR;IAElC,MAAM,EAAES,QAAQ,EAAEC,KAAK,EAAE,GAAGX,SAAiB;QAC3CQ,MAAMC;IACR;IAEA,MAAM,EAAEG,uBAAuB,EAAE,GAAGT,gBAAgB;QAClDK,MAAMC;IACR;IAEA,qBACE,MAACI;QAAIC,WAAU;;0BACb,KAACf;gBAAWQ,OAAOA;gBAAOQ,OAAOR,MAAMQ,KAAK;;0BAC5C,KAACX;gBACCY,gBAAgB,CAACC,SAASC;oBACxB,OAAOD,UAAUC,WAAW;gBAC9B;gBACAC,UAAU,CAACC;oBACTV,SAASU;gBACX;gBACAC,SAAST;gBACTK,SAAS;oBAAC;iBAAM;gBAChBN,OAAOA;;;;AAIf,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SelectFieldClientProps } from 'payload';
|
|
2
2
|
export declare const SelectField: (props: {
|
|
3
3
|
filterByField: string;
|
|
4
4
|
options: {
|
|
@@ -6,5 +6,5 @@ export declare const SelectField: (props: {
|
|
|
6
6
|
label: string;
|
|
7
7
|
value: string;
|
|
8
8
|
}[];
|
|
9
|
-
} &
|
|
9
|
+
} & SelectFieldClientProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=SelectField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../src/fields/SelectField/SelectField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,
|
|
1
|
+
{"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../src/fields/SelectField/SelectField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAMnE,eAAO,MAAM,WAAW,UACf;IACL,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC9D,GAAG,sBAAsB,4CAqC3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/SelectField/SelectField.tsx"],"sourcesContent":["'use client'\n\nimport type { OptionObject,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/SelectField/SelectField.tsx"],"sourcesContent":["'use client'\n\nimport type { OptionObject, SelectFieldClientProps } from 'payload'\n\nimport { SelectInput, useField, useFieldProps } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\n// Use to filter model options in settings based on field types\nexport const SelectField = (\n props: {\n filterByField: string\n options: { fields: string[]; label: string; value: string }[]\n } & SelectFieldClientProps,\n) => {\n const { field, filterByField, options } = props\n const { path } = useFieldProps()\n const { value: relatedField } = useField<string>({\n path: filterByField,\n })\n\n const [filterOptions, setFilterOptions] = useState<OptionObject[]>([])\n\n useEffect(() => {\n if (!Array.isArray(options)) return\n\n const opts = options.filter((option) => {\n if (!relatedField || !option.fields) return true\n\n if (Array.isArray(option.fields)) {\n return option.fields.includes(relatedField)\n }\n })\n setFilterOptions(opts)\n }, [relatedField, options])\n\n const { setValue, value: selectValue } = useField<string>({ path })\n\n return (\n <SelectInput\n label={field.label}\n name={path}\n onChange={(e: OptionObject) => {\n setValue(e.value)\n }}\n options={filterOptions}\n path={path}\n value={selectValue}\n />\n )\n}\n"],"names":["SelectInput","useField","useFieldProps","React","useEffect","useState","SelectField","props","field","filterByField","options","path","value","relatedField","filterOptions","setFilterOptions","Array","isArray","opts","filter","option","fields","includes","setValue","selectValue","label","name","onChange","e"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACrE,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,+DAA+D;AAC/D,OAAO,MAAMC,cAAc,CACzBC;IAKA,MAAM,EAAEC,KAAK,EAAEC,aAAa,EAAEC,OAAO,EAAE,GAAGH;IAC1C,MAAM,EAAEI,IAAI,EAAE,GAAGT;IACjB,MAAM,EAAEU,OAAOC,YAAY,EAAE,GAAGZ,SAAiB;QAC/CU,MAAMF;IACR;IAEA,MAAM,CAACK,eAAeC,iBAAiB,GAAGV,SAAyB,EAAE;IAErED,UAAU;QACR,IAAI,CAACY,MAAMC,OAAO,CAACP,UAAU;QAE7B,MAAMQ,OAAOR,QAAQS,MAAM,CAAC,CAACC;YAC3B,IAAI,CAACP,gBAAgB,CAACO,OAAOC,MAAM,EAAE,OAAO;YAE5C,IAAIL,MAAMC,OAAO,CAACG,OAAOC,MAAM,GAAG;gBAChC,OAAOD,OAAOC,MAAM,CAACC,QAAQ,CAACT;YAChC;QACF;QACAE,iBAAiBG;IACnB,GAAG;QAACL;QAAcH;KAAQ;IAE1B,MAAM,EAAEa,QAAQ,EAAEX,OAAOY,WAAW,EAAE,GAAGvB,SAAiB;QAAEU;IAAK;IAEjE,qBACE,KAACX;QACCyB,OAAOjB,MAAMiB,KAAK;QAClBC,MAAMf;QACNgB,UAAU,CAACC;YACTL,SAASK,EAAEhB,KAAK;QAClB;QACAF,SAASI;QACTH,MAAMA;QACNC,OAAOY;;AAGb,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/libraries/handlebars/asyncHandlebars.ts"],"sourcesContent":["import Handlebars from 'handlebars/
|
|
1
|
+
{"version":3,"sources":["../../../src/libraries/handlebars/asyncHandlebars.ts"],"sourcesContent":["import Handlebars from 'handlebars/dist/handlebars.js'\nimport asyncHelpers from 'handlebars-async-helpers'\n\nexport const asyncHandlebars = asyncHelpers(Handlebars)\n"],"names":["Handlebars","asyncHelpers","asyncHandlebars"],"mappings":"AAAA,OAAOA,gBAAgB,gCAA+B;AACtD,OAAOC,kBAAkB,2BAA0B;AAEnD,OAAO,MAAMC,kBAAkBD,aAAaD,YAAW"}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAgB9C,QAAA,MAAM,eAAe,iBACJ,YAAY,sBACV,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAgB9C,QAAA,MAAM,eAAe,iBACJ,YAAY,sBACV,MAAM,KAAG,MAgHzB,CAAA;AAEH,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
package/dist/plugin.js
CHANGED
|
@@ -9,8 +9,8 @@ import { translations } from './translations/index.js';
|
|
|
9
9
|
import { isPluginActivated } from './utilities/isPluginActivated.js';
|
|
10
10
|
import { updateFieldsConfig } from './utilities/updateFieldsConfig.js';
|
|
11
11
|
const defaultPluginConfig = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
collections: {},
|
|
13
|
+
generatePromptOnInit: true
|
|
14
14
|
};
|
|
15
15
|
const payloadAiPlugin = (pluginConfig)=>(incomingConfig)=>{
|
|
16
16
|
pluginConfig = {
|
|
@@ -51,14 +51,22 @@ const payloadAiPlugin = (pluginConfig)=>(incomingConfig)=>{
|
|
|
51
51
|
Instructions
|
|
52
52
|
];
|
|
53
53
|
const { collections: collectionSlugs = [] } = pluginConfig;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const { components: { providers = [] } = {} } = incomingConfig.admin || {};
|
|
55
|
+
const updatedProviders = [
|
|
56
|
+
...providers ?? [],
|
|
56
57
|
{
|
|
57
58
|
clientProps: {},
|
|
58
59
|
path: '@ai-stack/payloadcms/client#InstructionsProvider',
|
|
59
60
|
serverProps: {}
|
|
60
61
|
}
|
|
61
62
|
];
|
|
63
|
+
incomingConfig.admin = {
|
|
64
|
+
...incomingConfig.admin || {},
|
|
65
|
+
components: {
|
|
66
|
+
...incomingConfig.admin?.components ?? {},
|
|
67
|
+
providers: updatedProviders
|
|
68
|
+
}
|
|
69
|
+
};
|
|
62
70
|
updatedConfig = {
|
|
63
71
|
...incomingConfig,
|
|
64
72
|
collections: collections.map((collection)=>{
|
|
@@ -96,7 +104,7 @@ const payloadAiPlugin = (pluginConfig)=>(incomingConfig)=>{
|
|
|
96
104
|
}
|
|
97
105
|
],
|
|
98
106
|
i18n: {
|
|
99
|
-
...incomingConfig.i18n,
|
|
107
|
+
...incomingConfig.i18n || {},
|
|
100
108
|
translations: {
|
|
101
109
|
...deepMerge(translations, incomingConfig.i18n?.translations)
|
|
102
110
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport { deepMerge } from 'payload/shared'\nimport { zodToJsonSchema } from 'zod-to-json-schema'\n\nimport type { PluginConfig } from './types.js'\n\nimport { lexicalSchema } from './ai/schemas/lexical.schema.js'\nimport { Instructions } from './collections/Instructions.js'\nimport { PLUGIN_INSTRUCTIONS_MAP_GLOBAL, PLUGIN_NAME } from './defaults.js'\nimport { endpoints } from './endpoints/index.js'\nimport { init } from './init.js'\nimport { translations } from './translations/index.js'\nimport { isPluginActivated } from './utilities/isPluginActivated.js'\nimport { updateFieldsConfig } from './utilities/updateFieldsConfig.js'\n\nconst defaultPluginConfig: PluginConfig = {\n
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport { deepMerge } from 'payload/shared'\nimport { zodToJsonSchema } from 'zod-to-json-schema'\n\nimport type { PluginConfig } from './types.js'\n\nimport { lexicalSchema } from './ai/schemas/lexical.schema.js'\nimport { Instructions } from './collections/Instructions.js'\nimport { PLUGIN_INSTRUCTIONS_MAP_GLOBAL, PLUGIN_NAME } from './defaults.js'\nimport { endpoints } from './endpoints/index.js'\nimport { init } from './init.js'\nimport { translations } from './translations/index.js'\nimport { isPluginActivated } from './utilities/isPluginActivated.js'\nimport { updateFieldsConfig } from './utilities/updateFieldsConfig.js'\n\nconst defaultPluginConfig: PluginConfig = {\n collections: {},\n generatePromptOnInit: true,\n}\n\nconst payloadAiPlugin =\n (pluginConfig: PluginConfig) =>\n (incomingConfig: Config): Config => {\n pluginConfig = { ...defaultPluginConfig, ...pluginConfig }\n const isActivated = isPluginActivated()\n let updatedConfig: Config = { ...incomingConfig }\n let collectionsFieldPathMap = {}\n\n if (isActivated) {\n // Inject editor schema to config, so that it can be accessed when /textarea endpoint will hit\n const zodLexicalSchema = lexicalSchema(pluginConfig.editorConfig?.nodes)\n\n if (pluginConfig.debugging) {\n Instructions.admin.hidden = false\n }\n\n Instructions.admin.custom = {\n ...(Instructions.admin.custom || {}),\n [PLUGIN_NAME]: {\n editorConfig: {\n // Used in admin client for useObject hook\n schema: zodToJsonSchema(zodLexicalSchema),\n },\n },\n }\n\n Instructions.custom = {\n ...(Instructions.custom || {}),\n [PLUGIN_NAME]: {\n editorConfig: {\n // Used in textarea endpoint for llm\n schema: zodLexicalSchema,\n },\n },\n }\n\n const collections = [...(incomingConfig.collections ?? []), Instructions]\n const { collections: collectionSlugs = [] } = pluginConfig\n\n const { components: { providers = [] } = {} } = incomingConfig.admin || {}\n const updatedProviders = [\n ...(providers ?? []),\n {\n clientProps: {},\n path: '@ai-stack/payloadcms/client#InstructionsProvider',\n serverProps: {},\n },\n ]\n\n incomingConfig.admin = {\n ...(incomingConfig.admin || {}),\n components: {\n ...(incomingConfig.admin?.components ?? {}),\n providers: updatedProviders,\n },\n }\n\n updatedConfig = {\n ...incomingConfig,\n collections: collections.map((collection) => {\n if (collectionSlugs[collection.slug]) {\n const { schemaPathMap, updatedCollectionConfig } = updateFieldsConfig(collection)\n collectionsFieldPathMap = {\n ...collectionsFieldPathMap,\n ...schemaPathMap,\n }\n return updatedCollectionConfig\n }\n\n return collection\n }),\n endpoints: [...(incomingConfig.endpoints ?? []), endpoints.textarea, endpoints.upload],\n globals: [\n ...(incomingConfig.globals || []),\n {\n slug: PLUGIN_INSTRUCTIONS_MAP_GLOBAL,\n access: {\n read: () => true,\n },\n admin: {\n hidden: !pluginConfig.debugging,\n },\n fields: [\n {\n name: 'map',\n type: 'json',\n },\n ],\n },\n ],\n i18n: {\n ...(incomingConfig.i18n || {}),\n translations: {\n ...deepMerge(translations, incomingConfig.i18n?.translations),\n },\n },\n }\n }\n\n updatedConfig.onInit = async (payload) => {\n if (incomingConfig.onInit) await incomingConfig.onInit(payload)\n\n if (!isActivated) {\n payload.logger.warn(`— AI Plugin: Not activated. Please verify your environment keys.`)\n return\n }\n\n await init(payload, collectionsFieldPathMap, pluginConfig).catch((error) => {\n console.error(error)\n payload.logger.error(`— AI Plugin: Initialization Error: ${error}`)\n })\n }\n\n return updatedConfig\n }\n\nexport { payloadAiPlugin }\n"],"names":["deepMerge","zodToJsonSchema","lexicalSchema","Instructions","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_NAME","endpoints","init","translations","isPluginActivated","updateFieldsConfig","defaultPluginConfig","collections","generatePromptOnInit","payloadAiPlugin","pluginConfig","incomingConfig","isActivated","updatedConfig","collectionsFieldPathMap","zodLexicalSchema","editorConfig","nodes","debugging","admin","hidden","custom","schema","collectionSlugs","components","providers","updatedProviders","clientProps","path","serverProps","map","collection","slug","schemaPathMap","updatedCollectionConfig","textarea","upload","globals","access","read","fields","name","type","i18n","onInit","payload","logger","warn","catch","error","console"],"mappings":"AAEA,SAASA,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,YAAY,QAAQ,gCAA+B;AAC5D,SAASC,8BAA8B,EAAEC,WAAW,QAAQ,gBAAe;AAC3E,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,SAASC,kBAAkB,QAAQ,oCAAmC;AAEtE,MAAMC,sBAAoC;IACxCC,aAAa,CAAC;IACdC,sBAAsB;AACxB;AAEA,MAAMC,kBACJ,CAACC,eACD,CAACC;QACCD,eAAe;YAAE,GAAGJ,mBAAmB;YAAE,GAAGI,YAAY;QAAC;QACzD,MAAME,cAAcR;QACpB,IAAIS,gBAAwB;YAAE,GAAGF,cAAc;QAAC;QAChD,IAAIG,0BAA0B,CAAC;QAE/B,IAAIF,aAAa;YACf,8FAA8F;YAC9F,MAAMG,mBAAmBlB,cAAca,aAAaM,YAAY,EAAEC;YAElE,IAAIP,aAAaQ,SAAS,EAAE;gBAC1BpB,aAAaqB,KAAK,CAACC,MAAM,GAAG;YAC9B;YAEAtB,aAAaqB,KAAK,CAACE,MAAM,GAAG;gBAC1B,GAAIvB,aAAaqB,KAAK,CAACE,MAAM,IAAI,CAAC,CAAC;gBACnC,CAACrB,YAAY,EAAE;oBACbgB,cAAc;wBACZ,0CAA0C;wBAC1CM,QAAQ1B,gBAAgBmB;oBAC1B;gBACF;YACF;YAEAjB,aAAauB,MAAM,GAAG;gBACpB,GAAIvB,aAAauB,MAAM,IAAI,CAAC,CAAC;gBAC7B,CAACrB,YAAY,EAAE;oBACbgB,cAAc;wBACZ,oCAAoC;wBACpCM,QAAQP;oBACV;gBACF;YACF;YAEA,MAAMR,cAAc;mBAAKI,eAAeJ,WAAW,IAAI,EAAE;gBAAGT;aAAa;YACzE,MAAM,EAAES,aAAagB,kBAAkB,EAAE,EAAE,GAAGb;YAE9C,MAAM,EAAEc,YAAY,EAAEC,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,GAAGd,eAAeQ,KAAK,IAAI,CAAC;YACzE,MAAMO,mBAAmB;mBACnBD,aAAa,EAAE;gBACnB;oBACEE,aAAa,CAAC;oBACdC,MAAM;oBACNC,aAAa,CAAC;gBAChB;aACD;YAEDlB,eAAeQ,KAAK,GAAG;gBACrB,GAAIR,eAAeQ,KAAK,IAAI,CAAC,CAAC;gBAC9BK,YAAY;oBACV,GAAIb,eAAeQ,KAAK,EAAEK,cAAc,CAAC,CAAC;oBAC1CC,WAAWC;gBACb;YACF;YAEAb,gBAAgB;gBACd,GAAGF,cAAc;gBACjBJ,aAAaA,YAAYuB,GAAG,CAAC,CAACC;oBAC5B,IAAIR,eAAe,CAACQ,WAAWC,IAAI,CAAC,EAAE;wBACpC,MAAM,EAAEC,aAAa,EAAEC,uBAAuB,EAAE,GAAG7B,mBAAmB0B;wBACtEjB,0BAA0B;4BACxB,GAAGA,uBAAuB;4BAC1B,GAAGmB,aAAa;wBAClB;wBACA,OAAOC;oBACT;oBAEA,OAAOH;gBACT;gBACA9B,WAAW;uBAAKU,eAAeV,SAAS,IAAI,EAAE;oBAAGA,UAAUkC,QAAQ;oBAAElC,UAAUmC,MAAM;iBAAC;gBACtFC,SAAS;uBACH1B,eAAe0B,OAAO,IAAI,EAAE;oBAChC;wBACEL,MAAMjC;wBACNuC,QAAQ;4BACNC,MAAM,IAAM;wBACd;wBACApB,OAAO;4BACLC,QAAQ,CAACV,aAAaQ,SAAS;wBACjC;wBACAsB,QAAQ;4BACN;gCACEC,MAAM;gCACNC,MAAM;4BACR;yBACD;oBACH;iBACD;gBACDC,MAAM;oBACJ,GAAIhC,eAAegC,IAAI,IAAI,CAAC,CAAC;oBAC7BxC,cAAc;wBACZ,GAAGR,UAAUQ,cAAcQ,eAAegC,IAAI,EAAExC,aAAa;oBAC/D;gBACF;YACF;QACF;QAEAU,cAAc+B,MAAM,GAAG,OAAOC;YAC5B,IAAIlC,eAAeiC,MAAM,EAAE,MAAMjC,eAAeiC,MAAM,CAACC;YAEvD,IAAI,CAACjC,aAAa;gBAChBiC,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,gEAAgE,CAAC;gBACtF;YACF;YAEA,MAAM7C,KAAK2C,SAAS/B,yBAAyBJ,cAAcsC,KAAK,CAAC,CAACC;gBAChEC,QAAQD,KAAK,CAACA;gBACdJ,QAAQC,MAAM,CAACG,KAAK,CAAC,CAAC,mCAAmC,EAAEA,MAAM,CAAC;YACpE;QACF;QAEA,OAAOpC;IACT;AAEF,SAASJ,eAAe,GAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldDescriptionClientProps } from 'payload';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
type ComposeProps = {
|
|
4
|
+
descriptionProps?: FieldDescriptionClientProps;
|
|
5
|
+
instructionId: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const Compose: FC<ComposeProps>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=Compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Compose.d.ts","sourceRoot":"","sources":["../../../src/ui/Compose/Compose.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAC,MAAM,OAAO,CAAC;AA6B/B,KAAK,YAAY,GAAG;IAClB,gBAAgB,CAAC,EAAE,2BAA2B,CAAA;IAC9C,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAqJpC,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEditorConfigContext } from '@payloadcms/richtext-lexical/client';
|
|
4
|
-
import { Popup, useDocumentDrawer, useField, useFieldProps } from '@payloadcms/ui';
|
|
4
|
+
import { FieldDescription, Popup, useDocumentDrawer, useField, useFieldProps } from '@payloadcms/ui';
|
|
5
5
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { PLUGIN_INSTRUCTIONS_TABLE } from '../../defaults.js';
|
|
7
7
|
import { setSafeLexicalState } from '../../utilities/setSafeLexicalState.js';
|
|
8
8
|
import { PluginIcon } from '../Icons/Icons.js';
|
|
9
9
|
import { UndoRedoActions } from './UndoRedoActions.js';
|
|
10
|
-
import styles from './
|
|
10
|
+
import styles from './compose.module.scss';
|
|
11
11
|
import { useMenu } from './hooks/menu/useMenu.js';
|
|
12
12
|
import { useGenerate } from './hooks/useGenerate.js';
|
|
13
13
|
function findParentWithClass(element, className) {
|
|
@@ -22,9 +22,9 @@ function findParentWithClass(element, className) {
|
|
|
22
22
|
// Recursively call the function on the parent element
|
|
23
23
|
return findParentWithClass(element.parentElement, className);
|
|
24
24
|
}
|
|
25
|
-
export const
|
|
25
|
+
export const Compose = (props)=>{
|
|
26
26
|
const [DocumentDrawer, _, { closeDrawer, openDrawer }] = useDocumentDrawer({
|
|
27
|
-
id: instructionId,
|
|
27
|
+
id: props.instructionId,
|
|
28
28
|
collectionSlug: PLUGIN_INSTRUCTIONS_TABLE
|
|
29
29
|
});
|
|
30
30
|
const { type: fieldType, path: pathFromContext, schemaPath } = useFieldProps();
|
|
@@ -113,14 +113,14 @@ export const Actions = ({ descriptionProps = {}, instructionId })=>{
|
|
|
113
113
|
});
|
|
114
114
|
},
|
|
115
115
|
onTranslate: async (data)=>{
|
|
116
|
-
console.log('Translating...'
|
|
116
|
+
console.log('Translating...');
|
|
117
117
|
await generate({
|
|
118
118
|
action: 'Translate',
|
|
119
119
|
params: data
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
|
-
const { setValue
|
|
123
|
+
const { setValue } = useField({
|
|
124
124
|
path: pathFromContext
|
|
125
125
|
});
|
|
126
126
|
const setIfValueIsLexicalState = useCallback((val)=>{
|
|
@@ -129,41 +129,49 @@ export const Actions = ({ descriptionProps = {}, instructionId })=>{
|
|
|
129
129
|
}
|
|
130
130
|
// DO NOT PROVIDE lexicalEditor as a dependency, it freaks out and does not update the editor after first undo/redo
|
|
131
131
|
}, []);
|
|
132
|
-
return /*#__PURE__*/
|
|
133
|
-
children:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
132
|
+
return /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
133
|
+
children: [
|
|
134
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
135
|
+
className: `${styles.actions}`,
|
|
136
|
+
onClick: (e)=>e.preventDefault(),
|
|
137
|
+
ref: actionsRef,
|
|
138
|
+
role: "presentation",
|
|
139
|
+
children: [
|
|
140
|
+
/*#__PURE__*/ _jsx(DocumentDrawer, {
|
|
141
|
+
onSave: ()=>{
|
|
142
|
+
closeDrawer();
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ _jsx(Popup, {
|
|
146
|
+
button: /*#__PURE__*/ _jsx(PluginIcon, {
|
|
147
|
+
isLoading: isProcessing || isLoading
|
|
148
|
+
}),
|
|
149
|
+
render: ({ close })=>{
|
|
150
|
+
return /*#__PURE__*/ _jsx(Menu, {
|
|
151
|
+
isLoading: isProcessing || isLoading,
|
|
152
|
+
onClose: close
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
verticalAlign: "bottom"
|
|
156
|
+
}),
|
|
157
|
+
/*#__PURE__*/ _jsx(ActiveComponent, {
|
|
145
158
|
isLoading: isProcessing || isLoading
|
|
146
159
|
}),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/*#__PURE__*/ _jsx(UndoRedoActions, {
|
|
159
|
-
onChange: (val)=>{
|
|
160
|
-
setValue(val);
|
|
161
|
-
setIfValueIsLexicalState(val);
|
|
162
|
-
}
|
|
160
|
+
/*#__PURE__*/ _jsx(UndoRedoActions, {
|
|
161
|
+
onChange: (val)=>{
|
|
162
|
+
setValue(val);
|
|
163
|
+
setIfValueIsLexicalState(val);
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
props.descriptionProps ? /*#__PURE__*/ _jsx("div", {
|
|
169
|
+
children: /*#__PURE__*/ _jsx(FieldDescription, {
|
|
170
|
+
...props.descriptionProps
|
|
163
171
|
})
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
}) : null
|
|
173
|
+
]
|
|
166
174
|
});
|
|
167
175
|
};
|
|
168
176
|
|
|
169
|
-
//# sourceMappingURL=
|
|
177
|
+
//# sourceMappingURL=Compose.js.map
|