@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.
15 lines (14 loc) • 1.26 kB
JavaScript
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 { LuChevronDown } from "react-icons/lu";
import { fonts } from "../lib/constants";
import { cn } from "../lib/utils";
export function FontFamily() {
const { editor } = useEditorStore();
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { className: "dropdown-trigger-button", children: [_jsx("span", { className: "truncate", children: editor?.getAttributes("textStyle").fontFamily?.replace(/"/g, "") ||
"Arial" }), _jsx(LuChevronDown, { size: 16 })] }) }), _jsx(DropdownMenuContent, { className: "editor-dropdown-content", align: "start", children: fonts.map(({ label, value }) => {
return (_jsx("button", { onClick: () => editor?.chain().focus().setFontFamily(value).run(), className: cn("editor-dropdown-menu-button", editor?.getAttributes("textStyle").fontFamily === value &&
"editor-item-active"), style: { fontFamily: value }, children: label }, value));
}) })] }));
}