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)
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
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?
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.
Issue #3231
BUG: how to change gjs-ckeditor-format component
hi guys, we all know that gjs-ckeditor-plugin working with [data-gjs-type]="text" components. I wanna know , could we change this option? I...
Issue #2195
[Question] Define components in template
QuestionsHow can I make a part of my template a component ?How can I set draggableComponents on such a component?If so, then can I stop set...
Issue #1336
[Question] Can I make everything unselectable by default?
Currently all components are selectable/hoverable by default. And if you want you can change that behavior by providing data-gjs-hoverable=...
Issue #3279
QUESTION: how to make textnode editing update component content?
I'm building a custom textarea component and want it to behave like the built in text component such that editing the textnode on the grape...
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.