import { AlertTriangle, Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' import { CodeEditor } from '@/components/CodeEditor' import { Label } from '@/components/ui/label' import { sanitizeCSS } from '@/lib/theme/sanitizer' export type ComponentCSSEditorProps = { /** 组件唯一标识符 */ componentId: string /** 当前 CSS 内容 */ value: string /** CSS 内容变更回调 */ onChange: (css: string) => void /** 编辑器标签文字 */ label?: string /** 编辑器高度,默认 200px */ height?: string } /** * 组件级 CSS 编辑器 * 提供 CSS 代码编辑、语法高亮和安全过滤警告功能 */ export function ComponentCSSEditor({ componentId, value, onChange, label, height = '200px', }: ComponentCSSEditorProps) { // 实时计算 CSS 警告 const { warnings } = sanitizeCSS(value) return (
{warnings.length > 0 && (
检测到不安全的 CSS 规则:
    {warnings.map((w, i) => (
  • {w}
  • ))}
)}
) }