Issue #2506Opened January 13, 2020by andrewryan19061 reactions

Unable to make custom components hoverable/selectable/badgable

Question

I'm using GrapesJs with Angular and am extending the functionality using Angular components. So my template looks like this:

<rs-wc-custom-component lock_editing_in_pages custom-component-id="custom_component-KG3g7xE6Yf2SzTRTPA8ESjULVAlwmCsi" id="ij1i">
</rs-wc-custom-component>
<rs-wc-menu lock_editing_in_pages id="i1un">
</rs-wc-menu>
<div class="container">
  <div lock_editing_in_pages id="icom">
    <p>Insert your text here
    </p>
  </div>
</div>

This all works fine; I've added DomComponents to the designer, and the components show up in the layer designer and I can even change traits with no problem. Everything renders as it should.

However; while I can select my Text component and see a badge, I cannot select rs-wc-custom-component or rs-wc-menu. When I click on the items, there's no blue rectangle and no badge is shown; the only way I can select/change them is through the Layer panel on the left.

What do I need to do to make these selectable?

Answers (3)

andrewryan1906January 21, 20201 reactions

So,

What I ended up doing instead is using Angular elements, but NOT compiling the elements into a web component (wanted to avoid the extra complexity). This kept me from having to switch out the DOM elements, and so GrapesJS editor is playing nice. No more issue.

Thanks! Andrew

andrewryan1906January 13, 20200 reactions

This might help.

As part of processing the element, I'm swapping it out with my Angular element on the fly... so, after rs-wc-custom-component tag is rendered, I wait 1 ms and generate a dynamic Angular component, and swap out the rs-wc-custom-component with my dynamic Angular component.

Could that be the issue?

artfJanuary 18, 20200 reactions

As part of processing the element, I'm swapping it out with my Angular element on the fly... so, after rs-wc-custom-component tag is rendered, I wait 1 ms and generate a dynamic Angular component, and swap out the rs-wc-custom-component with my dynamic Angular component.

Definitely this sounds like the main issue from the editor's point of view. When GrapesJS parses elements it attaches Component models to the DOM so, when you try to interact with them the editor actually uses their model. But is not clear to me how are you able to use Layers (which uses the same Component models). Can you create a tiny live demo?

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.