@explita/editor
Version:
`@explita/editor` is a versatile, modern rich-text editor built on TipTap for seamless integration into React applications. It provides extensive customization options and advanced features to cater to diverse content creation needs.
12 lines (11 loc) • 1.08 kB
JavaScript
"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, } from "./ui/dropdown-menu";
import { useEditorStore } from "../store/useEditorState";
import { LuAlignLeft } from "react-icons/lu";
import { textAlignment } from "../lib/constants";
import { cn } from "../lib/utils";
export function TextAlignment() {
const { editor } = useEditorStore();
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { title: "Text Alignment", className: "toolbar-button", children: _jsx(LuAlignLeft, { size: 16 }) }) }), _jsx(DropdownMenuContent, { className: "editor-dropdown-content", children: textAlignment.map(({ label, value, icon: Icon }) => (_jsxs("button", { onClick: () => editor?.chain().focus().setTextAlign(value).run(), className: cn("editor-dropdown-menu-button", editor?.isActive({ textAlignment: value }) && "editor-item-active"), children: [_jsx(Icon, { size: 16 }), _jsx("span", { children: label })] }, value))) })] }));
}