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

[portable-text] Allow customization of user-defined styles #373

Closed
thomax opened this issue Nov 22, 2017 · 5 comments
Closed

[portable-text] Allow customization of user-defined styles #373

thomax opened this issue Nov 22, 2017 · 5 comments
Assignees

Comments

@thomax
Copy link
Contributor

thomax commented Nov 22, 2017

When defining your own styles, e.g.

{
  title: 'Block',
  type: 'block',
  styles: [
    {title: 'Normal', value: 'normal'},
    {title: 'H1', value: 'h1'},
    {title: 'Protip', value: 'protip'}
  ]
}

The dropdown will render the Proptip choice, but you have no control over:

  1. What your choice in the dropdown meny looks like
  2. How Slate applies styling to your block. At the moment, there is no visual cue at all in the editable text that a custom style has been applied.

I'm not sure what the best solution would be. Maybe custom styles could accept custom components for rendering?

For example:

{
  title: 'Block',
  type: 'block',
  styles: [
    {title: 'Normal', value: 'normal'},
    {title: 'H1', value: 'h1'},
    {
      title: 'Protip',
      value: 'protip',
      preview: {
        menuComponent: myReactComponent,
        editorComponent: myOtherReactComponent,        
      } 
  ]
}
@ghost
Copy link

ghost commented Jun 28, 2020

Offering a separate menu and editor preview override would be a great addition for scenarios where the style is very large. Would be great to create a smaller version of a style so the dropdown menu doesn't get too crazy. On a related note, I created a separate feature request for the separation of the HTML element from the style itself: #1929.

@rexxars rexxars changed the title [form-builder] Allow customization of user-defined styles [portable-text] Allow customization of user-defined styles Feb 11, 2021
@dwkns
Copy link

dwkns commented Sep 7, 2022

Is this going to make it into V3?

@kmelve
Copy link
Member

kmelve commented Jan 12, 2023

I believe this is solved with the component property. Closing this for now.

@kmelve kmelve closed this as completed Jan 12, 2023
@troymcginnis
Copy link

@kmelve This is still an issue for me on v3 using the component property.

Can you verify?

@essejmclean
Copy link

Hi - I highly recommend that this issue be opened again as previewing text block styles in the BlockStyleSelect.tsx does not appear to work or be supported in Sanity v3 with the component method.

The documentation says it works (https://www.sanity.io/docs/customizing-the-portable-text-editor#14d3f8b767ae) though the code appears to say otherwise.

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

No branches or pull requests