Add new buttons for undo and redo

[MAILPOET-3085]
This commit is contained in:
Jan Lysý
2020-11-17 09:47:08 +01:00
committed by Veljko V
parent 46322825d5
commit 14a4e55080
2 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import React from 'react';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { redo as redoIcon } from '@wordpress/icons';
function HistoryRedo(props) {
const hasRedo = useSelect(
(select) => select('mailpoet-form-editor').hasEditorRedo(),
[]
);
const { historyMove } = useDispatch('mailpoet-form-editor');
const redoAction = () => {
historyMove('redo');
};
return (
<Button
{...props}
icon={redoIcon}
label={__('Redo')}
aria-disabled={!hasRedo}
onClick={hasRedo ? redoAction : undefined}
className="editor-history__redo"
/>
);
}
export default HistoryRedo;

View File

@@ -0,0 +1,28 @@
import React from 'react';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { undo as undoIcon } from '@wordpress/icons';
function HistoryUndo(props) {
const hasUndo = useSelect(
(select) => select('mailpoet-form-editor').hasEditorUndo(),
[]
);
const { historyMove } = useDispatch('mailpoet-form-editor');
const undoAction = () => {
historyMove('undo');
};
return (
<Button
{...props}
icon={undoIcon}
label={__('Undo')}
aria-disabled={!hasUndo}
onClick={hasUndo ? undoAction : undefined}
className="editor-history__undo"
/>
);
}
export default HistoryUndo;