@ai-stack/payloadcms 3.0.0-beta.104.0 → 3.0.0-beta.104.2

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.
Files changed (95) hide show
  1. package/README.md +14 -0
  2. package/dist/ai/models/anthropic/generateRichText.js.map +1 -1
  3. package/dist/ai/models/openai/generateRichText.js.map +1 -1
  4. package/dist/ai/prompts.d.ts +1 -1
  5. package/dist/ai/prompts.d.ts.map +1 -1
  6. package/dist/ai/prompts.js +6 -3
  7. package/dist/ai/prompts.js.map +1 -1
  8. package/dist/ai/utils/generateFileNameByPrompt.js.map +1 -1
  9. package/dist/defaults.js.map +1 -1
  10. package/dist/exports/fields.d.ts +1 -1
  11. package/dist/exports/fields.d.ts.map +1 -1
  12. package/dist/exports/fields.js +1 -1
  13. package/dist/exports/fields.js.map +1 -1
  14. package/dist/fields/ComposeField/ComposeField.d.ts +4 -0
  15. package/dist/fields/ComposeField/ComposeField.d.ts.map +1 -0
  16. package/dist/fields/{DescriptionField/DescriptionField.js → ComposeField/ComposeField.js} +4 -4
  17. package/dist/fields/ComposeField/ComposeField.js.map +1 -0
  18. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts +2 -0
  19. package/dist/fields/LexicalEditor/ComposeFeatureComponent.d.ts.map +1 -0
  20. package/dist/fields/LexicalEditor/{ActionsFeatureComponent.js → ComposeFeatureComponent.js} +4 -4
  21. package/dist/fields/LexicalEditor/{ActionsFeatureComponent.js.map → ComposeFeatureComponent.js.map} +1 -1
  22. package/dist/fields/LexicalEditor/feature.client.d.ts +1 -4
  23. package/dist/fields/LexicalEditor/feature.client.d.ts.map +1 -1
  24. package/dist/fields/LexicalEditor/feature.client.js +2 -2
  25. package/dist/fields/LexicalEditor/feature.client.js.map +1 -1
  26. package/dist/fields/PromptEditorField/PromptEditorField.d.ts +2 -2
  27. package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
  28. package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
  29. package/dist/fields/SelectField/SelectField.d.ts +2 -2
  30. package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
  31. package/dist/fields/SelectField/SelectField.js.map +1 -1
  32. package/dist/init.js.map +1 -1
  33. package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +1 -1
  34. package/dist/libraries/handlebars/asyncHandlebars.js +1 -1
  35. package/dist/libraries/handlebars/asyncHandlebars.js.map +1 -1
  36. package/dist/libraries/handlebars/helpers.js.map +1 -1
  37. package/dist/plugin.d.ts.map +1 -1
  38. package/dist/plugin.js +13 -5
  39. package/dist/plugin.js.map +1 -1
  40. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  41. package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -1
  42. package/dist/ui/Compose/Compose.d.ts +9 -0
  43. package/dist/ui/Compose/Compose.d.ts.map +1 -0
  44. package/dist/ui/{Actions/Actions.js → Compose/Compose.js} +45 -38
  45. package/dist/ui/Compose/Compose.js.map +1 -0
  46. package/dist/ui/{Actions → Compose}/UndoRedoActions.d.ts.map +1 -1
  47. package/dist/ui/{Actions → Compose}/UndoRedoActions.js +15 -2
  48. package/dist/ui/Compose/UndoRedoActions.js.map +1 -0
  49. package/dist/ui/{Actions → Compose}/hooks/menu/Item.d.ts.map +1 -1
  50. package/dist/ui/{Actions → Compose}/hooks/menu/Item.js.map +1 -1
  51. package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts.map +1 -0
  52. package/dist/ui/{Actions → Compose}/hooks/menu/TranslateMenu.js.map +1 -1
  53. package/dist/ui/{Actions → Compose}/hooks/menu/items.d.ts.map +1 -1
  54. package/dist/ui/{Actions → Compose}/hooks/menu/items.js.map +1 -1
  55. package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.d.ts.map +1 -1
  56. package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.js.map +1 -1
  57. package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.d.ts.map +1 -1
  58. package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.js.map +1 -1
  59. package/dist/ui/{Actions → Compose}/hooks/useGenerate.d.ts.map +1 -1
  60. package/dist/ui/{Actions → Compose}/hooks/useGenerate.js +1 -2
  61. package/dist/ui/{Actions → Compose}/hooks/useGenerate.js.map +1 -1
  62. package/dist/ui/Compose/hooks/useHistory.d.ts.map +1 -0
  63. package/dist/ui/{Actions → Compose}/hooks/useHistory.js +3 -1
  64. package/dist/ui/Compose/hooks/useHistory.js.map +1 -0
  65. package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
  66. package/dist/utilities/updateFieldsConfig.js +4 -9
  67. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  68. package/package.json +35 -59
  69. package/dist/fields/DescriptionField/DescriptionField.d.ts +0 -4
  70. package/dist/fields/DescriptionField/DescriptionField.d.ts.map +0 -1
  71. package/dist/fields/DescriptionField/DescriptionField.js.map +0 -1
  72. package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts +0 -2
  73. package/dist/fields/LexicalEditor/ActionsFeatureComponent.d.ts.map +0 -1
  74. package/dist/ui/Actions/Actions.d.ts +0 -5
  75. package/dist/ui/Actions/Actions.d.ts.map +0 -1
  76. package/dist/ui/Actions/Actions.js.map +0 -1
  77. package/dist/ui/Actions/UndoRedoActions.js.map +0 -1
  78. package/dist/ui/Actions/hooks/menu/TranslateMenu.d.ts.map +0 -1
  79. package/dist/ui/Actions/hooks/useHistory.d.ts.map +0 -1
  80. package/dist/ui/Actions/hooks/useHistory.js.map +0 -1
  81. /package/dist/ui/{Actions → Compose}/UndoRedoActions.d.ts +0 -0
  82. /package/dist/ui/{Actions/actions.module.scss → Compose/compose.module.scss} +0 -0
  83. /package/dist/ui/{Actions → Compose}/hooks/menu/Item.d.ts +0 -0
  84. /package/dist/ui/{Actions → Compose}/hooks/menu/Item.js +0 -0
  85. /package/dist/ui/{Actions → Compose}/hooks/menu/TranslateMenu.d.ts +0 -0
  86. /package/dist/ui/{Actions → Compose}/hooks/menu/TranslateMenu.js +0 -0
  87. /package/dist/ui/{Actions → Compose}/hooks/menu/items.d.ts +0 -0
  88. /package/dist/ui/{Actions → Compose}/hooks/menu/items.js +0 -0
  89. /package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.d.ts +0 -0
  90. /package/dist/ui/{Actions → Compose}/hooks/menu/itemsMap.js +0 -0
  91. /package/dist/ui/{Actions → Compose}/hooks/menu/menu.module.scss +0 -0
  92. /package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.d.ts +0 -0
  93. /package/dist/ui/{Actions → Compose}/hooks/menu/useMenu.js +0 -0
  94. /package/dist/ui/{Actions → Compose}/hooks/useGenerate.d.ts +0 -0
  95. /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
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { streamObject } from 'ai'\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: anthropic(options.model),\n prompt: text,\n schema: options.editorSchema,\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nSAMPLE OUTPUT OBJECT:\n${JSON.stringify(exampleOutput)}\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n- Double-check that all JSON fields are properly filled and formatted.`,\n })\n\n return streamResult.toTextStreamResponse()\n}\n"],"names":["anthropic","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,YAAY,QAAQ,KAAI;AACjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,UAAUK,QAAQE,KAAK;QAC9BC,QAAQJ;QACRK,QAAQJ,QAAQK,YAAY;QAC5BC,QAAQ,CAAC,EAAEN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IAEA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
1
+ {"version":3,"sources":["../../../../src/ai/models/anthropic/generateRichText.ts"],"sourcesContent":["import { anthropic } from '@ai-sdk/anthropic'\nimport { streamObject } from 'ai'\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: anthropic(options.model),\n prompt: text,\n schema: options.editorSchema,\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nSAMPLE OUTPUT OBJECT:\n${JSON.stringify(exampleOutput)}\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n- Double-check that all JSON fields are properly filled and formatted.`,\n })\n\n return streamResult.toTextStreamResponse()\n}\n"],"names":["anthropic","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,SAASC,YAAY,QAAQ,KAAI;AACjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,UAAUK,QAAQE,KAAK;QAC9BC,QAAQJ;QACRK,QAAQJ,QAAQK,YAAY;QAC5BC,QAAQ,GAAGN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IAEA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { openai } from '@ai-sdk/openai'\nimport { streamObject } from 'ai'\n\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: openai(options.model),\n prompt: text,\n schema: options.editorSchema,\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nSAMPLE OUTPUT OBJECT:\n${JSON.stringify(exampleOutput)}\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n- Double-check that all JSON fields are properly filled and formatted.`,\n })\n return streamResult.toTextStreamResponse()\n}\n"],"names":["openai","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,YAAY,QAAQ,KAAI;AAEjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,OAAOK,QAAQE,KAAK;QAC3BC,QAAQJ;QACRK,QAAQJ,QAAQK,YAAY;QAC5BC,QAAQ,CAAC,EAAEN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IACA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
1
+ {"version":3,"sources":["../../../../src/ai/models/openai/generateRichText.ts"],"sourcesContent":["import { openai } from '@ai-sdk/openai'\nimport { streamObject } from 'ai'\n\nimport { exampleOutput } from '../example.js'\n\nexport const generateRichText = async (text: string, options: any) => {\n const streamResult = await streamObject({\n model: openai(options.model),\n prompt: text,\n schema: options.editorSchema,\n system: `${options.system}\n\nRULES:\n- Generate original and unique content based on the given topic.\n- Strictly adhere to the specified layout and formatting instructions.\n- Utilize the provided rich text editor tools for appropriate formatting.\n- Ensure the output follows the structure of the sample output object.\n- Produce valid JSON with no undefined or null values.\n\nLAYOUT INSTRUCTIONS:\n${options.layout}\n\nRICH TEXT EDITOR TOOLS:\n- Use appropriate formatting tools such as bold, italic, or underline for emphasis where needed.\n- Apply correct heading levels (h1, h2, h3) for hierarchical structure.\n- Utilize bullet points or numbered lists as required by the layout.\n\nSAMPLE OUTPUT OBJECT:\n${JSON.stringify(exampleOutput)}\n\nADDITIONAL GUIDELINES:\n- Ensure coherence and logical flow between all sections.\n- Maintain a consistent tone and style throughout the content.\n- Use clear and concise language appropriate for the target audience.\n- Double-check that all JSON fields are properly filled and formatted.`,\n })\n return streamResult.toTextStreamResponse()\n}\n"],"names":["openai","streamObject","exampleOutput","generateRichText","text","options","streamResult","model","prompt","schema","editorSchema","system","layout","JSON","stringify","toTextStreamResponse"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,YAAY,QAAQ,KAAI;AAEjC,SAASC,aAAa,QAAQ,gBAAe;AAE7C,OAAO,MAAMC,mBAAmB,OAAOC,MAAcC;IACnD,MAAMC,eAAe,MAAML,aAAa;QACtCM,OAAOP,OAAOK,QAAQE,KAAK;QAC3BC,QAAQJ;QACRK,QAAQJ,QAAQK,YAAY;QAC5BC,QAAQ,GAAGN,QAAQM,MAAM,CAAC;;;;;;;;;;AAU9B,EAAEN,QAAQO,MAAM,CAAC;;;;;;;;AAQjB,EAAEC,KAAKC,SAAS,CAACZ,eAAe;;;;;;sEAMsC,CAAC;IACrE;IACA,OAAOI,aAAaS,oBAAoB;AAC1C,EAAC"}
@@ -10,7 +10,7 @@ type ActionPrompt = {
10
10
  name: ActionMenuItems;
11
11
  system: (options: ActionPromptOptions) => string;
12
12
  };
13
- export declare const defaultSystemPrompt = "\nIMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!\n";
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;
@@ -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;AAED,eAAO,MAAM,mBAAmB,6EAE/B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAyGxC,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;CA6GvB,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"}
@@ -1,6 +1,9 @@
1
- export const defaultSystemPrompt = `
2
- IMPORTANT: JUST PRODUCE THE OUTPUT WITHOUT QUOTES AND DO NOT ENGAGE!
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',
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ai/utils/generateFileNameByPrompt.ts"],"sourcesContent":["export function generateFileNameByPrompt(prompt) {\n // Helper function to get a random integer between min and max (inclusive)\n function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min\n }\n\n // Define the desired length of the filename part from the prompt\n const maxLength = 30\n const promptLength = prompt.length\n\n // Determine the start position for the random substring\n const startPos = getRandomInt(0, Math.max(0, promptLength - maxLength))\n\n // Get the random substring and truncate it if necessary\n let randomSubstring = prompt.substring(startPos, startPos + maxLength)\n\n // Replace invalid filename characters with an underscore\n randomSubstring = randomSubstring.replace(/[^a-z\\d]/gi, '_').toLowerCase()\n\n // Add a timestamp for uniqueness\n const timestamp = new Date().toISOString().replace(/[:.-]/g, '')\n\n // Combine the truncated prompt and timestamp to form the filename\n return `${randomSubstring}_${timestamp}`\n}\n"],"names":["generateFileNameByPrompt","prompt","getRandomInt","min","max","Math","floor","random","maxLength","promptLength","length","startPos","randomSubstring","substring","replace","toLowerCase","timestamp","Date","toISOString"],"mappings":"AAAA,OAAO,SAASA,yBAAyBC,MAAM;IAC7C,0EAA0E;IAC1E,SAASC,aAAaC,GAAG,EAAEC,GAAG;QAC5B,OAAOC,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAMH,CAAAA,MAAMD,MAAM,CAAA,KAAMA;IACvD;IAEA,iEAAiE;IACjE,MAAMK,YAAY;IAClB,MAAMC,eAAeR,OAAOS,MAAM;IAElC,wDAAwD;IACxD,MAAMC,WAAWT,aAAa,GAAGG,KAAKD,GAAG,CAAC,GAAGK,eAAeD;IAE5D,wDAAwD;IACxD,IAAII,kBAAkBX,OAAOY,SAAS,CAACF,UAAUA,WAAWH;IAE5D,yDAAyD;IACzDI,kBAAkBA,gBAAgBE,OAAO,CAAC,cAAc,KAAKC,WAAW;IAExE,iCAAiC;IACjC,MAAMC,YAAY,IAAIC,OAAOC,WAAW,GAAGJ,OAAO,CAAC,UAAU;IAE7D,kEAAkE;IAClE,OAAO,CAAC,EAAEF,gBAAgB,CAAC,EAAEI,UAAU,CAAC;AAC1C"}
1
+ {"version":3,"sources":["../../../src/ai/utils/generateFileNameByPrompt.ts"],"sourcesContent":["export function generateFileNameByPrompt(prompt) {\n // Helper function to get a random integer between min and max (inclusive)\n function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min\n }\n\n // Define the desired length of the filename part from the prompt\n const maxLength = 30\n const promptLength = prompt.length\n\n // Determine the start position for the random substring\n const startPos = getRandomInt(0, Math.max(0, promptLength - maxLength))\n\n // Get the random substring and truncate it if necessary\n let randomSubstring = prompt.substring(startPos, startPos + maxLength)\n\n // Replace invalid filename characters with an underscore\n randomSubstring = randomSubstring.replace(/[^a-z\\d]/gi, '_').toLowerCase()\n\n // Add a timestamp for uniqueness\n const timestamp = new Date().toISOString().replace(/[:.-]/g, '')\n\n // Combine the truncated prompt and timestamp to form the filename\n return `${randomSubstring}_${timestamp}`\n}\n"],"names":["generateFileNameByPrompt","prompt","getRandomInt","min","max","Math","floor","random","maxLength","promptLength","length","startPos","randomSubstring","substring","replace","toLowerCase","timestamp","Date","toISOString"],"mappings":"AAAA,OAAO,SAASA,yBAAyBC,MAAM;IAC7C,0EAA0E;IAC1E,SAASC,aAAaC,GAAG,EAAEC,GAAG;QAC5B,OAAOC,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAMH,CAAAA,MAAMD,MAAM,CAAA,KAAMA;IACvD;IAEA,iEAAiE;IACjE,MAAMK,YAAY;IAClB,MAAMC,eAAeR,OAAOS,MAAM;IAElC,wDAAwD;IACxD,MAAMC,WAAWT,aAAa,GAAGG,KAAKD,GAAG,CAAC,GAAGK,eAAeD;IAE5D,wDAAwD;IACxD,IAAII,kBAAkBX,OAAOY,SAAS,CAACF,UAAUA,WAAWH;IAE5D,yDAAyD;IACzDI,kBAAkBA,gBAAgBE,OAAO,CAAC,cAAc,KAAKC,WAAW;IAExE,iCAAiC;IACjC,MAAMC,YAAY,IAAIC,OAAOC,WAAW,GAAGJ,OAAO,CAAC,UAAU;IAE7D,kEAAkE;IAClE,OAAO,GAAGF,gBAAgB,CAAC,EAAEI,WAAW;AAC1C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_INSTRUCTIONS_MAP_GLOBAL = `${PLUGIN_INSTRUCTIONS_TABLE}-map`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-sonnet-20240229`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,CAAC,EAAED,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,iCAAiC,CAAC,EAAED,0BAA0B,IAAI,CAAC,CAAA;AAChF,OAAO,MAAME,gCAAgC,CAAC,EAAEH,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMI,2BAA2B,CAAC,CAAC,EAAEJ,YAAY,CAAC,CAAA;AACzD,OAAO,MAAMK,+BAA+B,CAAC,EAAED,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,CAAC,EAAED,6BAA6B,OAAO,CAAC,CAAA;AAE3F,eAAe;AACf,OAAO,MAAME,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_INSTRUCTIONS_MAP_GLOBAL = `${PLUGIN_INSTRUCTIONS_TABLE}-map`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-sonnet-20240229`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,GAAGD,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,iCAAiC,GAAGD,0BAA0B,IAAI,CAAC,CAAA;AAChF,OAAO,MAAME,gCAAgC,GAAGH,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMI,2BAA2B,CAAC,CAAC,EAAEJ,aAAa,CAAA;AACzD,OAAO,MAAMK,+BAA+B,GAAGD,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,GAAGD,6BAA6B,OAAO,CAAC,CAAA;AAE3F,eAAe;AACf,OAAO,MAAME,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
1
  export { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js';
2
2
  export { SelectField } from '../fields/SelectField/SelectField.js';
3
- export { DescriptionField } from '../fields/DescriptionField/DescriptionField.js';
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,gBAAgB,EAAE,MAAM,gDAAgD,CAAA"}
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"}
@@ -1,5 +1,5 @@
1
1
  export { PromptEditorField } from '../fields/PromptEditorField/PromptEditorField.js';
2
2
  export { SelectField } from '../fields/SelectField/SelectField.js';
3
- export { DescriptionField } from '../fields/DescriptionField/DescriptionField.js';
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 { DescriptionField } from '../fields/DescriptionField/DescriptionField.js'\n"],"names":["PromptEditorField","SelectField","DescriptionField"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,mDAAkD;AACpF,SAASC,WAAW,QAAQ,uCAAsC;AAClE,SAASC,gBAAgB,QAAQ,iDAAgD"}
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,4 @@
1
+ import React from 'react';
2
+ import { FieldDescriptionClientProps } from 'payload';
3
+ export declare const ComposeField: React.FC<FieldDescriptionClientProps>;
4
+ //# sourceMappingURL=ComposeField.d.ts.map
@@ -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 { Actions } from '../../ui/Actions/Actions.js';
7
- export const DescriptionField = (props)=>{
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(Actions, {
12
+ return /*#__PURE__*/ _jsx(Compose, {
13
13
  descriptionProps: props,
14
14
  instructionId: instructionId
15
15
  });
16
16
  };
17
17
 
18
- //# sourceMappingURL=DescriptionField.js.map
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,2 @@
1
+ export declare const ComposeFeatureComponent: () => import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=ComposeFeatureComponent.d.ts.map
@@ -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 { Actions } from '../../ui/Actions/Actions.js';
5
- export const ActionsFeatureComponent = ()=>{
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(Actions, {
10
+ return /*#__PURE__*/ _jsx(Compose, {
11
11
  instructionId: instructionId
12
12
  });
13
13
  };
14
14
 
15
- //# sourceMappingURL=ActionsFeatureComponent.js.map
15
+ //# sourceMappingURL=ComposeFeatureComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/LexicalEditor/ActionsFeatureComponent.tsx"],"sourcesContent":["import { useFieldProps } from '@payloadcms/ui'\n\nimport { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js'\nimport { Actions } from '../../ui/Actions/Actions.js'\n\nexport const ActionsFeatureComponent = () => {\n const { schemaPath } = useFieldProps()\n\n const { id: instructionId } = useInstructions({\n path: schemaPath,\n })\n\n return <Actions instructionId={instructionId} />\n}\n"],"names":["useFieldProps","useInstructions","Actions","ActionsFeatureComponent","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
+ {"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("react").FC<{
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;;;EAOrC,CAAA"}
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 { ActionsFeatureComponent } from './ActionsFeatureComponent.js';
3
+ import { ComposeFeatureComponent } from './ComposeFeatureComponent.js';
4
4
  export const LexicalEditorFeatureClient = createClientFeature({
5
5
  plugins: [
6
6
  {
7
- Component: ActionsFeatureComponent,
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 { ActionsFeatureComponent } from './ActionsFeatureComponent.js'\n\nexport const LexicalEditorFeatureClient = createClientFeature({\n plugins: [\n {\n Component: ActionsFeatureComponent,\n position: 'belowContainer',\n },\n ],\n})\n"],"names":["createClientFeature","ActionsFeatureComponent","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
+ {"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
- export declare const PromptEditorField: React.FC<TextareaFieldProps>;
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":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAGjD,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA4B1D,CAAA"}
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 type { TextareaFieldProps } from 'payload'\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'\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<TextareaFieldProps> = (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;;AAIA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACpE,OAAOC,WAAW,QAAO;AAEzB,SAASC,eAAe,QAAQ,0DAAyD;AACzF,SAASC,qBAAqB,QAAQ,uDAAsD;AAE5F,yGAAyG;AACzG,OAAO,MAAMC,oBAAkD,CAACC;IAC9D,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
+ {"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 { SelectFieldProps } from 'payload';
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
- } & SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
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,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM7D,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,gBAAgB,4CAqCrB,CAAA"}
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, SelectFieldProps } 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 } & SelectFieldProps,\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
+ {"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"}
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport { GenerationModels } from './ai/models/index.js'\nimport { seedPrompts } from './ai/prompts.js'\nimport { generateSeedPrompt } from './ai/utils/generateSeedPrompt.js'\nimport { PLUGIN_INSTRUCTIONS_MAP_GLOBAL, PLUGIN_INSTRUCTIONS_TABLE } from './defaults.js'\nimport type { PluginConfig } from './types.js'\n\nexport const init = async (payload: Payload, fieldSchemaPaths, pluginConfig: PluginConfig) => {\n payload.logger.info(`— AI Plugin: Initializing...`)\n\n const paths = Object.keys(fieldSchemaPaths)\n\n const fieldInstructionsMap = {}\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]\n const { type: fieldType, label: fieldLabel } = fieldSchemaPaths[path]\n //TODO: if global is broken the plugin doesn't know and does not run reindexing\n const entry = await payload.find({\n collection: PLUGIN_INSTRUCTIONS_TABLE,\n where: {\n 'field-type': {\n equals: fieldType,\n },\n 'schema-path': {\n equals: path,\n },\n },\n })\n\n if (!entry?.docs?.length) {\n const { prompt, system } = seedPrompts({\n fieldLabel,\n fieldSchemaPaths,\n fieldType,\n path,\n })\n\n let generatedPrompt = '{{ title }}'\n if (pluginConfig.generatePromptOnInit) {\n generatedPrompt = await generateSeedPrompt({\n prompt,\n system,\n })\n payload.logger.info(\n `\\nPrompt generated for \"${fieldLabel}\" field:\\nprompt: ${generatedPrompt}\\n\\n`,\n )\n }\n\n const instructions = await payload\n .create({\n collection: PLUGIN_INSTRUCTIONS_TABLE,\n data: {\n 'field-type': fieldType,\n 'model-id': GenerationModels.find((a) => {\n return a.fields.includes(fieldType)\n })?.id,\n prompt: generatedPrompt,\n 'schema-path': path,\n },\n })\n .then((a) => a)\n .catch((a) => {\n console.log('err-', a)\n })\n\n // @ts-expect-error\n if (instructions?.id) {\n fieldInstructionsMap[path] = {\n id: instructions.id,\n fieldType,\n }\n }\n } else {\n const [instructions] = entry.docs\n fieldInstructionsMap[path] = {\n id: instructions.id,\n fieldType,\n }\n }\n }\n\n payload.logger.info(\n `— AI Plugin: Enabled fieldMap: ${JSON.stringify(fieldInstructionsMap, null, 2)}`,\n )\n await payload.updateGlobal({\n slug: PLUGIN_INSTRUCTIONS_MAP_GLOBAL, // required\n data: {\n map: fieldInstructionsMap,\n },\n depth: 2,\n })\n\n payload.logger.info(`— AI Plugin: Initialized!`)\n if (pluginConfig.generatePromptOnInit) {\n payload.logger.info(\n '\\n\\n-AI Plugin: Example prompts are added to get you started, Now go break some code 🚀🚀🚀\\n\\n',\n )\n }\n}\n"],"names":["GenerationModels","seedPrompts","generateSeedPrompt","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_INSTRUCTIONS_TABLE","init","payload","fieldSchemaPaths","pluginConfig","logger","info","paths","Object","keys","fieldInstructionsMap","i","length","path","type","fieldType","label","fieldLabel","entry","find","collection","where","equals","docs","prompt","system","generatedPrompt","generatePromptOnInit","instructions","create","data","a","fields","includes","id","then","catch","console","log","JSON","stringify","updateGlobal","slug","map","depth"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,uBAAsB;AACvD,SAASC,WAAW,QAAQ,kBAAiB;AAC7C,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,8BAA8B,EAAEC,yBAAyB,QAAQ,gBAAe;AAGzF,OAAO,MAAMC,OAAO,OAAOC,SAAkBC,kBAAkBC;IAC7DF,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,4BAA4B,CAAC;IAElD,MAAMC,QAAQC,OAAOC,IAAI,CAACN;IAE1B,MAAMO,uBAAuB,CAAC;IAC9B,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,MAAM,EAAED,IAAK;QACrC,MAAME,OAAON,KAAK,CAACI,EAAE;QACrB,MAAM,EAAEG,MAAMC,SAAS,EAAEC,OAAOC,UAAU,EAAE,GAAGd,gBAAgB,CAACU,KAAK;QACrE,+EAA+E;QAC/E,MAAMK,QAAQ,MAAMhB,QAAQiB,IAAI,CAAC;YAC/BC,YAAYpB;YACZqB,OAAO;gBACL,cAAc;oBACZC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;IAEA1C,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,yBAAyB,CAAC;IAC/C,IAAIF,aAAauB,oBAAoB,EAAE;QACrCzB,QAAQG,MAAM,CAACC,IAAI,CACjB;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport { GenerationModels } from './ai/models/index.js'\nimport { seedPrompts } from './ai/prompts.js'\nimport { generateSeedPrompt } from './ai/utils/generateSeedPrompt.js'\nimport { PLUGIN_INSTRUCTIONS_MAP_GLOBAL, PLUGIN_INSTRUCTIONS_TABLE } from './defaults.js'\nimport type { PluginConfig } from './types.js'\n\nexport const init = async (payload: Payload, fieldSchemaPaths, pluginConfig: PluginConfig) => {\n payload.logger.info(`— AI Plugin: Initializing...`)\n\n const paths = Object.keys(fieldSchemaPaths)\n\n const fieldInstructionsMap = {}\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]\n const { type: fieldType, label: fieldLabel } = fieldSchemaPaths[path]\n //TODO: if global is broken the plugin doesn't know and does not run reindexing\n const entry = await payload.find({\n collection: PLUGIN_INSTRUCTIONS_TABLE,\n where: {\n 'field-type': {\n equals: fieldType,\n },\n 'schema-path': {\n equals: path,\n },\n },\n })\n\n if (!entry?.docs?.length) {\n const { prompt, system } = seedPrompts({\n fieldLabel,\n fieldSchemaPaths,\n fieldType,\n path,\n })\n\n let generatedPrompt = '{{ title }}'\n if (pluginConfig.generatePromptOnInit) {\n generatedPrompt = await generateSeedPrompt({\n prompt,\n system,\n })\n payload.logger.info(\n `\\nPrompt generated for \"${fieldLabel}\" field:\\nprompt: ${generatedPrompt}\\n\\n`,\n )\n }\n\n const instructions = await payload\n .create({\n collection: PLUGIN_INSTRUCTIONS_TABLE,\n data: {\n 'field-type': fieldType,\n 'model-id': GenerationModels.find((a) => {\n return a.fields.includes(fieldType)\n })?.id,\n prompt: generatedPrompt,\n 'schema-path': path,\n },\n })\n .then((a) => a)\n .catch((a) => {\n console.log('err-', a)\n })\n\n // @ts-expect-error\n if (instructions?.id) {\n fieldInstructionsMap[path] = {\n id: instructions.id,\n fieldType,\n }\n }\n } else {\n const [instructions] = entry.docs\n fieldInstructionsMap[path] = {\n id: instructions.id,\n fieldType,\n }\n }\n }\n\n payload.logger.info(\n `— AI Plugin: Enabled fieldMap: ${JSON.stringify(fieldInstructionsMap, null, 2)}`,\n )\n await payload.updateGlobal({\n slug: PLUGIN_INSTRUCTIONS_MAP_GLOBAL, // required\n data: {\n map: fieldInstructionsMap,\n },\n depth: 2,\n })\n\n payload.logger.info(`— AI Plugin: Initialized!`)\n if (pluginConfig.generatePromptOnInit) {\n payload.logger.info(\n '\\n\\n-AI Plugin: Example prompts are added to get you started, Now go break some code 🚀🚀🚀\\n\\n',\n )\n }\n}\n"],"names":["GenerationModels","seedPrompts","generateSeedPrompt","PLUGIN_INSTRUCTIONS_MAP_GLOBAL","PLUGIN_INSTRUCTIONS_TABLE","init","payload","fieldSchemaPaths","pluginConfig","logger","info","paths","Object","keys","fieldInstructionsMap","i","length","path","type","fieldType","label","fieldLabel","entry","find","collection","where","equals","docs","prompt","system","generatedPrompt","generatePromptOnInit","instructions","create","data","a","fields","includes","id","then","catch","console","log","JSON","stringify","updateGlobal","slug","map","depth"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,uBAAsB;AACvD,SAASC,WAAW,QAAQ,kBAAiB;AAC7C,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,8BAA8B,EAAEC,yBAAyB,QAAQ,gBAAe;AAGzF,OAAO,MAAMC,OAAO,OAAOC,SAAkBC,kBAAkBC;IAC7DF,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,4BAA4B,CAAC;IAElD,MAAMC,QAAQC,OAAOC,IAAI,CAACN;IAE1B,MAAMO,uBAAuB,CAAC;IAC9B,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,MAAM,EAAED,IAAK;QACrC,MAAME,OAAON,KAAK,CAACI,EAAE;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AQG,MAAM,CAACC,IAAI,CACjB,CAAC,+BAA+B,EAAEiC,KAAKC,SAAS,CAAC9B,sBAAsB,MAAM,IAAI;IAEnF,MAAMR,QAAQuC,YAAY,CAAC;QACzBC,MAAM3C;QACN+B,MAAM;YACJa,KAAKjC;QACP;QACAkC,OAAO;IACT;IAEA1C,QAAQG,MAAM,CAACC,IAAI,CAAC,CAAC,yBAAyB,CAAC;IAC/C,IAAIF,aAAauB,oBAAoB,EAAE;QACrCzB,QAAQG,MAAM,CAACC,IAAI,CACjB;IAEJ;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/libraries/autocomplete/AutocompleteTextArea.tsx"],"sourcesContent":["/**\n * Credit: Yury Dymov\n * Github: https://github.com/yury-dymov/react-autocomplete-input\n *\n * Modified to only be use for PromptEditorField\n */\n\nimport * as inputSelection from 'get-input-selection'\nimport isEqual from 'lodash.isequal'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport getCaretCoordinates from 'textarea-caret'\n\nimport styles from './AutocompleteTextArea.module.scss'\n\nconst KEY_UP = 38\nconst KEY_DOWN = 40\nconst KEY_RETURN = 13\nconst KEY_ENTER = 14\nconst KEY_ESCAPE = 27\nconst KEY_TAB = 9\n\nconst OPTION_LIST_MIN_WIDTH = 100\n\nexport const AutocompleteTextField = (props) => {\n const {\n changeOnSelect = (trigger, slug) => trigger + slug,\n defaultValue = '',\n disabled = false,\n matchAny = false,\n maxOptions = 10,\n minChars = 0,\n offsetX = 0,\n offsetY = 0,\n onBlur = (e: any) => {},\n onChange = (e: any) => {},\n onKeyDown = (e: any) => {},\n onRequestOptions = (e: any) => {},\n onSelect = (e: any) => {},\n options = [],\n passThroughEnter = false,\n passThroughTab = true,\n regex = '^[A-Za-z0-9\\\\-_]+$',\n requestOnlyIfNoOptions = true,\n spaceRemovers = [',', '.', '!', '?'],\n spacer = ' ',\n trigger = '@',\n triggerCaseInsensitive = false,\n triggerMatchWholeWord = false,\n value: propValue = null,\n ...rest\n } = props\n\n const [helperVisible, setHelperVisible] = useState(false)\n const [left, setLeft] = useState(0)\n const [top, setTop] = useState(0)\n const [triggerChar, setTriggerChar] = useState(null)\n const [matchLength, setMatchLength] = useState(0)\n const [matchStart, setMatchStart] = useState(0)\n const [selection, setSelection] = useState(0)\n const [value, setValue] = useState(null)\n const [caret, setCaret] = useState(0)\n const [currentOptions, setCurrentOptions] = useState([])\n\n const recentValue = useRef(defaultValue)\n const enableSpaceRemovers = useRef(false)\n const inputRef = useRef(null)\n const currentRef = useRef(null)\n const parentRef = useRef(null)\n\n useEffect(() => {\n window.addEventListener('resize', handleResize)\n window.addEventListener('scroll', handleResize)\n\n return () => {\n window.removeEventListener('resize', handleResize)\n window.removeEventListener('scroll', handleResize)\n }\n }, [])\n\n useEffect(() => {\n if (!isEqual(options, currentOptions)) {\n updateHelper(recentValue.current, caret, options)\n }\n }, [options, caret])\n\n useEffect(() => {\n if (helperVisible && currentRef.current) {\n scrollIntoView(currentRef.current, { boundary: parentRef.current, scrollMode: 'if-needed' })\n }\n }, [helperVisible, selection])\n\n const handleResize = useCallback(() => {\n setHelperVisible(false)\n }, [])\n\n const isTrigger = useCallback(\n (triggerStr, str, i) => {\n if (!triggerStr || !triggerStr.length) {\n return true\n }\n\n if (triggerMatchWholeWord && i > 0 && str.charAt(i - 1).match(/\\w/)) {\n return false\n }\n\n if (\n str.substr(i, triggerStr.length) === triggerStr ||\n (triggerCaseInsensitive &&\n str.substr(i, triggerStr.length).toLowerCase() === triggerStr.toLowerCase())\n ) {\n return true\n }\n\n return false\n },\n [triggerMatchWholeWord, triggerCaseInsensitive],\n )\n\n const arrayTriggerMatch = useCallback((triggers, re) => {\n return triggers.map((trigger) => ({\n triggerLength: trigger.length,\n triggerMatch: trigger.match(re),\n triggerStr: trigger,\n }))\n }, [])\n\n const getMatch = useCallback(\n (str, caret, providedOptions) => {\n const re = new RegExp(regex)\n const triggers = Array.isArray(trigger) ? trigger : [trigger]\n triggers.sort()\n\n const providedOptionsObject = Array.isArray(providedOptions)\n ? triggers.reduce((acc, triggerStr) => ({ ...acc, [triggerStr]: providedOptions }), {})\n : providedOptions\n\n const triggersMatch = arrayTriggerMatch(triggers, re)\n let slugData = null\n\n for (let triggersIndex = 0; triggersIndex < triggersMatch.length; triggersIndex++) {\n const { triggerLength, triggerMatch, triggerStr } = triggersMatch[triggersIndex]\n\n for (let i = caret - 1; i >= 0; --i) {\n const substr = str.substring(i, caret)\n const match = substr.match(re)\n let matchStart = -1\n\n if (triggerLength > 0) {\n const triggerIdx = triggerMatch ? i : i - triggerLength + 1\n\n if (triggerIdx < 0) {\n break\n }\n\n if (isTrigger(triggerStr, str, triggerIdx)) {\n matchStart = triggerIdx + triggerLength\n }\n\n if (!match && matchStart < 0) {\n break\n }\n } else {\n if (match && i > 0) {\n continue\n }\n matchStart = i === 0 && match ? 0 : i + 1\n\n if (caret - matchStart === 0) {\n break\n }\n }\n\n if (matchStart >= 0) {\n const triggerOptions = providedOptionsObject[triggerStr]\n if (triggerOptions == null) {\n continue\n }\n\n const matchedSlug = str.substring(matchStart, caret)\n\n const filteredOptions = triggerOptions.filter((slug) => {\n const idx = slug.toLowerCase().indexOf(matchedSlug.toLowerCase())\n return idx !== -1 && (matchAny || idx === 0)\n })\n\n const currTrigger = triggerStr\n const matchLength = matchedSlug.length\n\n slugData = {\n matchLength,\n matchStart,\n options: filteredOptions,\n trigger: currTrigger,\n }\n }\n }\n }\n\n return slugData\n },\n [regex, trigger, arrayTriggerMatch, isTrigger, matchAny],\n )\n\n const updateCaretPosition = useCallback((newCaret) => {\n requestAnimationFrame(() => {\n setCaret(newCaret)\n inputSelection.default.setCaretPosition(inputRef.current, newCaret)\n })\n }, [])\n\n const updateHelper = useCallback(\n (str, caretPos, helperOptions) => {\n const slug = getMatch(str, caretPos, helperOptions)\n\n if (slug) {\n const caretCoordinates = getCaretCoordinates(inputRef.current, caretPos)\n const rect = inputRef.current.getBoundingClientRect()\n\n const newTop = caretCoordinates.top + rect.top - inputRef.current.scrollTop\n const newLeft = Math.min(\n caretCoordinates.left + rect.left - inputRef.current.scrollLeft,\n window.innerWidth - OPTION_LIST_MIN_WIDTH,\n )\n\n if (\n slug.matchLength >= minChars &&\n (slug.options.length > 1 ||\n (slug.options.length === 1 &&\n (slug.options[0].length !== slug.matchLength || slug.options[0].length === 1)))\n ) {\n setHelperVisible(true)\n setTop(newTop)\n setLeft(newLeft)\n setTriggerChar(slug.trigger)\n setMatchLength(slug.matchLength)\n setMatchStart(slug.matchStart)\n setCurrentOptions(slug.options)\n } else {\n if (!requestOnlyIfNoOptions || !slug.options.length) {\n onRequestOptions(str.substr(slug.matchStart, slug.matchLength))\n }\n resetHelper()\n }\n updateCaretPosition(caretPos)\n } else {\n resetHelper()\n }\n },\n [getMatch, minChars, requestOnlyIfNoOptions, onRequestOptions, updateCaretPosition],\n )\n\n const resetHelper = useCallback(() => {\n setHelperVisible(false)\n setSelection(0)\n }, [])\n\n const handleChange = useCallback(\n (e) => {\n const str = e.target.value\n const caretPos = inputSelection.default.default(e.target).end\n\n if (!str.length) {\n setHelperVisible(false)\n }\n\n recentValue.current = str\n\n if (!str.length || !caretPos) {\n return onChange(e.target.value)\n }\n\n // Space removers logic\n if (enableSpaceRemovers.current && spaceRemovers.length && str.length > 2 && spacer.length) {\n for (let i = 0; i < Math.max(recentValue.current.length, str.length); ++i) {\n if (recentValue.current[i] !== str[i]) {\n if (\n i >= 2 &&\n str[i - 1] === spacer &&\n spaceRemovers.indexOf(str[i - 2]) === -1 &&\n spaceRemovers.indexOf(str[i]) !== -1 &&\n getMatch(str.substring(0, i - 2), caretPos - 3, options)\n ) {\n const newValue = `${str.slice(0, i - 1)}${str.slice(i, i + 1)}${str.slice(i - 1, i)}${str.slice(i + 1)}`\n\n updateCaretPosition(i + 1)\n inputRef.current.value = newValue\n\n if (!propValue) {\n setValue(newValue)\n }\n\n return onChange(newValue)\n }\n\n break\n }\n }\n\n enableSpaceRemovers.current = false\n }\n\n updateHelper(str, caretPos, options)\n\n if (!propValue) {\n setValue(e.target.value)\n }\n\n return onChange(e.target.value)\n },\n [\n onChange,\n propValue,\n spaceRemovers,\n spacer,\n options,\n updateCaretPosition,\n updateHelper,\n getMatch,\n ],\n )\n\n const handleBlur = useCallback(\n (e) => {\n resetHelper()\n onBlur(e)\n },\n [onBlur, resetHelper],\n )\n\n const handleSelection = useCallback(\n (idx) => {\n const slug = currentOptions[idx]\n const value = recentValue.current\n const part1 =\n triggerChar.length === 0 ? '' : value.substring(0, matchStart - triggerChar.length)\n const part2 = value.substring(matchStart + matchLength)\n\n const event = { target: inputRef.current }\n const changedStr = changeOnSelect(triggerChar, slug)\n\n event.target.value = `${part1}${changedStr}${spacer}${part2}`\n handleChange(event)\n onSelect(event.target.value)\n\n resetHelper()\n\n const advanceCaretDistance = part1.length + changedStr.length + (spacer ? spacer.length : 1)\n updateCaretPosition(advanceCaretDistance)\n\n enableSpaceRemovers.current = true\n },\n [\n currentOptions,\n triggerChar,\n matchStart,\n matchLength,\n changeOnSelect,\n spacer,\n handleChange,\n onSelect,\n resetHelper,\n updateCaretPosition,\n ],\n )\n\n const handleKeyDown = useCallback(\n (event) => {\n const optionsCount =\n maxOptions > 0 ? Math.min(currentOptions.length, maxOptions) : currentOptions.length\n\n if (helperVisible) {\n switch (event.keyCode) {\n case KEY_ESCAPE:\n event.preventDefault()\n resetHelper()\n break\n case KEY_UP:\n event.preventDefault()\n if (optionsCount > 0) {\n setSelection(\n (prevSelection) => Math.max(0, optionsCount + prevSelection - 1) % optionsCount,\n )\n }\n break\n case KEY_DOWN:\n event.preventDefault()\n if (optionsCount > 0) {\n setSelection((prevSelection) => (prevSelection + 1) % optionsCount)\n }\n break\n case KEY_ENTER:\n case KEY_RETURN:\n if (!passThroughEnter) {\n event.preventDefault()\n }\n handleSelection(selection)\n break\n case KEY_TAB:\n if (!passThroughTab) {\n event.preventDefault()\n }\n handleSelection(selection)\n break\n default:\n onKeyDown(event)\n break\n }\n } else {\n onKeyDown(event)\n }\n },\n [\n helperVisible,\n currentOptions,\n maxOptions,\n passThroughEnter,\n passThroughTab,\n selection,\n onKeyDown,\n resetHelper,\n handleSelection,\n ],\n )\n\n const renderAutocompleteList = useCallback(() => {\n if (!helperVisible || currentOptions.length === 0) {\n return null\n }\n\n if (selection >= currentOptions.length) {\n setSelection(0)\n return null\n }\n\n const optionNumber = maxOptions === 0 ? currentOptions.length : maxOptions\n\n const helperOptions = currentOptions.slice(0, optionNumber).map((val, idx) => {\n let [helper, value] = val.split(' ')\n if (!value) {\n helper = undefined\n value = val\n }\n\n const renderHighlightedText = (text) => {\n const highlightStart = text\n .toLowerCase()\n .indexOf(recentValue.current.substr(matchStart, matchLength).toLowerCase())\n\n const highlightedText = text.substr(highlightStart, matchLength)\n\n if (!val.startsWith(text)) {\n return text\n }\n\n return (\n <>\n {text.slice(0, highlightStart)}\n <strong>{highlightedText}</strong>\n {text.slice(highlightStart + matchLength)}\n </>\n )\n }\n\n return (\n <li\n className={idx === selection ? styles.active : null}\n key={val}\n onClick={() => {\n handleSelection(idx)\n }}\n onMouseDown={(e) => {\n e.preventDefault()\n }}\n onMouseEnter={() => {\n setSelection(idx)\n }}\n ref={idx === selection ? currentRef : null}\n role=\"presentation\"\n >\n {helper && <code className={styles.helper}>{renderHighlightedText(helper)}</code>}\n {renderHighlightedText(value)}\n </li>\n )\n })\n\n const maxWidth = window.innerWidth - left - offsetX - 5\n const maxHeight = window.innerHeight - top - offsetY - 5\n\n return (\n <ul\n className={styles.autocompleteInput + ' ' + 'popup__content'}\n ref={parentRef}\n style={{\n left: left + offsetX,\n maxHeight,\n maxWidth,\n opacity: 'initial',\n pointerEvents: 'initial',\n position: 'fixed',\n top: top + offsetY,\n visibility: 'initial',\n }}\n >\n {helperOptions}\n </ul>\n )\n }, [\n helperVisible,\n currentOptions,\n selection,\n maxOptions,\n left,\n top,\n offsetX,\n offsetY,\n matchStart,\n matchLength,\n handleSelection,\n ])\n\n return (\n <div className=\"popup\">\n <textarea\n className=\"textarea-outer\"\n disabled={disabled}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n ref={inputRef}\n rows={6}\n style={{ overflow: 'auto' }}\n value={propValue !== null ? propValue : value || defaultValue}\n {...rest}\n />\n {renderAutocompleteList()}\n </div>\n )\n}\n"],"names":["inputSelection","isEqual","React","useCallback","useEffect","useRef","useState","scrollIntoView","getCaretCoordinates","styles","KEY_UP","KEY_DOWN","KEY_RETURN","KEY_ENTER","KEY_ESCAPE","KEY_TAB","OPTION_LIST_MIN_WIDTH","AutocompleteTextField","props","changeOnSelect","trigger","slug","defaultValue","disabled","matchAny","maxOptions","minChars","offsetX","offsetY","onBlur","e","onChange","onKeyDown","onRequestOptions","onSelect","options","passThroughEnter","passThroughTab","regex","requestOnlyIfNoOptions","spaceRemovers","spacer","triggerCaseInsensitive","triggerMatchWholeWord","value","propValue","rest","helperVisible","setHelperVisible","left","setLeft","top","setTop","triggerChar","setTriggerChar","matchLength","setMatchLength","matchStart","setMatchStart","selection","setSelection","setValue","caret","setCaret","currentOptions","setCurrentOptions","recentValue","enableSpaceRemovers","inputRef","currentRef","parentRef","window","addEventListener","handleResize","removeEventListener","updateHelper","current","boundary","scrollMode","isTrigger","triggerStr","str","i","length","charAt","match","substr","toLowerCase","arrayTriggerMatch","triggers","re","map","triggerLength","triggerMatch","getMatch","providedOptions","RegExp","Array","isArray","sort","providedOptionsObject","reduce","acc","triggersMatch","slugData","triggersIndex","substring","triggerIdx","triggerOptions","matchedSlug","filteredOptions","filter","idx","indexOf","currTrigger","updateCaretPosition","newCaret","requestAnimationFrame","default","setCaretPosition","caretPos","helperOptions","caretCoordinates","rect","getBoundingClientRect","newTop","scrollTop","newLeft","Math","min","scrollLeft","innerWidth","resetHelper","handleChange","target","end","max","newValue","slice","handleBlur","handleSelection","part1","part2","event","changedStr","advanceCaretDistance","handleKeyDown","optionsCount","keyCode","preventDefault","prevSelection","renderAutocompleteList","optionNumber","val","helper","split","undefined","renderHighlightedText","text","highlightStart","highlightedText","startsWith","strong","li","className","active","onClick","onMouseDown","onMouseEnter","ref","role","code","maxWidth","maxHeight","innerHeight","ul","autocompleteInput","style","opacity","pointerEvents","position","visibility","div","textarea","rows","overflow"],"mappings":"AAAA;;;;;CAKC;AAED,YAAYA,oBAAoB,sBAAqB;AACrD,OAAOC,aAAa,iBAAgB;AACpC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACvE,OAAOC,oBAAoB,6BAA4B;AACvD,OAAOC,yBAAyB,iBAAgB;AAEhD,OAAOC,YAAY,qCAAoC;AAEvD,MAAMC,SAAS;AACf,MAAMC,WAAW;AACjB,MAAMC,aAAa;AACnB,MAAMC,YAAY;AAClB,MAAMC,aAAa;AACnB,MAAMC,UAAU;AAEhB,MAAMC,wBAAwB;AAE9B,OAAO,MAAMC,wBAAwB,CAACC;IACpC,MAAM,EACJC,iBAAiB,CAACC,SAASC,OAASD,UAAUC,IAAI,EAClDC,eAAe,EAAE,EACjBC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChBC,aAAa,EAAE,EACfC,WAAW,CAAC,EACZC,UAAU,CAAC,EACXC,UAAU,CAAC,EACXC,SAAS,CAACC,KAAY,CAAC,EACvBC,WAAW,CAACD,KAAY,CAAC,EACzBE,YAAY,CAACF,KAAY,CAAC,EAC1BG,mBAAmB,CAACH,KAAY,CAAC,EACjCI,WAAW,CAACJ,KAAY,CAAC,EACzBK,UAAU,EAAE,EACZC,mBAAmB,KAAK,EACxBC,iBAAiB,IAAI,EACrBC,QAAQ,oBAAoB,EAC5BC,yBAAyB,IAAI,EAC7BC,gBAAgB;QAAC;QAAK;QAAK;QAAK;KAAI,EACpCC,SAAS,GAAG,EACZrB,UAAU,GAAG,EACbsB,yBAAyB,KAAK,EAC9BC,wBAAwB,KAAK,EAC7BC,OAAOC,YAAY,IAAI,EACvB,GAAGC,MACJ,GAAG5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,iBAAiB,GAAG,MAAM;YAC5CP,KAAKnG;YACL2G,OAAO;gBACLhI,MAAMA,OAAOtB;gBACbkJ;gBACAD;gBACAM,SAAS;gBACTC,eAAe;gBACfC,UAAU;gBACVjI,KAAKA,MAAMvB;gBACXyJ,YAAY;YACd;sBAEC5D;;IAGP,GAAG;QACD1E;QACAiB;QACAL;QACAlC;QACAwB;QACAE;QACAxB;QACAC;QACA6B;QACAF;QACAqF;KACD;IAED,qBACE,MAAC0C;QAAIlB,WAAU;;0BACb,KAACmB;gBACCnB,WAAU;gBACV7I,UAAUA;gBACVM,QAAQ8G;gBACR5G,UAAUsG;gBACVrG,WAAWkH;gBACXuB,KAAKrG;gBACLoH,MAAM;gBACNP,OAAO;oBAAEQ,UAAU;gBAAO;gBAC1B7I,OAAOC,cAAc,OAAOA,YAAYD,SAAStB;gBAChD,GAAGwB,IAAI;;YAETyG;;;AAGP,EAAC"}
1
+ {"version":3,"sources":["../../../src/libraries/autocomplete/AutocompleteTextArea.tsx"],"sourcesContent":["/**\n * Credit: Yury Dymov\n * Github: https://github.com/yury-dymov/react-autocomplete-input\n *\n * Modified to only be use for PromptEditorField\n */\n\nimport * as inputSelection from 'get-input-selection'\nimport isEqual from 'lodash.isequal'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport getCaretCoordinates from 'textarea-caret'\n\nimport styles from './AutocompleteTextArea.module.scss'\n\nconst KEY_UP = 38\nconst KEY_DOWN = 40\nconst KEY_RETURN = 13\nconst KEY_ENTER = 14\nconst KEY_ESCAPE = 27\nconst KEY_TAB = 9\n\nconst OPTION_LIST_MIN_WIDTH = 100\n\nexport const AutocompleteTextField = (props) => {\n const {\n changeOnSelect = (trigger, slug) => trigger + slug,\n defaultValue = '',\n disabled = false,\n matchAny = false,\n maxOptions = 10,\n minChars = 0,\n offsetX = 0,\n offsetY = 0,\n onBlur = (e: any) => {},\n onChange = (e: any) => {},\n onKeyDown = (e: any) => {},\n onRequestOptions = (e: any) => {},\n onSelect = (e: any) => {},\n options = [],\n passThroughEnter = false,\n passThroughTab = true,\n regex = '^[A-Za-z0-9\\\\-_]+$',\n requestOnlyIfNoOptions = true,\n spaceRemovers = [',', '.', '!', '?'],\n spacer = ' ',\n trigger = '@',\n triggerCaseInsensitive = false,\n triggerMatchWholeWord = false,\n value: propValue = null,\n ...rest\n } = props\n\n const [helperVisible, setHelperVisible] = useState(false)\n const [left, setLeft] = useState(0)\n const [top, setTop] = useState(0)\n const [triggerChar, setTriggerChar] = useState(null)\n const [matchLength, setMatchLength] = useState(0)\n const [matchStart, setMatchStart] = useState(0)\n const [selection, setSelection] = useState(0)\n const [value, setValue] = useState(null)\n const [caret, setCaret] = useState(0)\n const [currentOptions, setCurrentOptions] = useState([])\n\n const recentValue = useRef(defaultValue)\n const enableSpaceRemovers = useRef(false)\n const inputRef = useRef(null)\n const currentRef = useRef(null)\n const parentRef = useRef(null)\n\n useEffect(() => {\n window.addEventListener('resize', handleResize)\n window.addEventListener('scroll', handleResize)\n\n return () => {\n window.removeEventListener('resize', handleResize)\n window.removeEventListener('scroll', handleResize)\n }\n }, [])\n\n useEffect(() => {\n if (!isEqual(options, currentOptions)) {\n updateHelper(recentValue.current, caret, options)\n }\n }, [options, caret])\n\n useEffect(() => {\n if (helperVisible && currentRef.current) {\n scrollIntoView(currentRef.current, { boundary: parentRef.current, scrollMode: 'if-needed' })\n }\n }, [helperVisible, selection])\n\n const handleResize = useCallback(() => {\n setHelperVisible(false)\n }, [])\n\n const isTrigger = useCallback(\n (triggerStr, str, i) => {\n if (!triggerStr || !triggerStr.length) {\n return true\n }\n\n if (triggerMatchWholeWord && i > 0 && str.charAt(i - 1).match(/\\w/)) {\n return false\n }\n\n if (\n str.substr(i, triggerStr.length) === triggerStr ||\n (triggerCaseInsensitive &&\n str.substr(i, triggerStr.length).toLowerCase() === triggerStr.toLowerCase())\n ) {\n return true\n }\n\n return false\n },\n [triggerMatchWholeWord, triggerCaseInsensitive],\n )\n\n const arrayTriggerMatch = useCallback((triggers, re) => {\n return triggers.map((trigger) => ({\n triggerLength: trigger.length,\n triggerMatch: trigger.match(re),\n triggerStr: trigger,\n }))\n }, [])\n\n const getMatch = useCallback(\n (str, caret, providedOptions) => {\n const re = new RegExp(regex)\n const triggers = Array.isArray(trigger) ? trigger : [trigger]\n triggers.sort()\n\n const providedOptionsObject = Array.isArray(providedOptions)\n ? triggers.reduce((acc, triggerStr) => ({ ...acc, [triggerStr]: providedOptions }), {})\n : providedOptions\n\n const triggersMatch = arrayTriggerMatch(triggers, re)\n let slugData = null\n\n for (let triggersIndex = 0; triggersIndex < triggersMatch.length; triggersIndex++) {\n const { triggerLength, triggerMatch, triggerStr } = triggersMatch[triggersIndex]\n\n for (let i = caret - 1; i >= 0; --i) {\n const substr = str.substring(i, caret)\n const match = substr.match(re)\n let matchStart = -1\n\n if (triggerLength > 0) {\n const triggerIdx = triggerMatch ? i : i - triggerLength + 1\n\n if (triggerIdx < 0) {\n break\n }\n\n if (isTrigger(triggerStr, str, triggerIdx)) {\n matchStart = triggerIdx + triggerLength\n }\n\n if (!match && matchStart < 0) {\n break\n }\n } else {\n if (match && i > 0) {\n continue\n }\n matchStart = i === 0 && match ? 0 : i + 1\n\n if (caret - matchStart === 0) {\n break\n }\n }\n\n if (matchStart >= 0) {\n const triggerOptions = providedOptionsObject[triggerStr]\n if (triggerOptions == null) {\n continue\n }\n\n const matchedSlug = str.substring(matchStart, caret)\n\n const filteredOptions = triggerOptions.filter((slug) => {\n const idx = slug.toLowerCase().indexOf(matchedSlug.toLowerCase())\n return idx !== -1 && (matchAny || idx === 0)\n })\n\n const currTrigger = triggerStr\n const matchLength = matchedSlug.length\n\n slugData = {\n matchLength,\n matchStart,\n options: filteredOptions,\n trigger: currTrigger,\n }\n }\n }\n }\n\n return slugData\n },\n [regex, trigger, arrayTriggerMatch, isTrigger, matchAny],\n )\n\n const updateCaretPosition = useCallback((newCaret) => {\n requestAnimationFrame(() => {\n setCaret(newCaret)\n inputSelection.default.setCaretPosition(inputRef.current, newCaret)\n })\n }, [])\n\n const updateHelper = useCallback(\n (str, caretPos, helperOptions) => {\n const slug = getMatch(str, caretPos, helperOptions)\n\n if (slug) {\n const caretCoordinates = getCaretCoordinates(inputRef.current, caretPos)\n const rect = inputRef.current.getBoundingClientRect()\n\n const newTop = caretCoordinates.top + rect.top - inputRef.current.scrollTop\n const newLeft = Math.min(\n caretCoordinates.left + rect.left - inputRef.current.scrollLeft,\n window.innerWidth - OPTION_LIST_MIN_WIDTH,\n )\n\n if (\n slug.matchLength >= minChars &&\n (slug.options.length > 1 ||\n (slug.options.length === 1 &&\n (slug.options[0].length !== slug.matchLength || slug.options[0].length === 1)))\n ) {\n setHelperVisible(true)\n setTop(newTop)\n setLeft(newLeft)\n setTriggerChar(slug.trigger)\n setMatchLength(slug.matchLength)\n setMatchStart(slug.matchStart)\n setCurrentOptions(slug.options)\n } else {\n if (!requestOnlyIfNoOptions || !slug.options.length) {\n onRequestOptions(str.substr(slug.matchStart, slug.matchLength))\n }\n resetHelper()\n }\n updateCaretPosition(caretPos)\n } else {\n resetHelper()\n }\n },\n [getMatch, minChars, requestOnlyIfNoOptions, onRequestOptions, updateCaretPosition],\n )\n\n const resetHelper = useCallback(() => {\n setHelperVisible(false)\n setSelection(0)\n }, [])\n\n const handleChange = useCallback(\n (e) => {\n const str = e.target.value\n const caretPos = inputSelection.default.default(e.target).end\n\n if (!str.length) {\n setHelperVisible(false)\n }\n\n recentValue.current = str\n\n if (!str.length || !caretPos) {\n return onChange(e.target.value)\n }\n\n // Space removers logic\n if (enableSpaceRemovers.current && spaceRemovers.length && str.length > 2 && spacer.length) {\n for (let i = 0; i < Math.max(recentValue.current.length, str.length); ++i) {\n if (recentValue.current[i] !== str[i]) {\n if (\n i >= 2 &&\n str[i - 1] === spacer &&\n spaceRemovers.indexOf(str[i - 2]) === -1 &&\n spaceRemovers.indexOf(str[i]) !== -1 &&\n getMatch(str.substring(0, i - 2), caretPos - 3, options)\n ) {\n const newValue = `${str.slice(0, i - 1)}${str.slice(i, i + 1)}${str.slice(i - 1, i)}${str.slice(i + 1)}`\n\n updateCaretPosition(i + 1)\n inputRef.current.value = newValue\n\n if (!propValue) {\n setValue(newValue)\n }\n\n return onChange(newValue)\n }\n\n break\n }\n }\n\n enableSpaceRemovers.current = false\n }\n\n updateHelper(str, caretPos, options)\n\n if (!propValue) {\n setValue(e.target.value)\n }\n\n return onChange(e.target.value)\n },\n [\n onChange,\n propValue,\n spaceRemovers,\n spacer,\n options,\n updateCaretPosition,\n updateHelper,\n getMatch,\n ],\n )\n\n const handleBlur = useCallback(\n (e) => {\n resetHelper()\n onBlur(e)\n },\n [onBlur, resetHelper],\n )\n\n const handleSelection = useCallback(\n (idx) => {\n const slug = currentOptions[idx]\n const value = recentValue.current\n const part1 =\n triggerChar.length === 0 ? '' : value.substring(0, matchStart - triggerChar.length)\n const part2 = value.substring(matchStart + matchLength)\n\n const event = { target: inputRef.current }\n const changedStr = changeOnSelect(triggerChar, slug)\n\n event.target.value = `${part1}${changedStr}${spacer}${part2}`\n handleChange(event)\n onSelect(event.target.value)\n\n resetHelper()\n\n const advanceCaretDistance = part1.length + changedStr.length + (spacer ? spacer.length : 1)\n updateCaretPosition(advanceCaretDistance)\n\n enableSpaceRemovers.current = true\n },\n [\n currentOptions,\n triggerChar,\n matchStart,\n matchLength,\n changeOnSelect,\n spacer,\n handleChange,\n onSelect,\n resetHelper,\n updateCaretPosition,\n ],\n )\n\n const handleKeyDown = useCallback(\n (event) => {\n const optionsCount =\n maxOptions > 0 ? Math.min(currentOptions.length, maxOptions) : currentOptions.length\n\n if (helperVisible) {\n switch (event.keyCode) {\n case KEY_ESCAPE:\n event.preventDefault()\n resetHelper()\n break\n case KEY_UP:\n event.preventDefault()\n if (optionsCount > 0) {\n setSelection(\n (prevSelection) => Math.max(0, optionsCount + prevSelection - 1) % optionsCount,\n )\n }\n break\n case KEY_DOWN:\n event.preventDefault()\n if (optionsCount > 0) {\n setSelection((prevSelection) => (prevSelection + 1) % optionsCount)\n }\n break\n case KEY_ENTER:\n case KEY_RETURN:\n if (!passThroughEnter) {\n event.preventDefault()\n }\n handleSelection(selection)\n break\n case KEY_TAB:\n if (!passThroughTab) {\n event.preventDefault()\n }\n handleSelection(selection)\n break\n default:\n onKeyDown(event)\n break\n }\n } else {\n onKeyDown(event)\n }\n },\n [\n helperVisible,\n currentOptions,\n maxOptions,\n passThroughEnter,\n passThroughTab,\n selection,\n onKeyDown,\n resetHelper,\n handleSelection,\n ],\n )\n\n const renderAutocompleteList = useCallback(() => {\n if (!helperVisible || currentOptions.length === 0) {\n return null\n }\n\n if (selection >= currentOptions.length) {\n setSelection(0)\n return null\n }\n\n const optionNumber = maxOptions === 0 ? currentOptions.length : maxOptions\n\n const helperOptions = currentOptions.slice(0, optionNumber).map((val, idx) => {\n let [helper, value] = val.split(' ')\n if (!value) {\n helper = undefined\n value = val\n }\n\n const renderHighlightedText = (text) => {\n const highlightStart = text\n .toLowerCase()\n .indexOf(recentValue.current.substr(matchStart, matchLength).toLowerCase())\n\n const highlightedText = text.substr(highlightStart, matchLength)\n\n if (!val.startsWith(text)) {\n return text\n }\n\n return (\n <>\n {text.slice(0, highlightStart)}\n <strong>{highlightedText}</strong>\n {text.slice(highlightStart + matchLength)}\n </>\n )\n }\n\n return (\n <li\n className={idx === selection ? styles.active : null}\n key={val}\n onClick={() => {\n handleSelection(idx)\n }}\n onMouseDown={(e) => {\n e.preventDefault()\n }}\n onMouseEnter={() => {\n setSelection(idx)\n }}\n ref={idx === selection ? currentRef : null}\n role=\"presentation\"\n >\n {helper && <code className={styles.helper}>{renderHighlightedText(helper)}</code>}\n {renderHighlightedText(value)}\n </li>\n )\n })\n\n const maxWidth = window.innerWidth - left - offsetX - 5\n const maxHeight = window.innerHeight - top - offsetY - 5\n\n return (\n <ul\n className={styles.autocompleteInput + ' ' + 'popup__content'}\n ref={parentRef}\n style={{\n left: left + offsetX,\n maxHeight,\n maxWidth,\n opacity: 'initial',\n pointerEvents: 'initial',\n position: 'fixed',\n top: top + offsetY,\n visibility: 'initial',\n }}\n >\n {helperOptions}\n </ul>\n )\n }, [\n helperVisible,\n currentOptions,\n selection,\n maxOptions,\n left,\n top,\n offsetX,\n offsetY,\n matchStart,\n matchLength,\n handleSelection,\n ])\n\n return (\n <div className=\"popup\">\n <textarea\n className=\"textarea-outer\"\n disabled={disabled}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n ref={inputRef}\n rows={6}\n style={{ overflow: 'auto' }}\n value={propValue !== null ? propValue : value || defaultValue}\n {...rest}\n />\n {renderAutocompleteList()}\n </div>\n )\n}\n"],"names":["inputSelection","isEqual","React","useCallback","useEffect","useRef","useState","scrollIntoView","getCaretCoordinates","styles","KEY_UP","KEY_DOWN","KEY_RETURN","KEY_ENTER","KEY_ESCAPE","KEY_TAB","OPTION_LIST_MIN_WIDTH","AutocompleteTextField","props","changeOnSelect","trigger","slug","defaultValue","disabled","matchAny","maxOptions","minChars","offsetX","offsetY","onBlur","e","onChange","onKeyDown","onRequestOptions","onSelect","options","passThroughEnter","passThroughTab","regex","requestOnlyIfNoOptions","spaceRemovers","spacer","triggerCaseInsensitive","triggerMatchWholeWord","value","propValue","rest","helperVisible","setHelperVisible","left","setLeft","top","setTop","triggerChar","setTriggerChar","matchLength","setMatchLength","matchStart","setMatchStart","selection","setSelection","setValue","caret","setCaret","currentOptions","setCurrentOptions","recentValue","enableSpaceRemovers","inputRef","currentRef","parentRef","window","addEventListener","handleResize","removeEventListener","updateHelper","current","boundary","scrollMode","isTrigger","triggerStr","str","i","length","charAt","match","substr","toLowerCase","arrayTriggerMatch","triggers","re","map","triggerLength","triggerMatch","getMatch","providedOptions","RegExp","Array","isArray","sort","providedOptionsObject","reduce","acc","triggersMatch","slugData","triggersIndex","substring","triggerIdx","triggerOptions","matchedSlug","filteredOptions","filter","idx","indexOf","currTrigger","updateCaretPosition","newCaret","requestAnimationFrame","default","setCaretPosition","caretPos","helperOptions","caretCoordinates","rect","getBoundingClientRect","newTop","scrollTop","newLeft","Math","min","scrollLeft","innerWidth","resetHelper","handleChange","target","end","max","newValue","slice","handleBlur","handleSelection","part1","part2","event","changedStr","advanceCaretDistance","handleKeyDown","optionsCount","keyCode","preventDefault","prevSelection","renderAutocompleteList","optionNumber","val","helper","split","undefined","renderHighlightedText","text","highlightStart","highlightedText","startsWith","strong","li","className","active","onClick","onMouseDown","onMouseEnter","ref","role","code","maxWidth","maxHeight","innerHeight","ul","autocompleteInput","style","opacity","pointerEvents","position","visibility","div","textarea","rows","overflow"],"mappings":"AAAA;;;;;CAKC;AAED,YAAYA,oBAAoB,sBAAqB;AACrD,OAAOC,aAAa,iBAAgB;AACpC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACvE,OAAOC,oBAAoB,6BAA4B;AACvD,OAAOC,yBAAyB,iBAAgB;AAEhD,OAAOC,YAAY,qCAAoC;AAEvD,MAAMC,SAAS;AACf,MAAMC,WAAW;AACjB,MAAMC,aAAa;AACnB,MAAMC,YAAY;AAClB,MAAMC,aAAa;AACnB,MAAMC,UAAU;AAEhB,MAAMC,wBAAwB;AAE9B,OAAO,MAAMC,wBAAwB,CAACC;IACpC,MAAM,EACJC,iBAAiB,CAACC,SAASC,OAASD,UAAUC,IAAI,EAClDC,eAAe,EAAE,EACjBC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChBC,aAAa,EAAE,EACfC,WAAW,CAAC,EACZC,UAAU,CAAC,EACXC,UAAU,CAAC,EACXC,SAAS,CAACC,KAAY,CAAC,EACvBC,WAAW,CAACD,KAAY,CAAC,EACzBE,YAAY,CAACF,KAAY,CAAC,EAC1BG,mBAAmB,CAACH,KAAY,CAAC,EACjCI,WAAW,CAACJ,KAAY,CAAC,EACzBK,UAAU,EAAE,EACZC,mBAAmB,KAAK,EACxBC,iBAAiB,IAAI,EACrBC,QAAQ,oBAAoB,EA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rG,OAAO4D,UAAU,GAAGlF,OAAOtB,UAAU;QACtD,MAAMkJ,YAAYtG,OAAOuG,WAAW,GAAG3H,MAAMvB,UAAU;QAEvD,qBACE,KAACmJ;YACCX,WAAW3J,OAAOuK,iBAAiB,GAAG,MAAM;YAC5CP,KAAKnG;YACL2G,OAAO;gBACLhI,MAAMA,OAAOtB;gBACbkJ;gBACAD;gBACAM,SAAS;gBACTC,eAAe;gBACfC,UAAU;gBACVjI,KAAKA,MAAMvB;gBACXyJ,YAAY;YACd;sBAEC5D;;IAGP,GAAG;QACD1E;QACAiB;QACAL;QACAlC;QACAwB;QACAE;QACAxB;QACAC;QACA6B;QACAF;QACAqF;KACD;IAED,qBACE,MAAC0C;QAAIlB,WAAU;;0BACb,KAACmB;gBACCnB,WAAU;gBACV7I,UAAUA;gBACVM,QAAQ8G;gBACR5G,UAAUsG;gBACVrG,WAAWkH;gBACXuB,KAAKrG;gBACLoH,MAAM;gBACNP,OAAO;oBAAEQ,UAAU;gBAAO;gBAC1B7I,OAAOC,cAAc,OAAOA,YAAYD,SAAStB;gBAChD,GAAGwB,IAAI;;YAETyG;;;AAGP,EAAC"}
@@ -1,4 +1,4 @@
1
- import Handlebars from 'handlebars/lib/handlebars.js';
1
+ import Handlebars from 'handlebars/dist/handlebars.js';
2
2
  import asyncHelpers from 'handlebars-async-helpers';
3
3
  export const asyncHandlebars = asyncHelpers(Handlebars);
4
4
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/libraries/handlebars/asyncHandlebars.ts"],"sourcesContent":["import Handlebars from 'handlebars/lib/handlebars.js'\nimport asyncHelpers from 'handlebars-async-helpers'\n\nexport const asyncHandlebars = asyncHelpers(Handlebars)\n"],"names":["Handlebars","asyncHelpers","asyncHandlebars"],"mappings":"AAAA,OAAOA,gBAAgB,+BAA8B;AACrD,OAAOC,kBAAkB,2BAA0B;AAEnD,OAAO,MAAMC,kBAAkBD,aAAaD,YAAW"}
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"}