function clampHeight(viewportHeight) { const numericHeight = Number(viewportHeight) if (!Number.isFinite(numericHeight) || numericHeight <= 0) { return 720 } return Math.max(520, numericHeight - 220) } export function buildOnlyOfficePreviewConfig(config, options = {}) { const viewportHeight = options.viewportHeight const editorConfig = { ...(config.editorConfig || {}), embedded: { embedUrl: '', fullscreenUrl: '', saveUrl: '', shareUrl: '', toolbarDocked: 'top' } } return { ...config, type: 'embedded', editorConfig, width: '100%', height: `${clampHeight(viewportHeight)}px` } }