Skip to content

Commit 743742d

Browse files
TheodoreSpeaksTheodore Licursoragent
authored
Show rendered md by default (#3594)
* Show rendered md by default * Lint fix * chore(file-viewer): remove dead PREVIEW_ONLY_EXTENSIONS export Co-authored-by: Theodore Li <TheodoreSpeaks@users.noreply.github.com> * Fix new file logic to default to text --------- Co-authored-by: Theodore Li <theo@sim.ai> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Theodore Li <TheodoreSpeaks@users.noreply.github.com>
1 parent b7b575c commit 743742d

File tree

6 files changed

+14
-20
lines changed

6 files changed

+14
-20
lines changed

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function FileViewer({
9898
file={file}
9999
workspaceId={workspaceId}
100100
canEdit={canEdit}
101-
previewMode={previewMode ?? (showPreview ? 'split' : 'editor')}
101+
previewMode={previewMode ?? (showPreview ? 'preview' : 'editor')}
102102
autoFocus={autoFocus}
103103
onDirtyChange={onDirtyChange}
104104
onSaveStatusChange={onSaveStatusChange}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export type { PreviewMode } from './file-viewer'
22
export { FileViewer, isPreviewable, isTextEditable } from './file-viewer'
3-
export { PREVIEW_ONLY_EXTENSIONS, RICH_PREVIEWABLE_EXTENSIONS } from './preview-panel'
3+
export { RICH_PREVIEWABLE_EXTENSIONS } from './preview-panel'

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ const PREVIEWABLE_EXTENSIONS: Record<string, PreviewType> = {
2323
svg: 'svg',
2424
}
2525

26-
/** Extensions that should default to rendered preview (no raw editor). */
27-
export const PREVIEW_ONLY_EXTENSIONS = new Set(['html', 'htm', 'svg'])
28-
2926
/** All extensions that have a rich preview renderer. */
3027
export const RICH_PREVIEWABLE_EXTENSIONS = new Set(Object.keys(PREVIEWABLE_EXTENSIONS))
3128

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,11 @@ export function Files() {
476476
}, [closeListContextMenu])
477477

478478
useEffect(() => {
479-
if (justCreatedFileIdRef.current && selectedFileId !== justCreatedFileIdRef.current) {
479+
const isJustCreated = selectedFileId != null && justCreatedFileIdRef.current === selectedFileId
480+
if (justCreatedFileIdRef.current && !isJustCreated) {
480481
justCreatedFileIdRef.current = null
481482
}
482-
setShowPreview(true)
483+
setShowPreview(!isJustCreated)
483484
}, [selectedFileId])
484485

485486
useEffect(() => {
@@ -521,8 +522,8 @@ export function Files() {
521522
...(canPreview
522523
? [
523524
{
524-
label: showPreview ? 'Hide Preview' : 'Preview',
525-
icon: Eye,
525+
label: showPreview ? 'Edit' : 'Preview',
526+
icon: showPreview ? Pencil : Eye,
526527
onClick: handleTogglePreview,
527528
},
528529
]

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
useState,
99
} from 'react'
1010
import { Button, Tooltip } from '@/components/emcn'
11-
import { Columns3, Eye, PanelLeft, Rows3 } from '@/components/emcn/icons'
11+
import { Columns3, Eye, PanelLeft, Pencil } from '@/components/emcn/icons'
1212
import { cn } from '@/lib/core/utils/cn'
1313
import type { PreviewMode } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
1414
import { AddResourceDropdown } from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown'
@@ -36,9 +36,9 @@ const EDGE_ZONE = 40
3636
const SCROLL_SPEED = 8
3737

3838
const PREVIEW_MODE_ICONS = {
39-
editor: Rows3,
40-
split: Columns3,
41-
preview: Eye,
39+
editor: Columns3,
40+
split: Eye,
41+
preview: Pencil,
4242
} satisfies Record<PreviewMode, (props: ComponentProps<typeof Eye>) => ReactNode>
4343

4444
/**

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/mothership-view.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { memo, useCallback, useEffect, useState } from 'react'
44
import { cn } from '@/lib/core/utils/cn'
55
import { getFileExtension } from '@/lib/uploads/utils/file-utils'
66
import type { PreviewMode } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
7-
import {
8-
PREVIEW_ONLY_EXTENSIONS,
9-
RICH_PREVIEWABLE_EXTENSIONS,
10-
} from '@/app/workspace/[workspaceId]/files/components/file-viewer'
7+
import { RICH_PREVIEWABLE_EXTENSIONS } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
118
import type {
129
MothershipResource,
1310
MothershipResourceType,
@@ -49,12 +46,11 @@ export const MothershipView = memo(function MothershipView({
4946
}: MothershipViewProps) {
5047
const active = resources.find((r) => r.id === activeResourceId) ?? resources[0] ?? null
5148

52-
const [previewMode, setPreviewMode] = useState<PreviewMode>('split')
49+
const [previewMode, setPreviewMode] = useState<PreviewMode>('preview')
5350
const handleCyclePreview = useCallback(() => setPreviewMode((m) => PREVIEW_CYCLE[m]), [])
5451

5552
useEffect(() => {
56-
const ext = active?.type === 'file' ? getFileExtension(active.title) : ''
57-
setPreviewMode(PREVIEW_ONLY_EXTENSIONS.has(ext) ? 'preview' : 'split')
53+
setPreviewMode('preview')
5854
}, [active?.id])
5955

6056
const isActivePreviewable =

0 commit comments

Comments
 (0)