Skip to content

Commit 33851c3

Browse files
fix(ui): address PR feedback on docx fit and Monaco type cast
Use computed padding from `.docx-wrapper` instead of a hardcoded 60px so the fit calculation survives docx-preview library changes. Replace the inline `import()` cast for ShowLightbulbIconMode with a top-level type import. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aa87090 commit 33851c3

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import {
1515

1616
const logger = createLogger('DocxPreview')
1717

18-
/** Horizontal padding the docx-preview library applies inside `.docx-wrapper`. */
19-
const WRAPPER_HORIZONTAL_PADDING_PX = 60
20-
2118
/**
2219
* Fit the rendered docx pages to the host container width using a CSS scale.
2320
* The library renders `<section class="docx">` at the document's natural page
@@ -38,7 +35,10 @@ function fitDocxToContainer(host: HTMLElement) {
3835
const naturalPageWidth = section.offsetWidth
3936
if (!naturalPageWidth) return
4037

41-
const naturalWrapperWidth = naturalPageWidth + WRAPPER_HORIZONTAL_PADDING_PX
38+
const wrapperStyle = window.getComputedStyle(wrapper)
39+
const horizontalPadding =
40+
parseFloat(wrapperStyle.paddingLeft) + parseFloat(wrapperStyle.paddingRight)
41+
const naturalWrapperWidth = naturalPageWidth + horizontalPadding
4242
const available = host.clientWidth
4343
const scale = Math.min(1, available / naturalWrapperWidth)
4444

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { memo, useCallback, useEffect, useReducer, useRef, useState } from 'react'
44
import type { OnMount } from '@monaco-editor/react'
5+
import type { editor as MonacoEditorTypes } from 'monaco-editor'
56
import dynamic from 'next/dynamic'
67
import { Skeleton } from '@/components/emcn'
78
import { cn } from '@/lib/core/utils/cn'
@@ -652,7 +653,7 @@ export const TextEditor = memo(function TextEditor({
652653
hover: { enabled: false },
653654
codeLens: false,
654655
lightbulb: {
655-
enabled: 'off' as import('monaco-editor').editor.ShowLightbulbIconMode,
656+
enabled: 'off' as MonacoEditorTypes.ShowLightbulbIconMode,
656657
},
657658
inlayHints: { enabled: 'off' },
658659
}}

0 commit comments

Comments
 (0)