Issue #915Opened February 28, 2018by JulyanoF0 reactions

[QUESTION] Enable confirmation box when remove block

Question

Is there any option to activate a confirmation box before delete any block?

Answers (3)

artfMarch 2, 20180 reactions

Nope, but you can extend the default tlb-delete command

editor.Commands.add('tlb-delete', ed => {
	if (confirm('Sure?')) {
		const selected = ed.getSelected();
		selected && selected.destroy();
	}
});
IceweexMarch 25, 20180 reactions

@artf this works only for toolbar button, but when I hit "delete" on my keyboard it doesn't. How can I override this event?

artfMarch 29, 20180 reactions

Hi @Iceweex, unfortunately, at the moment, you can't. For the next release, I'll centralize those commands and will update also its event lifecycle, so in that case, you'll able to achieve the task in this way

	const commandName = 'core:component-delete';
    editor.on(`run:${commandName}:before`, (options) => {
	  console.log(`BEFORE ${commandName}`);
      if (!confirm('Are you sure')) {
        options.abort = 1; 
      }
    });
    editor.on(`run:${commandName}`, (deleted, options) => {
      console.log(`AFTER ${commandName}`, deleted);
    });
    editor.on(`abort:${commandName}`, (options) => {
      console.log(`ABORT ${commandName}`);
    });

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.