Skip to content

Commit 1c396f5

Browse files
committed
Put id and class on holder
1 parent 5ea53fb commit 1c396f5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

django_editorjs_fields/widgets.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def __init__(self, plugins=None, tools=None, config=None, **kwargs):
1313
self.tools = tools
1414
self.config = config
1515

16-
widget = kwargs.pop('widget', None) # Fix "__init__() got an unexpected keyword argument 'widget'"
16+
# Fix "__init__() got an unexpected keyword argument 'widget'"
17+
widget = kwargs.pop('widget', None)
1718
if widget:
1819
self.plugins = widget.plugins
1920
self.tools = widget.tools
@@ -71,14 +72,14 @@ def render(self, name, value, attrs=None, renderer=None):
7172
html = super().render(name, value, attrs)
7273

7374
html += '''
74-
<div data-editorjs-holder></div>
75+
<div data-editorjs-holder id="%(id)s_editorjs_holder" class="editorjs-holder"></div>
7576
<script defer>
7677
addEventListener('DOMContentLoaded', function () {
77-
initEditorJsField('%s', %s);
78+
initEditorJsField('%(id)s', %(config)s);
7879
})
79-
</script>''' % (
80-
attrs.get('id'),
81-
json.dumps(self.configuration()),
82-
)
80+
</script>''' % {
81+
'id': attrs.get('id'),
82+
'config': json.dumps(self.configuration()),
83+
}
8384

8485
return mark_safe(html)

0 commit comments

Comments
 (0)