Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APIs to restrict components passed to a DropZone #257

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

chrisvxd
Copy link
Member

@chrisvxd chrisvxd commented Nov 24, 2023

Introduces two new DropZone APIs:

  • allow - only allow these components to be dropped in the DropZone
  • disallow - allow all but these components to be dropped in the DropZone, unless it's specified by allow.

Example

import { DropZone } from "@measured/puck";
 
const config = {
  components: {
    Example: {
      render: () => {
        return (
          <div>
            <DropZone zone="my-content" allow={["HeadingBlock"]} />
          </div>
        );
      },
    },
  },
};

These APIs be combined with categories:

import { DropZone } from "@measured/puck";
 
const config = {
  config: {
    typography: {
      components: ["HeadingBlock"],
    },
  },
  components: {
    Example: {
      render: () => {
        return (
          <div>
            <DropZone zone="my-content" allow={config.typography.components} />
          </div>
        );
      },
    },
  },
};

Closes #103, closes #185

Copy link

vercel bot commented Nov 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
puck-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 24, 2023 11:06am
puck-docs ✅ Ready (Inspect) Visit Preview Nov 24, 2023 11:06am

@chrisvxd chrisvxd merged commit 28f24f9 into main Nov 27, 2023
2 checks passed
@chrisvxd chrisvxd deleted the restrict-dropzones-by-tag branch November 27, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant