"use client" import { cn } from "@/lib/utils" import { CONTENT_MODE_OPTIONS, type ContentMode, } from "./types" type EditorModeSwitchProps = { value: ContentMode allowedModes?: ReadonlyArray disabled?: boolean onChange: (nextMode: ContentMode) => void } const MODE_OPTIONS: Array<{ value: ContentMode; label: string }> = [ { value: "markdown", label: "Markdown" }, { value: "html", label: "HTML" }, ] export function EditorModeSwitch({ value, allowedModes = CONTENT_MODE_OPTIONS, disabled = false, onChange, }: EditorModeSwitchProps) { const options = MODE_OPTIONS.filter((option) => allowedModes.includes(option.value)) if (options.length <= 1) { return null } return (
{options.map((option) => { const active = option.value === value return ( ) })}
) }