Issue #2936✓ SolvedOpened August 3, 2020by lavioros5 reactions

Inline style loads on id instead of class

快速解答by artf5

I'd suggest using this option

Read full answer below ↓

Question

Hello,

I have been using your tool for a while and I decided to upgrade to a newer version(from v0.12.37 to v0.16.3 + gjs-preset-newsletter). I have the styles stored inline, I know it is not desirable, but since we use the tool for authoring emails, it is still a safer option.

Is there a way to load inline styles on the class, if the component has a class already set(as it used to be in older versions)?

I have a JSfiddle example here: https://jsfiddle.net/Lo91v0um/1/

Hence, in my case, I have the following component:

<div style="font-size: 20px;" class="my-class" >A text component</div>

If I select the component, the selector is shown to be class "my-class", but the style is added to the id. When editing the component's font-size it would be added to the class and the changes would not be visible because they are overwritten by those already set on id.

I tried adding avoidInlineStyle, but this added one extra class for each component at every editor load, and that was not the desired behavior.

Is there any way I can still achieve the old behavior? (prior to 0.14.40)

Thank you very much! Lavinia

Answers (1)

👍 Most helpfulartfAugust 26, 2020

I'd suggest using this option

grapesjs.init({
  ...
  selectorManager: {
   componentFirst: true,
  },
})

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.