react-text-editor-kit
Version:
React Text Editor Kit is a customizable rich text editor component for React applications. It provides a flexible and easy-to-use interface for users to create and edit content with various formatting options. And also easy to integrate in react applicati
53 lines (48 loc) • 1.24 kB
JSX
import React from "react";
import { AlignCenter, AlignJustify, AlignLeft, AlignRight } from ".";
import Styles from "../css/style.module.css";
function SelectAlignment({ handleHideChildOptions }) {
const alignments = [
{
title: "Left",
icon: <AlignLeft />,
type: "justifyLeft",
},
{
title: "Center",
icon: <AlignCenter />,
type: "justifyCenter",
},
{
title: "Right",
icon: <AlignRight />,
type: "justifyRight",
},
{
title: "Justify",
icon: <AlignJustify />,
type: "justifyFull",
},
];
const handleOptionClick = (e, option) => {
e.preventDefault();
document.execCommand(option.type);
handleHideChildOptions();
};
return (
<>
{alignments.map((option, index) => (
<button
key={`key${index}`}
type="button"
onClick={(e) => handleOptionClick(e, option)}
className={`${Styles.selectOption} ${Styles.reactEditorTextLeft}`}
>
<span className={Styles.reactEditorMe5}>{option.icon}</span>
{option.title}
</button>
))}
</>
);
}
export default SelectAlignment;