"use client" import { useState } from "react" import { useEditor } from "@tiptap/react" import { ChevronDown, AlignLeft, AlignCenter, AlignRight, AlignJustify, Palette, ALargeSmall, CaseSensitive, } from "lucide-react" import { cn } from "@/lib/utils" import { MAIL_COMPOSE_MENU_SELECTED_CLASS, MAIL_COMPOSE_TOOLBAR_BTN_ACTIVE, } from "@/lib/mail-chrome-classes" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { COMPOSE_PORTAL_Z } from "./compose-shared" export const FONT_FAMILIES = [ { label: "Sans Serif", value: "sans-serif" }, { label: "Serif", value: "serif" }, { label: "Monospace", value: "monospace" }, { label: "Cursive", value: "cursive" }, { label: "Comic Sans MS", value: "Comic Sans MS, cursive" }, { label: "Garamond", value: "Garamond, serif" }, { label: "Georgia", value: "Georgia, serif" }, { label: "Impact", value: "Impact, sans-serif" }, { label: "Tahoma", value: "Tahoma, sans-serif" }, { label: "Trebuchet MS", value: "Trebuchet MS, sans-serif" }, { label: "Verdana", value: "Verdana, sans-serif" }, ] export const FONT_SIZES = [ { label: "Très petit", value: "10px" }, { label: "Petit", value: "13px" }, { label: "Normal", value: "" }, { label: "Grand", value: "18px" }, { label: "Très grand", value: "24px" }, { label: "Énorme", value: "32px" }, ] export const TEXT_COLORS = [ "#000000", "#434343", "#666666", "#999999", "#cccccc", "#efefef", "#f3f3f3", "#ffffff", "#fb4934", "#fe8019", "#fabd2f", "#b8bb26", "#8ec07c", "#83a598", "#d3869b", "#ebdbb2", "#cc241d", "#d65d0e", "#d79921", "#98971a", "#689d6a", "#458588", "#b16286", "#a89984", "#9d0006", "#af3a03", "#b57614", "#79740e", "#427b58", "#076678", "#8f3f71", "#7c6f64", ] export function AlignmentDropdown({ editor, btnClass, activeClass, }: { editor: NonNullable> btnClass: string activeClass: string }) { const currentIcon = editor.isActive({ textAlign: "center" }) ? AlignCenter : editor.isActive({ textAlign: "right" }) ? AlignRight : editor.isActive({ textAlign: "justify" }) ? AlignJustify : AlignLeft const CurrentIcon = currentIcon return ( editor.chain().focus().setTextAlign("left").run()} className={cn(editor.isActive({ textAlign: "left" }) && MAIL_COMPOSE_MENU_SELECTED_CLASS)} > Aligner à gauche editor.chain().focus().setTextAlign("center").run()} className={cn(editor.isActive({ textAlign: "center" }) && MAIL_COMPOSE_MENU_SELECTED_CLASS)} > Centrer editor.chain().focus().setTextAlign("right").run()} className={cn(editor.isActive({ textAlign: "right" }) && MAIL_COMPOSE_MENU_SELECTED_CLASS)} > Aligner à droite editor.chain().focus().setTextAlign("justify").run()} className={cn(editor.isActive({ textAlign: "justify" }) && MAIL_COMPOSE_TOOLBAR_BTN_ACTIVE)} > Justifier ) } export function FontDropdown({ editor, btnClass, }: { editor: NonNullable> btnClass: string }) { return ( {FONT_FAMILIES.map((f) => ( editor.chain().focus().setMark("textStyle", { fontFamily: f.value }).run()} style={{ fontFamily: f.value }} className={cn( editor.isActive("textStyle", { fontFamily: f.value }) && MAIL_COMPOSE_TOOLBAR_BTN_ACTIVE )} > {f.label} ))} ) } export function FontSizeDropdown({ editor, btnClass, }: { editor: NonNullable> btnClass: string }) { return ( {FONT_SIZES.map((s) => ( { if (s.value) { editor.chain().focus().setMark("textStyle", { fontSize: s.value }).run() } else { editor.chain().focus().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run() } }} style={s.value ? { fontSize: s.value } : undefined} className={cn( s.value && editor.isActive("textStyle", { fontSize: s.value }) && MAIL_COMPOSE_TOOLBAR_BTN_ACTIVE )} > {s.label} ))} ) } export function ColorDropdown({ editor, btnClass, }: { editor: NonNullable> btnClass: string }) { const [tab, setTab] = useState<"text" | "bg">("text") return ( e.preventDefault()} >
{TEXT_COLORS.map((color) => (
) }