Use css variables for editor markup
Hi @artf After a year, I wonder if your opinion on this matter changed? We'd love to use it and IE11 becomes less and less of a thing ;) @SamMousa if you need help with the PR, we can contribute as well. Looking forward to hearing back from you! Philipp
Read full answer below ↓Question
Given that all modern browsers (https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties#Browser_compatibility) support CSS variables, the added value of using SCSS for them is limited.
I do not propose fully removing SCSS, what I do propose is the following:
- Replace all uses of
darken()andlighten()functions and replace them with SCSS variable in_gjs_variables.scss. - For all sass variables used in
_gjs_variables.scssreplace it with css variable:
// This
$primaryColor: #444 !default;
// Becomes
:root {
--gjs-primary-color: #444;
}
$primaryColor: var(--gjs-primary-color);
This is a simple change that should not result in a BC break. After doing this theming the editor will become even simpler since we can just specify the variables directly in CSS and we're done; no recompilation needed.
Answers (3)
Hi @artf After a year, I wonder if your opinion on this matter changed? We'd love to use it and IE11 becomes less and less of a thing ;) @SamMousa if you need help with the PR, we can contribute as well. Looking forward to hearing back from you! Philipp
After a year, I wonder if your opinion on this matter changed?
Unfortunately, it doesn't depend only on my decision, from what I know, they're still a good percentage of users relying on IE11 compatibility. So, the only solution would be creating a good SCSS file import usage (avoid writing the same styles declaration twice) and generate a new CSS file with custom properties.
For now, I'll close the issue as the traction for this is very low, but a PR would still be welcome
I'll make a PR if you're open to this.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2853
[QUESTION] Do you have plans to remove dependency on Document.execCommand in RTE?
I noticed that in https://github.com/artf/grapesjs/issues/74 when the move to the Pell based editor is listed it's use of Document.execComm...
Issue #6152
CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #4529
When we resize an image with a class 'xyz', all the elements on the page with same class also gets resized because editor adds css to those classes.
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Version 104.0.5112.101 (Official Build) (arm...
Issue #2586
[Question]: How update style manager panel using few devices and custom css class
There is a custom class added to simple grapesjs project: If there is no devices and user adds the class into the selectors field Settings...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.