From 4915744c843d915cca7a6d2e65bc2bf7b5df2660 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 22 Jan 2020 11:53:19 +0700 Subject: [PATCH] undo and redo functionality --- src/components/dialogs/StickersDialog.tsx | 2 +- src/components/panels/EditorPanel.tsx | 27 +++++++- src/redux/editor/actions.ts | 21 +++++- src/redux/editor/constants.ts | 7 ++ src/redux/editor/handlers.ts | 13 ++++ src/redux/editor/index.ts | 15 +++++ src/redux/editor/sagas.ts | 71 +++++++++++++++++++- src/redux/map/sagas.ts | 11 +-- src/redux/user/sagas.ts | 5 -- src/sprites/icon.svg | 10 +++ src/styles/panel.less | 81 ++++++++++++++--------- 11 files changed, 216 insertions(+), 47 deletions(-) diff --git a/src/components/dialogs/StickersDialog.tsx b/src/components/dialogs/StickersDialog.tsx index be9dede..37847f4 100644 --- a/src/components/dialogs/StickersDialog.tsx +++ b/src/components/dialogs/StickersDialog.tsx @@ -15,7 +15,7 @@ type Props = ReturnType & }; const StickersDialogUnconnected = ({ editorSetActiveSticker, width }: Props) => ( -
+
{Object.keys(STICKERS).map(set => (
diff --git a/src/components/panels/EditorPanel.tsx b/src/components/panels/EditorPanel.tsx index 6d770e7..86247c8 100644 --- a/src/components/panels/EditorPanel.tsx +++ b/src/components/panels/EditorPanel.tsx @@ -11,6 +11,8 @@ import { editorStopEditing, editorTakeAShot, editorKeyPressed, + editorUndo, + editorRedo, } from '~/redux/editor/actions'; import { Tooltip } from '~/components/panels/Tooltip'; import { IState } from '~/redux/store'; @@ -18,7 +20,7 @@ import { selectEditor } from '~/redux/editor/selectors'; import pick from 'ramda/es/pick'; const mapStateToProps = (state: IState) => - pick(['mode', 'changed', 'editing', 'features'], selectEditor(state)); + pick(['mode', 'changed', 'editing', 'features', 'history'], selectEditor(state)); const mapDispatchToProps = { editorChangeMode, @@ -26,6 +28,8 @@ const mapDispatchToProps = { editorStopEditing, editorTakeAShot, editorKeyPressed, + editorUndo, + editorRedo, }; type Props = ReturnType & typeof mapDispatchToProps & {}; @@ -68,6 +72,7 @@ class EditorPanelUnconnected extends PureComponent { changed, editing, features: { routing }, + history: { records, position }, } = this.props; return ( @@ -78,6 +83,26 @@ class EditorPanelUnconnected extends PureComponent { this.panel = el; }} > +
+ + + +
+
{routing && (