mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
['text' file view] use 'Ctrl + S' or 'Cmd + S'(in Mac) to save the edited file (#6758)
This commit is contained in:
@@ -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 (
|
||||
<FileView
|
||||
|
Reference in New Issue
Block a user