Issue #3275Opened February 18, 2021by confettidc2 reactions

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)

theSC0RPFebruary 19, 20212 reactions

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.

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

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.