GrapesJS Issues

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

644 issues found

๐Ÿ” components
#2816June 8, 2020by scaneNo answers
0 reactions

[QUESTION]: Automatically apply style to components of similar type

Hello, I have written a custom GrapesJS component. So what I'm trying to achieve with this custom component is, if I place 2 components of the same type in the GrapesJS canvas and on editing the style of one component through style manager should automatically update the style of the other component. Is there a way to...

#2808May 27, 2020by robertraf3 answers
1 reactions

[QUESTION] Custom type component in production environment

Hi, I have a question, when I create a custom type component from the editor, what would be the next step to show that component in my application? Currently I am saving the component data in firebase with the firestore plugin, the attributes that are stored in the object are the following: gjs-assets, gjs-components,...

Ju99ernaut

onRender simply specifies what should happen when you successfully place a component onto the canvas, whereas script is code that will be generated in your html inside script tags. Something like:

Ju99ernaut

I think in a production environment all you need is the html and css code generated by grapesjs.

robertraf

I understand that part, but if I want to render the component I have created it doesn't work. I'll explain a little, I have created a type of component that renders data from an endpoint, if I use the html and css code it doesn't work. Cus...

#2807May 27, 2020by alesub3 answers
0 reactions

[Bug]: Starting editor "fromElement" creates components inside tag with data-gjs-type="text"

Hi, I'm currently trying to start the editor "fromElement", setting the following html inside the container: But when executed, grapesjs creates components inside the <p> tag even after setting the data-gjs-type attribute as text. What I'm trying to do is to present the paragraph to be edited as a single component. Yo...

alesub

@artf just to clarify: this bug is based on the expected behaviour you described on this comment: https://github.com/artf/grapesjs/issues/576#issuecomment-348550694 And how the divs with text behave on the demo page. Please let me know if...

alesub

Hi, any luck reviewing this issue? What got me lost is this doesn't happen on the demo page, any bold or italic text doesn't become a separate component after saving or reloading. Any insight will be greatly appreciated, Thanks!

artf

Closing this one as now this is the default behavior. There is also a possibility to customize the behavior via disableTextInnerChilds option added from https://github.com/GrapesJS/grapesjs/releases/tag/v0.21.2

#2801May 25, 2020by fedd3 answers
1 reactions

[Questions] Enrich any component with the serverside if or foreach expressions (namely, MVEL)

I am researching how to make a template with server side expressions that will repeat a component (foreach) or completely remove it (if). My backend parses templates with mvel. What I am thinking is to add a couple of settings to all or some select elements. For example, to a <div> of a Cell, so it looks like this: <d...

Ju99ernaut

To surround an element take look at toHtml, you can search it in the issues for examples. In any case I don't think it's a good idea to replace the default component type, I'd suggest creating a new component that extends the default type...

fedd

The docs for components might be helpful I've written my code based on this article. It says,Updating component types is quite easy, let's see how: .... // The defaults property is handled differently // and will be merged with the old def...

artf

@fedd you can add your new traits in model.init function

#2800May 25, 2020by meyerco3 answers
0 reactions

[Bug] when removing a tooltip its css is not removed

DescriptionThe bug is reproduced on the current demo Expected behavior When a tooltip is removed its css is removed What happens instead ? When a tooltip is removed its css is not removed Steps to reproduce on the demo Clear the canvas Drag a tooltip Remove the tooltipClick on Import button on top toolbar , the toolti...

artf

Yeah, I think you're right, probably replacing with might fix the issue, would you like to check and create a PR? :)

meyerco

@artf Maybe this code to keep the code generic ?

artf

@meyerco ๐Ÿ˜… yeah sure, sorry, it was a copy-paste from my try

#2799May 24, 2020by dintifla3 answers
0 reactions

[Questions] Ordering of selector with id and class selectors, space after id-selector

I am currently working on a web application for which we integrate this project as GUI editor to customize the environments. Our GUI components are loaded and parsed from the database. We can identify e.g. a button, data grid, etc. by an ID (e.g. 17190fbd-13d6-430f-bb32-1a09d2151a77). These components are then built f...

dintifla

a short update: I managed to get the the selectors in the right order when using selectors.unshift(idSelector) instead of selectors.add(idSelector) in above sample. Now i still have the issue with the missing space between the id- and the...

artf

Hi @dintifla SelectorManager is not meant to work like that (you can only have a mix of classes .class1.class2 but not with IDs), but honestly I don't understand what is your goal of using the SelectorManager at all. If you need to query a...

dintifla

Hi @artf Thanks for your reply. In the end it is not just about querying a component, but generate the CSS for it. I don't need the HTML since my application is designed in a rich client application, stored in an abstract representation in...

#2793May 20, 2020by Lerdouille3 answers
3 reactions

Extend Image Traits

Hello, i would like to extend the image type with some options, specially with a redirect option on click. I tried this solution after the editor initialization (i precise that i work in full javascript and non Node.js environment) : editor.DomComponents.addType('image', { isComponent: el => el.tagName == 'img', model...

Lerdouille

Hi again, here is the final solution to create a a href image : Now i have to found how to check the URL integrity when you want to update the href variable Best regards

felipesotero

I have the same need in my project. I tried creating a block, but I couldn't get the initial popup to "pop". I tried creating a component with a plugin, but there's too much work that I can't understand how it can connect to each other. An...

artf

You've added this listener change:url but the name of the trait is name: 'href', so just change it with change:href

#2791May 20, 2020by MarlonV1231 answer
4 reactions

Import and export templates help please

Good morning, please I need help to create templates and then load them, I really cannot do anything, I want to be able to save templates, later load them, I have been days without trying, I am new to programming I have followed everything to the letter , and really the only thing that I am missing are the templates p...

Ju99ernaut

At the bare minimum you need commands for saving the templates and opening a modal that shows the saved templates, and to handle loading a template onto the editor. To save a template using local storage you can use something like To open...

#2786May 18, 2020by amitbhoj7771 answer
0 reactions

Adding multiple text type traits

Whenever i am trying to add multiple traits of type text with all different conditions and on different tags/attributes but it will take only last one at every traits conditions. Please help me out with the solution. Below is the code editor.DomComponents.addType('text', { isComponent: el =>( (el.attributes&&el.attrib...

amitbhoj777

Got the solution. we need to extend type text in traits. Thankyou. editor.DomComponents.addType('paraJustify', { isComponent: el => ((el.attributes && el.attributes.paraJustify && el.attributes.paraJustify.value)), extend: 'text', model: {...

#2778May 15, 2020by ashishtyd2 answers
0 reactions

BUGS - Cannot read property 'querySelector' of null at r.getBody

Hi I was trying to use grapesjs on visualsource pages. Following is the init function - initEditor: function(){ var self = this; this.editor = grapesjs.init({ container: '#gjs', fromElement: true, height: '500px', width: 'auto', storageManager: false, panels: { defaults: [] }, blockManager: { appendTo: '#blocks', bloc...

artf

Create a reproducible demo please

no-response[bot]

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take ac...