🏡 index : quine-global-labs/libreoffice-js.git

/**
 * Command images — counterpart of vcl/source/image/ImplImageTree.cxx, which
 * resolves `cmd/sc_<command>.png` from the active icon theme (Colibre,
 * Breeze, …). Until the upstream icon themes are wired in, commands map to
 * Lucide icons.
 */
import {
  AlignCenter,
  AlignJustify,
  AlignLeft,
  AlignRight,
  Baseline,
  Bold,
  ChartColumn,
  ClipboardPaste,
  Compass,
  Copy,
  FileDown,
  FilePlus,
  FolderOpen,
  Highlighter,
  Image,
  Info,
  Italic,
  Link,
  List,
  ListIndentDecrease,
  ListIndentIncrease,
  ListOrdered,
  MessageSquare,
  Omega,
  Paintbrush,
  PanelRight,
  Pilcrow,
  Printer,
  Redo2,
  RemoveFormatting,
  Ruler,
  Save,
  Scissors,
  Search,
  SeparatorHorizontal,
  SlidersHorizontal,
  SpellCheck,
  Strikethrough,
  Subscript,
  Superscript,
  Table,
  Type,
  Underline,
  Undo2,
  ZoomIn,
  ZoomOut,
  type LucideIcon,
} from "lucide-react";

const IMAGES: Record<string, LucideIcon> = {
  ".uno:AddDirect": FilePlus,
  ".uno:Open": FolderOpen,
  ".uno:Save": Save,
  ".uno:ExportDirectToPDF": FileDown,
  ".uno:Print": Printer,
  ".uno:Cut": Scissors,
  ".uno:Copy": Copy,
  ".uno:Paste": ClipboardPaste,
  ".uno:FormatPaintbrush": Paintbrush,
  ".uno:ResetAttributes": RemoveFormatting,
  ".uno:Undo": Undo2,
  ".uno:Redo": Redo2,
  ".uno:SearchDialog": Search,
  ".uno:SpellingAndGrammarDialog": SpellCheck,
  ".uno:ControlCodes": Pilcrow,
  ".uno:InsertTable": Table,
  ".uno:InsertGraphic": Image,
  ".uno:InsertObjectChart": ChartColumn,
  ".uno:CharmapControl": Omega,
  ".uno:InsertPagebreak": SeparatorHorizontal,
  ".uno:HyperlinkDialog": Link,
  ".uno:InsertAnnotation": MessageSquare,
  ".uno:Bold": Bold,
  ".uno:Italic": Italic,
  ".uno:Underline": Underline,
  ".uno:Strikeout": Strikethrough,
  ".uno:SuperScript": Superscript,
  ".uno:SubScript": Subscript,
  ".uno:FontColor": Baseline,
  ".uno:CharBackColor": Highlighter,
  ".uno:LeftPara": AlignLeft,
  ".uno:CenterPara": AlignCenter,
  ".uno:RightPara": AlignRight,
  ".uno:JustifyPara": AlignJustify,
  ".uno:DefaultBullet": List,
  ".uno:DefaultNumbering": ListOrdered,
  ".uno:IncrementIndent": ListIndentIncrease,
  ".uno:DecrementIndent": ListIndentDecrease,
  ".uno:ZoomIn": ZoomIn,
  ".uno:ZoomOut": ZoomOut,
  ".uno:Ruler": Ruler,
  ".uno:Sidebar": PanelRight,
  ".uno:Navigator": Compass,
  ".uno:DesignerDialog": Type,
  ".uno:About": Info,
  ".uno:SidebarDeck.PropertyDeck": SlidersHorizontal,
};

export function hasCommandImage(command: string): boolean {
  return command in IMAGES;
}

export function CommandImage({ command, size = 18 }: { command: string; size?: number }) {
  const Icon = IMAGES[command];
  return Icon ? <Icon size={size} strokeWidth={1.75} /> : null;
}