Prevent/Disable Custom Blocks from being dropped inside other Custom Blocks
You can use :not() selector, eg. :not(.except-this-class)
Read full answer below βQuestion
Hello, I have a custom component, let's call it a Section Block. I want to prevent the user from dropping Section Blocks inside other Section Blocks. Is that possible? Ref: https://grapesjs.com/docs/modules/Components.html#define-custom-component-type I am aware of the draggable/droppable options that I can define on new component types. My understanding of these options is that they are inclusive. Is there a way to make draggable exclusive, where I say, "this block can be dropped anywhere EXCEPT [[component type]]"?
Answers (4)
You can use :not() selector, eg. :not(.except-this-class)
Thanks @artf . This solution works, mostly. Now I am encountering a new problem where some placeholder text is disappearing. On some elements inside my blocks, I'll have an HTML element with a text node, then some other nested html element. An example would be a link tag containing an icon. When I...
You're defining the component with the old API, which requires other stuff to work properly and that might be the cause of the issue (I've tried on my side and everything works as expected). Please check here for the correct API https://grapesjs.com/docs/modules/Components.html#define-custom-compon...
Thanks for reporting this, @stljeff1. Great question about Prevent/Disable Custom Blocks from being dropped inside other Custom Blocks. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() ev...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3688
How to customize a component
I read this document https://grapesjs.com/docs/modules/Components.html#define-custom-component-type and tried to write the following code....
Issue #3574
Adding traits are not picked up by trait manager.
Following example from docs . Is there further configurtion to make new traitsa show for elements? The example using the input does not run...
Issue #5768
Wrong Type for "content" property in BlockProperties
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v122 Reproducible demo link not app...
Issue #4384
Index.d.ts says that components must be Backbone.Collection<Component> but the docs say Component[] is also accepted
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? AnyReproducible demo link https://grapesjs.c...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins βPremium plugins ship with support, regular updates, and production-ready features β save days of integration work.
Browse premium plugins βRelated tutorials
In-depth guides on the same topic.
Tutorial
Introducing GJS.Market Services: ship your GrapesJS editor without the integration risk
It's everything that usually eats weeks of engineering time, scoped and priced up front. No open-ended hourly surprises.
Tutorial
GrapesJS custom components guide (2026)
Define custom GrapesJS components with DomComponents.addType: detection with isComponent, a model with traits and defaults, and a view for canvas behavior.
Tutorial
Building an AI-Assisted Document Engine with Next.js, GrapesJS, and the AI SDK
Transform your static template editor into an intelligent, generative design workspace with Vercel AI SDK, AI Elements and Next.js.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.