@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) • 939 B
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 { SketchPicker } from "react-color";
import { LuHighlighter } from "react-icons/lu";
export function HighlightColor() {
const { editor } = useEditorStore();
const currentColor = editor?.getAttributes("highlight").color || "#C7C7C7";
function onChage(color) {
editor?.chain().focus().setHighlight({ color: color.hex }).run();
}
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { title: "Highlight Color", className: "toolbar-button", children: _jsx(LuHighlighter, { size: 16 }) }) }), _jsx(DropdownMenuContent, { className: "p-0", children: _jsx(SketchPicker, { color: currentColor, onChange: onChage }) })] }));
}