Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.2 KB
Raw Blame
import { DiffEditor } from '@monaco-editor/react'

import 'lib/monaco/monacoEnvironment'
import { initHogLanguage } from 'lib/monaco/languages/hog'

export interface DiffProps {
    before: string
    after: string
    language?: string
}

export function Diff({ before, after, language }: DiffProps): JSX.Element {
    return (
        <DiffEditor
            height="300px"
            original={before}
            modified={after}
            language={language ?? 'json'}
            onMount={(_, monaco) => {
                if (language === 'hog') {
                    initHogLanguage(monaco)
                }
            }}
            options={{
                lineNumbers: 'off',
                minimap: { enabled: false },
                folding: false,
                wordWrap: 'on',
                renderLineHighlight: 'none',
                scrollbar: { vertical: 'auto', horizontal: 'hidden' },
                overviewRulerBorder: false,
                hideCursorInOverviewRuler: true,
                overviewRulerLanes: 0,
                tabFocusMode: true,
                enableSplitViewResizing: false,
                renderSideBySide: false,
                readOnly: true,
            }}
        />
    )
}