({ blockId, original, modified, language, fileName }: DiffViewerProps)
| 37 | } |
| 38 | |
| 39 | export function DiffViewer({ blockId, original, modified, language, fileName }: DiffViewerProps) { |
| 40 | const minimapEnabled = useOverrideConfigAtom(blockId, "editor:minimapenabled") ?? false; |
| 41 | const fontSize = boundNumber(useOverrideConfigAtom(blockId, "editor:fontsize"), 6, 64); |
| 42 | const inlineDiff = useOverrideConfigAtom(blockId, "editor:inlinediff"); |
| 43 | const uuidRef = useRef(crypto.randomUUID()).current; |
| 44 | let editorPath: string; |
| 45 | if (fileName) { |
| 46 | const separator = fileName.startsWith("/") ? "" : "/"; |
| 47 | editorPath = blockId + separator + fileName; |
| 48 | } else { |
| 49 | editorPath = uuidRef; |
| 50 | } |
| 51 | |
| 52 | const editorOpts = useMemo(() => { |
| 53 | const opts = defaultDiffEditorOptions(); |
| 54 | opts.minimap.enabled = minimapEnabled; |
| 55 | opts.fontSize = fontSize; |
| 56 | if (inlineDiff != null) { |
| 57 | opts.renderSideBySide = !inlineDiff; |
| 58 | } |
| 59 | return opts; |
| 60 | }, [minimapEnabled, fontSize, inlineDiff]); |
| 61 | |
| 62 | return ( |
| 63 | <div className="flex flex-col w-full h-full overflow-hidden items-center justify-center"> |
| 64 | <div className="flex flex-col h-full w-full"> |
| 65 | <MonacoDiffViewer |
| 66 | path={editorPath} |
| 67 | original={original} |
| 68 | modified={modified} |
| 69 | options={editorOpts} |
| 70 | language={language} |
| 71 | /> |
| 72 | </div> |
| 73 | </div> |
| 74 | ); |
| 75 | } |
nothing calls this directly
no test coverage detected