diff --git a/frontend/src/view-file-text.js b/frontend/src/view-file-text.js index c62c5f096e..3678d64fac 100644 --- a/frontend/src/view-file-text.js +++ b/frontend/src/view-file-text.js @@ -117,8 +117,21 @@ class ViewFileText extends React.Component { componentDidMount() { this.getParticipants(); + window.addEventListener('keydown', this.saveFile); } + componentWillUnmount() { + window.removeEventListener('keydown', this.saveFile); + } + + saveFile = (e) => { + if ((e.ctrlKey || e.metaKey) && e.key == 's' && this.state.needSave) { + // `Ctrl + S` or `Cmd + S`(in Mac) + e.preventDefault(); + this.onSave(); + } + }; + render() { return (