GrapesJS Issues

3,464 parsed GitHub issues โ€” 370 solved ยท 90 open. Search, filter and explore battle-tested answers.

644 issues found

๐Ÿ” components
#527November 15, 2017by krunal0392 answers
1 reactions

Model and HTML return issue

#522 @artf I tried as you said but still no luck, I do not want to waste your time but it would be very useful if you can please create small sample or point me to sample, I am sure I am missing something. sorry had to open another issue but it in continuation of same #522, here it editor.html() only return default va...

adamlc

@krunal039 this isn't a support form. If you have any problems asking here is only going to infuriate the contributors. If you have a problem ask on Stack overflow, thats what its for....

lock[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

#522November 14, 2017by krunal0393 answers
0 reactions

Model Html Issue

#513 Sorry for opening new issue but you have closed last one so had to create new one, I am struggling with below so if you can help to resolve or guide me at sample code that would be great, or if you have quick 5 mins and create small codepen would be good, really appreciate your help. I tried you suggested but sti...

artf

You can trigger your actions on render...

krunal039

@artf I tried bust still no luck, can you please create small sample if that is possible?

lock[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

#518November 14, 2017by HarshOB3 answers
0 reactions

change only component body not whole page body.

Hello @artf As we discussed in issue #374. setComponents will set the body and replace all the contents that are present on the page with a new select page from the list. What if I want to set the body to only that component without changing the whole content of the page?

artf

You can replace the content of the model

HarshOB

How can I replace the content of a component with specific value like "Hello"?

artf

Tried with this model.components('Hello')?!?

#514November 13, 2017by krunal0392 answers
0 reactions

template/ Blocks/ Components

We have requirement to create custom templates for different areas and all templates has below 4 variables anchor link, anchor target, image source, image hover text, title. We want to create one custom component and it will provide mechanism to select variables via traits. Is there way to provide template via block a...

artf

Well, with data-gjs-* attribute you can even use objects (JSONs) but, for bigger templates, I'd recommend block definition via an object instead

lock[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

#510November 12, 2017by asvine-p3 answers
6 reactions

Add new class programatically

Hello Artf, I want to edit the styles of components (mostly imported html) without modifying all components with the same class. I tried to add a random named class programmatically like this: this.editor.on('component:selected', function(model) { if (model && model.length > 2) { const uuid = this.s4(); // generate ne...

artf

@wemod123 editor.getWrapper().addClass('my-class')

artf

@IrinaCodixis from the https://github.com/artf/grapesjs/releases/tag/v0.14.52 we've added setRule/getRule methods, so to add some CSS rule programatically you should do this:

artf

You mean something like model.set('style', {...})? This adds an inline style on the component

#509November 12, 2017by asvine-p3 answers
0 reactions

Span are not editable as text

Hello Artf, I have a problem when importing some html templates. I was initially not able to see span texts. But after helping the editor reconizing them, i'm not able to edit them as texts. let domc = this.editor.DomComponents; let textType = domc.getType("text"); domc.addType('span', { // Define the Model model: tex...

artf

For editable contents, you have to use content

asvine-p

Hello artf, I have replaced "components: el.innerHTML" by "content: el.innerHTML" but the content is still not editable. Here is my code: ' let domc = this.editor.DomComponents; let textType = domc.getType("text");' domc.addType('span', {...

bakgat

``` return {type: 'Span', src: el.src, tagName: el.tagName.toLowerCase(), // components: el.innerHTML, content: el.innerHTML, editable: true }

#502November 10, 2017by sanjeevSavitr3 answers
0 reactions

Hide a particular component in preview

Hi, Is it possible to hide "BannerOptionsBtn" component when I click preview button. I Used toHTML() function. And when I called editor.getHtml() it is returning the html as expected, but when I click preview button the "BannerOptionsBtn" appears. Here is the code. Please Help me domc.addType('bannergal', { model: def...

artf

You can make use of command events inside your component, eg.

sanjeevSavitr

Thanks for the help. And please send the command event that is triggered when we click "Hide Preview".

lock[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

#494November 8, 2017by z-vr3 answers
0 reactions

Place block as component programmatically

I've created a custom type, and a block is it possible to insert it into DomComponents by name or any other means? I don't want to be drag'n'dropping the block manually each time. Thanks.

z-vr

Oh I found out how to do it -- via editor.addComponents({ type: 'MyComponent' }). Is there a way to insert it into a specific element by a CSS selector? Found this snippet, but how would i find the correct index?

z-vr

ok so what i've done is and then I think traversing the model tree would be a very good feature -- I'll work on the PR at some point. Cheers!

artf

You can actually get the model from the cash element instance with view.$el.data('model'), so you might make it work with less code

#490November 8, 2017by ryandeba3 answers
0 reactions

Prevent modifying specific image components

I have a use case where I would like to make some specific components completely locked down (i.e. not resizable, not draggable, not copyable, not removable, etc). I have this mostly working, but I'm having a problem with images - I cannot seem to prevent the double-click functionality that opens the asset manager mod...

artf

Yeah, you're right, I use editable only for text components, but what you're asking actually make sense. I'd be happy to accept your PR. You should add editable: true, to the model https://github.com/artf/grapesjs/blob/dev/src/domcomponent...

ryandeba

Thanks @artf! Here's the pull request: https://github.com/artf/grapesjs/pull/496

artf

Merged https://github.com/artf/grapesjs/pull/496 ๐Ÿ‘

#488November 7, 2017by richieteh943 answers
4 reactions

editor.setComponents auto generate unwanted css

I'm used the html and css editor that mention in #324 . After I edited the html and css it will generate a CSS where I suspect caused by editor.setComponents() Not sure this is a bug or normal behavior. grapesjs version - 0.12.8 grapesjs preset - gjs-preset-newsletter 0.2.15

thecodefish

In my use case I am constantly getting & setting the html/css inside the editor, and what I found is that it would end up duplicating the 'default' styles (see the * and body styles in the image above - they appear twice). I managed to sol...

thecodefish

@chiqui3d I think whenever you need to modify the css from some external source, you'll probably want to reset the css composer first. So if you have something like editor.setStyle(css); in your code, you may need to call editor.CssCompose...

artf

First of all, update your grapesjs version, then be more specific about your changes. What did you change? What do you mean with unwanted css?