@nodehive/nextjs 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/puck-editor/index.d.ts +1 -1
- package/dist/puck-editor/index.js +1 -1
- package/dist/puck-editor/index.js.map +1 -1
- package/dist/puck-editor/internal/api/client.d.ts +4 -4
- package/dist/puck-editor/internal/api/client.js +14 -6
- package/dist/puck-editor/internal/api/client.js.map +1 -1
- package/dist/puck-editor/internal/api/create-puck-api.js +1 -1
- package/dist/puck-editor/internal/api/create-puck-api.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/template.d.ts +1 -1
- package/dist/puck-editor/internal/api/handlers/template.js +16 -4
- package/dist/puck-editor/internal/api/handlers/template.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/upload.js +6 -3
- package/dist/puck-editor/internal/api/handlers/upload.js.map +1 -1
- package/dist/puck-editor/internal/api/media-upload.d.ts +2 -2
- package/dist/puck-editor/internal/api/media-upload.js +6 -1
- package/dist/puck-editor/internal/api/media-upload.js.map +1 -1
- package/dist/puck-editor/internal/editor/picker-model.d.ts +1 -1
- package/dist/puck-editor/internal/editor/puck-editor.js +148 -134
- package/dist/puck-editor/internal/editor/puck-editor.js.map +1 -1
- package/dist/puck-editor/internal/editor-config.d.ts +5 -2
- package/dist/puck-editor/internal/editor-config.js +32 -26
- package/dist/puck-editor/internal/editor-config.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js +323 -290
- package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js +3 -2
- package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js +3 -4
- package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.d.ts +2 -2
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.js +118 -101
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js +3 -2
- package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js.map +1 -1
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.d.ts +21 -13
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js +9 -35
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/node-selector/node-selector-field.d.ts +12 -0
- package/dist/puck-editor/internal/fields/node-selector/node-selector-field.js +56 -0
- package/dist/puck-editor/internal/fields/node-selector/node-selector-field.js.map +1 -0
- package/dist/puck-editor/internal/locale.d.ts +2 -6
- package/dist/puck-editor/internal/locale.js +6 -8
- package/dist/puck-editor/internal/locale.js.map +1 -1
- package/dist/puck-editor/internal/native-puck-dictionaries.d.ts +2 -0
- package/dist/puck-editor/internal/native-puck-dictionaries.js +160 -0
- package/dist/puck-editor/internal/native-puck-dictionaries.js.map +1 -0
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js +4 -4
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.js +0 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.d.ts +2 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.js +7 -7
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js +3 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.d.ts +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.js +3 -3
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js +32 -37
- package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.d.ts +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js +95 -72
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js.map +1 -1
- package/dist/puck-editor/internal/puck-wrapper.d.ts +1 -1
- package/dist/puck-editor/internal/puck-wrapper.js +89 -83
- package/dist/puck-editor/internal/puck-wrapper.js.map +1 -1
- package/dist/puck-editor/internal/use-puck-overlay.d.ts +3 -2
- package/dist/puck-editor/internal/use-puck-overlay.js +67 -56
- package/dist/puck-editor/internal/use-puck-overlay.js.map +1 -1
- package/dist/puck-editor/puck-theme.css +3 -3
- package/dist/theme.css +2 -2
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-form.js","names":["useState","Button","toast","saveTemplate","localizeApiMessage","usePuckDictionary","AiOptionsFields","jsx","_jsx","jsxs","_jsxs","TemplateForm","content","onTemplateSaved","onCancel","category","dict","t","templates","isPending","setIsPending","errorMessage","setErrorMessage","scopeLabel","scopePage","scopeSection","handleSubmit","e","preventDefault","formElement","currentTarget","formData","FormData","append","JSON","stringify","result","success","saveFailed","error","console","message","saved","reset","onSubmit","className","children","htmlFor","name","type","id","required","savedAsLabel","variant","onClick","cancel","disabled","stopPropagation","saving","save"],"sources":["../../../../../src/puck-editor/internal/plugins/templates-plugin/template-form.tsx"],"sourcesContent":["'use client';\n\nimport { FormEvent, useState } from 'react';\nimport { Button, Content } from '@puckeditor/core';\nimport { toast } from 'sonner';\n\nimport { saveTemplate } from '../../api/client.ts';\nimport { localizeApiMessage } from '../../api/localize-message.ts';\nimport { usePuckDictionary } from '../../i18n.tsx';\nimport { AiOptionsFields } from './ai-options-fields.tsx';\nimport type { TemplateCategory } from './templates.ts';\n\ninterface TemplateFormProps {\n content: Content;\n onCancel?: () => void;\n onTemplateSaved?: () => void;\n category: TemplateCategory;\n}\n\nexport function TemplateForm({\n content,\n onTemplateSaved,\n onCancel,\n category,\n}: TemplateFormProps) {\n const dict = usePuckDictionary();\n const t = dict.templates;\n const [isPending, setIsPending] = useState(false);\n const [errorMessage, setErrorMessage] = useState('');\n\n const scopeLabel = category === 'page' ? t.scopePage : t.scopeSection;\n\n const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n setIsPending(true);\n setErrorMessage('');\n\n try {\n const formElement = e.currentTarget;\n const formData = new FormData(formElement);\n formData.append('content', JSON.stringify(content));\n formData.append('category', category);\n\n const result = await saveTemplate(formData);\n\n if (!result.success) {\n setErrorMessage(localizeApiMessage(dict, result) || t.saveFailed);\n toast.error(t.saveFailed);\n console.error('Failed to save template:', result.message);\n setIsPending(false);\n return;\n }\n\n toast.success(t.saved);\n formElement.reset();\n if (onTemplateSaved) {\n onTemplateSaved();\n }\n } catch (error) {\n setErrorMessage(t.saveFailed);\n toast.error(t.saveFailed);\n console.error('Failed to save template:', error);\n }\n\n setIsPending(false);\n };\n\n return (\n <form onSubmit={handleSubmit} className=\"nh:space-y-4\">\n {errorMessage && (\n <div className=\"nh:rounded nh:border nh:border-red-200 nh:bg-red-100 nh:p-2 nh:text-sm nh:font-medium text-red-700\">\n {errorMessage}\n </div>\n )}\n\n <div>\n <label\n htmlFor=\"name\"\n className=\"nh:block nh:text-sm nh:font-medium nh:text-gray-700\"\n >\n {t.name}\n </label>\n <input\n type=\"text\"\n id=\"name\"\n name=\"name\"\n className=\"nh:mt-1 nh:block nh:w-full nh:max-w-3xl nh:rounded-md nh:border-gray-300 nh:shadow-sm\"\n required\n />\n </div>\n\n <AiOptionsFields />\n\n <p className=\"nh:text-sm nh:text-gray-500\">\n {t.savedAsLabel} <span className=\"nh:font-medium\">{scopeLabel}</span>\n </p>\n\n <div className=\"nh:mt-6 nh:flex nh:justify-between nh:gap-2\">\n <Button type=\"button\" variant=\"secondary\" onClick={onCancel}>\n {t.cancel}\n </Button>\n <Button\n type=\"submit\"\n disabled={isPending}\n onClick={(e) => {\n e.stopPropagation();\n }}\n >\n {isPending ? t.saving : t.save}\n </Button>\n </div>\n </form>\n );\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAoBA,QAAQ,QAAQ,OAAO;AAC3C,SAASC,MAAM,QAAiB,kBAAkB;AAClD,SAASC,KAAK,QAAQ,QAAQ;AAE9B,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,iBAAiB,QAAQ,eAAgB;AAClD,SAASC,eAAe,QAAQ,wBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAU1D,OAAO,SAASC,YAAYA,CAAC;EAC3BC,OAAO;EACPC,eAAe;EACfC,QAAQ;EACRC;AACiB,CAAC,EAAE;EACpB,MAAMC,IAAI,GAAGX,iBAAiB,CAAC,CAAC;EAChC,MAAMY,CAAC,
|
|
1
|
+
{"version":3,"file":"template-form.js","names":["useState","Button","toast","saveTemplate","localizeApiMessage","usePuckContentLocale","usePuckDictionary","AiOptionsFields","jsx","_jsx","jsxs","_jsxs","TemplateForm","content","onTemplateSaved","onCancel","category","dict","contentLocale","t","templates","isPending","setIsPending","errorMessage","setErrorMessage","scopeLabel","scopePage","scopeSection","handleSubmit","e","preventDefault","formElement","currentTarget","formData","FormData","append","JSON","stringify","result","success","saveFailed","error","console","message","saved","reset","onSubmit","className","children","htmlFor","name","type","id","required","savedAsLabel","variant","onClick","cancel","disabled","stopPropagation","saving","save"],"sources":["../../../../../src/puck-editor/internal/plugins/templates-plugin/template-form.tsx"],"sourcesContent":["'use client';\n\nimport { FormEvent, useState } from 'react';\nimport { Button, Content } from '@puckeditor/core';\nimport { toast } from 'sonner';\n\nimport { saveTemplate } from '../../api/client.ts';\nimport { localizeApiMessage } from '../../api/localize-message.ts';\nimport { usePuckContentLocale } from '../../editor-config.tsx';\nimport { usePuckDictionary } from '../../i18n.tsx';\nimport { AiOptionsFields } from './ai-options-fields.tsx';\nimport type { TemplateCategory } from './templates.ts';\n\ninterface TemplateFormProps {\n content: Content;\n onCancel?: () => void;\n onTemplateSaved?: () => void;\n category: TemplateCategory;\n}\n\nexport function TemplateForm({\n content,\n onTemplateSaved,\n onCancel,\n category,\n}: TemplateFormProps) {\n const dict = usePuckDictionary();\n const contentLocale = usePuckContentLocale();\n const t = dict.templates;\n const [isPending, setIsPending] = useState(false);\n const [errorMessage, setErrorMessage] = useState('');\n\n const scopeLabel = category === 'page' ? t.scopePage : t.scopeSection;\n\n const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {\n e.preventDefault();\n setIsPending(true);\n setErrorMessage('');\n\n try {\n const formElement = e.currentTarget;\n const formData = new FormData(formElement);\n formData.append('content', JSON.stringify(content));\n formData.append('category', category);\n\n const result = await saveTemplate(formData, contentLocale);\n\n if (!result.success) {\n setErrorMessage(localizeApiMessage(dict, result) || t.saveFailed);\n toast.error(t.saveFailed);\n console.error('Failed to save template:', result.message);\n setIsPending(false);\n return;\n }\n\n toast.success(t.saved);\n formElement.reset();\n if (onTemplateSaved) {\n onTemplateSaved();\n }\n } catch (error) {\n setErrorMessage(t.saveFailed);\n toast.error(t.saveFailed);\n console.error('Failed to save template:', error);\n }\n\n setIsPending(false);\n };\n\n return (\n <form onSubmit={handleSubmit} className=\"nh:space-y-4\">\n {errorMessage && (\n <div className=\"nh:rounded nh:border nh:border-red-200 nh:bg-red-100 nh:p-2 nh:text-sm nh:font-medium text-red-700\">\n {errorMessage}\n </div>\n )}\n\n <div>\n <label\n htmlFor=\"name\"\n className=\"nh:block nh:text-sm nh:font-medium nh:text-gray-700\"\n >\n {t.name}\n </label>\n <input\n type=\"text\"\n id=\"name\"\n name=\"name\"\n className=\"nh:mt-1 nh:block nh:w-full nh:max-w-3xl nh:rounded-md nh:border-gray-300 nh:shadow-sm\"\n required\n />\n </div>\n\n <AiOptionsFields />\n\n <p className=\"nh:text-sm nh:text-gray-500\">\n {t.savedAsLabel} <span className=\"nh:font-medium\">{scopeLabel}</span>\n </p>\n\n <div className=\"nh:mt-6 nh:flex nh:justify-between nh:gap-2\">\n <Button type=\"button\" variant=\"secondary\" onClick={onCancel}>\n {t.cancel}\n </Button>\n <Button\n type=\"submit\"\n disabled={isPending}\n onClick={(e) => {\n e.stopPropagation();\n }}\n >\n {isPending ? t.saving : t.save}\n </Button>\n </div>\n </form>\n );\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAoBA,QAAQ,QAAQ,OAAO;AAC3C,SAASC,MAAM,QAAiB,kBAAkB;AAClD,SAASC,KAAK,QAAQ,QAAQ;AAE9B,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,oBAAoB,QAAQ,wBAAyB;AAC9D,SAASC,iBAAiB,QAAQ,eAAgB;AAClD,SAASC,eAAe,QAAQ,wBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAU1D,OAAO,SAASC,YAAYA,CAAC;EAC3BC,OAAO;EACPC,eAAe;EACfC,QAAQ;EACRC;AACiB,CAAC,EAAE;EACpB,MAAMC,IAAI,GAAGX,iBAAiB,CAAC,CAAC;EAChC,MAAMY,aAAa,GAAGb,oBAAoB,CAAC,CAAC;EAC5C,MAAMc,CAAC,GAAGF,IAAI,CAACG,SAAS;EACxB,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGtB,QAAQ,CAAC,KAAK,CAAC;EACjD,MAAM,CAACuB,YAAY,EAAEC,eAAe,CAAC,GAAGxB,QAAQ,CAAC,EAAE,CAAC;EAEpD,MAAMyB,UAAU,GAAGT,QAAQ,KAAK,MAAM,GAAGG,CAAC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AA,CACF,CAAC;AAEX","ignoreList":[]}
|
|
@@ -35,7 +35,7 @@ export declare const templateMatchesQuery: (template: Template, locale: string,
|
|
|
35
35
|
export declare const asBuiltinTemplates: (builtins: BuiltinTemplate[]) => Template[];
|
|
36
36
|
export declare const mergeTemplates: (builtins: BuiltinTemplate[], custom: Template[]) => Template[];
|
|
37
37
|
export declare const isBrokenTemplate: (template: Template | BrokenTemplate) => template is BrokenTemplate;
|
|
38
|
-
export declare const fetchTemplates: (config: PuckTemplatesConfig) => Promise<FetchedTemplates>;
|
|
38
|
+
export declare const fetchTemplates: (config: PuckTemplatesConfig, contentLocale: string) => Promise<FetchedTemplates>;
|
|
39
39
|
export declare const expandTemplate: (template: Template, config: Config, outlineLabel?: string, propTransforms?: PuckPropTransforms) => {
|
|
40
40
|
content: ComponentData[];
|
|
41
41
|
skipped: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { walkTree } from '@puckeditor/core';
|
|
2
2
|
import { puckFetch } from "../../api/client.js";
|
|
3
3
|
import { applyPropTransforms } from "../../content-model.js";
|
|
4
|
-
import {
|
|
4
|
+
import { requireContentLocale } from "../../locale.js";
|
|
5
5
|
import { generateId } from "../../utils.js";
|
|
6
6
|
import { ICON_PROP, NAME_PROP } from "../outline-plugin/outline-tree.js";
|
|
7
7
|
const asString = value => typeof value === 'string' && value ? value : undefined;
|
|
@@ -58,8 +58,8 @@ const mapFragment = (raw, config) => {
|
|
|
58
58
|
data
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
|
-
export const fetchTemplates = async config => {
|
|
62
|
-
const language =
|
|
61
|
+
export const fetchTemplates = async (config, contentLocale) => {
|
|
62
|
+
const language = requireContentLocale(contentLocale);
|
|
63
63
|
const {
|
|
64
64
|
data
|
|
65
65
|
} = await puckFetch(`/fragment/${config.fragmentType}?lang=${language}&limit=100`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","names":["walkTree","puckFetch","applyPropTransforms","getPathLocale","generateId","ICON_PROP","NAME_PROP","asString","value","undefined","parseCategory","templateKey","template","source","id","isRootLevelTemplate","category","templateLabel","locale","name","split","en","Object","values","templateMatchesQuery","query","toLowerCase","includes","trim","asBuiltinTemplates","builtins","map","mergeTemplates","custom","isBrokenTemplate","mapFragment","raw","config","broken","title","data","parsed","JSON","parse","String","dataField","Array","isArray","console","warn","categoryField","description","aiDescriptionField","instructions","aiInstructionsField","ai","fetchTemplates","language","window","location","pathname","fragmentType","valid","mapped","push","expandTemplate","outlineLabel","propTransforms","root","props","content","zones","skipped","expanded","filter","component","known","Boolean","components","type","defaultProps","length","icon"],"sources":["../../../../../src/puck-editor/internal/plugins/templates-plugin/templates.ts"],"sourcesContent":["import { walkTree } from '@puckeditor/core';\nimport type { ComponentData, Config } from '@puckeditor/core';\n\nimport { puckFetch } from '../../api/client.ts';\nimport {\n applyPropTransforms,\n type PuckPropTransforms,\n type PuckTemplatesConfig,\n} from '../../content-model.ts';\nimport { getPathLocale } from '../../locale.ts';\nimport { generateId } from '../../utils.ts';\nimport { ICON_PROP, NAME_PROP } from '../outline-plugin/outline-tree.ts';\n\nexport type TemplateCategory = 'page' | 'section' | 'block';\n\nexport type TemplateAi = {\n description?: string;\n instructions?: string;\n};\n\nexport type TemplateEnvelope = {\n id: string;\n name: string | Record<string, string>;\n category: TemplateCategory;\n icon?: string;\n ai?: TemplateAi;\n group?: string;\n data: ComponentData[];\n};\n\nexport type BuiltinTemplate = TemplateEnvelope;\n\nexport type Template = TemplateEnvelope & {\n source: 'builtin' | 'custom';\n};\n\nexport type BrokenTemplate = {\n source: 'custom';\n broken: true;\n id: string;\n name: string;\n};\n\nexport type FetchedTemplates = {\n valid: Template[];\n broken: BrokenTemplate[];\n};\n\ntype RawFragment = { id: string; title: string } & Record<string, unknown>;\n\nconst asString = (value: unknown): string | undefined =>\n typeof value === 'string' && value ? value : undefined;\n\nconst parseCategory = (value: unknown): TemplateCategory | null =>\n value === 'page' || value === 'section' || value === 'block' ? value : null;\n\nexport const templateKey = (template: Template): string =>\n template.source === 'custom' ? template.id : `builtin-${template.id}`;\n\nexport const isRootLevelTemplate = (\n template: Template | BuiltinTemplate\n): boolean => template.category === 'section' || template.category === 'page';\n\nexport const templateLabel = (\n template: Template | BuiltinTemplate,\n locale: string\n): string => {\n const name = template.name;\n if (typeof name === 'string') return name;\n if (!name) return '';\n return (\n name[locale] ??\n name[locale.split('-')[0]] ??\n name.en ??\n Object.values(name)[0] ??\n ''\n );\n};\n\nexport const templateMatchesQuery = (\n template: Template,\n locale: string,\n query: string\n): boolean =>\n templateLabel(template, locale)\n .toLowerCase()\n .includes(query.trim().toLowerCase());\n\nexport const asBuiltinTemplates = (builtins: BuiltinTemplate[]): Template[] =>\n builtins.map((template) => ({ ...template, source: 'builtin' as const }));\n\nexport const mergeTemplates = (\n builtins: BuiltinTemplate[],\n custom: Template[]\n): Template[] => [...asBuiltinTemplates(builtins), ...custom];\n\nexport const isBrokenTemplate = (\n template: Template | BrokenTemplate\n): template is BrokenTemplate => 'broken' in template;\n\nconst mapFragment = (\n raw: RawFragment,\n config: PuckTemplatesConfig\n): Template | BrokenTemplate => {\n const broken = (): BrokenTemplate => ({\n source: 'custom',\n broken: true,\n id: raw.id,\n name: raw.title,\n });\n\n let data: ComponentData[];\n try {\n const parsed = JSON.parse(String(raw[config.dataField] ?? ''));\n data = Array.isArray(parsed) ? parsed : [parsed];\n } catch {\n console.warn(\n `puck-editor: template fragment \"${raw.id}\" has unparseable data`\n );\n return broken();\n }\n\n const category = parseCategory(raw[config.categoryField]);\n if (!category) {\n console.warn(\n `puck-editor: template fragment \"${raw.id}\" has an invalid category`\n );\n return broken();\n }\n\n const description = asString(raw[config.aiDescriptionField]);\n const instructions = asString(raw[config.aiInstructionsField]);\n const ai =\n description || instructions ? { description, instructions } : undefined;\n\n return {\n source: 'custom',\n id: raw.id,\n name: asString(raw.title) ?? raw.id,\n category,\n ...(ai ? { ai } : {}),\n data,\n };\n};\n\nexport const fetchTemplates = async (\n config: PuckTemplatesConfig\n): Promise<FetchedTemplates> => {\n const language = getPathLocale(window.location.pathname);\n const { data } = await puckFetch<{ data: RawFragment[] }>(\n `/fragment/${config.fragmentType}?lang=${language}&limit=100`\n );\n const valid: Template[] = [];\n const broken: BrokenTemplate[] = [];\n for (const raw of data) {\n const mapped = mapFragment(raw, config);\n if (isBrokenTemplate(mapped)) broken.push(mapped);\n else valid.push(mapped);\n }\n return { valid, broken };\n};\n\nexport const expandTemplate = (\n template: Template,\n config: Config,\n outlineLabel?: string,\n propTransforms?: PuckPropTransforms\n): { content: ComponentData[]; skipped: number } => {\n const raw = applyPropTransforms(\n { root: { props: {} }, content: template.data, zones: {} },\n propTransforms,\n config,\n `template \"${template.id}\"`\n ).content as ComponentData[];\n\n let skipped = 0;\n const expanded = walkTree(\n { root: { props: {} }, content: raw, zones: {} },\n config,\n (content) =>\n content\n .filter((component) => {\n const known = Boolean(config.components[component.type]);\n if (!known) skipped++;\n return known;\n })\n .map((component) => ({\n ...component,\n props: {\n ...config.components[component.type]?.defaultProps,\n ...component.props,\n id: generateId(component.type),\n },\n }))\n );\n\n const content = expanded.content;\n if (\n outlineLabel &&\n template.category !== 'page' &&\n template.data.length === 1 &&\n content.length === 1\n ) {\n content[0] = {\n ...content[0],\n props: {\n ...content[0].props,\n [NAME_PROP]: outlineLabel,\n ...(template.icon ? { [ICON_PROP]: template.icon } : {}),\n },\n };\n }\n return { content, skipped };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAG3C,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SACEC,mBAAmB,QAGd,wBAAwB;AAC/B,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,SAAS,EAAEC,SAAS,QAAQ,mCAAmC;AAuCxE,MAAMC,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,GAAGA,KAAK,GAAGC,SAAS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G4D,YAAY;QACzB,IAAItD,QAAQ,CAACsE,IAAI,GAAG;UAAE,CAAC7E,SAAS,GAAGO,QAAQ,CAACsE;QAAK,CAAC,GAAG,CAAC,CAAC;MACzD;IACF,CAAC;EACH;EACA,OAAO;IAAEZ,OAAO;IAAEE;EAAQ,CAAC;AAC7B,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"templates.js","names":["walkTree","puckFetch","applyPropTransforms","requireContentLocale","generateId","ICON_PROP","NAME_PROP","asString","value","undefined","parseCategory","templateKey","template","source","id","isRootLevelTemplate","category","templateLabel","locale","name","split","en","Object","values","templateMatchesQuery","query","toLowerCase","includes","trim","asBuiltinTemplates","builtins","map","mergeTemplates","custom","isBrokenTemplate","mapFragment","raw","config","broken","title","data","parsed","JSON","parse","String","dataField","Array","isArray","console","warn","categoryField","description","aiDescriptionField","instructions","aiInstructionsField","ai","fetchTemplates","contentLocale","language","fragmentType","valid","mapped","push","expandTemplate","outlineLabel","propTransforms","root","props","content","zones","skipped","expanded","filter","component","known","Boolean","components","type","defaultProps","length","icon"],"sources":["../../../../../src/puck-editor/internal/plugins/templates-plugin/templates.ts"],"sourcesContent":["import { walkTree } from '@puckeditor/core';\nimport type { ComponentData, Config } from '@puckeditor/core';\n\nimport { puckFetch } from '../../api/client.ts';\nimport {\n applyPropTransforms,\n type PuckPropTransforms,\n type PuckTemplatesConfig,\n} from '../../content-model.ts';\nimport { requireContentLocale } from '../../locale.ts';\nimport { generateId } from '../../utils.ts';\nimport { ICON_PROP, NAME_PROP } from '../outline-plugin/outline-tree.ts';\n\nexport type TemplateCategory = 'page' | 'section' | 'block';\n\nexport type TemplateAi = {\n description?: string;\n instructions?: string;\n};\n\nexport type TemplateEnvelope = {\n id: string;\n name: string | Record<string, string>;\n category: TemplateCategory;\n icon?: string;\n ai?: TemplateAi;\n group?: string;\n data: ComponentData[];\n};\n\nexport type BuiltinTemplate = TemplateEnvelope;\n\nexport type Template = TemplateEnvelope & {\n source: 'builtin' | 'custom';\n};\n\nexport type BrokenTemplate = {\n source: 'custom';\n broken: true;\n id: string;\n name: string;\n};\n\nexport type FetchedTemplates = {\n valid: Template[];\n broken: BrokenTemplate[];\n};\n\ntype RawFragment = { id: string; title: string } & Record<string, unknown>;\n\nconst asString = (value: unknown): string | undefined =>\n typeof value === 'string' && value ? value : undefined;\n\nconst parseCategory = (value: unknown): TemplateCategory | null =>\n value === 'page' || value === 'section' || value === 'block' ? value : null;\n\nexport const templateKey = (template: Template): string =>\n template.source === 'custom' ? template.id : `builtin-${template.id}`;\n\nexport const isRootLevelTemplate = (\n template: Template | BuiltinTemplate\n): boolean => template.category === 'section' || template.category === 'page';\n\nexport const templateLabel = (\n template: Template | BuiltinTemplate,\n locale: string\n): string => {\n const name = template.name;\n if (typeof name === 'string') return name;\n if (!name) return '';\n return (\n name[locale] ??\n name[locale.split('-')[0]] ??\n name.en ??\n Object.values(name)[0] ??\n ''\n );\n};\n\nexport const templateMatchesQuery = (\n template: Template,\n locale: string,\n query: string\n): boolean =>\n templateLabel(template, locale)\n .toLowerCase()\n .includes(query.trim().toLowerCase());\n\nexport const asBuiltinTemplates = (builtins: BuiltinTemplate[]): Template[] =>\n builtins.map((template) => ({ ...template, source: 'builtin' as const }));\n\nexport const mergeTemplates = (\n builtins: BuiltinTemplate[],\n custom: Template[]\n): Template[] => [...asBuiltinTemplates(builtins), ...custom];\n\nexport const isBrokenTemplate = (\n template: Template | BrokenTemplate\n): template is BrokenTemplate => 'broken' in template;\n\nconst mapFragment = (\n raw: RawFragment,\n config: PuckTemplatesConfig\n): Template | BrokenTemplate => {\n const broken = (): BrokenTemplate => ({\n source: 'custom',\n broken: true,\n id: raw.id,\n name: raw.title,\n });\n\n let data: ComponentData[];\n try {\n const parsed = JSON.parse(String(raw[config.dataField] ?? ''));\n data = Array.isArray(parsed) ? parsed : [parsed];\n } catch {\n console.warn(\n `puck-editor: template fragment \"${raw.id}\" has unparseable data`\n );\n return broken();\n }\n\n const category = parseCategory(raw[config.categoryField]);\n if (!category) {\n console.warn(\n `puck-editor: template fragment \"${raw.id}\" has an invalid category`\n );\n return broken();\n }\n\n const description = asString(raw[config.aiDescriptionField]);\n const instructions = asString(raw[config.aiInstructionsField]);\n const ai =\n description || instructions ? { description, instructions } : undefined;\n\n return {\n source: 'custom',\n id: raw.id,\n name: asString(raw.title) ?? raw.id,\n category,\n ...(ai ? { ai } : {}),\n data,\n };\n};\n\nexport const fetchTemplates = async (\n config: PuckTemplatesConfig,\n contentLocale: string\n): Promise<FetchedTemplates> => {\n const language = requireContentLocale(contentLocale);\n const { data } = await puckFetch<{ data: RawFragment[] }>(\n `/fragment/${config.fragmentType}?lang=${language}&limit=100`\n );\n const valid: Template[] = [];\n const broken: BrokenTemplate[] = [];\n for (const raw of data) {\n const mapped = mapFragment(raw, config);\n if (isBrokenTemplate(mapped)) broken.push(mapped);\n else valid.push(mapped);\n }\n return { valid, broken };\n};\n\nexport const expandTemplate = (\n template: Template,\n config: Config,\n outlineLabel?: string,\n propTransforms?: PuckPropTransforms\n): { content: ComponentData[]; skipped: number } => {\n const raw = applyPropTransforms(\n { root: { props: {} }, content: template.data, zones: {} },\n propTransforms,\n config,\n `template \"${template.id}\"`\n ).content as ComponentData[];\n\n let skipped = 0;\n const expanded = walkTree(\n { root: { props: {} }, content: raw, zones: {} },\n config,\n (content) =>\n content\n .filter((component) => {\n const known = Boolean(config.components[component.type]);\n if (!known) skipped++;\n return known;\n })\n .map((component) => ({\n ...component,\n props: {\n ...config.components[component.type]?.defaultProps,\n ...component.props,\n id: generateId(component.type),\n },\n }))\n );\n\n const content = expanded.content;\n if (\n outlineLabel &&\n template.category !== 'page' &&\n template.data.length === 1 &&\n content.length === 1\n ) {\n content[0] = {\n ...content[0],\n props: {\n ...content[0].props,\n [NAME_PROP]: outlineLabel,\n ...(template.icon ? { [ICON_PROP]: template.icon } : {}),\n },\n };\n }\n return { content, skipped };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAG3C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CAACI,QAAQ,KAAK,MAAM,IAC5BJ,QAAQ,CAAC4B,IAAI,CAACuC,MAAM,KAAK,CAAC,IAC1BX,OAAO,CAACW,MAAM,KAAK,CAAC,EACpB;IACAX,OAAO,CAAC,CAAC,CAAC,GAAG;MACX,GAAGA,OAAO,CAAC,CAAC,CAAC;MACbD,KAAK,EAAE;QACL,GAAGC,OAAO,CAAC,CAAC,CAAC,CAACD,KAAK;QACnB,CAAC7D,SAAS,GAAG0D,YAAY;QACzB,IAAIpD,QAAQ,CAACoE,IAAI,GAAG;UAAE,CAAC3E,SAAS,GAAGO,QAAQ,CAACoE;QAAK,CAAC,GAAG,CAAC,CAAC;MACzD;IACF,CAAC;EACH;EACA,OAAO;IAAEZ,OAAO;IAAEE;EAAQ,CAAC;AAC7B,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
4
4
|
import { useRef } from 'react';
|
|
5
5
|
import { useQuery } from '@tanstack/react-query';
|
|
6
6
|
import { toast } from 'sonner';
|
|
7
|
-
import { useBuiltinTemplates, usePuckContentModel, usePuckPropTransforms } from "../../editor-config.js";
|
|
7
|
+
import { useBuiltinTemplates, usePuckContentLocale, usePuckContentModel, usePuckPropTransforms } from "../../editor-config.js";
|
|
8
8
|
import { TEMPLATES_QUERY_KEY } from "../../editor-query-client.js";
|
|
9
9
|
import { usePuckDictionary, usePuckLocale } from "../../i18n.js";
|
|
10
10
|
import { appendComponents } from "../../utils.js";
|
|
@@ -17,30 +17,25 @@ export function useTemplateDnd(config) {
|
|
|
17
17
|
const t = usePuckDictionary().templates;
|
|
18
18
|
const locale = usePuckLocale();
|
|
19
19
|
const templatesConfig = usePuckContentModel().templates;
|
|
20
|
+
const contentLocale = usePuckContentLocale();
|
|
20
21
|
const builtins = useBuiltinTemplates();
|
|
21
22
|
const propTransforms = usePuckPropTransforms();
|
|
22
23
|
let t0;
|
|
23
|
-
if ($[0]
|
|
24
|
-
t0 =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
t0 = $[0];
|
|
28
|
-
}
|
|
29
|
-
let t1;
|
|
30
|
-
if ($[1] !== templatesConfig) {
|
|
31
|
-
t1 = {
|
|
32
|
-
queryKey: t0,
|
|
33
|
-
queryFn: () => fetchTemplates(templatesConfig)
|
|
24
|
+
if ($[0] !== contentLocale || $[1] !== templatesConfig) {
|
|
25
|
+
t0 = {
|
|
26
|
+
queryKey: [...TEMPLATES_QUERY_KEY, contentLocale, templatesConfig],
|
|
27
|
+
queryFn: () => fetchTemplates(templatesConfig, contentLocale)
|
|
34
28
|
};
|
|
29
|
+
$[0] = contentLocale;
|
|
35
30
|
$[1] = templatesConfig;
|
|
36
|
-
$[2] =
|
|
31
|
+
$[2] = t0;
|
|
37
32
|
} else {
|
|
38
|
-
|
|
33
|
+
t0 = $[2];
|
|
39
34
|
}
|
|
40
35
|
const {
|
|
41
36
|
data
|
|
42
|
-
} = useQuery(
|
|
43
|
-
let
|
|
37
|
+
} = useQuery(t0);
|
|
38
|
+
let t1;
|
|
44
39
|
let templates;
|
|
45
40
|
if ($[3] !== builtins || $[4] !== config || $[5] !== data?.valid || $[6] !== locale) {
|
|
46
41
|
templates = mergeTemplates(builtins, data?.valid ?? []);
|
|
@@ -51,32 +46,32 @@ export function useTemplateDnd(config) {
|
|
|
51
46
|
...buildTemplateVehicles(templates, locale)
|
|
52
47
|
}
|
|
53
48
|
};
|
|
54
|
-
|
|
49
|
+
t1 = applyVehicleSlotConstraints(withVehicles, rootLevelVehicleTypes(templates));
|
|
55
50
|
$[3] = builtins;
|
|
56
51
|
$[4] = config;
|
|
57
52
|
$[5] = data?.valid;
|
|
58
53
|
$[6] = locale;
|
|
59
|
-
$[7] =
|
|
54
|
+
$[7] = t1;
|
|
60
55
|
$[8] = templates;
|
|
61
56
|
} else {
|
|
62
|
-
|
|
57
|
+
t1 = $[7];
|
|
63
58
|
templates = $[8];
|
|
64
59
|
}
|
|
65
|
-
const configWithTemplates =
|
|
60
|
+
const configWithTemplates = t1;
|
|
66
61
|
const dispatchRef = useRef(null);
|
|
67
|
-
let
|
|
62
|
+
let t2;
|
|
68
63
|
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
69
|
-
|
|
64
|
+
t2 = dispatch => {
|
|
70
65
|
dispatchRef.current = dispatch;
|
|
71
66
|
};
|
|
72
|
-
$[9] =
|
|
67
|
+
$[9] = t2;
|
|
73
68
|
} else {
|
|
74
|
-
|
|
69
|
+
t2 = $[9];
|
|
75
70
|
}
|
|
76
|
-
const captureDispatch =
|
|
77
|
-
let
|
|
71
|
+
const captureDispatch = t2;
|
|
72
|
+
let t3;
|
|
78
73
|
if ($[10] !== config || $[11] !== locale || $[12] !== propTransforms || $[13] !== t || $[14] !== templates) {
|
|
79
|
-
|
|
74
|
+
t3 = action => {
|
|
80
75
|
if (action.type !== "insert") {
|
|
81
76
|
return;
|
|
82
77
|
}
|
|
@@ -112,8 +107,8 @@ export function useTemplateDnd(config) {
|
|
|
112
107
|
;
|
|
113
108
|
try {
|
|
114
109
|
expanded = expandTemplate(template, config, templateLabel(template, locale), propTransforms);
|
|
115
|
-
} catch (
|
|
116
|
-
const error =
|
|
110
|
+
} catch (t4) {
|
|
111
|
+
const error = t4;
|
|
117
112
|
console.error("Failed to expand template:", error);
|
|
118
113
|
removeVehicle();
|
|
119
114
|
toast.error(t.insertFailed);
|
|
@@ -131,24 +126,24 @@ export function useTemplateDnd(config) {
|
|
|
131
126
|
$[12] = propTransforms;
|
|
132
127
|
$[13] = t;
|
|
133
128
|
$[14] = templates;
|
|
134
|
-
$[15] =
|
|
129
|
+
$[15] = t3;
|
|
135
130
|
} else {
|
|
136
|
-
|
|
131
|
+
t3 = $[15];
|
|
137
132
|
}
|
|
138
|
-
const onAction =
|
|
139
|
-
let
|
|
133
|
+
const onAction = t3;
|
|
134
|
+
let t4;
|
|
140
135
|
if ($[16] !== configWithTemplates || $[17] !== onAction) {
|
|
141
|
-
|
|
136
|
+
t4 = {
|
|
142
137
|
configWithTemplates,
|
|
143
138
|
onAction,
|
|
144
139
|
captureDispatch
|
|
145
140
|
};
|
|
146
141
|
$[16] = configWithTemplates;
|
|
147
142
|
$[17] = onAction;
|
|
148
|
-
$[18] =
|
|
143
|
+
$[18] = t4;
|
|
149
144
|
} else {
|
|
150
|
-
|
|
145
|
+
t4 = $[18];
|
|
151
146
|
}
|
|
152
|
-
return
|
|
147
|
+
return t4;
|
|
153
148
|
}
|
|
154
149
|
//# sourceMappingURL=use-template-dnd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-template-dnd.js","names":["c","_c","useRef","useQuery","toast","useBuiltinTemplates","usePuckContentModel","usePuckPropTransforms","TEMPLATES_QUERY_KEY","usePuckDictionary","usePuckLocale","appendComponents","ROOT_ZONE","applyVehicleSlotConstraints","buildTemplateVehicles","rootLevelVehicleTypes","TEMPLATE_PREFIX","expandTemplate","fetchTemplates","isRootLevelTemplate","mergeTemplates","templateKey","templateLabel","useTemplateDnd","config","$","t","templates","locale","templatesConfig","builtins","propTransforms","t0","
|
|
1
|
+
{"version":3,"file":"use-template-dnd.js","names":["c","_c","useRef","useQuery","toast","useBuiltinTemplates","usePuckContentLocale","usePuckContentModel","usePuckPropTransforms","TEMPLATES_QUERY_KEY","usePuckDictionary","usePuckLocale","appendComponents","ROOT_ZONE","applyVehicleSlotConstraints","buildTemplateVehicles","rootLevelVehicleTypes","TEMPLATE_PREFIX","expandTemplate","fetchTemplates","isRootLevelTemplate","mergeTemplates","templateKey","templateLabel","useTemplateDnd","config","$","t","templates","locale","templatesConfig","contentLocale","builtins","propTransforms","t0","queryKey","queryFn","data","t1","valid","withVehicles","components","configWithTemplates","dispatchRef","t2","Symbol","for","dispatch","current","captureDispatch","t3","action","type","componentType","startsWith","dispatch_0","zone","destinationZone","index","destinationIndex","key","slice","length","setTimeout","removeVehicle","template","find","tpl","error","unavailable","isRootZone","wrongZone","expanded","t4","console","insertFailed","content","skipped","warning","partiallyInserted","replace","String","onAction"],"sources":["../../../../../src/puck-editor/internal/plugins/templates-plugin/use-template-dnd.ts"],"sourcesContent":["'use client';\n\nimport { useRef } from 'react';\nimport { Config, PuckAction } from '@puckeditor/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { toast } from 'sonner';\n\nimport {\n useBuiltinTemplates,\n usePuckContentLocale,\n usePuckContentModel,\n usePuckPropTransforms,\n} from '../../editor-config.tsx';\nimport { TEMPLATES_QUERY_KEY } from '../../editor-query-client.ts';\nimport { usePuckDictionary, usePuckLocale } from '../../i18n.tsx';\nimport { appendComponents } from '../../utils.ts';\nimport { ROOT_ZONE } from '../outline-plugin/outline-tree.ts';\nimport { applyVehicleSlotConstraints } from './apply-vehicle-slot-constraints.ts';\nimport {\n buildTemplateVehicles,\n rootLevelVehicleTypes,\n TEMPLATE_PREFIX,\n} from './template-vehicles.ts';\nimport {\n expandTemplate,\n fetchTemplates,\n isRootLevelTemplate,\n mergeTemplates,\n templateKey,\n templateLabel,\n} from './templates.ts';\n\ntype Dispatch = (action: PuckAction) => void;\n\nexport function useTemplateDnd(config: Config) {\n const t = usePuckDictionary().templates;\n const locale = usePuckLocale();\n const templatesConfig = usePuckContentModel().templates;\n const contentLocale = usePuckContentLocale();\n const builtins = useBuiltinTemplates();\n const propTransforms = usePuckPropTransforms();\n const { data } = useQuery({\n queryKey: [...TEMPLATES_QUERY_KEY, contentLocale, templatesConfig],\n queryFn: () => fetchTemplates(templatesConfig, contentLocale),\n });\n const templates = mergeTemplates(builtins, data?.valid ?? []);\n\n const withVehicles = {\n ...config,\n components: {\n ...config.components,\n ...buildTemplateVehicles(templates, locale),\n },\n };\n const configWithTemplates = applyVehicleSlotConstraints(\n withVehicles,\n rootLevelVehicleTypes(templates)\n );\n\n const dispatchRef = useRef<Dispatch | null>(null);\n const captureDispatch = (dispatch: Dispatch) => {\n dispatchRef.current = dispatch;\n };\n\n const onAction = (action: PuckAction) => {\n if (action.type !== 'insert') return;\n if (!action.componentType.startsWith(TEMPLATE_PREFIX)) return;\n\n const dispatch = dispatchRef.current;\n if (!dispatch) return;\n\n const zone = action.destinationZone;\n const index = action.destinationIndex;\n const key = action.componentType.slice(TEMPLATE_PREFIX.length);\n\n // onAction runs inside Puck's dispatch cycle; re-entrant dispatch is\n // swallowed, so defer the swap to the next tick.\n setTimeout(() => {\n const removeVehicle = () => dispatch({ type: 'remove', zone, index });\n const template = templates.find((tpl) => templateKey(tpl) === key);\n\n if (!template) {\n removeVehicle();\n toast.error(t.unavailable);\n return;\n }\n\n const isRootZone = zone === ROOT_ZONE;\n if (isRootLevelTemplate(template) !== isRootZone) {\n removeVehicle();\n toast.error(t.wrongZone);\n return;\n }\n\n let expanded;\n try {\n expanded = expandTemplate(\n template,\n config,\n templateLabel(template, locale),\n propTransforms\n );\n } catch (error) {\n console.error('Failed to expand template:', error);\n removeVehicle();\n toast.error(t.insertFailed);\n return;\n }\n\n removeVehicle();\n appendComponents(dispatch, zone, index, expanded.content);\n\n if (expanded.skipped > 0) {\n toast.warning(\n t.partiallyInserted\n .replace('{skipped}', String(expanded.skipped))\n .replace(\n '{total}',\n String(expanded.content.length + expanded.skipped)\n )\n );\n }\n }, 0);\n };\n\n return { configWithTemplates, onAction, captureDispatch };\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,CAAA,IAAAC,EAAA;AAEb,SAASC,MAAM,QAAQ,OAAO;AAE9B,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,KAAK,QAAQ,QAAQ;AAE9B,SACEC,mBAAmB,EACnBC,oBAAoB,EACpBC,mBAAmB,EACnBC,qBAAqB,QAChB,wBAAyB;AAChC,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,eAAgB;AACjE,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,SAAS,QAAQ,mCAAmC;AAC7D,SAASC,2BAA2B,QAAQ,qCAAqC;AACjF,SACEC,qBAAqB,EACrBC,qBAAqB,EACrB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,QAAQ,CAAAI,OAAQ,CAAC;QAEzD,IAAIJ,QAAQ,CAAAK,OAAQ,GAAG,CAAC;UACtBzE,KAAK,CAAA0E,OAAQ,CACXnD,CAAC,CAAAoD,iBAAkB,CAAAC,OACT,CAAC,WAAW,EAAEC,MAAM,CAACT,QAAQ,CAAAK,OAAQ,CAAC,CAAC,CAAAG,OACvC,CACN,SAAS,EACTC,MAAM,CAACT,QAAQ,CAAAI,OAAQ,CAAAd,MAAO,GAAGU,QAAQ,CAAAK,OAAQ,CACnD,CACJ,CAAC;QAAA;MACF,CACF,EAAE,CAAC,CAAC;IAAA,CACN;IAAAnD,CAAA,OAAAD,MAAA;IAAAC,CAAA,OAAAG,MAAA;IAAAH,CAAA,OAAAO,cAAA;IAAAP,CAAA,OAAAC,CAAA;IAAAD,CAAA,OAAAE,SAAA;IAAAF,CAAA,OAAAwB,EAAA;EAAA;IAAAA,EAAA,GAAAxB,CAAA;EAAA;EA3DD,MAAAwD,QAAA,GAAiBhC,EA2DhB;EAAC,IAAAuB,EAAA;EAAA,IAAA/C,CAAA,SAAAgB,mBAAA,IAAAhB,CAAA,SAAAwD,QAAA;IAEKT,EAAA;MAAA/B,mBAAA;MAAAwC,QAAA;MAAAjC;IAAiD,CAAC;IAAAvB,CAAA,OAAAgB,mBAAA;IAAAhB,CAAA,OAAAwD,QAAA;IAAAxD,CAAA,OAAA+C,EAAA;EAAA;IAAAA,EAAA,GAAA/C,CAAA;EAAA;EAAA,OAAlD+C,EAAkD;AAAA","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ export declare function useTemplates(): {
|
|
|
9
9
|
brokenTemplates: BrokenTemplate[];
|
|
10
10
|
isLoading: boolean;
|
|
11
11
|
isError: boolean;
|
|
12
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
12
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("./templates.js").FetchedTemplates, Error>>;
|
|
13
13
|
invalidate: () => Promise<void>;
|
|
14
14
|
update: (template: RemovableTemplate, fields: TemplateUpdate) => Promise<import("../../api/client.js").PuckApiResult | {
|
|
15
15
|
success: boolean;
|
|
@@ -3,73 +3,94 @@
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
5
5
|
import { deleteTemplate, updateTemplate } from "../../api/client.js";
|
|
6
|
-
import { useBuiltinTemplates, usePuckContentModel } from "../../editor-config.js";
|
|
6
|
+
import { useBuiltinTemplates, usePuckContentLocale, usePuckContentModel } from "../../editor-config.js";
|
|
7
7
|
import { TEMPLATES_QUERY_KEY } from "../../editor-query-client.js";
|
|
8
8
|
import { fetchTemplates, mergeTemplates } from "./templates.js";
|
|
9
|
-
const QUERY_KEY = [...TEMPLATES_QUERY_KEY];
|
|
10
9
|
export function useTemplates() {
|
|
11
|
-
const $ = _c(
|
|
10
|
+
const $ = _c(36);
|
|
12
11
|
const queryClient = useQueryClient();
|
|
12
|
+
const contentLocale = usePuckContentLocale();
|
|
13
13
|
const templatesConfig = usePuckContentModel().templates;
|
|
14
14
|
const builtins = useBuiltinTemplates();
|
|
15
15
|
let t0;
|
|
16
|
-
if ($[0] !== templatesConfig) {
|
|
17
|
-
t0 =
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
if ($[0] !== contentLocale || $[1] !== templatesConfig) {
|
|
17
|
+
t0 = [...TEMPLATES_QUERY_KEY, contentLocale, templatesConfig];
|
|
18
|
+
$[0] = contentLocale;
|
|
19
|
+
$[1] = templatesConfig;
|
|
20
|
+
$[2] = t0;
|
|
21
|
+
} else {
|
|
22
|
+
t0 = $[2];
|
|
23
|
+
}
|
|
24
|
+
const queryKey = t0;
|
|
25
|
+
let t1;
|
|
26
|
+
if ($[3] !== contentLocale || $[4] !== templatesConfig) {
|
|
27
|
+
t1 = () => fetchTemplates(templatesConfig, contentLocale);
|
|
28
|
+
$[3] = contentLocale;
|
|
29
|
+
$[4] = templatesConfig;
|
|
30
|
+
$[5] = t1;
|
|
31
|
+
} else {
|
|
32
|
+
t1 = $[5];
|
|
33
|
+
}
|
|
34
|
+
let t2;
|
|
35
|
+
if ($[6] !== queryKey || $[7] !== t1) {
|
|
36
|
+
t2 = {
|
|
37
|
+
queryKey,
|
|
38
|
+
queryFn: t1
|
|
20
39
|
};
|
|
21
|
-
$[
|
|
22
|
-
$[
|
|
40
|
+
$[6] = queryKey;
|
|
41
|
+
$[7] = t1;
|
|
42
|
+
$[8] = t2;
|
|
23
43
|
} else {
|
|
24
|
-
|
|
44
|
+
t2 = $[8];
|
|
25
45
|
}
|
|
26
46
|
const {
|
|
27
47
|
data,
|
|
28
48
|
isLoading,
|
|
29
49
|
isError,
|
|
30
50
|
refetch
|
|
31
|
-
} = useQuery(
|
|
32
|
-
let
|
|
33
|
-
if ($[
|
|
34
|
-
|
|
35
|
-
$[
|
|
36
|
-
$[
|
|
51
|
+
} = useQuery(t2);
|
|
52
|
+
let t3;
|
|
53
|
+
if ($[9] !== data?.valid) {
|
|
54
|
+
t3 = data?.valid ?? [];
|
|
55
|
+
$[9] = data?.valid;
|
|
56
|
+
$[10] = t3;
|
|
37
57
|
} else {
|
|
38
|
-
|
|
58
|
+
t3 = $[10];
|
|
39
59
|
}
|
|
40
|
-
let
|
|
41
|
-
if ($[
|
|
42
|
-
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
60
|
+
let t4;
|
|
61
|
+
if ($[11] !== builtins || $[12] !== t3) {
|
|
62
|
+
t4 = mergeTemplates(builtins, t3);
|
|
63
|
+
$[11] = builtins;
|
|
64
|
+
$[12] = t3;
|
|
65
|
+
$[13] = t4;
|
|
46
66
|
} else {
|
|
47
|
-
|
|
67
|
+
t4 = $[13];
|
|
48
68
|
}
|
|
49
|
-
const templates =
|
|
50
|
-
let
|
|
51
|
-
if ($[
|
|
52
|
-
|
|
53
|
-
$[
|
|
54
|
-
$[
|
|
69
|
+
const templates = t4;
|
|
70
|
+
let t5;
|
|
71
|
+
if ($[14] !== data?.broken) {
|
|
72
|
+
t5 = data?.broken ?? [];
|
|
73
|
+
$[14] = data?.broken;
|
|
74
|
+
$[15] = t5;
|
|
55
75
|
} else {
|
|
56
|
-
|
|
76
|
+
t5 = $[15];
|
|
57
77
|
}
|
|
58
|
-
const brokenTemplates =
|
|
59
|
-
let
|
|
60
|
-
if ($[
|
|
61
|
-
|
|
62
|
-
queryKey
|
|
78
|
+
const brokenTemplates = t5;
|
|
79
|
+
let t6;
|
|
80
|
+
if ($[16] !== queryClient || $[17] !== queryKey) {
|
|
81
|
+
t6 = () => queryClient.invalidateQueries({
|
|
82
|
+
queryKey
|
|
63
83
|
});
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
84
|
+
$[16] = queryClient;
|
|
85
|
+
$[17] = queryKey;
|
|
86
|
+
$[18] = t6;
|
|
66
87
|
} else {
|
|
67
|
-
|
|
88
|
+
t6 = $[18];
|
|
68
89
|
}
|
|
69
|
-
const invalidate =
|
|
70
|
-
let
|
|
71
|
-
if ($[
|
|
72
|
-
|
|
90
|
+
const invalidate = t6;
|
|
91
|
+
let t7;
|
|
92
|
+
if ($[19] !== contentLocale || $[20] !== invalidate || $[21] !== templatesConfig) {
|
|
93
|
+
t7 = async (template, fields) => {
|
|
73
94
|
if (template.source !== "custom" || !template.id) {
|
|
74
95
|
return {
|
|
75
96
|
success: false,
|
|
@@ -77,22 +98,23 @@ export function useTemplates() {
|
|
|
77
98
|
code: "builtinNotEditable"
|
|
78
99
|
};
|
|
79
100
|
}
|
|
80
|
-
const result = await updateTemplate(templatesConfig.fragmentType, template.id, fields);
|
|
101
|
+
const result = await updateTemplate(templatesConfig.fragmentType, template.id, fields, contentLocale);
|
|
81
102
|
if (result.success) {
|
|
82
103
|
invalidate();
|
|
83
104
|
}
|
|
84
105
|
return result;
|
|
85
106
|
};
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
107
|
+
$[19] = contentLocale;
|
|
108
|
+
$[20] = invalidate;
|
|
109
|
+
$[21] = templatesConfig;
|
|
110
|
+
$[22] = t7;
|
|
89
111
|
} else {
|
|
90
|
-
|
|
112
|
+
t7 = $[22];
|
|
91
113
|
}
|
|
92
|
-
const update =
|
|
93
|
-
let
|
|
94
|
-
if ($[
|
|
95
|
-
|
|
114
|
+
const update = t7;
|
|
115
|
+
let t8;
|
|
116
|
+
if ($[23] !== contentLocale || $[24] !== invalidate || $[25] !== templatesConfig) {
|
|
117
|
+
t8 = async template_0 => {
|
|
96
118
|
if (template_0.source !== "custom" || !template_0.id) {
|
|
97
119
|
return {
|
|
98
120
|
success: false,
|
|
@@ -100,22 +122,23 @@ export function useTemplates() {
|
|
|
100
122
|
code: "builtinNotDeletable"
|
|
101
123
|
};
|
|
102
124
|
}
|
|
103
|
-
const result_0 = await deleteTemplate(templatesConfig.fragmentType, template_0.id);
|
|
125
|
+
const result_0 = await deleteTemplate(templatesConfig.fragmentType, template_0.id, contentLocale);
|
|
104
126
|
if (result_0.success) {
|
|
105
127
|
invalidate();
|
|
106
128
|
}
|
|
107
129
|
return result_0;
|
|
108
130
|
};
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
131
|
+
$[23] = contentLocale;
|
|
132
|
+
$[24] = invalidate;
|
|
133
|
+
$[25] = templatesConfig;
|
|
134
|
+
$[26] = t8;
|
|
112
135
|
} else {
|
|
113
|
-
|
|
136
|
+
t8 = $[26];
|
|
114
137
|
}
|
|
115
|
-
const remove =
|
|
116
|
-
let
|
|
117
|
-
if ($[
|
|
118
|
-
|
|
138
|
+
const remove = t8;
|
|
139
|
+
let t9;
|
|
140
|
+
if ($[27] !== brokenTemplates || $[28] !== invalidate || $[29] !== isError || $[30] !== isLoading || $[31] !== refetch || $[32] !== remove || $[33] !== templates || $[34] !== update) {
|
|
141
|
+
t9 = {
|
|
119
142
|
templates,
|
|
120
143
|
brokenTemplates,
|
|
121
144
|
isLoading,
|
|
@@ -125,18 +148,18 @@ export function useTemplates() {
|
|
|
125
148
|
update,
|
|
126
149
|
remove
|
|
127
150
|
};
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
133
|
-
$[
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
151
|
+
$[27] = brokenTemplates;
|
|
152
|
+
$[28] = invalidate;
|
|
153
|
+
$[29] = isError;
|
|
154
|
+
$[30] = isLoading;
|
|
155
|
+
$[31] = refetch;
|
|
156
|
+
$[32] = remove;
|
|
157
|
+
$[33] = templates;
|
|
158
|
+
$[34] = update;
|
|
159
|
+
$[35] = t9;
|
|
137
160
|
} else {
|
|
138
|
-
|
|
161
|
+
t9 = $[35];
|
|
139
162
|
}
|
|
140
|
-
return
|
|
163
|
+
return t9;
|
|
141
164
|
}
|
|
142
165
|
//# sourceMappingURL=use-templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-templates.js","names":["c","_c","useQuery","useQueryClient","deleteTemplate","updateTemplate","useBuiltinTemplates","usePuckContentModel","TEMPLATES_QUERY_KEY","fetchTemplates","mergeTemplates","
|
|
1
|
+
{"version":3,"file":"use-templates.js","names":["c","_c","useQuery","useQueryClient","deleteTemplate","updateTemplate","useBuiltinTemplates","usePuckContentLocale","usePuckContentModel","TEMPLATES_QUERY_KEY","fetchTemplates","mergeTemplates","useTemplates","$","queryClient","contentLocale","templatesConfig","templates","builtins","t0","queryKey","t1","t2","queryFn","data","isLoading","isError","refetch","t3","valid","t4","t5","broken","brokenTemplates","t6","invalidateQueries","invalidate","t7","template","fields","source","id","success","message","code","result","fragmentType","update","t8","template_0","result_0","remove","t9"],"sources":["../../../../../src/puck-editor/internal/plugins/templates-plugin/use-templates.ts"],"sourcesContent":["'use client';\n\nimport { useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport {\n deleteTemplate,\n updateTemplate,\n type TemplateUpdate,\n} from '../../api/client.ts';\nimport {\n useBuiltinTemplates,\n usePuckContentLocale,\n usePuckContentModel,\n} from '../../editor-config.tsx';\nimport { TEMPLATES_QUERY_KEY } from '../../editor-query-client.ts';\nimport {\n BrokenTemplate,\n fetchTemplates,\n mergeTemplates,\n Template,\n} from './templates.ts';\n\ntype RemovableTemplate = { source: 'builtin' | 'custom'; id?: string };\n\nexport function useTemplates() {\n const queryClient = useQueryClient();\n const contentLocale = usePuckContentLocale();\n const templatesConfig = usePuckContentModel().templates;\n const builtins = useBuiltinTemplates();\n const queryKey = [...TEMPLATES_QUERY_KEY, contentLocale, templatesConfig];\n const { data, isLoading, isError, refetch } = useQuery({\n queryKey,\n queryFn: () => fetchTemplates(templatesConfig, contentLocale),\n });\n\n const templates = mergeTemplates(builtins, data?.valid ?? []);\n const brokenTemplates: BrokenTemplate[] = data?.broken ?? [];\n\n const invalidate = () => queryClient.invalidateQueries({ queryKey });\n\n const update = async (\n template: RemovableTemplate,\n fields: TemplateUpdate\n ) => {\n if (template.source !== 'custom' || !template.id) {\n return {\n success: false,\n message: 'Built-in templates cannot be edited',\n code: 'builtinNotEditable',\n };\n }\n const result = await updateTemplate(\n templatesConfig.fragmentType,\n template.id,\n fields,\n contentLocale\n );\n if (result.success) invalidate();\n return result;\n };\n\n const remove = async (template: RemovableTemplate) => {\n if (template.source !== 'custom' || !template.id) {\n return {\n success: false,\n message: 'Built-in templates cannot be deleted',\n code: 'builtinNotDeletable',\n };\n }\n const result = await deleteTemplate(\n templatesConfig.fragmentType,\n template.id,\n contentLocale\n );\n if (result.success) invalidate();\n return result;\n };\n\n return {\n templates,\n brokenTemplates,\n isLoading,\n isError,\n refetch,\n invalidate,\n update,\n remove,\n };\n}\n\nexport type { Template };\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,CAAA,IAAAC,EAAA;AAEb,SAASC,QAAQ,EAAEC,cAAc,QAAQ,uBAAuB;AAEhE,SACEC,cAAc,EACdC,cAAc,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AC;MAAA;MAAC,OAC1BS,QAAM;IAAA,CACd;IAAAhC,CAAA,OAAAE,aAAA;IAAAF,CAAA,OAAAuB,UAAA;IAAAvB,CAAA,OAAAG,eAAA;IAAAH,CAAA,OAAAmC,EAAA;EAAA;IAAAA,EAAA,GAAAnC,CAAA;EAAA;EAfD,MAAAsC,MAAA,GAAeH,EAed;EAAC,IAAAI,EAAA;EAAA,IAAAvC,CAAA,SAAAoB,eAAA,IAAApB,CAAA,SAAAuB,UAAA,IAAAvB,CAAA,SAAAa,OAAA,IAAAb,CAAA,SAAAY,SAAA,IAAAZ,CAAA,SAAAc,OAAA,IAAAd,CAAA,SAAAsC,MAAA,IAAAtC,CAAA,SAAAI,SAAA,IAAAJ,CAAA,SAAAkC,MAAA;IAEKK,EAAA;MAAAnC,SAAA;MAAAgB,eAAA;MAAAR,SAAA;MAAAC,OAAA;MAAAC,OAAA;MAAAS,UAAA;MAAAW,MAAA;MAAAI;IASP,CAAC;IAAAtC,CAAA,OAAAoB,eAAA;IAAApB,CAAA,OAAAuB,UAAA;IAAAvB,CAAA,OAAAa,OAAA;IAAAb,CAAA,OAAAY,SAAA;IAAAZ,CAAA,OAAAc,OAAA;IAAAd,CAAA,OAAAsC,MAAA;IAAAtC,CAAA,OAAAI,SAAA;IAAAJ,CAAA,OAAAkC,MAAA;IAAAlC,CAAA,OAAAuC,EAAA;EAAA;IAAAA,EAAA,GAAAvC,CAAA;EAAA;EAAA,OATMuC,EASN;AAAA","ignoreList":[]}
|
|
@@ -34,5 +34,5 @@ type PuckWrapperProps = {
|
|
|
34
34
|
* Requires the `sonner` (save/upload/template toasts) and `motion` (overlay
|
|
35
35
|
* animation) peers, alongside `@puckeditor/core`; see the module README.
|
|
36
36
|
*/
|
|
37
|
-
export default function PuckWrapper({ node, config, isLoggedIn, editorLocale, dictionaryOverrides, plugins, overrides, onAction, validate, puckProps, drupalBaseUrl, contentModel, builtinTemplates, propTransforms, api, children, }: PuckWrapperProps): import("react").JSX.Element;
|
|
37
|
+
export default function PuckWrapper({ node, config, isLoggedIn, editorLocale, dictionaryOverrides, plugins, overrides, onAction, validate, puckProps, drupalBaseUrl, contentLocale, contentModel, builtinTemplates, propTransforms, api, children, }: PuckWrapperProps): import("react").JSX.Element;
|
|
38
38
|
export {};
|