@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,133 @@
|
|
|
1
|
+
# Custom Fields
|
|
2
|
+
|
|
3
|
+
Puck can be extended with completely custom fields for different use-cases.
|
|
4
|
+
|
|
5
|
+
## Creating a custom field
|
|
6
|
+
|
|
7
|
+
Creating a custom field is possible using the [`custom` field type](/docs/api-reference/fields/custom):
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
const config = {
|
|
11
|
+
components: {
|
|
12
|
+
Example: {
|
|
13
|
+
fields: {
|
|
14
|
+
title: {
|
|
15
|
+
type: "custom",
|
|
16
|
+
render: ({ name, onChange, value }) => (
|
|
17
|
+
<input
|
|
18
|
+
defaultValue={value}
|
|
19
|
+
name={name}
|
|
20
|
+
onChange={(e) => onChange(e.currentTarget.value)}
|
|
21
|
+
style={{ border: "1px solid black", padding: 4 }}
|
|
22
|
+
/>
|
|
23
|
+
),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
render: ({ title }) => {
|
|
27
|
+
return <p>{title}</p>;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The [`onChange` function](/docs/api-reference/fields/custom#onchangevalue-ui) updates the Puck data payload for the field name, in this case "title".
|
|
35
|
+
|
|
36
|
+
## Adding a label
|
|
37
|
+
|
|
38
|
+
You can add your own label, but it's recommended to use the [`<FieldLabel>` component](/docs/api-reference/components/field-label) provided by Puck to seamlessly integrate into the Puck field UI.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { FieldLabel } from "@puckeditor/core";
|
|
42
|
+
|
|
43
|
+
const config = {
|
|
44
|
+
components: {
|
|
45
|
+
Example: {
|
|
46
|
+
fields: {
|
|
47
|
+
title: {
|
|
48
|
+
type: "custom",
|
|
49
|
+
label: "Label Example",
|
|
50
|
+
render: ({ field }) => (
|
|
51
|
+
<FieldLabel label={field.label}>
|
|
52
|
+
<input {/*...*/} />
|
|
53
|
+
</FieldLabel>
|
|
54
|
+
),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
// ...
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Rendering Puck fields internally
|
|
64
|
+
|
|
65
|
+
Use the [`<AutoField>` component](/docs/api-reference/components/auto-field) to render Puck fields within your custom field.
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { AutoField } from "@puckeditor/core";
|
|
69
|
+
|
|
70
|
+
const config = {
|
|
71
|
+
components: {
|
|
72
|
+
Example: {
|
|
73
|
+
fields: {
|
|
74
|
+
title: {
|
|
75
|
+
type: "custom",
|
|
76
|
+
label: "Label Example",
|
|
77
|
+
render: ({ field, value, onChange }) => (
|
|
78
|
+
<FieldLabel label={field.label}>
|
|
79
|
+
<AutoField
|
|
80
|
+
field={{ type: "text" }}
|
|
81
|
+
onChange={(value) => onChange(value)}
|
|
82
|
+
value={value}
|
|
83
|
+
/>
|
|
84
|
+
</FieldLabel>
|
|
85
|
+
),
|
|
86
|
+
},
|
|
87
|
+
// ...
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Updating the UI state
|
|
95
|
+
|
|
96
|
+
The [`onChange` function](/docs/api-reference/fields/custom#onchangevalue-ui) can also be used to modify the [Puck UI state](/docs/api-reference/data-model/app-state#ui) at the same time as updating the field value:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
const config = {
|
|
100
|
+
components: {
|
|
101
|
+
Example: {
|
|
102
|
+
fields: {
|
|
103
|
+
title: {
|
|
104
|
+
type: "custom",
|
|
105
|
+
render: ({ name, onChange, value }) => (
|
|
106
|
+
<input
|
|
107
|
+
defaultValue={value}
|
|
108
|
+
name={name}
|
|
109
|
+
onChange={(e) =>
|
|
110
|
+
onChange(
|
|
111
|
+
e.currentTarget.value,
|
|
112
|
+
// Close the left side bar when this field is changed
|
|
113
|
+
{ leftSideBarVisible: false }
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
style={{ border: "1px solid black", padding: 4 }}
|
|
117
|
+
/>
|
|
118
|
+
),
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
render: ({ title }) => {
|
|
122
|
+
return <p>{title}</p>;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Further reading
|
|
130
|
+
|
|
131
|
+
- [The `<AutoField>` API reference](/docs/api-reference/components/auto-field)
|
|
132
|
+
- [The `<FieldLabel>` API reference](/docs/api-reference/components/field-label)
|
|
133
|
+
- [The `custom` field API reference](/docs/api-reference/fields/custom)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Field Transforms
|
|
2
|
+
|
|
3
|
+
Puck lets you modify props before rendering in the editor via the [`FieldTransforms` API](/docs/api-reference/field-transforms).
|
|
4
|
+
|
|
5
|
+
Use this API to implement custom rendering behavior for specific field types, which can be used to implement features such as inline text editing.
|
|
6
|
+
|
|
7
|
+
> **Note:** Field transforms only apply to components rendered in `<Puck>` and will not be applied to `<Render>`.
|
|
8
|
+
|
|
9
|
+
## Implementing a transform
|
|
10
|
+
|
|
11
|
+
Specify a transforms object for the fields you want to modify before rendering:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
const fieldTransforms = {
|
|
15
|
+
text: ({ value }) => value.toUpperCase(), // Transform text fields to uppercase
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Example = () => <Puck fieldTransforms={fieldTransforms} />;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Making it interactive
|
|
22
|
+
|
|
23
|
+
Combine transforms with [Overlay Portals](/docs/integrating-puck/overlay-portals) to make them interactive.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { registerOverlayPortal } from "@puckeditor/core";
|
|
27
|
+
|
|
28
|
+
const EditableText = ({ value }) => {
|
|
29
|
+
const ref = useRef(null);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (ref.current) {
|
|
33
|
+
// Register the element as an overlay portal
|
|
34
|
+
registerOverlayPortal(ref.current);
|
|
35
|
+
}
|
|
36
|
+
}, [ref.current]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
// Mark the element as editable for inline text editing
|
|
40
|
+
<p ref={ref} contentEditable>
|
|
41
|
+
{value}
|
|
42
|
+
</p>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const fieldTransforms = {
|
|
47
|
+
text: (props) => <EditableText {...props} />,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const Example = () => <Puck fieldTransforms={fieldTransforms} />;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Because Puck calls transforms as functions, render components that use hooks from the transform instead of passing them directly.
|
|
54
|
+
|
|
55
|
+
## Define new fields
|
|
56
|
+
|
|
57
|
+
As with [field type overrides](/docs/extending-puck/ui-overrides#introducing-new-field-types), field transforms let you define your own field types:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
const fieldTransforms = {
|
|
61
|
+
example: () => <div />,
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Distributing field transforms as plugins
|
|
66
|
+
|
|
67
|
+
Distribute transforms as plugins to package up custom behavior.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
const plugin = {
|
|
71
|
+
fieldTransforms: {
|
|
72
|
+
example: ({ value }) => <div>{value}</div>, // Wrap all example fields with divs
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// This example combines transforms with overrides
|
|
76
|
+
overrides: {
|
|
77
|
+
fieldTypes: {
|
|
78
|
+
example: () => <input />, // Define a field interface
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const Example = () => <Puck plugins={[plugin]} />;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Further reading
|
|
87
|
+
|
|
88
|
+
- [Field Transforms API reference](/docs/api-reference/field-transforms)
|
|
89
|
+
- [Overlay Portals API reference](/docs/integrating-puck/overlay-portals)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Internal Puck API
|
|
2
|
+
|
|
3
|
+
Puck exposes its internal API as [`PuckApi`](/docs/api-reference/puck-api) for extending Puck with custom functionality within [custom fields](/docs/extending-puck/custom-fields), [compositional interfaces](/docs/extending-puck/composition) or [UI overrides](/docs/extending-puck/ui-overrides).
|
|
4
|
+
|
|
5
|
+
## Accessing the internal API
|
|
6
|
+
|
|
7
|
+
You can access [`PuckApi`](/docs/api-reference/puck-api) via two hooks:
|
|
8
|
+
|
|
9
|
+
- [`usePuck`](/docs/api-reference/functions/use-puck) - returns `PuckApi` as part of your component render lifecycle
|
|
10
|
+
- [`useGetPuck`](/docs/api-reference/functions/use-get-puck) - returns a function to access the latest `PuckApi` at call time
|
|
11
|
+
|
|
12
|
+
### Within the render lifecycle
|
|
13
|
+
|
|
14
|
+
To access the API within your render lifecycle, use the `usePuck` hook. You can use a selector to limit re-rendering to a specific part of the API.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { createUsePuck } from "@puckeditor/core";
|
|
18
|
+
|
|
19
|
+
const usePuck = createUsePuck();
|
|
20
|
+
|
|
21
|
+
const Example = () => {
|
|
22
|
+
// Use a selector so you only re-render when the selected type changes
|
|
23
|
+
const type = usePuck((s) => s.selectedItem?.type || "Nothing");
|
|
24
|
+
|
|
25
|
+
return <h2>{type} selected</h2>;
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
See the [`usePuck`](/docs/api-reference/functions/use-puck) docs for a full API reference.
|
|
30
|
+
|
|
31
|
+
### Outside of the render lifecycle
|
|
32
|
+
|
|
33
|
+
Often it's not necessary to re-render your component when the PuckApi changes. Puck provides the `useGetPuck` hook for accessing the latest `PuckApi` at call time.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { useGetPuck } from "@puckeditor/core";
|
|
37
|
+
|
|
38
|
+
const Example = () => {
|
|
39
|
+
const getPuck = useGetPuck();
|
|
40
|
+
|
|
41
|
+
const handleClick = useCallback(() => {
|
|
42
|
+
// Get the latest PuckApi value
|
|
43
|
+
const { appState } = getPuck();
|
|
44
|
+
|
|
45
|
+
console.log(appState);
|
|
46
|
+
}, [getPuck]);
|
|
47
|
+
|
|
48
|
+
return <button onClick={handleClick}>Click me</button>;
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
See the [`useGetPuck`](/docs/api-reference/functions/use-get-puck) docs for a full API reference.
|
|
53
|
+
|
|
54
|
+
## Usage in practice
|
|
55
|
+
|
|
56
|
+
Generally, you'll want to combine this with composition, UI overrides or custom fields.
|
|
57
|
+
|
|
58
|
+
Here's an example using the internal API to log the page data as JSON while retaining the standard Puck UI:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { Puck, createUsePuck } from "@puckeditor/core";
|
|
62
|
+
|
|
63
|
+
const usePuck = createUsePuck();
|
|
64
|
+
|
|
65
|
+
const JSONLogger = ({ children }) => {
|
|
66
|
+
const appState = usePuck((s) => s.appState);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
console.log(appState);
|
|
70
|
+
}, [appState]);
|
|
71
|
+
|
|
72
|
+
return <>{children}</>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export function Editor() {
|
|
76
|
+
return (
|
|
77
|
+
// Render the Puck context
|
|
78
|
+
<Puck>
|
|
79
|
+
<JSONLogger>
|
|
80
|
+
{/* Since we're overriding Puck's children, we restore the standard Puck UI */}
|
|
81
|
+
<Puck.Layout />
|
|
82
|
+
</JSONLogger>
|
|
83
|
+
</Puck>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Further reading
|
|
89
|
+
|
|
90
|
+
- [`PuckApi` API reference](/docs/api-reference/puck-api)
|
|
91
|
+
- [`usePuck` API reference](/docs/api-reference/functions/use-puck)
|
|
92
|
+
- [`useGetPuck` API reference](/docs/api-reference/functions/use-get-puck)
|
|
93
|
+
- [`<Puck.Layout>` API reference](/docs/api-reference/components/puck-layout)
|
|
94
|
+
- [Composition](/docs/extending-puck/composition)
|
|
95
|
+
- [Custom fields](/docs/extending-puck/custom-fields)
|
|
96
|
+
- [UI overrides](/docs/extending-puck/ui-overrides)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Plugin API
|
|
2
|
+
|
|
3
|
+
The [plugin API](/docs/api-reference/plugins) enables developers to share extensions to Puck.
|
|
4
|
+
|
|
5
|
+
Plugins can display dedicated UI in the **Plugin Rail** on the left-hand side of the screen (bottom on mobile), configure their own [overrides](/docs/extending-puck/ui-overrides), or apply [field transforms](/docs/extending-puck/field-transforms).
|
|
6
|
+
|
|
7
|
+
## Official plugins
|
|
8
|
+
|
|
9
|
+
### Core plugins
|
|
10
|
+
|
|
11
|
+
These plugins are included in the core package:
|
|
12
|
+
|
|
13
|
+
- [`blocks`](/docs/api-reference/plugins/blocks-plugin): show the component drawer for dragging components onto the canvas
|
|
14
|
+
- [`fields`](/docs/api-reference/plugins/fields-plugin): render the fields for the currently selected component
|
|
15
|
+
- [`outline`](/docs/api-reference/plugins/outline-plugin): display an outline of the current page structure
|
|
16
|
+
- [`legacy-side-bar`](/docs/api-reference/plugins/legacy-side-bar-plugin): disable the plugin rail in favor of stacked "Components" / "Outline" sections
|
|
17
|
+
|
|
18
|
+
### Enhancements
|
|
19
|
+
|
|
20
|
+
Puck provides official plugins that can be installed for common use-cases:
|
|
21
|
+
|
|
22
|
+
- [`ai`](https://puckeditor.com/docs/ai/overview): Use AI to generate pages using your own components.
|
|
23
|
+
- [`emotion-cache`](https://github.com/puckeditor/puck/tree/main/packages/plugin-emotion-cache): Inject emotion cache into the Puck iframe.
|
|
24
|
+
- [`heading-analyzer`](https://github.com/puckeditor/puck/tree/main/packages/plugin-heading-analyzer): Analyze the heading outline of your page and be warned when you're not respecting WCAG 2 accessibility standards.
|
|
25
|
+
|
|
26
|
+
Please see the [awesome-puck repo](https://github.com/puckeditor/awesome-puck) for a full list of community plugins.
|
|
27
|
+
|
|
28
|
+
## Loading a Plugin
|
|
29
|
+
|
|
30
|
+
To load a plugin, provide it to the [`plugins` prop](/docs/api-reference/components/puck#plugins) on the `<Puck>` component.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Puck } from "@puckeditor/core";
|
|
34
|
+
import myPlugin from "my-puck-plugin";
|
|
35
|
+
|
|
36
|
+
export function Editor() {
|
|
37
|
+
return (
|
|
38
|
+
<Puck
|
|
39
|
+
// ...
|
|
40
|
+
plugins={[myPlugin]}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Developing a Plugin
|
|
47
|
+
|
|
48
|
+
If you're familiar with Puck, you can likely already build a Puck plugin. See the [Plugin API reference](/docs/api-reference/plugins) for a full breakdown of available APIs.
|
|
49
|
+
|
|
50
|
+
### Rendering UI in the Plugin Rail
|
|
51
|
+
|
|
52
|
+
Plugins can render dedicated UI in a panel shown by the Plugin Rail. To add a plugin to the rail, create a new plugin and provide some parameters:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Coffee } from "lucide-react";
|
|
56
|
+
|
|
57
|
+
const myPlugin = {
|
|
58
|
+
name: "my-plugin", // Globally unique name
|
|
59
|
+
label: "My Plugin", // Human-readable name shown in the rail
|
|
60
|
+
icon: <Coffee />, // Icon shown in the rail (use lucide to match Puck)
|
|
61
|
+
render: () => <div>My plugin UI</div>, // Component rendered in plugin panel
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
You can leverage the [internal Puck API](/docs/extending-puck/internal-puck-api) to integrate Puck behavior with your plugin:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { Coffee } from "lucide-react";
|
|
69
|
+
import { createUsePuck } from "@puckeditor/core";
|
|
70
|
+
|
|
71
|
+
const usePuck = createUsePuck();
|
|
72
|
+
|
|
73
|
+
const myPlugin = {
|
|
74
|
+
name: "my-plugin",
|
|
75
|
+
label: "My Plugin",
|
|
76
|
+
icon: <Coffee />,
|
|
77
|
+
render: () => {
|
|
78
|
+
const type = usePuck((s) => s.selectedItem?.type || "Nothing");
|
|
79
|
+
|
|
80
|
+
return <h2>{type} selected</h2>;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Transforming fields
|
|
86
|
+
|
|
87
|
+
Plugins support [Field Transforms](/docs/extending-puck/field-transforms), enabling you to modify prop data before it's rendered in the `<Puck>` preview.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
const plugin = {
|
|
91
|
+
fieldTransforms: {
|
|
92
|
+
// Make all props powered by "text" field pink in the canvas
|
|
93
|
+
text: ({ value }) => <span style={{ color: "hotpink" }}>{value}</span>,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Overriding the UI
|
|
99
|
+
|
|
100
|
+
Plugins support [UI Overrides](/docs/extending-puck/ui-overrides), enabling you to override discrete section of the Puck interface.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
const plugin = {
|
|
104
|
+
overrides: {
|
|
105
|
+
// Make all drawer items pink
|
|
106
|
+
drawerItem: ({ name }) => <div style={{ color: "hotpink" }}>{name}</div>,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> **Note:** Override currying
|
|
112
|
+
>
|
|
113
|
+
> Plugin overrides are rendered in the order they are defined. Unless otherwise specified, all overrides are _curried_, meaning that the return node of one plugin will be passed as `children` to the next plugin.
|
|
114
|
+
>
|
|
115
|
+
> This may result in some incompatible plugin combinations. To improve your chance of building a widely compatible plugin, consider:
|
|
116
|
+
>
|
|
117
|
+
> 1. Implementing as few override methods as you need
|
|
118
|
+
> 2. Always rendering `children` if possible
|
|
119
|
+
|
|
120
|
+
### Introducing new field types
|
|
121
|
+
|
|
122
|
+
Both the field transforms and overrides let you introduce [entirely new field types](/docs/extending-puck/ui-overrides#introducing-new-field-types). Plugins can combine this functionality to bundle up new field behavior in a convenient package.
|
|
123
|
+
|
|
124
|
+
This example uses [Overlay Portals](/docs/extending-puck/overlay-portals) to create an interactive rich text field that can be modified directly in the editor preview.
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { useCallback } from "react";
|
|
128
|
+
import { registerOverlayPortal } from "@puckeditor/core";
|
|
129
|
+
|
|
130
|
+
const InlineRichText = ({ value }) => {
|
|
131
|
+
const handleInput = useCallback(() => {}, []); // Implement your input behavior
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
// Wrap the value in a span, create an overlay portal, and make it editable
|
|
135
|
+
<span ref={registerOverlayPortal} contentEditable onInput={handleInput}>
|
|
136
|
+
{value}
|
|
137
|
+
</span>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const plugin = {
|
|
142
|
+
overrides: {
|
|
143
|
+
// Add a richText field type
|
|
144
|
+
fieldTypes: {
|
|
145
|
+
richText: ({ name, value }) => <input name={name} value={value} />,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
fieldTransforms: {
|
|
149
|
+
// Make the richText field editable inline
|
|
150
|
+
richText: (props) => <InlineRichText {...props} />,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Further reading
|
|
156
|
+
|
|
157
|
+
- [Plugin API reference](/docs/api-reference/plugin)
|
|
158
|
+
- [FieldTransforms API reference](/docs/api-reference/field-transforms)
|
|
159
|
+
- [UI Overrides](/docs/extending-puck/ui-overrides)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Theming
|
|
2
|
+
|
|
3
|
+
Puck's default interface is styled with CSS custom properties (design tokens). You can override these tokens to create a custom theme that matches your brand or product, or to implement dark mode.
|
|
4
|
+
|
|
5
|
+
See the theming API reference for the full list of tokens:
|
|
6
|
+
|
|
7
|
+
- [Global tokens](/docs/api-reference/theming/global): Tokens that restyle the whole interface at once.
|
|
8
|
+
- [Action bar](/docs/api-reference/theming/action-bar): Tokens that style the action bar shown when selecting a component.
|
|
9
|
+
- [Button](/docs/api-reference/theming/button): Tokens that style the text buttons.
|
|
10
|
+
- [Canvas](/docs/api-reference/theming/canvas): Tokens that style the canvas preview area.
|
|
11
|
+
- [Drawer](/docs/api-reference/theming/drawer): Tokens that style the component drawer.
|
|
12
|
+
- [Fields](/docs/api-reference/theming/fields): Tokens that style the puck [fields](/docs/api-reference/fields).
|
|
13
|
+
- [Header](/docs/api-reference/theming/header): Tokens that style the editor header.
|
|
14
|
+
- [Icon button](/docs/api-reference/theming/icon-button): Tokens that style the icon buttons.
|
|
15
|
+
- [Outline](/docs/api-reference/theming/outline): Tokens that style the outline panel.
|
|
16
|
+
- [Plugin bar](/docs/api-reference/theming/plugin-bar): Tokens that style the side navigation for switching plugins.
|
|
17
|
+
- [Sidebar](/docs/api-reference/theming/sidebar): Tokens that style the left and right sidebar panels.
|
|
18
|
+
- [Slot](/docs/api-reference/theming/slot): Tokens that style the slots.
|
|
19
|
+
- [Computed values](/docs/api-reference/theming/computed-values): Tokens that define default computed values for all component-level tokens.
|
|
20
|
+
|
|
21
|
+
## Applying a theme
|
|
22
|
+
|
|
23
|
+
To apply a theme override the token you want in any element above the editor in the DOM tree:
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
@import "@puckeditor/core/puck.css";
|
|
27
|
+
|
|
28
|
+
.Container {
|
|
29
|
+
--puck-color-interactive: #0f5fff;
|
|
30
|
+
--puck-radius-m: 8px;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Global tokens
|
|
35
|
+
|
|
36
|
+
[Global tokens](/docs/api-reference/theming/global) restyle the whole interface at once, covering color, spacing, radius, motion and typography.
|
|
37
|
+
|
|
38
|
+
For example, to change the palette to match the interactive colors of your brand:
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
.Container {
|
|
42
|
+
--puck-color-interactive: #0d9488;
|
|
43
|
+
--puck-color-interactive-hover: #0f766e;
|
|
44
|
+
--puck-color-interactive-active: #115e59;
|
|
45
|
+
--puck-color-interactive-subtle: #ccfbf1;
|
|
46
|
+
--puck-color-interactive-soft: #f0fdfa;
|
|
47
|
+
--puck-color-interactive-soft-hover: #ccfbf1;
|
|
48
|
+
--puck-color-focus-ring: #14b8a6;
|
|
49
|
+
--puck-color-selection-bg: color-mix(in srgb, #14b8a6 20%, transparent);
|
|
50
|
+
--puck-color-selection-border: #14b8a6;
|
|
51
|
+
--puck-slot-component-color-placeholder: #99f6e4;
|
|
52
|
+
--puck-slot-component-color-border-dragging: #5eead4;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The [API reference](/docs/api-reference/theming/global) lists where each global token is used.
|
|
57
|
+
|
|
58
|
+
## Component tokens
|
|
59
|
+
|
|
60
|
+
When you need finer control, component tokens restyle a single part of the UI and override global tokens.
|
|
61
|
+
|
|
62
|
+
For example, to set the header and plugin bar background:
|
|
63
|
+
|
|
64
|
+
```css
|
|
65
|
+
.Container {
|
|
66
|
+
--puck-header-color-bg: #fff4e6;
|
|
67
|
+
--puck-pluginbar-color-bg: #fff4e6;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Load your own font file
|
|
72
|
+
|
|
73
|
+
By default, Puck loads the [Inter typeface family](https://rsms.me/inter/) from a CDN. To host your own copy of Inter, or load a different font file, switch Puck to the `no-external` runtime bundle:
|
|
74
|
+
|
|
75
|
+
```css
|
|
76
|
+
/* @import "@puckeditor/core/puck.css"; */
|
|
77
|
+
@import "@puckeditor/core/no-external.css";
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Going further
|
|
81
|
+
|
|
82
|
+
CSS tokens restyle the default interface. To change its behavior or visuals not covered by tokens, use the [composition](/docs/extending-puck/composition) or [UI overrides](/docs/extending-puck/ui-overrides) APIs.
|
|
83
|
+
|
|
84
|
+
## Further reading
|
|
85
|
+
|
|
86
|
+
- [Theming API reference](/docs/api-reference/theming)
|
|
87
|
+
- [Composition](/docs/extending-puck/composition)
|
|
88
|
+
- [UI overrides](/docs/extending-puck/ui-overrides)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# UI overrides
|
|
2
|
+
|
|
3
|
+
> **Note:** The overrides API is highly experimental and is likely to experience breaking
|
|
4
|
+
> changes.
|
|
5
|
+
|
|
6
|
+
Overrides allow you to change how Puck renders its default interface. It can be used with or without [composition](/docs/extending-puck/composition).
|
|
7
|
+
|
|
8
|
+
There are many different overrides available. See the [`overrides` API reference](/docs/api-reference/overrides) for the full list.
|
|
9
|
+
|
|
10
|
+
## Implementing an override
|
|
11
|
+
|
|
12
|
+
Use the [`overrides` prop](/docs/api-reference/components/puck#overrides) to implement an override:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Puck } from "@puckeditor/core";
|
|
16
|
+
|
|
17
|
+
export function Editor() {
|
|
18
|
+
return (
|
|
19
|
+
<Puck
|
|
20
|
+
// ...
|
|
21
|
+
overrides={{
|
|
22
|
+
// Render a custom element for each item in the component list
|
|
23
|
+
drawerItem: ({ name }) => (
|
|
24
|
+
<div style={{ backgroundColor: "hotpink" }}>{name}</div>
|
|
25
|
+
),
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Overriding field types
|
|
33
|
+
|
|
34
|
+
You can override all fields of certain type by specifying the [`fieldTypes` override](/docs/api-reference/overrides/field-types).
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { Puck } from "@puckeditor/core";
|
|
38
|
+
|
|
39
|
+
export function Editor() {
|
|
40
|
+
return (
|
|
41
|
+
<Puck
|
|
42
|
+
// ...
|
|
43
|
+
overrides={{
|
|
44
|
+
fieldTypes: {
|
|
45
|
+
// Override all text fields with a custom input
|
|
46
|
+
text: ({ name, onChange, value }) => (
|
|
47
|
+
<input
|
|
48
|
+
defaultValue={value}
|
|
49
|
+
name={name}
|
|
50
|
+
onChange={(e) => onChange(e.currentTarget.value)}
|
|
51
|
+
style={{ border: "1px solid black", padding: 4 }}
|
|
52
|
+
/>
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Introducing new field types
|
|
62
|
+
|
|
63
|
+
Specify new field types to expose new fields to your components.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { Puck } from "@puckeditor/core";
|
|
67
|
+
|
|
68
|
+
export function Editor() {
|
|
69
|
+
return (
|
|
70
|
+
<Puck
|
|
71
|
+
// ...
|
|
72
|
+
overrides={{
|
|
73
|
+
fieldTypes: {
|
|
74
|
+
myField: ({ name, onChange, value }) => <div />,
|
|
75
|
+
},
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
> **Note:** TypeScript consideration: When introducing new field types with
|
|
83
|
+
> TypeScript, you'll need to extend the available field types with the `fields`
|
|
84
|
+
> key in your `Config` type generic.
|
|
85
|
+
|
|
86
|
+
## Examples
|
|
87
|
+
|
|
88
|
+
### Custom publish button
|
|
89
|
+
|
|
90
|
+
A common use case is to override the Puck header. You can either use the [`header` override](/docs/api-reference/overrides/header) to change the entire header, or use the [`headerActions` override](/docs/api-reference/overrides/header-actions) to inject new controls into the header and change the publish button.
|
|
91
|
+
|
|
92
|
+
Here's an example that also leverage the [internal Puck API](/docs/extending-puck/internal-puck-api) to replace the default publish button with a custom one:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { Puck, createUsePuck } from "@puckeditor/core";
|
|
96
|
+
|
|
97
|
+
const usePuck = createUsePuck();
|
|
98
|
+
|
|
99
|
+
const save = () => {};
|
|
100
|
+
|
|
101
|
+
export function Editor() {
|
|
102
|
+
return (
|
|
103
|
+
<Puck
|
|
104
|
+
// ...
|
|
105
|
+
overrides={{
|
|
106
|
+
headerActions: ({ children }) => {
|
|
107
|
+
const appState = usePuck((s) => s.appState);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<>
|
|
111
|
+
<button
|
|
112
|
+
onClick={() => {
|
|
113
|
+
save(appState.data);
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
Save
|
|
117
|
+
</button>
|
|
118
|
+
|
|
119
|
+
{/* Render default header actions, such as the default Button */}
|
|
120
|
+
{/*{children}*/}
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
},
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Further reading
|
|
131
|
+
|
|
132
|
+
- [`overrides` API reference](/docs/api-reference/overrides)
|
|
133
|
+
- [Composition](/docs/extending-puck/composition)
|
|
134
|
+
- [Internal Puck API](/docs/extending-puck/internal-puck-api)
|