Skip to content

Commit 9fc5939

Browse files
committed
Expand the documentation a bit to mention the importmap requirement
Refs #71.
1 parent 30c22a0 commit 9fc5939

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

docs/forms.rst

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,50 @@ If you're rendering the form in a template you have to include the form media:
3333
Note that the form media isn't django-prose-editor specific, that's a Django
3434
feature.
3535

36-
The django-prose-editor CSS uses the following CSS custom properties.
36+
37+
Importmap requirement
38+
---------------------
39+
40+
**Important**: The ``{{ form.media }}`` tag includes the JavaScript files, but
41+
you also need to set up the importmap as described in the :doc:`installation`
42+
documentation. Without this, you'll get errors about bare module specifiers.
43+
44+
Add the context processor to your settings:
45+
46+
.. code-block:: python
47+
48+
TEMPLATES = [
49+
{
50+
# ...
51+
'OPTIONS': {
52+
'context_processors': [
53+
# ... your other context processors
54+
'js_asset.context_processors.importmap',
55+
],
56+
},
57+
},
58+
]
59+
60+
And add ``{{ importmap }}`` to your base template, **above all other scripts**:
61+
62+
.. code-block:: html+django
63+
64+
<!DOCTYPE html>
65+
<html>
66+
<head>
67+
<title>My Site</title>
68+
{{ importmap }} {# Required for django-prose-editor #}
69+
</head>
70+
<body>
71+
{% block content %}{% endblock %}
72+
</body>
73+
</html>
74+
75+
76+
CSS custom properties
77+
---------------------
78+
79+
The django-prose-editor CSS uses the following CSS custom properties:
3780

3881
* ``--prose-editor-background``
3982
* ``--prose-editor-foreground``

docs/installation.rst

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,35 @@ Add ``django_prose_editor`` to ``INSTALLED_APPS``:
2323
"django_prose_editor",
2424
]
2525
26-
Add the importmap by adding the ``js_asset.context_processors.importmap``
26+
**Important**: Add the importmap by adding the ``js_asset.context_processors.importmap``
2727
context processor and inserting ``{{ importmap }}`` somewhere in your base
28-
template, above all other scripts.
28+
template, above all other scripts:
29+
30+
.. code-block:: python
31+
32+
TEMPLATES = [
33+
{
34+
# ...
35+
'OPTIONS': {
36+
'context_processors': [
37+
# ... your other context processors
38+
'js_asset.context_processors.importmap',
39+
],
40+
},
41+
},
42+
]
43+
44+
.. code-block:: html+django
45+
46+
<!DOCTYPE html>
47+
<html>
48+
<head>
49+
{{ importmap }} {# Must be above other scripts #}
50+
</head>
51+
<body>
52+
<!-- your content -->
53+
</body>
54+
</html>
2955

3056
Replace ``models.TextField`` with ``ProseEditorField`` where appropriate:
3157

0 commit comments

Comments
 (0)