Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,47 @@ export function FieldFormat({
)
}

if (field.type === 'files') {
const lineCount = fieldValue.split('\n').length
const gutterWidth = calculateGutterWidth(lineCount)

const renderLineNumbers = () => {
return Array.from({ length: lineCount }, (_, i) => (
<div
key={i}
className='font-medium font-mono text-[var(--text-muted)] text-xs'
style={{ height: `${21}px`, lineHeight: `${21}px` }}
>
{i + 1}
</div>
))
}

return (
<Code.Container className='min-h-[120px]'>
<Code.Gutter width={gutterWidth}>{renderLineNumbers()}</Code.Gutter>
<Code.Content paddingLeft={`${gutterWidth}px`}>
<Code.Placeholder gutterWidth={gutterWidth} show={fieldValue.length === 0}>
{
'[\n {\n "data": "data:application/pdf;base64,...",\n "type": "file",\n "name": "document.pdf",\n "mime": "application/pdf"\n }\n]'
}
</Code.Placeholder>
<Editor
value={fieldValue}
onValueChange={(newValue) => {
if (!isReadOnly) {
updateField(field.id, 'value', newValue)
}
}}
highlight={(code) => highlight(code, languages.json, 'json')}
disabled={isReadOnly}
{...getCodeEditorProps({ disabled: isReadOnly })}
/>
</Code.Content>
</Code.Container>
)
}

return (
<>
<Input
Expand Down
4 changes: 4 additions & 0 deletions apps/sim/components/emcn/components/code/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ function Container({
'group relative min-h-[100px] rounded-[4px] border border-[var(--border-strong)]',
'bg-[#1F1F1F] font-medium font-mono text-sm transition-colors',
'dark:border-[var(--border-strong)]',
// Overflow handling for long content
'overflow-x-auto',
// Vertical resize handle
'resize-y overflow-y-auto',
// Streaming state
isStreaming && 'streaming-effect',
className
Expand Down