MCPcopy Index your code
hub / github.com/winfunc/opcode / WriteWidget

Function WriteWidget

src/components/ToolWidgets.tsx:699–865  ·  view source on GitHub ↗
({ filePath, content, result: _result })

Source from the content-addressed store, hash-verified

697 * Widget for Write tool
698 */
699export const WriteWidget: React.FC<{ filePath: string; content: string; result?: any }> = ({ filePath, content, result: _result }) => {
700 const [isMaximized, setIsMaximized] = useState(false);
701 const { theme } = useTheme();
702 const syntaxTheme = getClaudeSyntaxTheme(theme);
703
704 // Extract file extension for syntax highlighting
705 const getLanguage = (path: string) => {
706 const ext = path.split('.').pop()?.toLowerCase();
707 const languageMap: Record<string, string> = {
708 ts: "typescript",
709 tsx: "tsx",
710 js: "javascript",
711 jsx: "jsx",
712 py: "python",
713 rs: "rust",
714 go: "go",
715 java: "java",
716 cpp: "cpp",
717 c: "c",
718 cs: "csharp",
719 php: "php",
720 rb: "ruby",
721 swift: "swift",
722 kt: "kotlin",
723 scala: "scala",
724 sh: "bash",
725 bash: "bash",
726 zsh: "bash",
727 yaml: "yaml",
728 yml: "yaml",
729 json: "json",
730 xml: "xml",
731 html: "html",
732 css: "css",
733 scss: "scss",
734 sass: "sass",
735 less: "less",
736 sql: "sql",
737 md: "markdown",
738 toml: "ini",
739 ini: "ini",
740 dockerfile: "dockerfile",
741 makefile: "makefile"
742 };
743 return languageMap[ext || ""] || "text";
744 };
745
746 const language = getLanguage(filePath);
747 const isLargeContent = content.length > 1000;
748 const displayContent = isLargeContent ? content.substring(0, 1000) + "\n..." : content;
749
750 // Maximized view as a modal
751 const MaximizedView = () => {
752 if (!isMaximized) return null;
753
754 return createPortal(
755 <div className="fixed inset-0 z-50 flex items-center justify-center">
756 {/* Backdrop with blur */}

Callers

nothing calls this directly

Calls 3

useThemeFunction · 0.90
getClaudeSyntaxThemeFunction · 0.90
getLanguageFunction · 0.85

Tested by

no test coverage detected