Limit the number of times of block to be dropped
Question
Hi,
Is it possible to limit the number of times of block to be dropped? e.g. the form block and be dropped once only.
Thanks.
Answers (1)
Hi @confettidc, you can try doing something like, have a counter variable and update it once a block of a type is added and remove the newly added block if the counter condition is satisfied.
editor.on('block:drag:stop', (comp, addedBlock) => {
// if the counter condition is satisfied then remove the component `comp`
// else check the type of 'addedBlock' If it matches with the one you want to limit and update the counter
})
Do check the API Reference.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2552
Only allow one component to be dropped
Sorry for the newbie question, but say I have a text field component and I only want to allow the user to drop a specific number of them in...
Issue #3258
QUESTION: Prevent/Disable Custom Blocks from being dropped inside other Custom Blocks
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 Secti...
Issue #1895
[QUESTION] Drag component over canvas with script, script appended multiple times.
Hi, not sure if this is a bug or not. But I noticed a weird behavior, when I drag a block that has a component that contains a script funct...
Issue #1809
Customize image resizing
If i want to limit resizing an image to only specific dimensions, how can i do that? Also is it possible to enable resizing only from the b...
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.