@delmaredigital/payload-puck 0.1.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/LICENSE +73 -0
- package/README.md +1580 -0
- package/dist/AccordionClient.d.mts +24 -0
- package/dist/AccordionClient.d.ts +24 -0
- package/dist/AccordionClient.js +786 -0
- package/dist/AccordionClient.js.map +1 -0
- package/dist/AccordionClient.mjs +784 -0
- package/dist/AccordionClient.mjs.map +1 -0
- package/dist/AnimatedWrapper.d.mts +30 -0
- package/dist/AnimatedWrapper.d.ts +30 -0
- package/dist/AnimatedWrapper.js +379 -0
- package/dist/AnimatedWrapper.js.map +1 -0
- package/dist/AnimatedWrapper.mjs +377 -0
- package/dist/AnimatedWrapper.mjs.map +1 -0
- package/dist/admin/client.d.mts +108 -0
- package/dist/admin/client.d.ts +108 -0
- package/dist/admin/client.js +177 -0
- package/dist/admin/client.js.map +1 -0
- package/dist/admin/client.mjs +173 -0
- package/dist/admin/client.mjs.map +1 -0
- package/dist/admin/index.d.mts +157 -0
- package/dist/admin/index.d.ts +157 -0
- package/dist/admin/index.js +31 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/index.mjs +29 -0
- package/dist/admin/index.mjs.map +1 -0
- package/dist/api/index.d.mts +460 -0
- package/dist/api/index.d.ts +460 -0
- package/dist/api/index.js +588 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +578 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/components/index.css +339 -0
- package/dist/components/index.css.map +1 -0
- package/dist/components/index.d.mts +222 -0
- package/dist/components/index.d.ts +222 -0
- package/dist/components/index.js +9177 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +9130 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/config.editor.css +339 -0
- package/dist/config/config.editor.css.map +1 -0
- package/dist/config/config.editor.d.mts +153 -0
- package/dist/config/config.editor.d.ts +153 -0
- package/dist/config/config.editor.js +9400 -0
- package/dist/config/config.editor.js.map +1 -0
- package/dist/config/config.editor.mjs +9368 -0
- package/dist/config/config.editor.mjs.map +1 -0
- package/dist/config/index.d.mts +68 -0
- package/dist/config/index.d.ts +68 -0
- package/dist/config/index.js +2017 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.mjs +1991 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/editor/index.d.mts +784 -0
- package/dist/editor/index.d.ts +784 -0
- package/dist/editor/index.js +4517 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/index.mjs +4483 -0
- package/dist/editor/index.mjs.map +1 -0
- package/dist/fields/index.css +339 -0
- package/dist/fields/index.css.map +1 -0
- package/dist/fields/index.d.mts +600 -0
- package/dist/fields/index.d.ts +600 -0
- package/dist/fields/index.js +7739 -0
- package/dist/fields/index.js.map +1 -0
- package/dist/fields/index.mjs +7590 -0
- package/dist/fields/index.mjs.map +1 -0
- package/dist/index-CQu6SzDg.d.mts +327 -0
- package/dist/index-CoUQnyC3.d.ts +327 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +569 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +555 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layouts/index.d.mts +96 -0
- package/dist/layouts/index.d.ts +96 -0
- package/dist/layouts/index.js +394 -0
- package/dist/layouts/index.js.map +1 -0
- package/dist/layouts/index.mjs +378 -0
- package/dist/layouts/index.mjs.map +1 -0
- package/dist/plugin/index.d.mts +289 -0
- package/dist/plugin/index.d.ts +289 -0
- package/dist/plugin/index.js +569 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/index.mjs +555 -0
- package/dist/plugin/index.mjs.map +1 -0
- package/dist/render/index.d.mts +109 -0
- package/dist/render/index.d.ts +109 -0
- package/dist/render/index.js +2146 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/index.mjs +2123 -0
- package/dist/render/index.mjs.map +1 -0
- package/dist/shared-DMAF1AcH.d.mts +545 -0
- package/dist/shared-DMAF1AcH.d.ts +545 -0
- package/dist/theme/index.d.mts +155 -0
- package/dist/theme/index.d.ts +155 -0
- package/dist/theme/index.js +201 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/index.mjs +186 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/types-D7D3rZ1J.d.mts +116 -0
- package/dist/types-D7D3rZ1J.d.ts +116 -0
- package/dist/types-_6MvjyKv.d.mts +104 -0
- package/dist/types-_6MvjyKv.d.ts +104 -0
- package/dist/utils/index.d.mts +267 -0
- package/dist/utils/index.d.ts +267 -0
- package/dist/utils/index.js +426 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +412 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils-DaRs9t0J.d.mts +85 -0
- package/dist/utils-gAvt0Vhw.d.ts +85 -0
- package/examples/README.md +240 -0
- package/examples/api/puck/pages/[id]/route.ts +64 -0
- package/examples/api/puck/pages/[id]/versions/route.ts +47 -0
- package/examples/api/puck/pages/route.ts +45 -0
- package/examples/app/(frontend)/page.tsx +94 -0
- package/examples/app/[...slug]/page.tsx +101 -0
- package/examples/app/pages/[id]/edit/page.tsx +148 -0
- package/examples/components/CustomBanner.tsx +368 -0
- package/examples/config/custom-config.ts +223 -0
- package/examples/config/payload.config.example.ts +64 -0
- package/examples/lib/puck-layouts.ts +258 -0
- package/examples/lib/puck-theme.ts +94 -0
- package/examples/styles/puck-theme.css +171 -0
- package/package.json +157 -0
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Data, Config, Plugin, Overrides } from '@measured/puck';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import { CSSProperties, ReactNode, ComponentType } from 'react';
|
|
5
|
+
import { T as ThemeConfig } from '../types-_6MvjyKv.mjs';
|
|
6
|
+
export { default as headingAnalyzer } from '@measured/puck-plugin-heading-analyzer';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Layout System Types
|
|
10
|
+
*
|
|
11
|
+
* Defines the structure for page layouts that affect how content is rendered.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A layout option shown in the Puck editor's layout selector
|
|
16
|
+
*/
|
|
17
|
+
interface LayoutOption {
|
|
18
|
+
/** Unique identifier for the layout */
|
|
19
|
+
value: string;
|
|
20
|
+
/** Display name in the editor */
|
|
21
|
+
label: string;
|
|
22
|
+
/** Optional description shown in the editor */
|
|
23
|
+
description?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* CSS class configuration for a layout
|
|
27
|
+
*/
|
|
28
|
+
interface LayoutClasses {
|
|
29
|
+
/** Classes applied to the outermost wrapper */
|
|
30
|
+
wrapper?: string;
|
|
31
|
+
/** Classes applied to the main content container */
|
|
32
|
+
container?: string;
|
|
33
|
+
/** Classes applied to the content area */
|
|
34
|
+
content?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Style configuration for a layout
|
|
38
|
+
*/
|
|
39
|
+
interface LayoutStyles {
|
|
40
|
+
/** Styles applied to the outermost wrapper */
|
|
41
|
+
wrapper?: CSSProperties;
|
|
42
|
+
/** Styles applied to the main content container */
|
|
43
|
+
container?: CSSProperties;
|
|
44
|
+
/** Styles applied to the content area */
|
|
45
|
+
content?: CSSProperties;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Complete layout definition
|
|
49
|
+
*/
|
|
50
|
+
interface LayoutDefinition extends LayoutOption {
|
|
51
|
+
/** CSS classes to apply */
|
|
52
|
+
classes?: LayoutClasses;
|
|
53
|
+
/** Inline styles to apply */
|
|
54
|
+
styles?: LayoutStyles;
|
|
55
|
+
/** Custom wrapper component (overrides default rendering) */
|
|
56
|
+
wrapper?: React.ComponentType<{
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
}>;
|
|
59
|
+
/** Max width constraint (e.g., '1200px', '100%') */
|
|
60
|
+
maxWidth?: string;
|
|
61
|
+
/** Whether the layout uses full viewport width */
|
|
62
|
+
fullWidth?: boolean;
|
|
63
|
+
/** Additional data attributes to add */
|
|
64
|
+
dataAttributes?: Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Header component to render above the page content.
|
|
67
|
+
* Shown in both the editor preview and the rendered page.
|
|
68
|
+
*/
|
|
69
|
+
header?: ComponentType;
|
|
70
|
+
/**
|
|
71
|
+
* Footer component to render below the page content.
|
|
72
|
+
* Shown in both the editor preview and the rendered page.
|
|
73
|
+
*/
|
|
74
|
+
footer?: ComponentType;
|
|
75
|
+
/**
|
|
76
|
+
* Background color/gradient for the editor preview.
|
|
77
|
+
* Applied to the iframe body in the Puck editor.
|
|
78
|
+
* @default '#ffffff'
|
|
79
|
+
*/
|
|
80
|
+
editorBackground?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Whether this layout uses dark mode styling in the editor preview.
|
|
83
|
+
* Controls text color and theme class on the iframe.
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
editorDarkMode?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Height of a sticky/fixed header in pixels.
|
|
89
|
+
* Used to add padding-top to the content area in the editor preview
|
|
90
|
+
* so content doesn't render behind the header.
|
|
91
|
+
* @example 64 // for a 64px tall sticky header
|
|
92
|
+
*/
|
|
93
|
+
stickyHeaderHeight?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Whether to push the footer to the bottom of the viewport.
|
|
96
|
+
* Uses flexbox to ensure the footer stays at the bottom even when
|
|
97
|
+
* page content is minimal. Set to `false` to allow footer to flow
|
|
98
|
+
* naturally after content.
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
stickyFooter?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Layout style configuration for theme-aware preview
|
|
106
|
+
* @deprecated Use LayoutDefinition with editorBackground and editorDarkMode instead
|
|
107
|
+
*/
|
|
108
|
+
interface LayoutStyle {
|
|
109
|
+
/**
|
|
110
|
+
* CSS background value (color, gradient, etc.)
|
|
111
|
+
*/
|
|
112
|
+
background: string;
|
|
113
|
+
/**
|
|
114
|
+
* Whether this layout uses dark mode styling
|
|
115
|
+
*/
|
|
116
|
+
isDark: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Header component to render above the page content in the editor preview
|
|
119
|
+
*/
|
|
120
|
+
header?: ComponentType;
|
|
121
|
+
/**
|
|
122
|
+
* Footer component to render below the page content in the editor preview
|
|
123
|
+
*/
|
|
124
|
+
footer?: ComponentType;
|
|
125
|
+
}
|
|
126
|
+
interface IframeWrapperProps {
|
|
127
|
+
children: ReactNode;
|
|
128
|
+
/**
|
|
129
|
+
* The iframe document to apply styles to
|
|
130
|
+
*/
|
|
131
|
+
document?: Document;
|
|
132
|
+
/**
|
|
133
|
+
* Layout definitions - the primary way to configure layouts.
|
|
134
|
+
* Reads header, footer, editorBackground, and editorDarkMode from each layout.
|
|
135
|
+
*/
|
|
136
|
+
layouts?: LayoutDefinition[];
|
|
137
|
+
/**
|
|
138
|
+
* Layout style configurations keyed by layout value
|
|
139
|
+
* @deprecated Use `layouts` prop instead
|
|
140
|
+
*/
|
|
141
|
+
layoutStyles?: Record<string, LayoutStyle>;
|
|
142
|
+
/**
|
|
143
|
+
* Key in root.props to read layout value from
|
|
144
|
+
* @default 'pageLayout'
|
|
145
|
+
*/
|
|
146
|
+
layoutKey?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Default layout to use if none specified
|
|
149
|
+
* @default 'default'
|
|
150
|
+
*/
|
|
151
|
+
defaultLayout?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Theme-aware iframe wrapper component
|
|
155
|
+
*
|
|
156
|
+
* Uses usePuck to read the pageLayout from root.props and applies
|
|
157
|
+
* appropriate background and theme class to the preview iframe.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```tsx
|
|
161
|
+
* // Using layouts (recommended)
|
|
162
|
+
* const overrides = {
|
|
163
|
+
* iframe: ({ children, document }) => (
|
|
164
|
+
* <IframeWrapper
|
|
165
|
+
* document={document}
|
|
166
|
+
* layouts={[
|
|
167
|
+
* { value: 'default', label: 'Default', header: Header, footer: Footer },
|
|
168
|
+
* { value: 'landing', label: 'Landing', editorBackground: '#f8fafc' },
|
|
169
|
+
* ]}
|
|
170
|
+
* >
|
|
171
|
+
* {children}
|
|
172
|
+
* </IframeWrapper>
|
|
173
|
+
* ),
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare const IframeWrapper: React$1.NamedExoticComponent<IframeWrapperProps>;
|
|
178
|
+
|
|
179
|
+
interface PuckEditorProps {
|
|
180
|
+
/**
|
|
181
|
+
* Page ID for save operations
|
|
182
|
+
*/
|
|
183
|
+
pageId: string;
|
|
184
|
+
/**
|
|
185
|
+
* Initial Puck data to load
|
|
186
|
+
*/
|
|
187
|
+
initialData: Data;
|
|
188
|
+
/**
|
|
189
|
+
* Puck configuration with components and settings
|
|
190
|
+
*/
|
|
191
|
+
config: Config;
|
|
192
|
+
/**
|
|
193
|
+
* Page title for display
|
|
194
|
+
*/
|
|
195
|
+
pageTitle: string;
|
|
196
|
+
/**
|
|
197
|
+
* Page slug for preview URL
|
|
198
|
+
*/
|
|
199
|
+
pageSlug: string;
|
|
200
|
+
/**
|
|
201
|
+
* API endpoint for save operations
|
|
202
|
+
* @default '/api/puck/pages'
|
|
203
|
+
*/
|
|
204
|
+
apiEndpoint?: string;
|
|
205
|
+
/**
|
|
206
|
+
* URL to navigate to when back button is clicked
|
|
207
|
+
*/
|
|
208
|
+
backUrl?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Preview URL or function to generate preview URL from slug
|
|
211
|
+
*/
|
|
212
|
+
previewUrl?: string | ((slug: string) => string);
|
|
213
|
+
/**
|
|
214
|
+
* Whether to enable viewport switching
|
|
215
|
+
* @default true
|
|
216
|
+
*/
|
|
217
|
+
enableViewports?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Additional Puck plugins to use.
|
|
220
|
+
* The headingAnalyzer plugin is included by default.
|
|
221
|
+
* Set to `false` to disable all default plugins.
|
|
222
|
+
*/
|
|
223
|
+
plugins?: Plugin[] | false;
|
|
224
|
+
/**
|
|
225
|
+
* Layout definitions for the editor preview.
|
|
226
|
+
* The editor reads header, footer, editorBackground, and editorDarkMode
|
|
227
|
+
* from the layout definition matching the selected pageLayout.
|
|
228
|
+
*/
|
|
229
|
+
layouts?: LayoutDefinition[];
|
|
230
|
+
/**
|
|
231
|
+
* Layout style configurations for theme-aware preview
|
|
232
|
+
* @deprecated Use `layouts` prop instead. layoutStyles will be removed in a future version.
|
|
233
|
+
*/
|
|
234
|
+
layoutStyles?: Record<string, LayoutStyle>;
|
|
235
|
+
/**
|
|
236
|
+
* Key in root.props to read layout value from
|
|
237
|
+
* @default 'pageLayout'
|
|
238
|
+
*/
|
|
239
|
+
layoutKey?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Custom actions to render at the start of the header
|
|
242
|
+
*/
|
|
243
|
+
headerActionsStart?: ReactNode;
|
|
244
|
+
/**
|
|
245
|
+
* Custom actions to render at the end of the header
|
|
246
|
+
*/
|
|
247
|
+
headerActionsEnd?: ReactNode;
|
|
248
|
+
/**
|
|
249
|
+
* Puck overrides to merge with defaults
|
|
250
|
+
*/
|
|
251
|
+
overrides?: Partial<Overrides>;
|
|
252
|
+
/**
|
|
253
|
+
* Callback on successful save
|
|
254
|
+
*/
|
|
255
|
+
onSaveSuccess?: (data: Data) => void;
|
|
256
|
+
/**
|
|
257
|
+
* Callback on save error
|
|
258
|
+
*/
|
|
259
|
+
onSaveError?: (error: Error) => void;
|
|
260
|
+
/**
|
|
261
|
+
* Callback when data changes
|
|
262
|
+
*/
|
|
263
|
+
onChange?: (data: Data) => void;
|
|
264
|
+
/**
|
|
265
|
+
* Initial document status from Payload (_status field)
|
|
266
|
+
* Automatically populated when using PuckEditorView
|
|
267
|
+
*/
|
|
268
|
+
initialStatus?: 'draft' | 'published';
|
|
269
|
+
/**
|
|
270
|
+
* Theme configuration for customizing component styles
|
|
271
|
+
* When provided, components will use themed styles
|
|
272
|
+
*/
|
|
273
|
+
theme?: ThemeConfig;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Puck Editor wrapper with dynamic import
|
|
277
|
+
*
|
|
278
|
+
* This component wraps PuckEditorCore with next/dynamic to prevent
|
|
279
|
+
* hydration mismatches caused by Puck's random ID generation for
|
|
280
|
+
* drag-and-drop functionality.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```tsx
|
|
284
|
+
* 'use client'
|
|
285
|
+
*
|
|
286
|
+
* import { PuckEditor } from '@delmaredigital/payload-puck/editor'
|
|
287
|
+
* import { editorConfig } from '@delmaredigital/payload-puck/config/editor'
|
|
288
|
+
*
|
|
289
|
+
* export function PageEditor({ page }) {
|
|
290
|
+
* return (
|
|
291
|
+
* <PuckEditor
|
|
292
|
+
* pageId={page.id}
|
|
293
|
+
* initialData={page.puckData}
|
|
294
|
+
* config={editorConfig}
|
|
295
|
+
* pageTitle={page.title}
|
|
296
|
+
* pageSlug={page.slug}
|
|
297
|
+
* backUrl="/admin/pages"
|
|
298
|
+
* />
|
|
299
|
+
* )
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
declare function PuckEditor({ pageId, initialData, config, pageTitle, pageSlug, apiEndpoint, backUrl, previewUrl, enableViewports, plugins, layouts, layoutStyles, layoutKey, headerActionsStart, headerActionsEnd, overrides, onSaveSuccess, onSaveError, onChange, initialStatus, theme, }: PuckEditorProps): react_jsx_runtime.JSX.Element;
|
|
304
|
+
|
|
305
|
+
interface PuckEditorCoreProps {
|
|
306
|
+
/**
|
|
307
|
+
* Page ID for save operations
|
|
308
|
+
*/
|
|
309
|
+
pageId: string;
|
|
310
|
+
/**
|
|
311
|
+
* Initial Puck data to load
|
|
312
|
+
*/
|
|
313
|
+
initialData: Data;
|
|
314
|
+
/**
|
|
315
|
+
* Puck configuration with components and settings
|
|
316
|
+
*/
|
|
317
|
+
config: Config;
|
|
318
|
+
/**
|
|
319
|
+
* Page title for display
|
|
320
|
+
*/
|
|
321
|
+
pageTitle: string;
|
|
322
|
+
/**
|
|
323
|
+
* Page slug for preview URL
|
|
324
|
+
*/
|
|
325
|
+
pageSlug: string;
|
|
326
|
+
/**
|
|
327
|
+
* API endpoint for save operations
|
|
328
|
+
* @default '/api/puck/pages'
|
|
329
|
+
*/
|
|
330
|
+
apiEndpoint?: string;
|
|
331
|
+
/**
|
|
332
|
+
* URL to navigate to when back button is clicked
|
|
333
|
+
*/
|
|
334
|
+
backUrl?: string;
|
|
335
|
+
/**
|
|
336
|
+
* Preview URL or function to generate preview URL from slug
|
|
337
|
+
*/
|
|
338
|
+
previewUrl?: string | ((slug: string) => string);
|
|
339
|
+
/**
|
|
340
|
+
* Whether to enable viewport switching
|
|
341
|
+
* @default true
|
|
342
|
+
*/
|
|
343
|
+
enableViewports?: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Additional Puck plugins to use.
|
|
346
|
+
* The headingAnalyzer plugin is included by default.
|
|
347
|
+
* Set to `false` to disable all default plugins.
|
|
348
|
+
*/
|
|
349
|
+
plugins?: Plugin[] | false;
|
|
350
|
+
/**
|
|
351
|
+
* Layout definitions for the editor preview.
|
|
352
|
+
* The editor reads header, footer, editorBackground, and editorDarkMode
|
|
353
|
+
* from the layout definition matching the selected pageLayout.
|
|
354
|
+
*/
|
|
355
|
+
layouts?: LayoutDefinition[];
|
|
356
|
+
/**
|
|
357
|
+
* Layout style configurations for theme-aware preview
|
|
358
|
+
* @deprecated Use `layouts` prop instead. layoutStyles will be removed in a future version.
|
|
359
|
+
*/
|
|
360
|
+
layoutStyles?: Record<string, LayoutStyle>;
|
|
361
|
+
/**
|
|
362
|
+
* Key in root.props to read layout value from
|
|
363
|
+
* @default 'pageLayout'
|
|
364
|
+
*/
|
|
365
|
+
layoutKey?: string;
|
|
366
|
+
/**
|
|
367
|
+
* Custom actions to render at the start of the header
|
|
368
|
+
*/
|
|
369
|
+
headerActionsStart?: ReactNode;
|
|
370
|
+
/**
|
|
371
|
+
* Custom actions to render at the end of the header
|
|
372
|
+
*/
|
|
373
|
+
headerActionsEnd?: ReactNode;
|
|
374
|
+
/**
|
|
375
|
+
* Puck overrides to merge with defaults
|
|
376
|
+
*/
|
|
377
|
+
overrides?: Partial<Overrides>;
|
|
378
|
+
/**
|
|
379
|
+
* Callback on successful save
|
|
380
|
+
*/
|
|
381
|
+
onSaveSuccess?: (data: Data) => void;
|
|
382
|
+
/**
|
|
383
|
+
* Callback on save error
|
|
384
|
+
*/
|
|
385
|
+
onSaveError?: (error: Error) => void;
|
|
386
|
+
/**
|
|
387
|
+
* Callback when data changes
|
|
388
|
+
*/
|
|
389
|
+
onChange?: (data: Data) => void;
|
|
390
|
+
/**
|
|
391
|
+
* Initial document status from Payload (_status field)
|
|
392
|
+
* Used to show draft/published badge in the header
|
|
393
|
+
*/
|
|
394
|
+
initialStatus?: 'draft' | 'published';
|
|
395
|
+
/**
|
|
396
|
+
* Theme configuration for customizing component styles
|
|
397
|
+
* When provided, components will use themed styles
|
|
398
|
+
*/
|
|
399
|
+
theme?: ThemeConfig;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Full-featured Puck editor implementation
|
|
403
|
+
*
|
|
404
|
+
* Provides a complete editing experience with:
|
|
405
|
+
* - Save draft and publish functionality
|
|
406
|
+
* - Unsaved changes tracking with beforeunload warning
|
|
407
|
+
* - Interactive/Edit mode toggle
|
|
408
|
+
* - Theme-aware preview backgrounds
|
|
409
|
+
* - Responsive viewport switching
|
|
410
|
+
* - Custom header actions
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```tsx
|
|
414
|
+
* 'use client'
|
|
415
|
+
*
|
|
416
|
+
* import { PuckEditorCore } from '@delmaredigital/payload-puck/editor'
|
|
417
|
+
* import { editorConfig } from '@delmaredigital/payload-puck/config/editor'
|
|
418
|
+
*
|
|
419
|
+
* export function PageEditor({ page }) {
|
|
420
|
+
* return (
|
|
421
|
+
* <PuckEditorCore
|
|
422
|
+
* pageId={page.id}
|
|
423
|
+
* initialData={page.puckData}
|
|
424
|
+
* config={editorConfig}
|
|
425
|
+
* pageTitle={page.title}
|
|
426
|
+
* pageSlug={page.slug}
|
|
427
|
+
* backUrl="/admin/pages"
|
|
428
|
+
* layoutStyles={{
|
|
429
|
+
* default: { background: '#fff', isDark: false },
|
|
430
|
+
* dark: { background: '#1a1a1a', isDark: true },
|
|
431
|
+
* }}
|
|
432
|
+
* />
|
|
433
|
+
* )
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
declare function PuckEditorCore({ pageId, initialData, config, pageTitle, pageSlug, apiEndpoint, backUrl, previewUrl, enableViewports, plugins, layouts, layoutStyles, layoutKey, headerActionsStart, headerActionsEnd, overrides: customOverrides, onSaveSuccess, onSaveError, onChange: onChangeProp, initialStatus, theme, }: PuckEditorCoreProps): react_jsx_runtime.JSX.Element;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Props for the PuckEditorView component
|
|
441
|
+
*/
|
|
442
|
+
interface PuckEditorViewProps {
|
|
443
|
+
/**
|
|
444
|
+
* Puck configuration with components and settings
|
|
445
|
+
*/
|
|
446
|
+
config: Config;
|
|
447
|
+
/**
|
|
448
|
+
* Collection slug for API endpoints
|
|
449
|
+
* @default 'pages'
|
|
450
|
+
*/
|
|
451
|
+
collectionSlug?: string;
|
|
452
|
+
/**
|
|
453
|
+
* Base API path for Puck operations
|
|
454
|
+
* @default '/api/puck'
|
|
455
|
+
*/
|
|
456
|
+
apiBasePath?: string;
|
|
457
|
+
/**
|
|
458
|
+
* URL to navigate to when back button is clicked
|
|
459
|
+
* Falls back to /admin/collections/{collectionSlug}
|
|
460
|
+
*/
|
|
461
|
+
backUrl?: string;
|
|
462
|
+
/**
|
|
463
|
+
* Preview URL or function to generate preview URL from slug
|
|
464
|
+
*/
|
|
465
|
+
previewUrl?: string | ((slug: string) => string);
|
|
466
|
+
/**
|
|
467
|
+
* Layout styles for theme-aware preview
|
|
468
|
+
*/
|
|
469
|
+
layoutStyles?: Record<string, {
|
|
470
|
+
background: string;
|
|
471
|
+
isDark: boolean;
|
|
472
|
+
}>;
|
|
473
|
+
/**
|
|
474
|
+
* Key in root.props to read layout value from
|
|
475
|
+
* @default 'pageLayout'
|
|
476
|
+
*/
|
|
477
|
+
layoutKey?: string;
|
|
478
|
+
/**
|
|
479
|
+
* Additional Puck plugins to use.
|
|
480
|
+
* The headingAnalyzer plugin is included by default.
|
|
481
|
+
* Set to `false` to disable all default plugins.
|
|
482
|
+
*/
|
|
483
|
+
plugins?: Plugin[] | false;
|
|
484
|
+
/**
|
|
485
|
+
* Callback on successful save
|
|
486
|
+
*/
|
|
487
|
+
onSaveSuccess?: (data: Data) => void;
|
|
488
|
+
/**
|
|
489
|
+
* Callback on save error
|
|
490
|
+
*/
|
|
491
|
+
onSaveError?: (error: Error) => void;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Ready-to-use Puck editor page component
|
|
495
|
+
*
|
|
496
|
+
* Use this in your own editor page route (e.g., /pages/[id]/edit).
|
|
497
|
+
* It auto-fetches page data from the API and renders the PuckEditor.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```tsx
|
|
501
|
+
* // src/app/pages/[id]/edit/page.tsx
|
|
502
|
+
* 'use client'
|
|
503
|
+
*
|
|
504
|
+
* import { PuckEditorView } from '@delmaredigital/payload-puck/editor'
|
|
505
|
+
* import { editorConfig } from '@/puck/config'
|
|
506
|
+
*
|
|
507
|
+
* export default function PageEditor() {
|
|
508
|
+
* return (
|
|
509
|
+
* <PuckEditorView
|
|
510
|
+
* config={editorConfig}
|
|
511
|
+
* collectionSlug="pages"
|
|
512
|
+
* apiBasePath="/api/puck"
|
|
513
|
+
* backUrl="/admin/collections/pages"
|
|
514
|
+
* previewUrl={(slug) => `/${slug}`}
|
|
515
|
+
* />
|
|
516
|
+
* )
|
|
517
|
+
* }
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
declare function PuckEditorView({ config, collectionSlug, apiBasePath, backUrl, previewUrl, layoutStyles, layoutKey, plugins, onSaveSuccess, onSaveError, }: PuckEditorViewProps): react_jsx_runtime.JSX.Element;
|
|
521
|
+
|
|
522
|
+
interface HeaderActionsProps {
|
|
523
|
+
/**
|
|
524
|
+
* Default Puck header actions (undo/redo, publish button)
|
|
525
|
+
*/
|
|
526
|
+
children: ReactNode;
|
|
527
|
+
/**
|
|
528
|
+
* Handler for back button click
|
|
529
|
+
*/
|
|
530
|
+
onBack: () => void;
|
|
531
|
+
/**
|
|
532
|
+
* Handler for preview button click
|
|
533
|
+
*/
|
|
534
|
+
onPreview: () => void;
|
|
535
|
+
/**
|
|
536
|
+
* Handler for save button click
|
|
537
|
+
*/
|
|
538
|
+
onSave: (data: Data) => void;
|
|
539
|
+
/**
|
|
540
|
+
* Handler for publish button click (optional, uses default Puck publish if not provided)
|
|
541
|
+
*/
|
|
542
|
+
onPublish?: (data: Data) => void;
|
|
543
|
+
/**
|
|
544
|
+
* Whether a save operation is in progress
|
|
545
|
+
*/
|
|
546
|
+
isSaving: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Whether there are unsaved changes
|
|
549
|
+
*/
|
|
550
|
+
hasUnsavedChanges: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Last saved timestamp
|
|
553
|
+
*/
|
|
554
|
+
lastSaved: Date | null;
|
|
555
|
+
/**
|
|
556
|
+
* Document status from Payload (_status field)
|
|
557
|
+
* Shows visual indicator for draft vs published
|
|
558
|
+
*/
|
|
559
|
+
documentStatus?: 'draft' | 'published';
|
|
560
|
+
/**
|
|
561
|
+
* Whether the document has ever been published (initially or during this session)
|
|
562
|
+
* Used to show "Unpublished Changes" vs "Draft" badge
|
|
563
|
+
*/
|
|
564
|
+
wasPublished?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Custom actions to render at the start of the header
|
|
567
|
+
*/
|
|
568
|
+
actionsStart?: ReactNode;
|
|
569
|
+
/**
|
|
570
|
+
* Custom actions to render at the end of the header (before publish)
|
|
571
|
+
*/
|
|
572
|
+
actionsEnd?: ReactNode;
|
|
573
|
+
/**
|
|
574
|
+
* Whether to show the save draft button
|
|
575
|
+
* @default true
|
|
576
|
+
*/
|
|
577
|
+
showSaveDraft?: boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Whether to show the view page button
|
|
580
|
+
* @default true
|
|
581
|
+
*/
|
|
582
|
+
showViewPage?: boolean;
|
|
583
|
+
/**
|
|
584
|
+
* Whether to show the interactive mode toggle
|
|
585
|
+
* @default false
|
|
586
|
+
* @deprecated Use the Preview button instead
|
|
587
|
+
*/
|
|
588
|
+
showInteractiveToggle?: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Whether to show the preview button
|
|
591
|
+
* @default true
|
|
592
|
+
*/
|
|
593
|
+
showPreviewButton?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Handler for opening the preview modal
|
|
596
|
+
*/
|
|
597
|
+
onOpenPreview?: () => void;
|
|
598
|
+
/**
|
|
599
|
+
* Whether to show the version history button
|
|
600
|
+
* @default true
|
|
601
|
+
*/
|
|
602
|
+
showVersionHistory?: boolean;
|
|
603
|
+
/**
|
|
604
|
+
* Page ID for version history (required if showVersionHistory is true)
|
|
605
|
+
*/
|
|
606
|
+
pageId?: string;
|
|
607
|
+
/**
|
|
608
|
+
* API endpoint base path for version history
|
|
609
|
+
* @default '/api/puck/pages'
|
|
610
|
+
*/
|
|
611
|
+
apiEndpoint?: string;
|
|
612
|
+
/**
|
|
613
|
+
* Error message to display (e.g., validation errors)
|
|
614
|
+
*/
|
|
615
|
+
saveError?: string | null;
|
|
616
|
+
/**
|
|
617
|
+
* Handler to dismiss the error message
|
|
618
|
+
*/
|
|
619
|
+
onDismissError?: () => void;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Custom header actions component for the Puck editor
|
|
623
|
+
*
|
|
624
|
+
* Provides standard actions: Back, Edit/Interactive toggle, View Page, Save Draft
|
|
625
|
+
* Also displays save status and last saved time.
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```tsx
|
|
629
|
+
* const overrides = {
|
|
630
|
+
* headerActions: ({ children }) => (
|
|
631
|
+
* <HeaderActions
|
|
632
|
+
* onBack={handleBack}
|
|
633
|
+
* onPreview={handlePreview}
|
|
634
|
+
* onSave={handleSave}
|
|
635
|
+
* isSaving={isSaving}
|
|
636
|
+
* hasUnsavedChanges={hasUnsavedChanges}
|
|
637
|
+
* lastSaved={lastSaved}
|
|
638
|
+
* >
|
|
639
|
+
* {children}
|
|
640
|
+
* </HeaderActions>
|
|
641
|
+
* ),
|
|
642
|
+
* }
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
declare const HeaderActions: React$1.NamedExoticComponent<HeaderActionsProps>;
|
|
646
|
+
|
|
647
|
+
interface LoadingStateProps {
|
|
648
|
+
/**
|
|
649
|
+
* Loading message to display
|
|
650
|
+
* @default 'Loading editor...'
|
|
651
|
+
*/
|
|
652
|
+
message?: string;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Loading indicator shown while the Puck editor is being loaded
|
|
656
|
+
*
|
|
657
|
+
* Used as the fallback for dynamic import with ssr: false
|
|
658
|
+
*/
|
|
659
|
+
declare function LoadingState({ message }: LoadingStateProps): react_jsx_runtime.JSX.Element;
|
|
660
|
+
|
|
661
|
+
interface PreviewModalProps {
|
|
662
|
+
/**
|
|
663
|
+
* Whether the modal is open
|
|
664
|
+
*/
|
|
665
|
+
isOpen: boolean;
|
|
666
|
+
/**
|
|
667
|
+
* Handler for closing the modal
|
|
668
|
+
*/
|
|
669
|
+
onClose: () => void;
|
|
670
|
+
/**
|
|
671
|
+
* Puck data to render in the preview
|
|
672
|
+
*/
|
|
673
|
+
data: Data | null;
|
|
674
|
+
/**
|
|
675
|
+
* Page title for the modal header
|
|
676
|
+
*/
|
|
677
|
+
pageTitle?: string;
|
|
678
|
+
/**
|
|
679
|
+
* Handler for opening the page in a new tab
|
|
680
|
+
*/
|
|
681
|
+
onOpenInNewTab?: () => void;
|
|
682
|
+
/**
|
|
683
|
+
* Available layouts for rendering
|
|
684
|
+
*/
|
|
685
|
+
layouts?: LayoutDefinition[];
|
|
686
|
+
/**
|
|
687
|
+
* Whether there are unsaved changes in the editor
|
|
688
|
+
*/
|
|
689
|
+
hasUnsavedChanges?: boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Handler to save the current data before navigating
|
|
692
|
+
*/
|
|
693
|
+
onSave?: () => Promise<void>;
|
|
694
|
+
/**
|
|
695
|
+
* Whether a save is in progress
|
|
696
|
+
*/
|
|
697
|
+
isSaving?: boolean;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Full-screen preview modal with client-side rendering
|
|
701
|
+
*
|
|
702
|
+
* Renders the current editor data directly using PageRenderer.
|
|
703
|
+
* Links prompt for confirmation before navigating (with option to save first).
|
|
704
|
+
*
|
|
705
|
+
* Features:
|
|
706
|
+
* - Zero consumer setup required
|
|
707
|
+
* - Shows current editor state (including unsaved changes)
|
|
708
|
+
* - Interactive elements (accordions, hover states) still work
|
|
709
|
+
* - Links show confirmation dialog before navigating
|
|
710
|
+
*/
|
|
711
|
+
declare const PreviewModal: React$1.NamedExoticComponent<PreviewModalProps>;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Version entry from Payload's versions system
|
|
715
|
+
*/
|
|
716
|
+
interface PageVersion {
|
|
717
|
+
id: string;
|
|
718
|
+
parent: string;
|
|
719
|
+
version: {
|
|
720
|
+
title?: string;
|
|
721
|
+
slug?: string;
|
|
722
|
+
_status?: 'draft' | 'published';
|
|
723
|
+
updatedAt: string;
|
|
724
|
+
createdAt: string;
|
|
725
|
+
};
|
|
726
|
+
createdAt: string;
|
|
727
|
+
updatedAt: string;
|
|
728
|
+
autosave?: boolean;
|
|
729
|
+
latest?: boolean;
|
|
730
|
+
}
|
|
731
|
+
interface VersionHistoryProps {
|
|
732
|
+
/**
|
|
733
|
+
* Page ID to fetch versions for
|
|
734
|
+
*/
|
|
735
|
+
pageId: string;
|
|
736
|
+
/**
|
|
737
|
+
* API endpoint base path
|
|
738
|
+
* @default '/api/puck/pages'
|
|
739
|
+
*/
|
|
740
|
+
apiEndpoint?: string;
|
|
741
|
+
/**
|
|
742
|
+
* Callback when a version is restored
|
|
743
|
+
*/
|
|
744
|
+
onRestore?: (version: PageVersion) => void;
|
|
745
|
+
/**
|
|
746
|
+
* Whether restore operations are disabled
|
|
747
|
+
*/
|
|
748
|
+
disabled?: boolean;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Version history dropdown for the Puck editor
|
|
752
|
+
*
|
|
753
|
+
* Shows a list of previous versions with the ability to restore them.
|
|
754
|
+
*/
|
|
755
|
+
declare const VersionHistory: React$1.NamedExoticComponent<VersionHistoryProps>;
|
|
756
|
+
|
|
757
|
+
interface UseUnsavedChangesReturn {
|
|
758
|
+
hasUnsavedChanges: boolean;
|
|
759
|
+
markClean: () => void;
|
|
760
|
+
markDirty: () => void;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Hook to track unsaved changes and warn before navigation
|
|
764
|
+
*
|
|
765
|
+
* Registers a beforeunload handler to prevent accidental navigation
|
|
766
|
+
* when there are unsaved changes.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```tsx
|
|
770
|
+
* const { hasUnsavedChanges, markClean, markDirty } = useUnsavedChanges()
|
|
771
|
+
*
|
|
772
|
+
* const handleChange = () => {
|
|
773
|
+
* markDirty()
|
|
774
|
+
* }
|
|
775
|
+
*
|
|
776
|
+
* const handleSave = async () => {
|
|
777
|
+
* await save()
|
|
778
|
+
* markClean()
|
|
779
|
+
* }
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
declare function useUnsavedChanges(): UseUnsavedChangesReturn;
|
|
783
|
+
|
|
784
|
+
export { HeaderActions, type HeaderActionsProps, IframeWrapper, type IframeWrapperProps, type LayoutStyle, LoadingState, type LoadingStateProps, type PageVersion, PreviewModal, type PreviewModalProps, PuckEditor, PuckEditorCore, type PuckEditorCoreProps, type PuckEditorProps, PuckEditorView, type PuckEditorViewProps, type UseUnsavedChangesReturn, VersionHistory, type VersionHistoryProps, useUnsavedChanges };
|