Skip to content

Commit 6a76c81

Browse files
authored
fix: Ensure styles are loaded for text-enabled dialog (#17)
1 parent 091239e commit 6a76c81

File tree

12 files changed

+175
-190
lines changed

12 files changed

+175
-190
lines changed

djangocms_text/cms_plugins.py

+9-17
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
import operator
33
import re
44

5-
from cms.utils import get_language_from_request
65
from django.apps import apps
76
from django.contrib.admin.utils import unquote
87
from django.core import signing
98
from django.core.exceptions import PermissionDenied, ValidationError
109
from django.db import transaction
1110
from django.forms.fields import CharField
1211
from django.http import (
13-
Http404,
14-
HttpResponse,
15-
HttpResponseBadRequest,
16-
HttpResponseForbidden,
17-
HttpResponseRedirect, JsonResponse,
12+
Http404, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, JsonResponse,
1813
)
1914
from django.shortcuts import get_object_or_404
2015
from django.template import RequestContext
@@ -26,12 +21,16 @@
2621
from django.views.decorators.http import require_POST
2722

2823
from cms.models import CMSPlugin, Page
24+
from cms.utils import get_language_from_request
25+
26+
from .settings import TEXT_CHILDREN_ENABLED
2927

3028

3129
try:
3230
from cms.models import PageContent
3331
except ImportError:
3432
from cms.models import Title as PageContent
33+
3534
from cms.plugin_base import CMSPluginBase
3635
from cms.plugin_pool import plugin_pool
3736
from cms.utils.placeholder import get_placeholder_conf
@@ -42,15 +41,8 @@
4241
from .html import render_dynamic_attributes
4342
from .models import Text
4443
from .utils import (
45-
OBJ_ADMIN_WITH_CONTENT_RE_PATTERN,
46-
_plugin_tags_to_html,
47-
cms_placeholder_add_plugin,
48-
plugin_tags_to_admin_html,
49-
plugin_tags_to_id_list,
50-
plugin_tags_to_user_html,
51-
plugin_to_tag,
52-
random_comment_exempt,
53-
replace_plugin_tags,
44+
OBJ_ADMIN_WITH_CONTENT_RE_PATTERN, _plugin_tags_to_html, cms_placeholder_add_plugin, plugin_tags_to_admin_html,
45+
plugin_tags_to_id_list, plugin_tags_to_user_html, plugin_to_tag, random_comment_exempt, replace_plugin_tags,
5446
)
5547
from .widgets import TextEditorWidget, rte_config
5648

@@ -572,7 +564,7 @@ def get_child_plugin_candidates(cls, slot, page):
572564
page=page,
573565
)
574566
# Filter out plugins that are not in the whitelist if given
575-
if settings.TEXT_CHILDREN_WHITELIST:
567+
if settings.TEXT_CHILDREN_WHITELIST is not None:
576568
text_enabled_plugins = [
577569
plugin
578570
for plugin in text_enabled_plugins
@@ -597,7 +589,7 @@ def render_plugin_icon(self, plugin):
597589

598590
def get_plugins(self, obj=None):
599591
plugin = getattr(self, "cms_plugin_instance", None) or obj
600-
if not plugin:
592+
if not plugin or not TEXT_CHILDREN_ENABLED:
601593
return []
602594
get_plugin = plugin_pool.get_plugin
603595
child_plugin_types = self.get_child_classes(

djangocms_text/cms_toolbars.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class IconButton(Button):
2121
class InlineEditingToolbar(CMSToolbar):
2222
@property
2323
def media(self):
24-
if self.toolbar.edit_mode_active and self.inline_editing:
24+
if self.toolbar.edit_mode_active:
2525
return forms.Media(
2626
css={
2727
**rte_config.css,
@@ -33,7 +33,7 @@ def media(self):
3333
js=(
3434
static("djangocms_text/bundles/bundle.editor.min.js"),
3535
*(static(js) for js in rte_config.js),
36-
),
36+
) if self.inline_editing else (),
3737
)
3838
return forms.Media()
3939

djangocms_text/contrib/text_ckeditor4/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from djangocms_text.editors import RTEConfig
22

3+
34
ckeditor4 = RTEConfig(
45
name="ckeditor4",
56
config="CKEDITOR",

djangocms_text/contrib/text_ckeditor5/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from djangocms_text.editors import RTEConfig
22

3+
34
ckeditor5 = RTEConfig(
45
name="ckeditor5",
56
config="CKEDITOR5",

djangocms_text/editors.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
from typing import Iterable, Optional
22

33
from django.conf import settings
4-
5-
6-
from django.utils.translation import gettext_lazy as _
7-
8-
from django.utils.functional import Promise
9-
from django.utils.encoding import force_str
104
from django.core.serializers.json import DjangoJSONEncoder
5+
from django.utils.encoding import force_str
6+
from django.utils.functional import Promise
7+
from django.utils.translation import gettext_lazy as _
118

129

1310
class LazyEncoder(DjangoJSONEncoder):

djangocms_text/html.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
from copy import deepcopy
77
from typing import Optional, Union
88

9-
import nh3
109
from django.apps import apps
11-
from lxml import etree
12-
1310
from django.db import models
1411

12+
import nh3
13+
from lxml import etree
1514
from lxml.etree import Element
1615

1716
from . import settings

djangocms_text/models.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010

1111
from . import settings
1212
from .html import clean_html, extract_images
13-
from .utils import (
14-
plugin_tags_to_db,
15-
plugin_tags_to_id_list,
16-
plugin_to_tag,
17-
replace_plugin_tags,
18-
)
13+
from .utils import plugin_tags_to_db, plugin_tags_to_id_list, plugin_to_tag, replace_plugin_tags
1914

2015

2116
try:

djangocms_text/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141

4242
TEXT_INLINE_EDITING = getattr(settings, "TEXT_INLINE_EDITING", False)
4343
TEXT_CHILDREN_ENABLED = getattr(settings, "TEXT_CHILDREN_ENABLED", True)
44-
TEXT_CHILDREN_WHITELIST = getattr(settings, "TEXT_CHILDREN_WHITELIST", [])
44+
TEXT_CHILDREN_WHITELIST = getattr(settings, "TEXT_CHILDREN_WHITELIST", None)
4545
TEXT_CHILDREN_BLACKLIST = getattr(settings, "TEXT_CHILDREN_BLACKLIST", [])

djangocms_text/static/djangocms_text/css/cms.text.css

+152
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,155 @@
1616
display: none;
1717
}
1818
}
19+
20+
21+
#cms-top dialog.cms-dialog {
22+
padding: 0;
23+
resize: both;
24+
top: 50%;
25+
left: 50%;
26+
inset-inline-start: 50%;
27+
inset-inline-end: unset;
28+
transform: translate(calc(-50% + 250px), calc(-50% + 121px));
29+
width: 32rem;
30+
height: 24rem;
31+
min-height: 16rem;
32+
min-width: 16rem;
33+
.cms-modal-foot {
34+
margin-inline-end: 1rem;
35+
.cms-modal-buttons {
36+
padding-inline-end: 10px;
37+
}
38+
}
39+
.cms-modal-body iframe {
40+
width: 100%;
41+
height: 100%;
42+
border: none;
43+
}
44+
}
45+
46+
[dir="rtl"] dialog.cms-dialog {
47+
inset-inline-start: unset;
48+
inset-inline-end: 50%;
49+
}
50+
51+
dialog.cms-form-dialog {
52+
&::before {
53+
position: absolute;
54+
background: var(--dca-white);
55+
border: 1px solid var(--dca-gray-light);
56+
box-shadow: 0 0 10px rgba(var(--dca-shadow), .25);
57+
height: 10px;
58+
width: 10px;
59+
left: 24px;
60+
top: 8px;
61+
transform: rotate(-135deg);
62+
transform-origin: 0 0;
63+
content: "";
64+
}
65+
&.right::before {
66+
right: 24px;
67+
left: auto;
68+
}
69+
&::after {
70+
position: absolute;
71+
background: var(--dca-white);
72+
height: 10px;
73+
left: 10px;
74+
top: 0;
75+
width: 40px;
76+
content: "";
77+
}
78+
&.right::after {
79+
right: 10px;
80+
left: auto;
81+
}
82+
.dropback {
83+
position: fixed;
84+
top: 0;
85+
left: 0;
86+
width: 100%;
87+
height: 100%;
88+
z-index: -1;
89+
cursor: unset; /* browser default */
90+
}
91+
z-index: 1001;
92+
position: fixed;
93+
margin: unset;
94+
left: auto;
95+
transform: translate(-50%, -50%);
96+
min-width: 200px;
97+
padding: 10px 15px;
98+
background-color: var(--dca-white);
99+
border: 1px solid var(--dca-gray-light);
100+
border-radius: 5px;
101+
box-shadow: 0 0 10px rgba(var(--dca-shadow), .25);
102+
form {
103+
display: flex;
104+
flex-flow: row;
105+
justify-content: space-between;
106+
align-content: baseline;
107+
align-items: center;
108+
}
109+
.cancel {
110+
display: inline-flex;
111+
color: #f00;
112+
margin-left: 0.5em;
113+
margin-right: 0.5em;
114+
cursor: pointer;
115+
}
116+
.submit {
117+
display: inline-flex;
118+
color: #693;
119+
cursor: pointer;
120+
}
121+
}
122+
123+
124+
form.cms-form {
125+
display: flex;
126+
flex-flow: row;
127+
justify-content: space-between;
128+
align-content: baseline;
129+
align-items: center;
130+
text-align: start;
131+
zoom: 1;
132+
input, select {
133+
min-width: 200px;
134+
width: 100%;
135+
margin-bottom: 3px;
136+
font-size: 0.8rem;
137+
min-height: 1rem;
138+
line-height: unset;
139+
height: unset;
140+
padding: 3px 6px !important;
141+
}
142+
select { /* !important for djangocms-admin-style */
143+
background: var(--dca-white) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="16" fill="%23808080" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg>') no-repeat right center !important;
144+
background-size: auto 1em !important;
145+
appearance: none;
146+
}
147+
label {
148+
font-size: 0.7rem;
149+
padding-bottom: 4px;
150+
}
151+
hr {
152+
margin: 0.3em -1em;
153+
}
154+
.cms-form-buttons {
155+
display: inline-flex;
156+
margin-inline-start: 1em;
157+
.cancel {
158+
color: #f00;
159+
cursor: pointer;
160+
zoom: 1.2;
161+
}
162+
.submit {
163+
margin-left: 0.5em;
164+
margin-right: 0.5em;
165+
color: #693;
166+
cursor: pointer;
167+
zoom: 1.2;
168+
}
169+
}
170+
}

djangocms_text/widgets.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from cms.utils.urlutils import admin_reverse, static_with_version
1515

1616
from . import settings as text_settings
17-
from .editors import DEFAULT_TOOLBAR_CMS, DEFAULT_TOOLBAR_HTMLField, LazyEncoder, get_editor_base_config
18-
from .editors import get_editor_config
17+
from .editors import (
18+
DEFAULT_TOOLBAR_CMS, DEFAULT_TOOLBAR_HTMLField, LazyEncoder, get_editor_base_config, get_editor_config,
19+
)
1920
from .utils import cms_placeholder_add_plugin
2021

2122

0 commit comments

Comments
 (0)