[QUESTION] - Event Handler from KeyMap should trigger the core events?
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)
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#L310
Would you like to create a PR? :)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1708
StyleManager events fire multiple times per change
To reproduce: On a fresh install of GrapesJS, within the demo page (within index.html), add an event listener like so: editor.on('component...
Issue #1470
[Question] Possible memory leaks
Hi, I am working on a project with Angular 6 and I am investigating a memory leak after destroying the editor on _previousAttributes and po...
Issue #1530
Click events in undo/redo manager
Hi @artf, I have a issue regarding undo manager and I have checked it's also on your demo page. Problem is that undo manger also count the...
Issue #660
Select Parent Function not working when parent element is not selectable
Hi @artf, I have a question about select parent function. Cannot select the parent when parent element is not selectable, suggest to skip t...
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.