Skip to content

Commit

Permalink
Keyboard Shortcuts: Bind Cmd/Ctrl+S as save
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Oct 3, 2017
1 parent 334351c commit 1db2e49
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion editor/modes/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ import PostTitle from '../../post-title';
import WritingFlow from '../../writing-flow';
import TableOfContents from '../../table-of-contents';
import { getBlockUids, getMultiSelectedBlockUids } from '../../selectors';
import { clearSelectedBlock, multiSelect, redo, undo, removeBlocks } from '../../actions';
import {
clearSelectedBlock,
multiSelect,
redo,
undo,
autosave,
removeBlocks,
} from '../../actions';

class VisualEditor extends Component {
constructor() {
Expand All @@ -31,6 +38,7 @@ class VisualEditor extends Component {
this.onClick = this.onClick.bind( this );
this.selectAll = this.selectAll.bind( this );
this.undoOrRedo = this.undoOrRedo.bind( this );
this.save = this.save.bind( this );
this.deleteSelectedBlocks = this.deleteSelectedBlocks.bind( this );
}

Expand Down Expand Up @@ -73,6 +81,11 @@ class VisualEditor extends Component {
event.preventDefault();
}

save( event ) {
event.preventDefault();
this.props.onSave();
}

deleteSelectedBlocks( event ) {
const { multiSelectedBlockUids, onRemove } = this.props;
if ( multiSelectedBlockUids.length ) {
Expand All @@ -98,6 +111,7 @@ class VisualEditor extends Component {
'mod+a': this.selectAll,
'mod+z': this.undoOrRedo,
'mod+shift+z': this.undoOrRedo,
'mod+s': [ this.save, true ],
backspace: this.deleteSelectedBlocks,
del: this.deleteSelectedBlocks,
} } />
Expand Down Expand Up @@ -126,5 +140,6 @@ export default connect(
onRedo: redo,
onUndo: undo,
onRemove: removeBlocks,
onSave: autosave,
}
)( VisualEditor );

0 comments on commit 1db2e49

Please sign in to comment.