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

Adding "Custom Props" Type to Base Field Type #471

Open
OsamuBlack opened this issue May 8, 2024 · 1 comment
Open

Adding "Custom Props" Type to Base Field Type #471

OsamuBlack opened this issue May 8, 2024 · 1 comment

Comments

@OsamuBlack
Copy link

Puck editor allows us to override the individual fields using override -> fieldTypes. I have a small recommendation regarding this. Add custom props type to base field in the core/types.ts file like this.

type BaseField = {
    label?: string;
    customProps: {
      [key: string]: any;
    }
};

This allows users to extend the existing fields for all sorts of requirements. For example, a user can extend the text field to support email or URL sub-types.

email: {
    type: "text",
    label: "Title",
    customProps: {subType: "email"}
}

and use it in the overrides to apply their own implementations.

Puck already passes the field props to the overrides but you need to typecast the modified fields.

email: {
    type: "text",
    label: "Title",
    customProps: {subType: "email"}
} as TextField
@chrisvxd
Copy link
Member

chrisvxd commented May 9, 2024

Hi @OsamuBlack! Is there a reason you couldn't use custom field types for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants