- {actions.map((action) => (
-
-
-
- ))}
+ {actions.map((action) => {
+ const action_info_list = actionsInfo[action];
+ const title = action_info_list[1];
+ return (
+
+
+
+ );
+ })}
);
diff --git a/src/Widgets/TextAlign.jsx b/src/Widgets/TextAlign.jsx
index 6319f1e..9e32a37 100644
--- a/src/Widgets/TextAlign.jsx
+++ b/src/Widgets/TextAlign.jsx
@@ -1,13 +1,9 @@
-import React from 'react';
-import { Button } from 'semantic-ui-react';
-import { FormFieldWrapper, Icon } from '@plone/volto/components';
-
import alignLeftSVG from '@plone/volto/icons/align-left.svg';
import alignRightSVG from '@plone/volto/icons/align-right.svg';
import alignJustifySVG from '@plone/volto/icons/align-justify.svg';
import alignCenterSVG from '@plone/volto/icons/align-center.svg';
-import clearSVG from '@plone/volto/icons/clear.svg';
-import { defineMessages, useIntl } from 'react-intl';
+import { defineMessages } from 'react-intl';
+import AlignWidget, { defaultActionsInfo } from './Align';
export const messages = defineMessages({
left: {
@@ -31,57 +27,13 @@ export const messages = defineMessages({
defaultMessage: 'Clear selection',
},
});
-const defaultActionsInfo = ({ intl }) => ({
- left: [alignLeftSVG, intl.formatMessage(messages.left)],
- right: [alignRightSVG, intl.formatMessage(messages.right)],
- center: [alignCenterSVG, intl.formatMessage(messages.center)],
- justify: [alignJustifySVG, intl.formatMessage(messages.justify)],
- '': [clearSVG, intl.formatMessage(messages[''])],
-});
-export default (props) => {
- const intl = useIntl();
- const {
- onChange,
- id,
- actions = ['left', 'right', 'center', 'justify'],
- actionsInfoMap = {},
- value,
- } = props;
- // add clear selection button to the actions mapping if it's not already present
- if (actions[actions.length - 1] !== '') {
- actions.push('');
- }
+defaultActionsInfo['left'] = [alignLeftSVG, messages.left];
+defaultActionsInfo['right'] = [alignRightSVG, messages.right];
+defaultActionsInfo['center'] = [alignCenterSVG, messages.center];
+defaultActionsInfo['justify'] = [alignJustifySVG, messages.justify];
- const actionsInfo = {
- ...defaultActionsInfo({ intl }),
- ...actionsInfoMap,
- };
-
- return (
-