Skip to content

Commit

Permalink
Move logic to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
belcherj committed Jul 30, 2020
1 parent d795851 commit fb2b90f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions lib/note-content-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ class NoteContentEditor extends Component<Props> {
window.monaco = monaco;
this.editor = editor;

window.electron.receive('appCommand', (command) => {
switch (command.action) {
case 'redo':
editor.trigger('', 'redo');
return;
case 'selectAll':
editor.setSelection(editor.getModel().getFullModelRange());
return;
case 'undo':
editor.trigger('', 'undo');
return;
}
});

const titleDecoration = (line: number) => ({
range: new monaco.Range(line, 1, line, 1),
options: {
Expand Down
14 changes: 0 additions & 14 deletions lib/state/electron/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,10 @@ export const middleware: S.Middleware = ({ dispatch, getState }) => {
dispatch({ type: 'INSERT_TASK' });
return;

case 'redo':
window?.editor.trigger('', 'redo');
return;

case 'showDialog':
dispatch(actions.ui.showDialog(command.dialog));
return;

case 'selectAll':
window?.editor.setSelection(
window?.editor.getModel().getFullModelRange()
);
return;

case 'trashNote':
dispatch(actions.ui.trashOpenNote());
return;
Expand Down Expand Up @@ -87,10 +77,6 @@ export const middleware: S.Middleware = ({ dispatch, getState }) => {
dispatch(actions.settings.toggleSpellCheck());
return;

case 'undo':
window?.editor.trigger('', 'undo');
return;

default:
console.log(command);
}
Expand Down

0 comments on commit fb2b90f

Please sign in to comment.