Skip to content

Commit

Permalink
Allow more easily overriding this
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Dec 2, 2024
1 parent 5f7fc5a commit c376dd6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions django_prose_editor/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ def __hash__(self):
return hash(self.__str__())


def _get_presets():
presets = {
"default": {
"script": "django_prose_editor/init.js",
},
}
return presets | getattr(settings, "DJANGO_PROSE_EDITOR_PRESETS", {})


class ProseEditorWidget(forms.Textarea):
def __init__(self, *args, **kwargs):
self.config = kwargs.pop("config", {})
Expand Down Expand Up @@ -95,11 +86,19 @@ def media(self):
preset["script"],
{"defer": True},
)
for key, preset in _get_presets().items()
for key, preset in self.get_presets().items()
),
],
)

def get_presets(self):
presets = {
"default": {
"script": "django_prose_editor/init.js",
},
}
return presets | getattr(settings, "DJANGO_PROSE_EDITOR_PRESETS", {})

def get_config(self):
return self.config or {
"types": None,
Expand Down

0 comments on commit c376dd6

Please sign in to comment.