From 6adf5ba00618c6624332a6755a3c8f308b996c98 Mon Sep 17 00:00:00 2001 From: Graham Hoyes Date: Mon, 26 Feb 2024 09:29:38 -0500 Subject: [PATCH] ENH: Allow setting the container class --- .../django_svelte_jsoneditor/widgets/svelte_jsoneditor.html | 2 +- django_svelte_jsoneditor/widgets.py | 5 ++++- poetry.lock | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/django_svelte_jsoneditor/templates/django_svelte_jsoneditor/widgets/svelte_jsoneditor.html b/django_svelte_jsoneditor/templates/django_svelte_jsoneditor/widgets/svelte_jsoneditor.html index c88a997..0b374d6 100644 --- a/django_svelte_jsoneditor/templates/django_svelte_jsoneditor/widgets/svelte_jsoneditor.html +++ b/django_svelte_jsoneditor/templates/django_svelte_jsoneditor/widgets/svelte_jsoneditor.html @@ -1,6 +1,6 @@ {% load static %} -
+
diff --git a/django_svelte_jsoneditor/widgets.py b/django_svelte_jsoneditor/widgets.py index 5b2d14d..b4045d2 100644 --- a/django_svelte_jsoneditor/widgets.py +++ b/django_svelte_jsoneditor/widgets.py @@ -7,11 +7,13 @@ class SvelteJSONEditorWidget(Textarea): template_name = "django_svelte_jsoneditor/widgets/svelte_jsoneditor.html" - def __init__(self, props=None, attrs=None): + def __init__(self, props=None, attrs=None, wrapper_class="svelte-jsoneditor-wrapper"): if attrs is None: attrs = {} self.props = {} if props is None else props.copy() + self.wrapper_class = wrapper_class + check_props(self.props) attrs.update({"class": "hidden"}) @@ -20,6 +22,7 @@ def __init__(self, props=None, attrs=None): def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) context["widget"].update({"props": json.dumps({**get_props(), **self.props})}) + context["widget"].update({"wrapper_class": self.wrapper_class}) return context class Media: diff --git a/poetry.lock b/poetry.lock index 2260b63..f2c0d4f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.0 and should not be changed by hand. [[package]] name = "alabaster" @@ -958,6 +958,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1439,4 +1440,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "b343d2d4cd1cfca5820ccf5e4e3fc5da1639b353fad4046bfcb60e30d336dd46" +content-hash = "fe01ee5b68577d4dec1252133814f5aeba798eedd0574c13162d3f6e99bbeb98"