Redactor inside Craft CMS is not applying format classes

906 Views Asked by At

I'm having trouble getting Craft 3 to apply the custom classes that I've created in my Standard.json file. I have set up the Redactor config in the Craft CP to use Standard.

My Standard.json file looks like this:

{
  "buttons": ["formatting", "bold", "italic", "unorderedlist", "orderedlist", 
  "link", "image", "video"],
  "plugins": ["fullscreen", "video"],
  "toolbarFixed": true,
  "formattingAdd": {
    "article-para": {
      "title": "Article Paragraph",
      "args": [
        "p",
        "class",
        "para"
      ]
    },
    "article-heading": {
      "title": "Article Heading",
      "args": [
        "h3",
        "class",
        "h2 txt-black mb"
      ]
    }
  }
}

Both Article Heading and Article Paragraph show up in my dropdown of formats, but when I select them, the elements don't change visually or in my inspector.

Any help would be appreciated.

1

There are 1 best solutions below

0
itsmattsoria On

Your json formatting appears to be off at the point that you set the args. Try this:

{
  "buttons": ["formatting", "bold", "italic", "unorderedlist", "orderedlist", 
  "link", "image", "video"],
  "plugins": ["fullscreen", "video"],
  "toolbarFixed": true,
  "formattingAdd": {
    "article-para": {
      "title": "Article Paragraph",
      "args": {
        "tag": "p",
        "class": "para"
      }
    },
    "article-heading": {
      "title": "Article Heading",
      "args": {
        "tag": "h3",
        "class": "h2 txt-black mb"
      }
    }
  }
}

That should do it.