@@ -834,7 +834,6 @@ const restoreAllSelectionActions = (moleculesAction, stage, isSelection) => (dis
834
834
} ;
835
835
836
836
const restoreAllSelectionByTypeActions = ( moleculesAction , stage , isSelection ) => ( dispatch , getState ) => {
837
-
838
837
let actions =
839
838
isSelection === true
840
839
? moleculesAction . filter (
@@ -1092,36 +1091,70 @@ const getCompound = (action, state) => {
1092
1091
} ;
1093
1092
1094
1093
export const undoAction = ( stages = [ ] ) => ( dispatch , getState ) => {
1095
- const state = getState ( ) ;
1096
- let action = null ;
1097
-
1098
1094
dispatch ( setIsUndoRedoAction ( true ) ) ;
1095
+ let action = dispatch ( getUndoAction ( ) ) ;
1096
+ if ( action ) {
1097
+ Promise . resolve ( dispatch ( handleUndoAction ( action , stages ) ) ) . then ( ( ) => {
1098
+ dispatch ( setIsUndoRedoAction ( false ) ) ;
1099
+ } ) ;
1100
+ }
1101
+ } ;
1099
1102
1103
+ const getUndoAction = ( ) => ( dispatch , getState ) => {
1104
+ const state = getState ( ) ;
1100
1105
const actionUndoList = state . undoableTrackingReducers . future ;
1106
+
1107
+ let action = { text : '' } ;
1101
1108
let actions = actionUndoList && actionUndoList [ 0 ] ;
1102
1109
if ( actions ) {
1103
1110
let actionsLenght = actions . undo_redo_actions_list . length ;
1104
1111
actionsLenght = actionsLenght > 0 ? actionsLenght - 1 : actionsLenght ;
1105
1112
action = actions . undo_redo_actions_list [ actionsLenght ] ;
1106
-
1107
- Promise . resolve ( dispatch ( handleUndoAction ( action , stages ) ) ) . then ( ( ) => {
1108
- dispatch ( setIsUndoRedoAction ( false ) ) ;
1109
- } ) ;
1110
1113
}
1114
+
1115
+ return action ;
1111
1116
} ;
1112
1117
1113
- export const redoAction = ( stages = [ ] ) => ( dispatch , getState ) => {
1118
+ const getRedoAction = ( ) => ( dispatch , getState ) => {
1114
1119
const state = getState ( ) ;
1115
- let action = null ;
1116
-
1117
- dispatch ( setIsUndoRedoAction ( true ) ) ;
1118
-
1119
1120
const actions = state . undoableTrackingReducers . present ;
1121
+
1122
+ let action = { text : '' } ;
1120
1123
if ( actions ) {
1121
1124
let actionsLenght = actions . undo_redo_actions_list . length ;
1122
1125
actionsLenght = actionsLenght > 0 ? actionsLenght - 1 : actionsLenght ;
1123
1126
action = actions . undo_redo_actions_list [ actionsLenght ] ;
1127
+ }
1124
1128
1129
+ return action ;
1130
+ } ;
1131
+
1132
+ const getNextUndoAction = ( ) => ( dispatch , getState ) => {
1133
+ const state = getState ( ) ;
1134
+ const actionUndoList = state . undoableTrackingReducers . present ;
1135
+
1136
+ let action = { text : '' } ;
1137
+ let actions = actionUndoList && actionUndoList . undo_redo_actions_list ;
1138
+ if ( actions ) {
1139
+ let actionsLenght = actions . length ;
1140
+ actionsLenght = actionsLenght > 0 ? actionsLenght - 1 : actionsLenght ;
1141
+ action = actions [ actionsLenght ] ;
1142
+ }
1143
+
1144
+ return action ;
1145
+ } ;
1146
+
1147
+ const getNextRedoAction = ( ) => ( dispatch , getState ) => {
1148
+ const state = getState ( ) ;
1149
+ let action = { text : '' } ;
1150
+
1151
+ return action ;
1152
+ } ;
1153
+
1154
+ export const redoAction = ( stages = [ ] ) => ( dispatch , getState ) => {
1155
+ dispatch ( setIsUndoRedoAction ( true ) ) ;
1156
+ let action = dispatch ( getRedoAction ( ) ) ;
1157
+ if ( action ) {
1125
1158
Promise . resolve ( dispatch ( dispatch ( handleRedoAction ( action , stages ) ) ) ) . then ( ( ) => {
1126
1159
dispatch ( setIsUndoRedoAction ( false ) ) ;
1127
1160
} ) ;
@@ -1709,6 +1742,16 @@ export const getCanRedo = () => (dispatch, getState) => {
1709
1742
return state . undoableTrackingReducers . future . length > 0 ;
1710
1743
} ;
1711
1744
1745
+ export const getUndoActionText = ( ) => ( dispatch , getState ) => {
1746
+ let action = dispatch ( getNextUndoAction ( ) ) ;
1747
+ return action ?. text ?? '' ;
1748
+ } ;
1749
+
1750
+ export const getRedoActionText = ( ) => ( dispatch , getState ) => {
1751
+ let action = dispatch ( getNextRedoAction ( ) ) ;
1752
+ return action ?. text ?? '' ;
1753
+ } ;
1754
+
1712
1755
export const appendAndSendTrackingActions = trackAction => ( dispatch , getState ) => {
1713
1756
const state = getState ( ) ;
1714
1757
const isUndoRedoAction = state . trackingReducers . isUndoRedoAction ;
0 commit comments