Skip to content

Put id and class on holder #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions django_editorjs_fields/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def __init__(self, plugins=None, tools=None, config=None, **kwargs):
self.tools = tools
self.config = config

widget = kwargs.pop('widget', None) # Fix "__init__() got an unexpected keyword argument 'widget'"
# Fix "__init__() got an unexpected keyword argument 'widget'"
widget = kwargs.pop('widget', None)
if widget:
self.plugins = widget.plugins
self.tools = widget.tools
Expand Down Expand Up @@ -71,14 +72,14 @@ def render(self, name, value, attrs=None, renderer=None):
html = super().render(name, value, attrs)

html += '''
<div data-editorjs-holder></div>
<div data-editorjs-holder id="%(id)s_editorjs_holder" class="editorjs-holder"></div>
<script defer>
addEventListener('DOMContentLoaded', function () {
initEditorJsField('%s', %s);
initEditorJsField('%(id)s', %(config)s);
})
</script>''' % (
attrs.get('id'),
json.dumps(self.configuration()),
)
</script>''' % {
'id': attrs.get('id'),
'config': json.dumps(self.configuration()),
}

return mark_safe(html)