7 #pragma mark - UndoManager channel method names.
10 #pragma mark - Undo State field names
15 @property(nonatomic, weak, readonly) id<FlutterUndoManagerDelegate> undoManagerDelegate;
24 _undoManagerDelegate = undoManagerDelegate;
31 [_undoManagerDelegate.undoManager removeAllActionsWithTarget:self];
35 NSString* method = call.
method;
38 [
self setUndoState:args];
45 - (void)resetUndoManager {
46 [
self.undoManagerDelegate.undoManager removeAllActionsWithTarget:self];
49 - (void)registerUndoWithDirection:(FlutterUndoRedoDirection)direction {
50 NSUndoManager* undoManager =
self.undoManagerDelegate.undoManager;
51 [undoManager beginUndoGrouping];
52 [undoManager registerUndoWithTarget:self
53 handler:^(FlutterUndoManagerPlugin* target) {
55 FlutterUndoRedoDirection newDirection =
56 (direction == FlutterUndoRedoDirectionRedo)
57 ? FlutterUndoRedoDirectionUndo
58 : FlutterUndoRedoDirectionRedo;
59 [target registerUndoWithDirection:newDirection];
61 [target.undoManagerDelegate handleUndoWithDirection:direction];
63 [undoManager endUndoGrouping];
66 - (void)registerRedo {
67 NSUndoManager* undoManager =
self.undoManagerDelegate.undoManager;
68 [undoManager beginUndoGrouping];
69 [undoManager registerUndoWithTarget:self
70 handler:^(id target) {
72 [target registerUndoWithDirection:FlutterUndoRedoDirectionRedo];
74 [undoManager endUndoGrouping];
78 - (void)setUndoState:(NSDictionary*)dictionary {
79 NSUndoManager* undoManager =
self.undoManagerDelegate.undoManager;
80 BOOL groupsByEvent = undoManager.groupsByEvent;
81 undoManager.groupsByEvent = NO;
82 BOOL canUndo = [dictionary[kCanUndo] boolValue];
83 BOOL canRedo = [dictionary[kCanRedo] boolValue];
85 [
self resetUndoManager];
88 [
self registerUndoWithDirection:FlutterUndoRedoDirectionUndo];
93 UIView<UITextInput>* textInputView =
self.undoManagerDelegate.activeTextInputView;
94 if (textInputView != nil) {
98 UITextInputAssistantItem* assistantItem = textInputView.inputAssistantItem;
99 assistantItem.leadingBarButtonGroups = assistantItem.leadingBarButtonGroups;
101 undoManager.groupsByEvent = groupsByEvent;