/** * MarkdownFormatToolbar — contextual toolbar for selected markdown cards. * Shows background color picker, width presets, and accent color picker. */ import React, { useState, useEffect } from 'react'; interface MarkdownFormatToolbarProps { x: number; y: number; bgColor: string; accentColor: string; width: number; onBgColorChange: (color: string) => void; onAccentColorChange: (color: string) => void; onWidthChange: (width: number) => void; } const PRESET_COLORS = [ '#232336', '#1e1e2e', '#2a2a3a', '#1a2332', '#2a1a2a', '#1a2a1a', '#2a2a1a', '#333333', '#1a1a1a', '#3a2a42', ]; const ACCENT_COLORS = [ '#7950f2', '#4dabf7', '#69db7c', '#ffd43b', '#ff6b6b', '#e64980', '#ffa94d', '#868e96', '#ffffff', '#f783ac', ]; const WIDTH_PRESETS = [ { label: 'S', value: 300 }, { label: 'M', value: 450 }, { label: 'L', value: 650 }, ]; export default function MarkdownFormatToolbar(props: MarkdownFormatToolbarProps) { const { x, y, bgColor, accentColor, width, onBgColorChange, onAccentColorChange, onWidthChange } = props; const [showBgPicker, setShowBgPicker] = useState(false); const [showAccentPicker, setShowAccentPicker] = useState(false); useEffect(() => { const onDown = () => { setShowBgPicker(false); setShowAccentPicker(false); }; window.addEventListener('pointerdown', onDown); return () => window.removeEventListener('pointerdown', onDown); }, []); const btnStyle: React.CSSProperties = { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '26px', background: 'transparent', border: 'none', borderRadius: '5px', color: '#999', cursor: 'pointer', padding: '0 6px', fontSize: '11px', fontFamily: 'system-ui, sans-serif', whiteSpace: 'nowrap', transition: 'all 0.1s', }; return (