Custom style in Rich Text doesn't work everywhere

Hello,

I don't understand why my custom style in the Rich Text editor in one slice section of my website is not reachable, but is reachable in another section.

I have this config:

   {
      "id": "introWithRichText",
      "name": "Intro avec texte riche",
      "docURL": "...",
      "version": "initial",
      "description": "Default",
      "imageUrl": "",
      "primary": {
        "title": {
          "type": "StructuredText",
          "config": {
            "label": "Title",
            "placeholder": "",
            "allowTargetBlank": false,
            "single": "heading2",
            "labels": ["btn"]
          }
        },
[...]

When it works:

When it doesn't work:

Thanks a lot for your help,

David

Hi @dgourdet,

Would you mind recording a Jam of this behavior so we have more information on what's happening here? It'd be helpful to have eyes on where it works and where it doesn't, to help us troubleshoot. If you don't want to post the Jam publicly on the forum, you can message it to me privately :slight_smile:

Thanks for the Jam!

I believe you need to allow some more formatting options for your rich text field in the Slice Machine. A rich text field with more options than just heading2 for example would have this in its model.json:

"single": "paragraph,preformatted,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl"

And the editing toolbar would pop up then, to allow you to choose which styles you'd like to apply to the text.

Whereas you only have:

"single": "heading2"

Your other rich text field example is probably configured differently. You can read more about this here: Edit Rich Text - Documentation - Prismic and here: Fields - Documentation - Prismic :slight_smile:

Let me know if I can clarify anything else for you!

Thanks a lot for your quick reply @Ezekiel !
I'm gonna try this!

1 Like

Sorry @Ezekiel, I don't know why I spoke about "Rich text" because the concerned fields are simple "Text" ("StructuredText") fields.

In fact, it works inside a custom type with this configuration:

          "fields": {
            "title": {
              "type": "StructuredText",
              "config": {
                "label": "Title",
                "placeholder": "",
                "allowTargetBlank": false,
              "single": "heading2,em",
                "labels": ["btn"]
              }
            },

but not inside a slice with this configuration:

        "title": {
          "type": "StructuredText",
          "config": {
            "label": "Title",
            "placeholder": "",
            "allowTargetBlank": false,
            "single": "heading2",
            "labels": ["btn"]
          }
        },

I've tried to add "em" in the "single" property like this:
"single": "heading2,em",
but it didn't work.

Hey @dgourdet, you need to add these options in the Slice Machine and push those changes for it to work, sorry if I was unclear.

Like here:

Selecting those will define what is in that property :slight_smile:

Thanks a lot Ezekiel!
This is working now!
So if I recap a bit, in order to get my custom style working, I need 2 things:

  • I need more formatting options for my text field than just a heading
  • Obviously, I need to push these options (that said, I totally forgot :grinning_face:)
1 Like

Exactly, you got that right :slight_smile:

1 Like