1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 19:08:21 +00:00

['text' file view] use 'Ctrl + S' or 'Cmd + S'(in Mac) to save the edited file (#6758)

This commit is contained in:
llj
2024-09-11 20:38:04 +08:00
committed by GitHub
parent f3f4879c02
commit 1ad28f61bd

View File

@@ -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