Issue #2769💬 AnsweredOpened May 12, 2020by cartifon0 reactions

Event Handler from KeyMap should trigger the core events?

快速解答by artf

Yeah, you're right, the command handler is executed directly here https://github.com/artf/grapesjs/blob/fbfa812eaaeeb467337107896ee6decfbfbc028e/src/keymaps/index.js#L154 it should pass through Commands.run(id, opts) https://github.com/artf/grapesjs/blob/fbfa812eaaeeb467337107896ee6decfbfbc028e/src/commands/index.js#L...

Read full answer below ↓

Question

Hey @artf, question, should the core commands be triggered when the keyMap is activated?

The situation:

I added this listeners:

 
function addCommands() {
  console.log(editor.Commands.getAll());
  editor.on('run:core:component-delete:before', function (options) {
    console.log('run:core:component-delete:before: ', options);
  });
  editor.on('run:core:component-delete', function (options) {
    console.log('run:core:component-delete: ', options);
  });
  editor.on('core:component-delete', function (options)  {
    console.log('core:component-delete: ', options);
  });
  const keyMaps = editor.Keymaps;
  console.log('keyMaps: ', keyMaps.getAll());
}

When I delete a component using the delete icon it calls my listener, but when I press the delete key, it does not trigger the listener... Am I doing anything wrong here?

You can check it here: https://www.w3schools.com/code/tryit.asp?filename=GEQBCR5CLYQF

Answers (1)

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.