Style gets lost on deselecting a component when using rte.exec method
Question
Hi @artf,
When setting the backcolor/forecolor (or any other formatting like fontsize, etc) using the RichTextEditor toolbar, the formatting gets lost on deselecting > selecting and deselecting the component again. Please see the demo on code pen - https://codepen.io/AbdiasM/pen/LYVydpr Moreover, the RTE toolbar doesn't show again on entering edit mode.
Steps to reproduce:
- Drop a text block
- Double click the text block and select some text (eg. here)
- Click on the last icon in the RTE Toolbar and set the backcolor Observe: Backcolor is applied
- Click outside the text block
- Double click text block again to enter edit mode
- Click outside text block again Observe: Backcolor is lost
- Double click inside text block again Observe: RTE toolbar doesn't show
Could you please take a look into this. This is kind of crucial.
Answers (3)
Anyone?
Solved this by setting
avoidInlineStyle: 0,
forceClass :0,
in editor's config
However, the issue still occurs if template is imported. It can be reproduced on the GrapesJS demo page (https://grapesjs.com/demo.html) as well.
1. Import the following template:
` <div id="ipwi" class="c1423">Test
<span draggable="true" id="iqhox">Template </span> issue
</div>
<style>* {
box-sizing: border-box;
}
body {
margin: 0;
}
*{
box-sizing:border-box;
}
body{
margin:0;
margin-top:0px;
margin-right:0px;
margin-bottom:0px;
margin-left:0px;
}
#ipwi{
display:inline-block;
padding:5px;
width:auto;
}
#iqhox{
display:inline-block;
padding:5px;
width:auto;
color:rgb(255, 0, 0);
}
</style>`
2. Double click on the text 'issue' to enter edit mode
3. Click outside the text component
Observe: The formatting applied on the text 'Template' gets lost
@artfThanks for the report @AbdiasM we're already aware of the issue, it should be fixed once #1470 will be solved (so you can subscribe to the issue there)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2472
DragData extend for other components like div etc
Hi @artf How to implement dragData event for custom components(external).I called dragData method on div drag but dataTransfer and content...
Issue #1639
[Question]: Would it be possible to have change settings under style manager in a way that it has href when a link is created?
I'm using preset newsletter with built-in RTE (do not want to use ck editor like the demo) In order to make any text to link, i need to cli...
Issue #1327
[QUESTIONS] Replacing selected text and getting html
Hi! Im trying to replace selected text with a code (random code). It's works, i can see the code, but when i do editor.getHtml() not. If i...
Issue #4797
change type keepUnusedStyles?: 0;
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link n/a Describe th...
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.