@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,230 @@
|
|
|
1
|
+
# Rich Text Editing
|
|
2
|
+
|
|
3
|
+
Puck supports rich text editing via the [`richtext`](/docs/api-reference/fields/richtext) field.
|
|
4
|
+
|
|
5
|
+
## Adding a rich text field
|
|
6
|
+
|
|
7
|
+
To use rich text, add the `richtext` field to your component config:
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
const config = {
|
|
11
|
+
components: {
|
|
12
|
+
Example: {
|
|
13
|
+
fields: {
|
|
14
|
+
body: {
|
|
15
|
+
type: "richtext",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
render: ({ body }) => body,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Enabling inline editing
|
|
25
|
+
|
|
26
|
+
Set [`contentEditable`](/docs/api-reference/fields/richtext#contenteditable) to make the field editable inline:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
const config = {
|
|
30
|
+
components: {
|
|
31
|
+
Example: {
|
|
32
|
+
fields: {
|
|
33
|
+
body: {
|
|
34
|
+
type: "richtext",
|
|
35
|
+
contentEditable: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
render: ({ body }) => body,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Customizing behavior
|
|
45
|
+
|
|
46
|
+
The rich text field is built with [Tiptap](https://tiptap.dev), and comes with [several Tiptap extensions](/docs/api-reference/fields/richtext#included-extensions) pre-configured. Editor behavior can be customized by configuring these extensions.
|
|
47
|
+
|
|
48
|
+
### Disabling functionality
|
|
49
|
+
|
|
50
|
+
Disable any extension by setting it to `false` in [`options`](/docs/api-reference/fields/richtext#options):
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const config = {
|
|
54
|
+
components: {
|
|
55
|
+
Example: {
|
|
56
|
+
fields: {
|
|
57
|
+
body: {
|
|
58
|
+
type: "richtext",
|
|
59
|
+
options: {
|
|
60
|
+
// Disable bold extension
|
|
61
|
+
bold: false,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
render: ({ body }) => body,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Configuring extensions
|
|
72
|
+
|
|
73
|
+
Provide configuration options for the [included extensions](/docs/api-reference/fields/richtext#included-extensions) directly to `options` for further customization:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const config = {
|
|
77
|
+
components: {
|
|
78
|
+
Example: {
|
|
79
|
+
fields: {
|
|
80
|
+
body: {
|
|
81
|
+
type: "richtext",
|
|
82
|
+
options: {
|
|
83
|
+
// Restrict headings to h1 and h2
|
|
84
|
+
// https://tiptap.dev/docs/editor/extensions/nodes/heading
|
|
85
|
+
heading: { levels: [1, 2] },
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
render: ({ body }) => body,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Customizing the menu bar
|
|
96
|
+
|
|
97
|
+
Use [`renderMenu()`](/docs/api-reference/fields/richtext#rendermenuprops) to customize the menu bar layout using the [`<RichTextMenu>`](/docs/api-reference/components/rich-text-menu) component:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { RichTextMenu } from "@puckeditor/core";
|
|
101
|
+
|
|
102
|
+
const config = {
|
|
103
|
+
components: {
|
|
104
|
+
Example: {
|
|
105
|
+
fields: {
|
|
106
|
+
body: {
|
|
107
|
+
type: "richtext",
|
|
108
|
+
renderMenu: () => (
|
|
109
|
+
{/* Always wrap in <RichTextMenu> */}
|
|
110
|
+
<RichTextMenu>
|
|
111
|
+
{/* Group items in <RichTextMenu.Group> */}
|
|
112
|
+
<RichTextMenu.Group>
|
|
113
|
+
{/* Only include the bold control */}
|
|
114
|
+
<RichTextMenu.Bold />
|
|
115
|
+
</RichTextMenu.Group>
|
|
116
|
+
</RichTextMenu>
|
|
117
|
+
),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
render: ({ body }) => body,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
> **Note:** Hiding a control does not disable the functionality. Users can still use
|
|
127
|
+
> keyboard shortcuts and other input mechanisms. To disable functionality, use
|
|
128
|
+
> [`options`](/docs/api-reference/fields/richtext#options).
|
|
129
|
+
|
|
130
|
+
A full list of controls is available in the [included controls API reference](/docs/api-reference/components/rich-text-menu#included-controls).
|
|
131
|
+
|
|
132
|
+
## Adding custom extensions
|
|
133
|
+
|
|
134
|
+
### Configure the extension
|
|
135
|
+
|
|
136
|
+
Provide additional [Tiptap extensions](https://tiptap.dev/docs/editor/extensions/overview) to the [`tiptap.extensions`](/docs/api-reference/fields/richtext#tiptapextensions) parameter to introduce new functionality:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import Superscript from "@tiptap/extension-superscript";
|
|
140
|
+
|
|
141
|
+
const config = {
|
|
142
|
+
components: {
|
|
143
|
+
Example: {
|
|
144
|
+
fields: {
|
|
145
|
+
body: {
|
|
146
|
+
type: "richtext",
|
|
147
|
+
tiptap: {
|
|
148
|
+
extensions: [Superscript],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
render: ({ body }) => body,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Add a new control
|
|
159
|
+
|
|
160
|
+
If you're adding a control for a new extension, first update the [`tiptap.selector`](/docs/api-reference/fields/richtext#tiptapselector) to make the state available to the menu:
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import Superscript from "@tiptap/extension-superscript";
|
|
164
|
+
|
|
165
|
+
const config = {
|
|
166
|
+
components: {
|
|
167
|
+
Example: {
|
|
168
|
+
fields: {
|
|
169
|
+
body: {
|
|
170
|
+
type: "richtext",
|
|
171
|
+
tiptap: {
|
|
172
|
+
extensions: [Superscript],
|
|
173
|
+
selector: ({ editor }) => ({
|
|
174
|
+
isSuperscript: editor?.isActive("superscript"),
|
|
175
|
+
canSuperscript: editor?.can().chain().toggleSuperscript().run(),
|
|
176
|
+
}),
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
render: ({ body }) => body,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Then implement a new control with [`<RichTextMenu.Control>`](/docs/api-reference/components/rich-text-menu-control) and render it with `renderMenu()`:
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import Superscript from "@tiptap/extension-superscript";
|
|
190
|
+
import { Superscript } from "lucide-react";
|
|
191
|
+
import { RichTextMenu } from "@puckeditor/core";
|
|
192
|
+
|
|
193
|
+
const config = {
|
|
194
|
+
components: {
|
|
195
|
+
Example: {
|
|
196
|
+
fields: {
|
|
197
|
+
body: {
|
|
198
|
+
type: "richtext",
|
|
199
|
+
// ...
|
|
200
|
+
renderMenu: ({ children, editor, editorState }) => (
|
|
201
|
+
<RichTextMenu>
|
|
202
|
+
{/* Render the default controls */}
|
|
203
|
+
{children}
|
|
204
|
+
|
|
205
|
+
<RichTextMenu.Group>
|
|
206
|
+
<RichTextMenu.Control
|
|
207
|
+
icon={<Superscript />}
|
|
208
|
+
onClick={() =>
|
|
209
|
+
editor?.chain().focus().toggleSuperscript().run()
|
|
210
|
+
}
|
|
211
|
+
active={editorState?.isSuperscript}
|
|
212
|
+
disabled={!editorState?.canSuperscript}
|
|
213
|
+
/>
|
|
214
|
+
</RichTextMenu.Group>
|
|
215
|
+
</RichTextMenu>
|
|
216
|
+
),
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
render: ({ body }) => body,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Further reading
|
|
226
|
+
|
|
227
|
+
- [`richtext` field API reference](/docs/api-reference/fields/richtext)
|
|
228
|
+
- [`<RichTextMenu>` API reference](/docs/api-reference/components/rich-text-menu)
|
|
229
|
+
- [Tiptap Overview](https://tiptap.dev/docs/editor/getting-started/overview)
|
|
230
|
+
- [Tiptap Extensions](https://tiptap.dev/docs/editor/extensions/overview)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Root Configuration
|
|
2
|
+
|
|
3
|
+
The root is the top-level component within Puck. It:
|
|
4
|
+
|
|
5
|
+
1. Renders a single wrapper around your other components. This can be overwritten with a `render` function.
|
|
6
|
+
2. Stores meta data, like the page title. This can be extended with `fields`.
|
|
7
|
+
|
|
8
|
+
Configuring the root is similar to [configuring components](/docs/integrating-puck/component-configuration).
|
|
9
|
+
|
|
10
|
+
## The root `render` function
|
|
11
|
+
|
|
12
|
+
Use the [`root` parameter](/docs/api-reference/configuration/config#root) to specify a [`render` function](/docs/api-reference/configuration/component-config#renderprops):
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
const config = {
|
|
16
|
+
components: {
|
|
17
|
+
HeadingBlock: {
|
|
18
|
+
render: () => {
|
|
19
|
+
return <h1>Hello, world</h1>;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
root: {
|
|
24
|
+
render: ({ children }) => {
|
|
25
|
+
return <div>{children}</div>;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The root `render` function will wrap all of the components. `children` is a node containing the nested components.
|
|
32
|
+
|
|
33
|
+
If you don't render `children`, your components will not be rendered unless you define another [slot](/docs/api-reference/fields/slot).
|
|
34
|
+
|
|
35
|
+
### Example output
|
|
36
|
+
|
|
37
|
+
Given a minimal data payload containing one **HeadingBlock**
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"content": [
|
|
42
|
+
{
|
|
43
|
+
"type": "HeadingBlock",
|
|
44
|
+
"props": {
|
|
45
|
+
"id": "HeadingBlock-1234"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"root": {}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
the example config will render HTML nodes like this:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<!-- root render -->
|
|
57
|
+
<div>
|
|
58
|
+
<!-- HeadingBlock render -->
|
|
59
|
+
<h1>Hello, world</h1>
|
|
60
|
+
|
|
61
|
+
<!-- Remaining nodes -->
|
|
62
|
+
</div>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Adding fields
|
|
66
|
+
|
|
67
|
+
Root fields provide user input to the root render method, and can be used to store metadata.
|
|
68
|
+
|
|
69
|
+
By default, `root` is configured with a `title` text field:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
const config = {
|
|
73
|
+
// ...
|
|
74
|
+
root: {
|
|
75
|
+
render: ({ children, title }) => {
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
<h1>{title}</h1>
|
|
79
|
+
{children}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
You can override the default field configuration by providing custom [Fields](/docs/api-reference/fields) to the [`fields` parameter](/docs/api-reference/configuration/component-config#fields):
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
const config = {
|
|
91
|
+
// ...
|
|
92
|
+
root: {
|
|
93
|
+
fields: {
|
|
94
|
+
title: { type: "text" }, // You need to redefine the `title` field if we want to retain it
|
|
95
|
+
description: { type: "textarea" },
|
|
96
|
+
},
|
|
97
|
+
render: ({ children, title, description }) => {
|
|
98
|
+
return (
|
|
99
|
+
<div>
|
|
100
|
+
<h1>{title}</h1>
|
|
101
|
+
<p>{description}</p>
|
|
102
|
+
{children}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
When the user modifies the inputs, the editor will produce a data payload like this:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"content": [
|
|
115
|
+
// ...
|
|
116
|
+
],
|
|
117
|
+
"root": {
|
|
118
|
+
"props": {
|
|
119
|
+
"title": "Hello, world",
|
|
120
|
+
"description": "Lorem ipsum"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### TypeScript
|
|
127
|
+
|
|
128
|
+
Generic types can be passed to the `Config` type to strictly type your root configuration:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import type { Config } from "@puckeditor/core";
|
|
132
|
+
|
|
133
|
+
type RootProps = {
|
|
134
|
+
description: string;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const config: Config<{}, RootProps> = {
|
|
138
|
+
// ...
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Setting default props
|
|
143
|
+
|
|
144
|
+
Provide an object to the [`defaultProps`](/docs/api-reference/configuration/component-config#fields) parameter to configure default props for the root fields:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
const config = {
|
|
148
|
+
// ...
|
|
149
|
+
root: {
|
|
150
|
+
fields: {
|
|
151
|
+
title: { type: "text" },
|
|
152
|
+
description: { type: "textarea" },
|
|
153
|
+
},
|
|
154
|
+
defaultProps: {
|
|
155
|
+
title: "Hello, world",
|
|
156
|
+
description: "Lorem ipsum",
|
|
157
|
+
},
|
|
158
|
+
render: ({ children, title, description }) => {
|
|
159
|
+
return (
|
|
160
|
+
<div>
|
|
161
|
+
<h1>{title}</h1>
|
|
162
|
+
<p>{description}</p>
|
|
163
|
+
{children}
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Unlike [default parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters), `defaultProps` are stored in the data payload and will populate the Puck fields.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# React Server Components
|
|
2
|
+
|
|
3
|
+
Puck provides support for [React Server Components](https://react.dev/reference/react/use-server#use-server) (RSC), but the interactive-nature of Puck requires special consideration.
|
|
4
|
+
|
|
5
|
+
## Environments
|
|
6
|
+
|
|
7
|
+
### Server
|
|
8
|
+
|
|
9
|
+
Puck supports the server environment for the following APIs:
|
|
10
|
+
|
|
11
|
+
- The [`<Render>`](/docs/api-reference/components/render) component, for rendering pages produced by Puck
|
|
12
|
+
- The [`resolveAllData`](/docs/api-reference/functions/resolve-all-data) lib, for running all [data resolvers](/docs/integrating-puck/dynamic-props)
|
|
13
|
+
|
|
14
|
+
These APIs can be used in an RSC environment, but in order to do so the Puck config that they reference must be RSC-friendly.
|
|
15
|
+
|
|
16
|
+
This can be done by either avoiding client-only code (React `useState`, etc), or split out client components with the `"use client";` directive.
|
|
17
|
+
|
|
18
|
+
### Client
|
|
19
|
+
|
|
20
|
+
All other Puck APIs, including the core `<Puck>` component, cannot run in an RSC environment due to their high-degree of interactivity.
|
|
21
|
+
|
|
22
|
+
As these APIs render on the client, the Puck config provided must be safe for client-use, avoiding any server-specific logic.
|
|
23
|
+
|
|
24
|
+
## Implementations
|
|
25
|
+
|
|
26
|
+
Since the Puck config can be referenced on the client or the server, we need to consider how to satisfy both environments.
|
|
27
|
+
|
|
28
|
+
There are three approaches to this:
|
|
29
|
+
|
|
30
|
+
1. Avoid using any client-specific functionality (like React `useState`) in your components
|
|
31
|
+
2. Mark your components up with the `"use client";` directive if you need client-specific functionality
|
|
32
|
+
3. Create separate configs for client and server rendering
|
|
33
|
+
|
|
34
|
+
### 1. Avoid client-specific code
|
|
35
|
+
|
|
36
|
+
Avoiding client-specific code is the easiest way to support RSC across both environments, but may not be realistic for all users. This normally means avoiding React hooks like `useState` or `useContext`.
|
|
37
|
+
|
|
38
|
+
If you're using the legacy [`<DropZone>` component](/docs/api-reference/components/drop-zone), you will may encounter issues with server components. We recommend migrating to the [`slot` field](/docs/api-reference/fields/slot) which provides native server component support. Alternatively, see [our previous server components guide](https://puckeditor.com/v/0.18.3/docs/integrating-puck/server-components) for information on handling DropZones.
|
|
39
|
+
|
|
40
|
+
### 2. Marking up components with `"use client";`
|
|
41
|
+
|
|
42
|
+
Many modern component libraries will require some degree of client-side behaviour. For these cases, you'll need to mark them up with the `"use client";` directive.
|
|
43
|
+
|
|
44
|
+
To achieve this, you must import each of those component from a separate file:
|
|
45
|
+
|
|
46
|
+
File: `puck.config.tsx`
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import type { Config } from "@puckeditor/core";
|
|
50
|
+
import type { HeadingBlockProps } from "./components/HeadingBlock";
|
|
51
|
+
import HeadingBlock from "./components/HeadingBlock";
|
|
52
|
+
|
|
53
|
+
type Props = {
|
|
54
|
+
HeadingBlock: HeadingBlockProps;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const config: Config<Props> = {
|
|
58
|
+
components: {
|
|
59
|
+
HeadingBlock: {
|
|
60
|
+
fields: {
|
|
61
|
+
title: { type: "text" },
|
|
62
|
+
},
|
|
63
|
+
defaultProps: {
|
|
64
|
+
title: "Heading",
|
|
65
|
+
},
|
|
66
|
+
// You must call the component, rather than passing it in directly. This will change in the future.
|
|
67
|
+
render: ({ title }) => <HeadingBlock title={title} />,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
And add the `"use client";` directive to the top of each component file:
|
|
74
|
+
|
|
75
|
+
File: `components/HeadingBlock.tsx`
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
"use client";
|
|
79
|
+
|
|
80
|
+
import { useState } from "react";
|
|
81
|
+
|
|
82
|
+
export type HeadingBlockProps = {
|
|
83
|
+
title: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default ({ title }: { title: string }) => {
|
|
87
|
+
useState(); // useState fails on the server
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div style={{ padding: 64 }}>
|
|
91
|
+
<h1>{title}</h1>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This config can now be rendered inside an RSC component, such as a Next.js app router page:
|
|
98
|
+
|
|
99
|
+
File: `app/page.tsx`
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { config } from "../puck.config.tsx";
|
|
103
|
+
|
|
104
|
+
export default async function Page() {
|
|
105
|
+
const data = await getData(); // Some server function
|
|
106
|
+
|
|
107
|
+
const resolvedData = await resolveAllData(data, config); // Optional call to resolveAllData, if this needs to run server-side
|
|
108
|
+
|
|
109
|
+
return <Render data={resolvedData} config={config} />;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 3. Creating separate configs
|
|
114
|
+
|
|
115
|
+
Alternatively, consider entirely separate configs for the `<Puck>` and `<Render>` components. This approach can enable you to have different rendering behavior for a component for when it renders on the client or the server.
|
|
116
|
+
|
|
117
|
+
Create a shared config type:
|
|
118
|
+
|
|
119
|
+
File: `puck-types.ts`
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import type { Config } from "@puckeditor/core";
|
|
123
|
+
|
|
124
|
+
type Props = {
|
|
125
|
+
HeadingBlock: {
|
|
126
|
+
title: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type UserConfig = Config<Props>;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Define a client component config for use within the `<Puck>` component:
|
|
134
|
+
|
|
135
|
+
File: `puck.config.client.tsx`
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import type { UserConfig } from "./puck-types.ts";
|
|
139
|
+
|
|
140
|
+
export const config: UserConfig = {
|
|
141
|
+
components: {
|
|
142
|
+
HeadingBlock: {
|
|
143
|
+
fields: {
|
|
144
|
+
title: { type: "text" },
|
|
145
|
+
},
|
|
146
|
+
defaultProps: {
|
|
147
|
+
title: "Heading",
|
|
148
|
+
},
|
|
149
|
+
render: ({ title }) => {
|
|
150
|
+
useState(); // useState fails on the server
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<div style={{ padding: 64 }}>
|
|
154
|
+
<h1>{title}</h1>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Define a server config using the shared types for use within the `<Render>` component, excluding editor-only behaviour where possible but preserving any fields required for render-time transforms like [`richtext`](/docs/api-reference/fields/richtext) and [`slot`](/docs/api-reference/fields/slot):
|
|
164
|
+
|
|
165
|
+
File: `puck.config.server.tsx`
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import type { UserConfig } from "./puck-types.ts";
|
|
169
|
+
|
|
170
|
+
export const config: UserConfig = {
|
|
171
|
+
components: {
|
|
172
|
+
HeadingBlock: {
|
|
173
|
+
render: ({ title }) => {
|
|
174
|
+
return (
|
|
175
|
+
<div style={{ padding: 64 }}>
|
|
176
|
+
<h1>{title}</h1>
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Render the appropriate config depending on the environment. Here's a Next.js app router example of a server render:
|
|
186
|
+
|
|
187
|
+
File: `app/page.tsx`
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { config } from "../puck.config.server.tsx";
|
|
191
|
+
|
|
192
|
+
export default async function Page() {
|
|
193
|
+
const data = await getData(); // Some server function
|
|
194
|
+
|
|
195
|
+
return <Render data={data} config={config} />;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
If your server config omits those render-relevant fields entirely, Puck cannot infer which props should be transformed before render. In practice this means rich text will be escaped as plain strings, and slot data will not be converted into nested components.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Styling
|
|
2
|
+
|
|
3
|
+
Puck includes stylesheets for the interface. There are two types of styles:
|
|
4
|
+
|
|
5
|
+
1. Editor styles, for the editor interface
|
|
6
|
+
2. Preview styles, for the drag-and-drop canvas, isolated within an iframe
|
|
7
|
+
|
|
8
|
+
By default, Puck will load styles at runtime.
|
|
9
|
+
|
|
10
|
+
## Style isolation
|
|
11
|
+
|
|
12
|
+
Puck isolates the canvas using an iframe, automatically syncing stylesheets from the host application. It also provides APIs for fine-tuning behavior.
|
|
13
|
+
|
|
14
|
+
### Opting out of iframes
|
|
15
|
+
|
|
16
|
+
Opt-out of iframe rendering to completely disable preview isolation with [`iframe.enabled`](/docs/api-reference/components/puck#enabled):
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
export function Editor() {
|
|
20
|
+
return (
|
|
21
|
+
<Puck
|
|
22
|
+
iframe={{
|
|
23
|
+
enabled: false,
|
|
24
|
+
}}
|
|
25
|
+
// ...
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Note that this will also disable [viewports](/docs/integrating-puck/viewports).
|
|
32
|
+
|
|
33
|
+
### Disabling style sync
|
|
34
|
+
|
|
35
|
+
Disable iframe style sync using [`iframe.syncHostStyles`](/docs/api-reference/components/puck#synchoststyles):
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
export function Editor() {
|
|
39
|
+
return (
|
|
40
|
+
<Puck
|
|
41
|
+
iframe={{
|
|
42
|
+
syncHostStyles: false,
|
|
43
|
+
}}
|
|
44
|
+
// ...
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Puck will still inject preview styles for drag-and-drop behavior into the iframe.
|
|
51
|
+
|
|
52
|
+
### Injecting styles manually
|
|
53
|
+
|
|
54
|
+
Manually inject styles into the iframe using the [`iframe` override](/docs/api-reference/overrides/iframe):
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
const overrides = {
|
|
58
|
+
iframe: ({ children, document }) => {
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (document) {
|
|
61
|
+
document.body.setAttribute("style", "background: hotpink;");
|
|
62
|
+
}
|
|
63
|
+
}, [document]);
|
|
64
|
+
|
|
65
|
+
return <>{children}</>;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export function Editor() {
|
|
70
|
+
return (
|
|
71
|
+
<Puck
|
|
72
|
+
overrides={overrides}
|
|
73
|
+
// ...
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Learn more about overrides in [Extending Puck: UI Overrides](/docs/extending-puck/ui-overrides).
|
|
80
|
+
|
|
81
|
+
## Bundling CSS
|
|
82
|
+
|
|
83
|
+
By default, Puck loads styles client-side. This is fine for most use-cases, but can result in a flash of unstyled content ([FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content)).
|
|
84
|
+
|
|
85
|
+
### Avoiding FOUC
|
|
86
|
+
|
|
87
|
+
You can avoid FOUC by bundling `puck.css`:
|
|
88
|
+
|
|
89
|
+
```css
|
|
90
|
+
@import "@puckeditor/core/puck.css";
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
When bundling CSS, make sure you consider the impact on your production CSS bundle.
|
|
94
|
+
|
|
95
|
+
> **Note:** Note that this will result in Puck's editor styles being injected into the
|
|
96
|
+
> iframe unless you [disable style sync](#disabling-style-sync).
|
|
97
|
+
|
|
98
|
+
### Excluding external imports
|
|
99
|
+
|
|
100
|
+
Puck includes references to external font packages. Use the `no-external` CSS bundle to exclude them:
|
|
101
|
+
|
|
102
|
+
```css
|
|
103
|
+
/* @import "@puckeditor/core/puck.css"; */
|
|
104
|
+
@import "@puckeditor/core/no-external.css";
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Theming
|
|
108
|
+
|
|
109
|
+
Puck supports theming through CSS variables. See [Theming](/docs/extending-puck/theming) for more information.
|
|
110
|
+
|
|
111
|
+
## Further reading
|
|
112
|
+
|
|
113
|
+
- [`iframe` API reference](/docs/api-reference/components/puck#iframe)
|
|
114
|
+
- [`iframe` override](/docs/api-reference/overrides/iframe)
|
|
115
|
+
- [Theming](/docs/extending-puck/theming)
|
|
116
|
+
- [UI Overrides](/docs/extending-puck/ui-overrides)
|
|
117
|
+
- [Viewports](/docs/integrating-puck/viewports)
|