How to modify django-ckeditor inline styles?

1.8k views Asked by At

Using django-ckeditor==4.4.6, how can I override the built-in ckeditor styles.js file to add some margins to the default object styles like the one listed below?

{
name: 'Styled image (left)',
element: 'img',
attributes: { 'class': 'left', 'margin-right': '1em' }
},

I don't want to directly modify the core styles.js file, but I'm guessing that maybe I can override it using Django's app template inheritance/override functionality?

Or can I somehow feed in a js plugin that contains the above style declaration?

1

There are 1 answers

0
Loscho19 On

With "stylesSet"

{
    "default": {
        "format_tags": "h1;h2;h3;h4;p",
        "toolbar": "Custom",
        "toolbar_Custom": [
            [
                "Format",
                "Styles",
                "RemoveFormat",
                "-",
                "Bold",
                "Italic",
                "Subscript",
                "Superscript",
                "-",
                "BulletedList",
                "NumberedList",
                "-",
                "Link",
                "Unlink",
                "Anchor",
            ],
        ],
        "stylesSet": [
            {"name": "Lead Text", "element": "p", "attributes": {"class": "lead"}},
            {
                "name": "Marker: Yellow",
                "element": "span",
                "styles": {"background-color": "Yellow"},
            },
        ],
    }
}