I would like know to how to prevent browser default page saving dialog pop-out when clicking CTRL+ S. Below is my command code for saving function of GrapesJS
keymaps.add('ns:save-keymap', '⌘+s, ctrl+s', editor => {
editor.runCommand('save-db');
});
editor.on('keymap:emit', (id, shortcut, event) => {
switch(id){
case 'ns:save-keymap':
event.preventDefault();
event.stopPropagation();
//alert('Saving template...');
break;
}
});
Bypass browser default page saving dialog pop-out in GrapesJS saving command. Although event.preventDefault();
already put into event trigger, but seem not working.
Thanks
The event in your example is actually an options argument which has a child event property on it.
so in your case, you would need to do:
event.event._parentEvent.preventDefault()
Doing it this way give you the option to prevent the default in some cases but not all, which might be helpful. However if you don't care, you can just change your keymap add like this:
keymaps.add('ns:save-keymap', '⌘+s, ctrl+s', 'save-db', {prevent:true})