FEAT: Allow dynamic droppable configuration using a function
Question
I have a requirement where I cannot use selectors to determine if an element is droppable. For example:

The "child" component must be within a "parent" component, however if the child component contains a ref attribute it can only be dragged into other parent containers that match the same ref value as the current parent. Given the above markup, the child component can be dropped into the last container but not the container with the ref of 5678. However the second child element could be dropped into any of the parent components.
This would easily be accomplished if droppable would allow a function:
droppable: (src, target) => {
//some logic
return true;
},
This would require a fairly simple change to the Sorter:
// Check if the target could accept the source
let droppable = trgModel.get('droppable');
if (typeof droppable === 'function') {
let res = droppable(src, trg);
result.droppable = res;
result.dropInfo = res;
droppable = res;
} else {
//existing logicAnswers (2)
Associated PR: https://github.com/artf/grapesjs/pull/3393
@artf do have any questions regarding this feature or the approach taken in the PR?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3683
How to set the component cannot be deleted
Issue #2547
Unable to drag an element if style has bottom or right values
Hi @artf , If any component CSS has bottom or right values , not able to drag them. Values are generating as NaN. Attached the screenshot f...
Issue #401
Cannot upload images
Hi, while uploading an image through asset manager, I get the following error: Assetmanager configuration at editor init looks like Folder...
Issue #362
How to create custom link components that prompts users to type link/choose link similar to Images Component Modal
Image Components have logic to call Modal and prompt user's interaction for options/configuration of image url. Would like to do similar to...
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.