feat: 完善知识库预览功能与配置管理优化
This commit is contained in:
30
web/src/views/scripts/onlyOfficePreviewConfig.js
Normal file
30
web/src/views/scripts/onlyOfficePreviewConfig.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user