@puckeditor/cli 0.24.0-canary.301a0304
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 +21 -0
- package/README.md +45 -0
- package/dist/bin.mjs +7304 -0
- package/dist/docs/api-reference/actions.md +63 -0
- package/dist/docs/api-reference/components/action-bar-action.md +35 -0
- package/dist/docs/api-reference/components/action-bar-group.md +24 -0
- package/dist/docs/api-reference/components/action-bar-label.md +25 -0
- package/dist/docs/api-reference/components/action-bar-separator.md +16 -0
- package/dist/docs/api-reference/components/action-bar.md +32 -0
- package/dist/docs/api-reference/components/auto-field.md +63 -0
- package/dist/docs/api-reference/components/drawer-item.md +75 -0
- package/dist/docs/api-reference/components/drawer.md +29 -0
- package/dist/docs/api-reference/components/drop-zone.md +232 -0
- package/dist/docs/api-reference/components/field-label.md +138 -0
- package/dist/docs/api-reference/components/inline-text-field.md +77 -0
- package/dist/docs/api-reference/components/puck-components.md +19 -0
- package/dist/docs/api-reference/components/puck-fields.md +39 -0
- package/dist/docs/api-reference/components/puck-layout.md +27 -0
- package/dist/docs/api-reference/components/puck-outline.md +19 -0
- package/dist/docs/api-reference/components/puck-preview.md +39 -0
- package/dist/docs/api-reference/components/puck.md +561 -0
- package/dist/docs/api-reference/components/render.md +94 -0
- package/dist/docs/api-reference/components/rich-text-menu-control.md +87 -0
- package/dist/docs/api-reference/components/rich-text-menu-group.md +27 -0
- package/dist/docs/api-reference/components/rich-text-menu.md +99 -0
- package/dist/docs/api-reference/components.md +32 -0
- package/dist/docs/api-reference/configuration/component-config.md +569 -0
- package/dist/docs/api-reference/configuration/config.md +108 -0
- package/dist/docs/api-reference/configuration.md +4 -0
- package/dist/docs/api-reference/data-model/app-state.md +168 -0
- package/dist/docs/api-reference/data-model/component-data.md +62 -0
- package/dist/docs/api-reference/data-model/data.md +95 -0
- package/dist/docs/api-reference/data-model/item-selector.md +34 -0
- package/dist/docs/api-reference/data-model/root-data.md +59 -0
- package/dist/docs/api-reference/data-model.md +8 -0
- package/dist/docs/api-reference/dictionary.md +172 -0
- package/dist/docs/api-reference/field-transforms.md +51 -0
- package/dist/docs/api-reference/fields/array.md +211 -0
- package/dist/docs/api-reference/fields/base.md +96 -0
- package/dist/docs/api-reference/fields/custom.md +193 -0
- package/dist/docs/api-reference/fields/external.md +413 -0
- package/dist/docs/api-reference/fields/number.md +132 -0
- package/dist/docs/api-reference/fields/object.md +78 -0
- package/dist/docs/api-reference/fields/radio.md +82 -0
- package/dist/docs/api-reference/fields/richtext.md +422 -0
- package/dist/docs/api-reference/fields/select.md +79 -0
- package/dist/docs/api-reference/fields/slot.md +302 -0
- package/dist/docs/api-reference/fields/text.md +93 -0
- package/dist/docs/api-reference/fields/textarea.md +93 -0
- package/dist/docs/api-reference/fields.md +16 -0
- package/dist/docs/api-reference/functions/migrate.md +204 -0
- package/dist/docs/api-reference/functions/register-overlay-portal.md +45 -0
- package/dist/docs/api-reference/functions/resolve-all-data.md +27 -0
- package/dist/docs/api-reference/functions/set-deep.md +55 -0
- package/dist/docs/api-reference/functions/transform-props.md +51 -0
- package/dist/docs/api-reference/functions/use-get-puck.md +24 -0
- package/dist/docs/api-reference/functions/use-puck.md +43 -0
- package/dist/docs/api-reference/functions/walk-tree.md +88 -0
- package/dist/docs/api-reference/functions.md +8 -0
- package/dist/docs/api-reference/overrides/action-bar.md +35 -0
- package/dist/docs/api-reference/overrides/component-overlay.md +41 -0
- package/dist/docs/api-reference/overrides/drawer-item.md +24 -0
- package/dist/docs/api-reference/overrides/drawer.md +19 -0
- package/dist/docs/api-reference/overrides/field-label.md +18 -0
- package/dist/docs/api-reference/overrides/field-types.md +51 -0
- package/dist/docs/api-reference/overrides/fields.md +19 -0
- package/dist/docs/api-reference/overrides/header-actions.md +24 -0
- package/dist/docs/api-reference/overrides/header.md +29 -0
- package/dist/docs/api-reference/overrides/iframe.md +32 -0
- package/dist/docs/api-reference/overrides/outline.md +19 -0
- package/dist/docs/api-reference/overrides/preview.md +19 -0
- package/dist/docs/api-reference/overrides/puck.md +19 -0
- package/dist/docs/api-reference/overrides.md +28 -0
- package/dist/docs/api-reference/permissions.md +55 -0
- package/dist/docs/api-reference/plugin.md +112 -0
- package/dist/docs/api-reference/plugins/blocks-plugin.md +57 -0
- package/dist/docs/api-reference/plugins/fields-plugin.md +68 -0
- package/dist/docs/api-reference/plugins/legacy-side-bar-plugin.md +54 -0
- package/dist/docs/api-reference/plugins/outline-plugin.md +57 -0
- package/dist/docs/api-reference/puck-api.md +278 -0
- package/dist/docs/api-reference/theming/action-bar.md +32 -0
- package/dist/docs/api-reference/theming/button.md +65 -0
- package/dist/docs/api-reference/theming/canvas.md +20 -0
- package/dist/docs/api-reference/theming/computed-values.md +194 -0
- package/dist/docs/api-reference/theming/drawer.md +34 -0
- package/dist/docs/api-reference/theming/fields.md +70 -0
- package/dist/docs/api-reference/theming/global.md +127 -0
- package/dist/docs/api-reference/theming/header.md +19 -0
- package/dist/docs/api-reference/theming/icon-button.md +28 -0
- package/dist/docs/api-reference/theming/outline.md +35 -0
- package/dist/docs/api-reference/theming/plugin-bar.md +24 -0
- package/dist/docs/api-reference/theming/sidebar.md +19 -0
- package/dist/docs/api-reference/theming/slot.md +27 -0
- package/dist/docs/cli.md +201 -0
- package/dist/docs/extending-puck/composition.md +54 -0
- package/dist/docs/extending-puck/custom-fields.md +133 -0
- package/dist/docs/extending-puck/field-transforms.md +89 -0
- package/dist/docs/extending-puck/internal-puck-api.md +96 -0
- package/dist/docs/extending-puck/plugins.md +159 -0
- package/dist/docs/extending-puck/theming.md +88 -0
- package/dist/docs/extending-puck/ui-overrides.md +134 -0
- package/dist/docs/getting-started.md +68 -0
- package/dist/docs/guides/migrations/dropzones-to-slots.md +138 -0
- package/dist/docs/index.json +466 -0
- package/dist/docs/index.md +37 -0
- package/dist/docs/integrating-puck/categories.md +92 -0
- package/dist/docs/integrating-puck/component-configuration.md +159 -0
- package/dist/docs/integrating-puck/data-migration.md +86 -0
- package/dist/docs/integrating-puck/dynamic-fields.md +86 -0
- package/dist/docs/integrating-puck/dynamic-props.md +137 -0
- package/dist/docs/integrating-puck/external-data-sources.md +149 -0
- package/dist/docs/integrating-puck/feature-toggling.md +121 -0
- package/dist/docs/integrating-puck/localization.md +228 -0
- package/dist/docs/integrating-puck/multi-column-layouts.md +226 -0
- package/dist/docs/integrating-puck/overlay-portals.md +25 -0
- package/dist/docs/integrating-puck/rich-text-editing.md +230 -0
- package/dist/docs/integrating-puck/root-configuration.md +171 -0
- package/dist/docs/integrating-puck/server-components.md +199 -0
- package/dist/docs/integrating-puck/styling.md +117 -0
- package/dist/docs/integrating-puck/viewports.md +75 -0
- package/dist/templates/astro/README.md +52 -0
- package/dist/templates/astro/_gitignore +24 -0
- package/dist/templates/astro/astro.config.mjs +14 -0
- package/dist/templates/astro/database.json +1 -0
- package/dist/templates/astro/package.json +25 -0
- package/dist/templates/astro/public/favicon.svg +9 -0
- package/dist/templates/astro/src/lib/pages.ts +21 -0
- package/dist/templates/astro/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/astro/src/pages/[...puckPath].astro +25 -0
- package/dist/templates/astro/src/pages/api/pages.ts +18 -0
- package/dist/templates/astro/src/puck/editor.tsx +32 -0
- package/dist/templates/astro/src/puck/pages.ts +15 -0
- package/dist/templates/astro/src/puck/render.tsx +9 -0
- package/dist/templates/astro/src/puck.config.tsx +23 -0
- package/dist/templates/astro/tsconfig.json +14 -0
- package/dist/templates/astro-ai/README.md +64 -0
- package/dist/templates/astro-ai/_gitignore +24 -0
- package/dist/templates/astro-ai/astro.config.mjs +21 -0
- package/dist/templates/astro-ai/database.json +1 -0
- package/dist/templates/astro-ai/package.json +27 -0
- package/dist/templates/astro-ai/public/favicon.svg +9 -0
- package/dist/templates/astro-ai/src/lib/pages.ts +21 -0
- package/dist/templates/astro-ai/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/astro-ai/src/pages/[...puckPath].astro +25 -0
- package/dist/templates/astro-ai/src/pages/api/pages.ts +18 -0
- package/dist/templates/astro-ai/src/pages/api/puck/[...all].ts +36 -0
- package/dist/templates/astro-ai/src/puck/editor.tsx +53 -0
- package/dist/templates/astro-ai/src/puck/pages.ts +15 -0
- package/dist/templates/astro-ai/src/puck/render.tsx +10 -0
- package/dist/templates/astro-ai/src/puck.config.tsx +23 -0
- package/dist/templates/astro-ai/tsconfig.json +14 -0
- package/dist/templates/express/README.md +66 -0
- package/dist/templates/express/_gitignore +16 -0
- package/dist/templates/express/database.json +1 -0
- package/dist/templates/express/package.json +20 -0
- package/dist/templates/express/src/index.ts +15 -0
- package/dist/templates/express/src/puck/pages.ts +39 -0
- package/dist/templates/express/tsconfig.json +12 -0
- package/dist/templates/express-ai/README.md +81 -0
- package/dist/templates/express-ai/_gitignore +16 -0
- package/dist/templates/express-ai/database.json +1 -0
- package/dist/templates/express-ai/package.json +22 -0
- package/dist/templates/express-ai/src/index.ts +17 -0
- package/dist/templates/express-ai/src/puck/cloud.ts +71 -0
- package/dist/templates/express-ai/src/puck/pages.ts +39 -0
- package/dist/templates/express-ai/tsconfig.json +12 -0
- package/dist/templates/hono/README.md +66 -0
- package/dist/templates/hono/_gitignore +32 -0
- package/dist/templates/hono/database.json +1 -0
- package/dist/templates/hono/package.json +20 -0
- package/dist/templates/hono/src/index.ts +21 -0
- package/dist/templates/hono/src/puck/pages.ts +32 -0
- package/dist/templates/hono/tsconfig.json +13 -0
- package/dist/templates/hono-ai/README.md +81 -0
- package/dist/templates/hono-ai/_gitignore +32 -0
- package/dist/templates/hono-ai/database.json +1 -0
- package/dist/templates/hono-ai/package.json +22 -0
- package/dist/templates/hono-ai/src/index.ts +23 -0
- package/dist/templates/hono-ai/src/puck/cloud.ts +30 -0
- package/dist/templates/hono-ai/src/puck/pages.ts +32 -0
- package/dist/templates/hono-ai/tsconfig.json +13 -0
- package/dist/templates/manifest.json +4 -0
- package/dist/templates/next/README.md +112 -0
- package/dist/templates/next/_gitignore +35 -0
- package/dist/templates/next/app/[...puckPath]/client.tsx +9 -0
- package/dist/templates/next/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/next/app/favicon.ico +0 -0
- package/dist/templates/next/app/layout.tsx +13 -0
- package/dist/templates/next/app/page.tsx +1 -0
- package/dist/templates/next/app/puck/[...puckPath]/client.tsx +20 -0
- package/dist/templates/next/app/puck/[...puckPath]/page.tsx +55 -0
- package/dist/templates/next/app/puck/api/route.ts +25 -0
- package/dist/templates/next/app/puck/page.tsx +3 -0
- package/dist/templates/next/app/styles.css +3 -0
- package/dist/templates/next/database.json +1 -0
- package/dist/templates/next/lib/get-page.ts +11 -0
- package/dist/templates/next/next.config.js +3 -0
- package/dist/templates/next/package.json +25 -0
- package/dist/templates/next/proxy.ts +27 -0
- package/dist/templates/next/puck.config.tsx +25 -0
- package/dist/templates/next/tsconfig/base.json +20 -0
- package/dist/templates/next/tsconfig/nextjs.json +21 -0
- package/dist/templates/next/tsconfig.json +8 -0
- package/dist/templates/next-ai/README.md +169 -0
- package/dist/templates/next-ai/_gitignore +35 -0
- package/dist/templates/next-ai/app/[...puckPath]/client.tsx +12 -0
- package/dist/templates/next-ai/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/next-ai/app/api/pages/route.ts +26 -0
- package/dist/templates/next-ai/app/api/puck/[...all]/route.ts +31 -0
- package/dist/templates/next-ai/app/layout.tsx +13 -0
- package/dist/templates/next-ai/app/page.tsx +1 -0
- package/dist/templates/next-ai/app/puck/[...puckPath]/client.tsx +38 -0
- package/dist/templates/next-ai/app/puck/[...puckPath]/page.tsx +57 -0
- package/dist/templates/next-ai/app/puck/page.tsx +3 -0
- package/dist/templates/next-ai/app/styles.css +3 -0
- package/dist/templates/next-ai/database.json +1 -0
- package/dist/templates/next-ai/lib/get-page.ts +11 -0
- package/dist/templates/next-ai/next.config.js +3 -0
- package/dist/templates/next-ai/package.json +27 -0
- package/dist/templates/next-ai/proxy.ts +27 -0
- package/dist/templates/next-ai/public/favicon.ico +0 -0
- package/dist/templates/next-ai/puck.config.tsx +25 -0
- package/dist/templates/next-ai/tsconfig/base.json +20 -0
- package/dist/templates/next-ai/tsconfig/nextjs.json +21 -0
- package/dist/templates/next-ai/tsconfig.json +8 -0
- package/dist/templates/react-router/README.md +113 -0
- package/dist/templates/react-router/_gitignore +6 -0
- package/dist/templates/react-router/app/components/puck-render.tsx +8 -0
- package/dist/templates/react-router/app/lib/pages.server.ts +29 -0
- package/dist/templates/react-router/app/lib/resolve-puck-path.server.ts +19 -0
- package/dist/templates/react-router/app/root.tsx +65 -0
- package/dist/templates/react-router/app/routes/_index.tsx +31 -0
- package/dist/templates/react-router/app/routes/puck-splat.tsx +95 -0
- package/dist/templates/react-router/app/routes.ts +7 -0
- package/dist/templates/react-router/database.json +1 -0
- package/dist/templates/react-router/package.json +33 -0
- package/dist/templates/react-router/public/favicon.ico +0 -0
- package/dist/templates/react-router/puck.config.tsx +23 -0
- package/dist/templates/react-router/react-router.config.ts +7 -0
- package/dist/templates/react-router/tsconfig.json +29 -0
- package/dist/templates/react-router/vite.config.ts +10 -0
- package/dist/templates/react-router-ai/README.md +172 -0
- package/dist/templates/react-router-ai/_gitignore +6 -0
- package/dist/templates/react-router-ai/app/components/puck-render.tsx +11 -0
- package/dist/templates/react-router-ai/app/lib/pages.server.ts +29 -0
- package/dist/templates/react-router-ai/app/lib/resolve-puck-path.server.ts +19 -0
- package/dist/templates/react-router-ai/app/root.tsx +65 -0
- package/dist/templates/react-router-ai/app/routes/_index.tsx +31 -0
- package/dist/templates/react-router-ai/app/routes/api.puck.ts +34 -0
- package/dist/templates/react-router-ai/app/routes/puck-splat.tsx +119 -0
- package/dist/templates/react-router-ai/app/routes.ts +8 -0
- package/dist/templates/react-router-ai/database.json +1 -0
- package/dist/templates/react-router-ai/package.json +35 -0
- package/dist/templates/react-router-ai/public/favicon.ico +0 -0
- package/dist/templates/react-router-ai/puck.config.tsx +25 -0
- package/dist/templates/react-router-ai/react-router.config.ts +7 -0
- package/dist/templates/react-router-ai/tsconfig.json +29 -0
- package/dist/templates/react-router-ai/vite.config.ts +10 -0
- package/dist/templates/tanstack-start/README.md +113 -0
- package/dist/templates/tanstack-start/_gitignore +12 -0
- package/dist/templates/tanstack-start/database.json +1 -0
- package/dist/templates/tanstack-start/package.json +26 -0
- package/dist/templates/tanstack-start/puck.config.tsx +23 -0
- package/dist/templates/tanstack-start/src/components/puck-render.tsx +8 -0
- package/dist/templates/tanstack-start/src/lib/pages.server.ts +26 -0
- package/dist/templates/tanstack-start/src/lib/pages.ts +39 -0
- package/dist/templates/tanstack-start/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/tanstack-start/src/routeTree.gen.ts +86 -0
- package/dist/templates/tanstack-start/src/router.tsx +19 -0
- package/dist/templates/tanstack-start/src/routes/$.tsx +41 -0
- package/dist/templates/tanstack-start/src/routes/__root.tsx +42 -0
- package/dist/templates/tanstack-start/src/routes/index.tsx +18 -0
- package/dist/templates/tanstack-start/src/styles.css +13 -0
- package/dist/templates/tanstack-start/tsconfig.json +24 -0
- package/dist/templates/tanstack-start/vite.config.ts +15 -0
- package/dist/templates/tanstack-start-ai/README.md +171 -0
- package/dist/templates/tanstack-start-ai/_gitignore +12 -0
- package/dist/templates/tanstack-start-ai/database.json +1 -0
- package/dist/templates/tanstack-start-ai/package.json +28 -0
- package/dist/templates/tanstack-start-ai/puck.config.tsx +23 -0
- package/dist/templates/tanstack-start-ai/src/components/puck-render.tsx +11 -0
- package/dist/templates/tanstack-start-ai/src/lib/pages.server.ts +26 -0
- package/dist/templates/tanstack-start-ai/src/lib/pages.ts +39 -0
- package/dist/templates/tanstack-start-ai/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/tanstack-start-ai/src/routeTree.gen.ts +104 -0
- package/dist/templates/tanstack-start-ai/src/router.tsx +19 -0
- package/dist/templates/tanstack-start-ai/src/routes/$.tsx +73 -0
- package/dist/templates/tanstack-start-ai/src/routes/__root.tsx +42 -0
- package/dist/templates/tanstack-start-ai/src/routes/api/puck/$.ts +39 -0
- package/dist/templates/tanstack-start-ai/src/routes/index.tsx +18 -0
- package/dist/templates/tanstack-start-ai/src/styles.css +13 -0
- package/dist/templates/tanstack-start-ai/tsconfig.json +24 -0
- package/dist/templates/tanstack-start-ai/vite.config.ts +15 -0
- package/dist/templates/vinext/README.md +112 -0
- package/dist/templates/vinext/_gitignore +33 -0
- package/dist/templates/vinext/app/[...puckPath]/client.tsx +9 -0
- package/dist/templates/vinext/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/vinext/app/favicon.ico +0 -0
- package/dist/templates/vinext/app/layout.tsx +13 -0
- package/dist/templates/vinext/app/page.tsx +1 -0
- package/dist/templates/vinext/app/puck/[...puckPath]/client.tsx +20 -0
- package/dist/templates/vinext/app/puck/[...puckPath]/page.tsx +55 -0
- package/dist/templates/vinext/app/puck/api/route.ts +25 -0
- package/dist/templates/vinext/app/puck/page.tsx +3 -0
- package/dist/templates/vinext/app/styles.css +3 -0
- package/dist/templates/vinext/database.json +1 -0
- package/dist/templates/vinext/lib/get-page.ts +11 -0
- package/dist/templates/vinext/package.json +30 -0
- package/dist/templates/vinext/proxy.ts +27 -0
- package/dist/templates/vinext/puck.config.tsx +25 -0
- package/dist/templates/vinext/tsconfig.json +30 -0
- package/dist/templates/vinext/vite.config.ts +6 -0
- package/dist/templates/vinext-ai/README.md +169 -0
- package/dist/templates/vinext-ai/_gitignore +33 -0
- package/dist/templates/vinext-ai/app/[...puckPath]/client.tsx +12 -0
- package/dist/templates/vinext-ai/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/vinext-ai/app/api/pages/route.ts +26 -0
- package/dist/templates/vinext-ai/app/api/puck/[...all]/route.ts +31 -0
- package/dist/templates/vinext-ai/app/layout.tsx +13 -0
- package/dist/templates/vinext-ai/app/page.tsx +1 -0
- package/dist/templates/vinext-ai/app/puck/[...puckPath]/client.tsx +38 -0
- package/dist/templates/vinext-ai/app/puck/[...puckPath]/page.tsx +57 -0
- package/dist/templates/vinext-ai/app/puck/page.tsx +3 -0
- package/dist/templates/vinext-ai/app/styles.css +3 -0
- package/dist/templates/vinext-ai/database.json +1 -0
- package/dist/templates/vinext-ai/lib/get-page.ts +11 -0
- package/dist/templates/vinext-ai/package.json +32 -0
- package/dist/templates/vinext-ai/proxy.ts +27 -0
- package/dist/templates/vinext-ai/public/favicon.ico +0 -0
- package/dist/templates/vinext-ai/puck.config.tsx +25 -0
- package/dist/templates/vinext-ai/tsconfig.json +30 -0
- package/dist/templates/vinext-ai/vite.config.ts +9 -0
- package/dist/templates/vite/README.md +56 -0
- package/dist/templates/vite/_gitignore +24 -0
- package/dist/templates/vite/database.json +1 -0
- package/dist/templates/vite/index.html +12 -0
- package/dist/templates/vite/package.json +29 -0
- package/dist/templates/vite/server/index.ts +13 -0
- package/dist/templates/vite/server/prod.ts +18 -0
- package/dist/templates/vite/server/puck/pages.ts +32 -0
- package/dist/templates/vite/src/App.tsx +11 -0
- package/dist/templates/vite/src/main.tsx +12 -0
- package/dist/templates/vite/src/puck/editor.tsx +28 -0
- package/dist/templates/vite/src/puck/page.tsx +27 -0
- package/dist/templates/vite/src/puck/pages.ts +15 -0
- package/dist/templates/vite/src/puck/root.tsx +27 -0
- package/dist/templates/vite/src/puck.config.tsx +23 -0
- package/dist/templates/vite/tsconfig.app.json +26 -0
- package/dist/templates/vite/tsconfig.json +7 -0
- package/dist/templates/vite/tsconfig.node.json +23 -0
- package/dist/templates/vite/vite.config.ts +14 -0
- package/dist/templates/vite-ai/README.md +67 -0
- package/dist/templates/vite-ai/_gitignore +24 -0
- package/dist/templates/vite-ai/database.json +1 -0
- package/dist/templates/vite-ai/index.html +12 -0
- package/dist/templates/vite-ai/package.json +31 -0
- package/dist/templates/vite-ai/server/index.ts +15 -0
- package/dist/templates/vite-ai/server/prod.ts +18 -0
- package/dist/templates/vite-ai/server/puck/cloud.ts +30 -0
- package/dist/templates/vite-ai/server/puck/pages.ts +32 -0
- package/dist/templates/vite-ai/src/App.tsx +11 -0
- package/dist/templates/vite-ai/src/main.tsx +12 -0
- package/dist/templates/vite-ai/src/puck/editor.tsx +49 -0
- package/dist/templates/vite-ai/src/puck/page.tsx +28 -0
- package/dist/templates/vite-ai/src/puck/pages.ts +15 -0
- package/dist/templates/vite-ai/src/puck/root.tsx +27 -0
- package/dist/templates/vite-ai/src/puck.config.tsx +23 -0
- package/dist/templates/vite-ai/tsconfig.app.json +26 -0
- package/dist/templates/vite-ai/tsconfig.json +7 -0
- package/dist/templates/vite-ai/tsconfig.node.json +23 -0
- package/dist/templates/vite-ai/vite.config.ts +14 -0
- package/package.json +51 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
# \<Puck\>
|
|
2
|
+
|
|
3
|
+
Render the Puck editor.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Puck } from "@puckeditor/core";
|
|
7
|
+
|
|
8
|
+
const config = {
|
|
9
|
+
components: {},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const initialData = {
|
|
13
|
+
content: [],
|
|
14
|
+
root: {},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function Editor() {
|
|
18
|
+
return <Puck config={config} data={initialData} />;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Props
|
|
23
|
+
|
|
24
|
+
| Param | Example | Type | Status |
|
|
25
|
+
| ----------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------ | ------------ |
|
|
26
|
+
| [`config`](#config) | `config: { components: {} }` | [Config](/docs/api-reference/configuration/config) | Required |
|
|
27
|
+
| [`data`](#data) | `data: {}` | [Data](/docs/api-reference/data-model/data) | Required |
|
|
28
|
+
| [`dictionary`](#dictionary) | `dictionary: { "header-publish": "Publicar" }` | [Dictionary](/docs/api-reference/dictionary) | - |
|
|
29
|
+
| [`dnd`](#dnd) | `dnd: {}` | [DndConfig](#dnd-params) | - |
|
|
30
|
+
| [`children`](#children) | `children: <Puck.Preview />` | ReactNode | - |
|
|
31
|
+
| [`fieldTransforms`](#fieldtransforms) | `fieldTransforms: {text: () => <div />}` | [FieldTransforms](/docs/api-reference/field-transforms) | - |
|
|
32
|
+
| [`headerPath`](#headerpath) | `headerPath: "/my-page"` | String | - |
|
|
33
|
+
| [`headerTitle`](#headertitle) | `headerTitle: "My Page"` | String | - |
|
|
34
|
+
| [`height`](#height) | `height: "100%"` | String \| Number | - |
|
|
35
|
+
| [`iframe`](#iframe) | `iframe: {}` | [IframeConfig](#iframe-params) | - |
|
|
36
|
+
| [`initialHistory`](#initialhistory) | `initialHistory: {}` | [InitialHistory](#initialhistory-params) | - |
|
|
37
|
+
| [`metadata`](#metadata) | `metadata: {}` | Object | - |
|
|
38
|
+
| [`onAction()`](#onactionaction-appstate-prevappstate) | `onAction: (action, appState, prevAppState) => {}` | Function | - |
|
|
39
|
+
| [`onChange()`](#onchangedata) | `onChange: (data) => {}` | Function | - |
|
|
40
|
+
| [`onPublish()`](#onpublishdata) | `onPublish: async (data) => {}` | Function | - |
|
|
41
|
+
| [`overrides`](#overrides) | `overrides: { header: () => <div /> }` | [Overrides](/docs/api-reference/overrides) | Experimental |
|
|
42
|
+
| [`permissions`](#permissions) | `permissions: {}` | [Permissions\[\]](/docs/api-reference/permissions#supported-permissions) | - |
|
|
43
|
+
| [`plugins`](#plugins) | `plugins: [myPlugin]` | [Plugin\[\]](/docs/api-reference/plugin) | Experimental |
|
|
44
|
+
| [`ui`](#ui) | `ui: {leftSideBarVisible: false}` | [AppState.ui](/docs/api-reference/data-model/app-state#ui) | - |
|
|
45
|
+
| [`viewports`](#viewports) | `viewports: [{ width: 1440 }]` | [Viewport\[\]](#viewport-params) | - |
|
|
46
|
+
| [`_experimentalFullScreenCanvas`](#_experimentalfullscreencanvas) | `_experimentalFullScreenCanvas: true` | Boolean | Experimental |
|
|
47
|
+
|
|
48
|
+
## Required props
|
|
49
|
+
|
|
50
|
+
### `config`
|
|
51
|
+
|
|
52
|
+
An object describing the available components, fields and more. See the [`Config` docs](/docs/api-reference/configuration/config) for a full reference.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
export function Editor() {
|
|
56
|
+
return (
|
|
57
|
+
<Puck
|
|
58
|
+
config={{
|
|
59
|
+
components: {
|
|
60
|
+
HeadingBlock: {
|
|
61
|
+
fields: {
|
|
62
|
+
children: {
|
|
63
|
+
type: "text",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
render: ({ children }) => {
|
|
67
|
+
return <h1>{children}</h1>;
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}}
|
|
72
|
+
// ...
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `data`
|
|
79
|
+
|
|
80
|
+
The initial data to render. Cannot be changed once `<Puck>` has been mounted. See the [`Data` docs](/docs/api-reference/data-model/data) for a full reference.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
export function Editor() {
|
|
84
|
+
return (
|
|
85
|
+
<Puck
|
|
86
|
+
data={{
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
props: { children: "Hello, world", id: "id" },
|
|
90
|
+
type: "HeadingBlock",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
root: {},
|
|
94
|
+
}}
|
|
95
|
+
// ...
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Optional props
|
|
102
|
+
|
|
103
|
+
### `children`
|
|
104
|
+
|
|
105
|
+
Render custom nodes to create [compositional interfaces](/docs/extending-puck/composition).
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
export function Editor() {
|
|
109
|
+
return (
|
|
110
|
+
<Puck /*...*/>
|
|
111
|
+
<Puck.Preview />
|
|
112
|
+
</Puck>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `dictionary`
|
|
118
|
+
|
|
119
|
+
Override Puck's default UI strings, or add your own. See the [`Dictionary` docs](/docs/api-reference/dictionary) for a full list of supported messages.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
export function Editor() {
|
|
123
|
+
return (
|
|
124
|
+
<Puck
|
|
125
|
+
dictionary={{ "header-publish": "Save" }}
|
|
126
|
+
// ...
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `dnd`
|
|
133
|
+
|
|
134
|
+
Configure drag-and-drop behavior.
|
|
135
|
+
|
|
136
|
+
#### dnd params
|
|
137
|
+
|
|
138
|
+
| Param | Example | Type | Status |
|
|
139
|
+
| ------------------------------------------- | -------------------------- | ------------------------------- | ------ |
|
|
140
|
+
| [`behavior`](#behavior) | `behavior: "static"` | `"auto" \| "fluid" \| "static"` | - |
|
|
141
|
+
| [`disableAutoScroll`](#disableautoscroll) | `disableAutoScroll: true` | boolean | - |
|
|
142
|
+
| [`disableOutlineDrag`](#disableoutlinedrag) | `disableOutlineDrag: true` | boolean | - |
|
|
143
|
+
|
|
144
|
+
##### `behavior`
|
|
145
|
+
|
|
146
|
+
Control animation behavior while dragging. Defaults to `"auto"`.
|
|
147
|
+
|
|
148
|
+
- `"auto"` (default): Use fluid behavior within a slot, then switch to static behavior when dragging an item between slots or inserting a new component.
|
|
149
|
+
- `"fluid"`: Move the item during a drag, animating other items out of the way.
|
|
150
|
+
- `"static"`: Freeze the item in-place during a drag, showing a line placeholder at the drop destination.
|
|
151
|
+
|
|
152
|
+
##### `disableAutoScroll`
|
|
153
|
+
|
|
154
|
+
Disable auto-scroll when the user drags an item near the edge of the preview area.
|
|
155
|
+
|
|
156
|
+
##### `disableOutlineDrag`
|
|
157
|
+
|
|
158
|
+
Disable drag-and-drop in the [outline](/docs/api-reference/components/puck-outline). Items can still be selected and expanded.
|
|
159
|
+
|
|
160
|
+
### `fieldTransforms`
|
|
161
|
+
|
|
162
|
+
Specify transforms to modify field values before being passed to the editor canvas. Implements the [Field Transforms API](/docs/api-reference/field-transforms).
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
export function Editor() {
|
|
166
|
+
return (
|
|
167
|
+
<Puck
|
|
168
|
+
fieldTransforms={{
|
|
169
|
+
text: ({ value }) => <div>{value}</div>, // Wrap all text field values in a div
|
|
170
|
+
}}
|
|
171
|
+
// ...
|
|
172
|
+
/>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `headerPath`
|
|
178
|
+
|
|
179
|
+
Set a path to show after the header title
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
export function Editor() {
|
|
183
|
+
return (
|
|
184
|
+
<Puck
|
|
185
|
+
headerPath="/my-page"
|
|
186
|
+
// ...
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### `headerTitle`
|
|
193
|
+
|
|
194
|
+
Set the title shown in the header
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
export function Editor() {
|
|
198
|
+
return (
|
|
199
|
+
<Puck
|
|
200
|
+
headerTitle="My page"
|
|
201
|
+
// ...
|
|
202
|
+
/>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### `height`
|
|
208
|
+
|
|
209
|
+
Modify the height of the Puck editor when using the standard layout. Defaults to `100dvh`.
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
export function Editor() {
|
|
213
|
+
return (
|
|
214
|
+
<Puck
|
|
215
|
+
height="100%"
|
|
216
|
+
// ...
|
|
217
|
+
/>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### `iframe`
|
|
223
|
+
|
|
224
|
+
Configure the iframe behaviour.
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
export function Editor() {
|
|
228
|
+
return (
|
|
229
|
+
<Puck
|
|
230
|
+
iframe={{ enabled: false }}
|
|
231
|
+
// ...
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### iframe params
|
|
238
|
+
|
|
239
|
+
| Param | Example | Type | Status |
|
|
240
|
+
| ----------------------------------- | ----------------------- | ------- | ------ |
|
|
241
|
+
| [`enabled`](#enabled) | `enabled: false` | boolean | - |
|
|
242
|
+
| [`waitForStyles`](#waitforstyles) | `waitForStyles: false` | boolean | - |
|
|
243
|
+
| [`syncHostStyles`](#synchoststyles) | `syncHostStyles: false` | boolean | - |
|
|
244
|
+
|
|
245
|
+
##### `enabled`
|
|
246
|
+
|
|
247
|
+
Render the Puck preview within iframe. Defaults to `true`.
|
|
248
|
+
|
|
249
|
+
Disabling iframes will also disable [viewports](#viewports).
|
|
250
|
+
|
|
251
|
+
##### `waitForStyles`
|
|
252
|
+
|
|
253
|
+
Defer rendering of the Puck preview until the iframe styles have loaded, showing a spinner. Defaults to `true`.
|
|
254
|
+
|
|
255
|
+
##### `syncHostStyles`
|
|
256
|
+
|
|
257
|
+
Mirror host `style` and stylesheet tags into the preview iframe. Defaults to `true`.
|
|
258
|
+
|
|
259
|
+
Set `syncHostStyles: false` to fully isolate the iframe from host styles and host `html` / `body` attributes while still keeping Puck's iframe interaction styles active.
|
|
260
|
+
|
|
261
|
+
### `initialHistory`
|
|
262
|
+
|
|
263
|
+
Sets the undo/redo Puck history state when using the `usePuck` [history API](/docs/api-reference/puck-api#history).
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
const historyState = {
|
|
267
|
+
data: {
|
|
268
|
+
root: {
|
|
269
|
+
props: { title: "My History" },
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export function Editor() {
|
|
275
|
+
return (
|
|
276
|
+
<Puck
|
|
277
|
+
initialHistory={{
|
|
278
|
+
histories: [{ state: historyState }],
|
|
279
|
+
index: 0,
|
|
280
|
+
}}
|
|
281
|
+
// ...
|
|
282
|
+
/>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
#### `initialHistory` params
|
|
288
|
+
|
|
289
|
+
| Param | Example | Type | Status |
|
|
290
|
+
| --------------------------- | ------------------- | ---------------------------------------------------------- | -------- |
|
|
291
|
+
| [`histories`](#histories) | `histories: []` | [History](/docs/api-reference/puck-api#history-params)\[\] | Required |
|
|
292
|
+
| [`index`](#index) | `index: 2` | Number | Required |
|
|
293
|
+
| [`appendData`](#appenddata) | `appendData: false` | Boolean | - |
|
|
294
|
+
|
|
295
|
+
##### `histories`
|
|
296
|
+
|
|
297
|
+
An array of histories to reset the Puck state history state to.
|
|
298
|
+
|
|
299
|
+
##### `index`
|
|
300
|
+
|
|
301
|
+
The index of the histories to set the user to.
|
|
302
|
+
|
|
303
|
+
##### `appendData`
|
|
304
|
+
|
|
305
|
+
Append the Puck [`data`](#data) prop onto the end of [`histories`](#histories). Defaults to `true`.
|
|
306
|
+
|
|
307
|
+
When `false`, the Puck `data` prop will be ignored but you must specify at least one item in the `histories` array.
|
|
308
|
+
|
|
309
|
+
### `onAction(action, appState, prevAppState)`
|
|
310
|
+
|
|
311
|
+
Callback that triggers when Puck dispatches an [action](https://puckeditor.com/docs/api-reference/actions), like `insert` or `set`. Use this to track changes, perform side effects, or sync with external systems.
|
|
312
|
+
|
|
313
|
+
Receives three arguments:
|
|
314
|
+
|
|
315
|
+
1. `action`: The action that was dispatched
|
|
316
|
+
2. `appState`: The new [`AppState`](/docs/api-reference/data-model/app-state) after the action was applied
|
|
317
|
+
3. `prevAppState`: The previous [`AppState`](/docs/api-reference/data-model/app-state) before the action was applied
|
|
318
|
+
|
|
319
|
+
```tsx
|
|
320
|
+
export function Editor() {
|
|
321
|
+
return (
|
|
322
|
+
<Puck
|
|
323
|
+
onAction={(action, appState, prevAppState) => {
|
|
324
|
+
if (action.type === "insert") {
|
|
325
|
+
console.log("New component was inserted", appState);
|
|
326
|
+
}
|
|
327
|
+
}}
|
|
328
|
+
// ...
|
|
329
|
+
/>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### `metadata`
|
|
335
|
+
|
|
336
|
+
An object containing additional data provided to each component's [`render`](/docs/api-reference/configuration/component-config#renderprops) and [`resolveData`](/docs/api-reference/configuration/component-config#resolvedatadata-params) functions.
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
export function Editor() {
|
|
340
|
+
return (
|
|
341
|
+
<Puck
|
|
342
|
+
metadata={{ title: "Hello, world" }}
|
|
343
|
+
config={{
|
|
344
|
+
HeadingBlock: {
|
|
345
|
+
render: ({ puck }) => {
|
|
346
|
+
return <h1>{puck.metadata.title}</h1>; // "Hello, world"
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
}}
|
|
350
|
+
// ...
|
|
351
|
+
/>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### `onChange(data)`
|
|
357
|
+
|
|
358
|
+
Callback that triggers when the user makes a change.
|
|
359
|
+
|
|
360
|
+
Receives a single [`Data`](/docs/api-reference/data-model/data) arg.
|
|
361
|
+
|
|
362
|
+
```tsx
|
|
363
|
+
export function Editor() {
|
|
364
|
+
return (
|
|
365
|
+
<Puck
|
|
366
|
+
onChange={(data) => {
|
|
367
|
+
console.log("Puck data was updated", data);
|
|
368
|
+
}}
|
|
369
|
+
// ...
|
|
370
|
+
/>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### `onPublish(data)`
|
|
376
|
+
|
|
377
|
+
Callback that triggers when the user hits the "Publish" button. Use this to save the Puck data to your database.
|
|
378
|
+
|
|
379
|
+
Receives a single [`Data`](/docs/api-reference/data-model/data) arg.
|
|
380
|
+
|
|
381
|
+
```tsx
|
|
382
|
+
export function Editor() {
|
|
383
|
+
return (
|
|
384
|
+
<Puck
|
|
385
|
+
onPublish={async (data) => {
|
|
386
|
+
await fetch("/my-api", {
|
|
387
|
+
method: "post",
|
|
388
|
+
body: JSON.stringify({ data }),
|
|
389
|
+
});
|
|
390
|
+
}}
|
|
391
|
+
// ...
|
|
392
|
+
/>
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### `overrides`
|
|
398
|
+
|
|
399
|
+
An [`Overrides`](/docs/api-reference/overrides) object defining custom render methods for various parts of the Puck UI.
|
|
400
|
+
|
|
401
|
+
```tsx
|
|
402
|
+
export function Editor() {
|
|
403
|
+
return (
|
|
404
|
+
<Puck
|
|
405
|
+
overrides={{
|
|
406
|
+
header: () => <div />,
|
|
407
|
+
}}
|
|
408
|
+
// ...
|
|
409
|
+
/>
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### `permissions`
|
|
415
|
+
|
|
416
|
+
Set the global [permissions](/docs/api-reference/permissions) for the Puck instance to toggle Puck functionality.
|
|
417
|
+
|
|
418
|
+
```tsx
|
|
419
|
+
export function Editor() {
|
|
420
|
+
return (
|
|
421
|
+
<Puck
|
|
422
|
+
permissions={{
|
|
423
|
+
delete: false, // Prevent deletion of all components
|
|
424
|
+
}}
|
|
425
|
+
// ...
|
|
426
|
+
/>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### `plugins`
|
|
432
|
+
|
|
433
|
+
An array of plugins to enhance Puck's behaviour. See the [Plugin API reference](/docs/api-reference/plugin).
|
|
434
|
+
|
|
435
|
+
```tsx
|
|
436
|
+
import headingAnalyzer from "@puckeditor/plugin-heading-analyzer";
|
|
437
|
+
|
|
438
|
+
export function Editor() {
|
|
439
|
+
return (
|
|
440
|
+
<Puck
|
|
441
|
+
plugins={[headingAnalyzer]}
|
|
442
|
+
// ...
|
|
443
|
+
/>
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### `ui`
|
|
449
|
+
|
|
450
|
+
Set the initial application UI state. See [`AppState.ui`](/docs/api-reference/data-model/app-state#ui).
|
|
451
|
+
|
|
452
|
+
```tsx
|
|
453
|
+
export function Editor() {
|
|
454
|
+
return (
|
|
455
|
+
<Puck
|
|
456
|
+
// Hide the left side bar by default
|
|
457
|
+
ui={{ leftSideBarVisible: false }}
|
|
458
|
+
// ...
|
|
459
|
+
/>
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### `viewports`
|
|
465
|
+
|
|
466
|
+
Configure the viewports available to the user, rendered as an iframe. Puck will select the most appropriate initial viewport based on the user's window size, unless otherwise specified via the [`ui`](#ui) prop.
|
|
467
|
+
|
|
468
|
+
```tsx
|
|
469
|
+
export function Editor() {
|
|
470
|
+
return (
|
|
471
|
+
<Puck
|
|
472
|
+
viewports={[
|
|
473
|
+
{
|
|
474
|
+
width: 1440,
|
|
475
|
+
},
|
|
476
|
+
]}
|
|
477
|
+
// ...
|
|
478
|
+
/>
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
#### Viewport params
|
|
484
|
+
|
|
485
|
+
| Param | Example | Type | Status |
|
|
486
|
+
| ------------------- | ----------------- | -------------------------------------------------------- | -------- |
|
|
487
|
+
| [`width`](#width) | `width: 1440` | number \| `"100%"` | Required |
|
|
488
|
+
| [`height`](#height) | `height: 968` | number \| `"auto"` | - |
|
|
489
|
+
| [`icon`](#icon) | `icon: "Monitor"` | `"Smartphone"` \| `"Tablet"` \| `"Monitor"` \| ReactNode | - |
|
|
490
|
+
| [`label`](#label) | `label: "iPhone"` | string | - |
|
|
491
|
+
|
|
492
|
+
##### `width`
|
|
493
|
+
|
|
494
|
+
The width of the viewport.
|
|
495
|
+
|
|
496
|
+
##### `height`
|
|
497
|
+
|
|
498
|
+
An optional height for the viewport. Defaults to `auto`, which will fit to the window.
|
|
499
|
+
|
|
500
|
+
##### `label`
|
|
501
|
+
|
|
502
|
+
An optional label for the viewport. This is used for browser tooltip.
|
|
503
|
+
|
|
504
|
+
##### `icon`
|
|
505
|
+
|
|
506
|
+
The icon to show in the viewport switcher. Can be:
|
|
507
|
+
|
|
508
|
+
- `"Smartphone"`
|
|
509
|
+
- `"Tablet"`
|
|
510
|
+
- `"Monitor"`
|
|
511
|
+
- ReactNode
|
|
512
|
+
|
|
513
|
+
Puck uses [Lucide icons](https://lucide.dev/icons/). You can use [lucide-react](https://lucide.dev/guide/packages/lucide-react) to choose a similar icon, if desired.
|
|
514
|
+
|
|
515
|
+
#### Default viewports
|
|
516
|
+
|
|
517
|
+
By default, Puck exposes small, medium and large viewports based on common viewport sizes.
|
|
518
|
+
|
|
519
|
+
```json
|
|
520
|
+
[
|
|
521
|
+
{
|
|
522
|
+
"width": 360,
|
|
523
|
+
"height": "auto",
|
|
524
|
+
"icon": "Smartphone",
|
|
525
|
+
"label": "Small"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"width": 768,
|
|
529
|
+
"height": "auto",
|
|
530
|
+
"icon": "Tablet",
|
|
531
|
+
"label": "Medium"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"width": 1280,
|
|
535
|
+
"height": "auto",
|
|
536
|
+
"icon": "Monitor",
|
|
537
|
+
"label": "Large"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"width": "100%",
|
|
541
|
+
"height": "auto",
|
|
542
|
+
"icon": "FullWidth",
|
|
543
|
+
"label": "Full-width"
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### `_experimentalFullScreenCanvas`
|
|
549
|
+
|
|
550
|
+
Use a full-screen mode for the Puck canvas, with a floating viewport switcher. **This param is experimental.**
|
|
551
|
+
|
|
552
|
+
```tsx
|
|
553
|
+
export function Editor() {
|
|
554
|
+
return (
|
|
555
|
+
<Puck
|
|
556
|
+
_experimentalFullScreenCanvas
|
|
557
|
+
// ...
|
|
558
|
+
/>
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# \<Render\>
|
|
2
|
+
|
|
3
|
+
Render a [`Data`](/docs/api-reference/data-model/data) object for a given [`Config`](/docs/api-reference/configuration/config).
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Render } from "@puckeditor/core";
|
|
7
|
+
|
|
8
|
+
export function Example() {
|
|
9
|
+
return <Render config={config} data={data} />;
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| Param | Example | Type | Status |
|
|
16
|
+
| ----------------------- | ---------------------------- | ------------------------------------------- | -------- |
|
|
17
|
+
| [`config`](#config) | `config: { components: {} }` | [Config](/docs/api-reference/config) | Required |
|
|
18
|
+
| [`data`](#data) | `data: {}` | [Data](/docs/api-reference/data-model/data) | Required |
|
|
19
|
+
| [`metadata`](#metadata) | `metadata: {}` | [Metadata](/docs/api-reference/metadata) | - |
|
|
20
|
+
|
|
21
|
+
## Required props
|
|
22
|
+
|
|
23
|
+
### `config`
|
|
24
|
+
|
|
25
|
+
An object describing the available components, fields and more. See the [`Config` docs](/docs/api-reference/configuration/config) for a full reference.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
export function Example() {
|
|
29
|
+
return (
|
|
30
|
+
<Render
|
|
31
|
+
config={{
|
|
32
|
+
components: {
|
|
33
|
+
HeadingBlock: {
|
|
34
|
+
fields: {
|
|
35
|
+
children: {
|
|
36
|
+
type: "text",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
render: ({ children }) => {
|
|
40
|
+
return <h1>{children}</h1>;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}}
|
|
45
|
+
// ...
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `data`
|
|
52
|
+
|
|
53
|
+
The data to render against the provided config. See the [`Data` docs](/docs/api-reference/data-model/data) for a full reference.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
export function Example() {
|
|
57
|
+
return (
|
|
58
|
+
<Render
|
|
59
|
+
data={{
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
props: { children: "Hello, world", id: "id" },
|
|
63
|
+
type: "HeadingBlock",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
root: {},
|
|
67
|
+
}}
|
|
68
|
+
// ...
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `metadata`
|
|
75
|
+
|
|
76
|
+
An object containing additional data provided to each component's [`render`](/docs/api-reference/configuration/component-config#renderprops) and [`resolveData`](/docs/api-reference/configuration/component-config#resolvedatadata-params) functions.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
export function Example() {
|
|
80
|
+
return (
|
|
81
|
+
<Render
|
|
82
|
+
metadata={{ title: "Hello, world" }}
|
|
83
|
+
config={{
|
|
84
|
+
HeadingBlock: {
|
|
85
|
+
render: ({ puck }) => {
|
|
86
|
+
return <h1>{puck.metadata.title}</h1>; // "Hello, world"
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}}
|
|
90
|
+
// ...
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|