editor.on('component:update:content', model => { }}) not work in some cause
Question
if the user remove all text from a element and click some where else . then again try to select empty element he is not able to select it again because it is hide and i dont know where it goes. So for this issue I am using this code
editor.on('component:update:content', model => {
const val = model.get('content');
if(val && val.length < 1){
model.set('content', ' ');
}
})
this code set a space in text if user remove all text from a element . By doing this these is no empty element so i does not hide . and again we can select it . if the user remove text character one by one it works fine . But now issue is that if a user select a text by CTRL + A and remove by BACKSPACE . At this time this above code not work . Can anyone help me .
Answers (2)
As already suggested here https://github.com/artf/grapesjs/issues/3603#issuecomment-885305546 avoid doing what you're doing now and add a simple default CSS in case the element is empty
Thank you i got it !
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3137
BUG: When I select an particular element I'm not getting its styles. This issue happens only with some elements.
Not getting styles of the selected element Here is my code, const model = editor.StyleManager.getModelToStyle(component); let styleObject =...
Issue #1660
Content will automatically removed while edit in editor
Hello @artf I am facing an issue with grapes.js while editing any textual content. I am using grapes.js Version 0.14.37 with angular 1.6.1....
Issue #3615
BUG: text in text component cannot update , cannot get final result from toHTML
it is text component, if select body, the text will correct save/apply/store in component toHTML method, if just updating text, but not lea...
Issue #3586
how to listen the components change in a component.
init() { this.listenTo(this.model,'change:components', this.handleComponentsChange); }, I develop a component, I try to listen the child co...
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.