Skip to content

Commit c2be4fd

Browse files
committed
Feat: add TipTap Admin Editor styles and update SCSS file references
1 parent 8ab4fdf commit c2be4fd

File tree

2 files changed

+103
-4
lines changed

2 files changed

+103
-4
lines changed

docs/frontend_development_guide.rst

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,89 @@ File Structure
7575
backend/static/
7676
├── scss/
7777
│ ├── main.scss # Main SCSS entry point
78+
│ ├── tiptap_admin.scss # TipTap Admin Editor styles
7879
| ├── theme/**.scss # Bootstrap SCSS files
7980
│ └── **/*.scss # All SCSS files (watched)
80-
└── css/
81-
├── main.css # Compiled CSS output
82-
└── main.css.map # Source map (dev mode only)
81+
├── css/
82+
│ ├── main.css # Compiled CSS output
83+
│ └── main.css.map # Source map (dev mode only)
84+
└── djangocms_text/css/
85+
└── tiptap.admin.css # Admin Editor styles (generated)
86+
87+
TipTap Admin Editor Styles
88+
===========================
89+
90+
The project includes a separate SCSS file for styling the djangoCMS Text Editor (TipTap) in the admin interface. This ensures that colors and styles in the editor match your theme settings.
91+
92+
What It Does
93+
------------
94+
95+
The ``tiptap_admin.scss`` file:
96+
97+
- Imports your theme variables (colors, fonts, etc.)
98+
- Defines CSS classes for text and background colors used in the editor
99+
- Compiles to ``backend/static/djangocms_text/css/tiptap.admin.css``
100+
- Uses the same color values as your frontend theme
101+
- Scopes all styles under ``.cms-admin`` to avoid conflicts
102+
103+
How It Works
104+
------------
105+
106+
When you run ``npm run dev`` or ``npm run build``, two CSS files are compiled **in parallel**:
107+
108+
1. **main.css** - Your frontend styles
109+
2. **tiptap.admin.css** - Admin editor styles
110+
111+
The build process automatically:
112+
113+
- Reads your theme colors from ``_variables.scss``
114+
- Generates matching CSS for the editor
115+
- Outputs to ``backend/static/djangocms_text/css/tiptap.admin.css``
116+
117+
Customizing Editor Colors
118+
--------------------------
119+
120+
To add or modify colors in the editor:
121+
122+
1. **Update the SCSS file:**
123+
124+
Edit ``backend/static/scss/tiptap_admin.scss`` and add your color class:
125+
126+
.. code-block:: scss
127+
128+
.cms-admin {
129+
.text-custom {
130+
color: $your-custom-color !important;
131+
}
132+
}
133+
134+
2. **Register in Django settings:**
135+
136+
Add the color to ``TEXT_EDITOR_SETTINGS`` in ``backend/settings.py``:
137+
138+
.. code-block:: python
139+
140+
TEXT_EDITOR_SETTINGS = {
141+
"textColors": {
142+
"text-custom": {"name": "Custom Color"},
143+
# ... other colors
144+
},
145+
}
146+
147+
3. **Rebuild CSS:**
148+
149+
The watcher will automatically rebuild, or run manually:
150+
151+
.. code-block:: bash
152+
153+
npx gulp styles
154+
155+
Why No Source Maps?
156+
--------------------
157+
158+
The ``tiptap.admin.css`` file is intentionally compiled **without source maps** to keep the admin interface clean. The file is simple enough for debugging without source maps, and it reduces clutter in the admin CSS directory.
159+
160+
If you need source maps for debugging, you can modify ``gulpfile.js`` line 40-52 to add ``sourcemaps.init()`` and ``sourcemaps.write(".")``.
83161

84162
Local Development Workflow
85163
===========================
@@ -173,6 +251,27 @@ Docker vs Local
173251
- **Local development**: You need to run ``npm install`` and ``npm run dev`` on your host machine
174252
- ``node_modules/`` is in ``.gitignore`` (correct) - each environment needs its own installation
175253

254+
TipTap Admin CSS not updating
255+
------------------------------
256+
257+
If changes to ``tiptap_admin.scss`` aren't reflected in the admin:
258+
259+
1. Verify the file is being compiled:
260+
261+
.. code-block:: bash
262+
263+
ls -la backend/static/djangocms_text/css/tiptap.admin.css
264+
265+
2. Check that the file is not in ``.gitignore`` (it should be)
266+
3. Rebuild manually:
267+
268+
.. code-block:: bash
269+
270+
npx gulp styles
271+
272+
4. Restart Django (``python manage.py runserver`` or ``docker compose restart``)
273+
5. Hard refresh browser in admin (Ctrl+F5)
274+
176275
Adding New SCSS Files
177276
======================
178277

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const isProd = process.env.NODE_ENV === "production";
1212

1313
const paths = {
1414
entry: "backend/static/scss/main.scss",
15-
tiptapAdmin: "backend/static/scss/tiptap-admin.scss",
15+
tiptapAdmin: "backend/static/scss/tiptap_admin.scss",
1616
scss: "backend/static/scss/**/*.scss",
1717
outDir: "backend/static/css",
1818
tiptapOutDir: "backend/static/djangocms_text/css",

0 commit comments

Comments
 (0)