How to override the default behavior that happens when pressing Ctrl+S

Hello,

I actually want to call an endpoint to save the file upon pressing ctrl+s, instead of popping up a browser window to save the json file.

Thanks

3 Replies 1 reply marked as answer

KB Kurthis Banu Abdul Majeeth Syncfusion Team January 21, 2021 06:01 AM UTC

Hi Omar, 

Using serialize () method you will get the document in SFDT format. 


API link: 


Code snippet for serialize API: 
this.$refs.doceditcontainer.ej2Instances.documentEditor.serialize();  

Please let us know if you have any questions. 
  

Regards, 
  
Kurthis Banu A. 


Marked as answer

OM Omar January 21, 2021 04:04 PM UTC

But how to override the behavior when hitting ctrl+s is the question.


KB Kurthis Banu Abdul Majeeth Syncfusion Team January 22, 2021 01:47 PM UTC

Hi Omar,  

Code snippet to prevent ctrl+s: 

if (isCtrlKey && !isAltKey && keyCode === 83)  
             //To prevent default save operation, set the isHandled property to true 
 
                args.isHandled = true; 
 
                this.$refs.documenteditor.save('sample', 'Docx'); 
 
                args.event.preventDefault(); 
 
 }  
else if (isCtrlKey && isAltKey && keyCode === 83) 
 
 
  this.$refs.documenteditor.save('sample', 'Sfdt'); 
 
 
 
 

Please refer the below documentation Link: 




Regards, 

Kurthis Banu A. 


Loader.
Up arrow icon