-
Notifications
You must be signed in to change notification settings - Fork 3
/
aldryn_config.py
42 lines (33 loc) · 1.19 KB
/
aldryn_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from aldryn_client import forms
class Form(forms.BaseForm):
style_set = forms.CharField(
'The "styles definition set" to use in the editor',
required=False,
)
content_css = forms.CharField(
"List of CSS files to be used to apply style to editor content",
required=False,
)
def clean(self):
data = super().clean()
if data.get("content_css"):
files = data["content_css"].split(",")
data["content_css"] = [item.strip() for item in files if item]
return data
def to_settings(self, data, settings):
ckeditor_settings = {
"height": 300,
"language": "{{ language }}",
"toolbar": "CMS",
"skin": "moono-lisa",
}
if data.get("content_css"):
ckeditor_settings["contentsCss"] = data["content_css"]
else:
ckeditor_settings["contentsCss"] = ["/static/css/base.css"]
style_set = ""
if data.get("style_set"):
style_set = data["style_set"]
ckeditor_settings["stylesSet"] = f"default:{style_set}"
settings["CKEDITOR_SETTINGS"] = ckeditor_settings
return settings