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:
@@ -117,8 +117,21 @@ class ViewFileText extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.getParticipants();
|
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() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<FileView
|
<FileView
|
||||||
|
Reference in New Issue
Block a user