To use ClassLoom in a Django model field, include it in the extensions dictionary of a ProseEditorField. You must define a groups object where each key represents a menu group.
To make the ClassLoom buttons visible in the editor UI, you must also integrate them into the Menu extension configuration by referencing them with the prefix classLoom:<key>.
Note on Menu Integration: Each group produces a dropdown named classLoom:<key>. Add these to your Menu configuration to display the buttons. Each dropdown includes a default entry to clear all classes in that group, plus an entry for each defined class.
content = ProseEditorField(
extensions={
"Bold": True,
"Italic": True,
"Table": True,
"ClassLoom": {
"groups": {
"tableStyles": {
"title": "Table style",
"type": "table",
"classes": [
{"className": "table--bordered", "title": "Bordered"},
{"className": "table--striped", "title": "Striped"},
],
},
"emphasisStyles": {
"title": "Emphasis style",
"type": "italic",
"classes": ["theme-color", "grey-color"],
},
"textDecoration": {
"title": "Text decoration",
"type": "text",
"combinable": True,
"classes": [
{"className": "color--primary", "title": "Primary colour"},
{"className": "underline--dashed", "title": "Dashed underline"},
],
},
},
},
"Menu": {
"groups": [
{"group": "blockType -lists", "type": "dropdown", "minItems": 2},
{"group": "lists"},
{"group": "nodes -blockType -lists"},
{"group": "marks"},
{"group": "classLoom:emphasisStyles", "type": "dropdown"},
{"group": "classLoom:textDecoration", "type": "dropdown"},
{"group": "link"},
{"group": "table"},
{"group": "classLoom:tableStyles", "type": "dropdown"},
{"group": "history"},
{"group": "utility"},
],
},
},
)