33 protected const UNDO =
'UNDO';
34 protected const REDO =
'REDO';
37 self::UNDO => RemoveBlockAction::class,
38 self::REDO => AddBlockAction::class,
41 self::UNDO => AddBlockAction::class,
42 self::REDO => RemoveBlockAction::class,
45 self::UNDO => SortBlockAction::class,
46 self::REDO => SortBlockAction::class,
49 self::UNDO => RemoveCardAction::class,
50 self::REDO => AddCardAction::class,
53 self::UNDO => AddCardAction::class,
54 self::REDO => RemoveCardAction::class,
57 self::UNDO => EditTextAction::class,
58 self::REDO => EditTextAction::class,
61 self::UNDO => EditMapAction::class,
62 self::REDO => EditMapAction::class,
65 self::UNDO => EditEmbedAction::class,
66 self::REDO => EditEmbedAction::class,
69 self::UNDO => EditImgAction::class,
70 self::REDO => EditImgAction::class,
73 self::UNDO => EditIconAction::class,
74 self::REDO => EditIconAction::class,
77 self::UNDO => EditLinkAction::class,
78 self::REDO => EditLinkAction::class,
81 self::UNDO => EditStyleAction::class,
82 self::REDO => EditStyleAction::class,
84 'EDIT_ATTRIBUTES' => [
85 self::UNDO => EditAttributesAction::class,
86 self::REDO => EditAttributesAction::class,
89 self::UNDO => UpdateContentAction::class,
90 self::REDO => UpdateContentAction::class,
93 self::UNDO => ChangeAnchorAction::class,
94 self::REDO => ChangeAnchorAction::class,
96 'CHANGE_NODE_NAME_ACTION' => [
97 self::UNDO => ChangeNodeNameAction::class,
98 self::REDO => ChangeNodeNameAction::class,
100 'UPDATE_DYNAMIC' => [
101 self::UNDO => UpdateDynamicAction::class,
102 self::REDO => UpdateDynamicAction::class,
105 self::UNDO => MultiplyAction::class,
106 self::REDO => MultiplyAction::class,
109 self::UNDO => RemoveNodeAction::class,
110 self::REDO => AddNodeAction::class,
113 self::UNDO => AddNodeAction::class,
114 self::REDO => RemoveNodeAction::class,
116 'REPLACE_LANDING' => [
117 self::UNDO => ReplaceLanding::class,
118 self::REDO => ReplaceLanding::class,
131 if (self::isActionExists($actionName))
151 return array_key_exists($actionName, self::ACTIONS);
160 public static function getActionClass(
string $actionName, ?
bool $undo =
false): ?string
163 $class = self::ACTIONS[$actionName][$direction];
165 if (class_exists($class))
189 public static function compareSteps(array $prevStep, array $nextStep): bool
192 $prevStep[
'ENTITY_TYPE'] === $nextStep[
'ENTITY_TYPE']
193 && $prevStep[
'ENTITY_ID'] === $nextStep[
'ENTITY_ID']
194 && $prevStep[
'ACTION'] === $nextStep[
'ACTION']
198 if ($class && is_callable([$class, self::COMPARE_METHOD]))
200 return call_user_func(
201 [$class, self::COMPARE_METHOD],
202 $prevStep[
'ACTION_PARAMS'],
203 $nextStep[
'ACTION_PARAMS']
static getAction(string $actionName, ?bool $undo=false)
static getActionClass(string $actionName, ?bool $undo=false)
static compareSteps(array $prevStep, array $nextStep)