Issue #2744💬 AnsweredOpened April 28, 2020by jcze910 reactions

Disable a block drag&drop

Quick answerby artf

From the latest release https://github.com/artf/grapesjs/releases/tag/v0.16.12 you can pass disable property to your block

Read full answer below ↓

Question

Hello everyone,

I would like to make forbidden the drop of one block before another specific one. Context : i've create a new trait for some blocks to set them as "page header", and I don't want to allow the drag&drop one block before this "page header" as it must be the first block of my template.

I saw I could listen sorter:drag:validation event and update the valid property to false in this perspective. But I can't known the future order of the block I would drop.

So, I would be glad to know one solution to this problem.

Thanks in advance :)

Answers (3)

jcze91April 29, 2020

Hello, Thx for your response but it's not my use case. I don't want to disable a block drag'n'drop on all the canvas, but I jus want this block to not to be added before another specific component.

artfMay 4, 2020

You can see if you're able to achieve it with by using the draggable property (Component) or make use of block:drag:stop event to ensure if the dropped component meets the necessary criteria and remove it if it doesn't

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

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.