Inline css to class
Question
@artf thanks for amazing project, it mad site editing much easier.
by default editor convert inline css to class but is there setting not to convert inline css to class as we do not want to convert it to class?
Answers (3)
If you grep forceClass you will see that it does just one thing
https://github.com/artf/grapesjs/blob/dev/src/dom_components/model/Components.js#L77
so when you add a new component and there is a not empty style attribute, all its properties will be moved into new class, so I apologize, probably have to change its name as seems to confuse a lot of people
For the newly proposed option, I was thinking about something which just brings back #ids styles inside the component style but if we're talking also about .classes, well, I don't think we need this kind of feature inside the core. So, If you need to inline all your styles, just use juice as I did here https://github.com/artf/grapesjs-preset-newsletter/blob/master/src/openExportCommand.js
@ryandeba editor.runCommand('gjs-get-inlined-html') :)
Have you tried with forceClass?
grapesjs.init({
...
forceClass: false,
})
I am also looking to do the same thing, but setting forceClass to false does not seem to work.
I made a minimal JSFiddle here that tries to use inline css instead of classes, but the editor always moves the styling into classes, even with forceClass set to false. Am I missing something?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1748
How to prevent drag items inside the editor
Hello @artf You are doing great job with grapesjs and it's extremely helpful to make our functionality more user friendly. Thanks for creat...
Issue #1608
[Question] Customize CSS class name
GrapesJs editor creates a unique class for element and adds CSS rules to it. For example, Now, is there any way to customize this behaviour...
Issue #1550
Remove Duplicate Css Rule by Class
Hi @artf , I'm reading and experimenting the setStyle method but when i used setStyle editor.getSelectedToStyle().setStyle({ color: 'red' }...
Issue #329
forceclass false doesn't work
Hi artf , thanks again for your answers since i started my project and thanks again for this beautifull project, I told you that i wanted t...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.