Custom labels for RichText

Hello, everyone!

I'm playing around with slice machine and love it.

I was trying to add custom labels to richtext inside model.json file but get error when trying to push to prismic.

Original

    "description": {
      "type": "StructuredText",
      "config": {
        "multi" : "paragraph, preformatted, heading2, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item",
        "label": "Description",
        "placeholder": "A nice description of your feature"
      }
    },

with labels

          "description" : {
            "type" : "StructuredText",
            "config" : {
              "multi" : "paragraph, preformatted, heading2, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item",
              "allowTargetBlank" : true,
              "label" : "Description",
              "labels" : {
                "" : [ {
                  "name" : "lg-paragraph"
                }, {
                  "name" : "sm-paragraph"
                } ]
              }
            }
          }

It works perfectly fine with slices created inside prismic dashboard.

Big thanks in advance :heart:

Edit: Code formation
Edit2 : Typo

Thanks for posting us. I find that configuration of labels field should be an array not an object.
Please find more details here.

 "description" : {
            "type" : "StructuredText",
            "config" : {
              "multi" : "paragraph, preformatted, heading2, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item",
              "allowTargetBlank" : true,
              "label" : "Description",
              "labels" :  ["lg-paragraph", "sm-paragraph"]
            }
          }

It’s working in this structure. Give this a try and let me know if you have any doubt.

Thanks,
Priyanka

Thank you @Priyanka using array it works as expected. :smile:

I have no idea why it works inside my old slice like this. :smiley: Gonna update this slice too.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.