Repository navigation
fix: File preview in full screen and download blocked in embedded mode #8306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| <script setup lang="ts"> | ||
| import { onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue' | ||
| import { useI18n } from 'vue-i18n' | ||
| import { useViewType } from '@/conversation-panel/view/index' | ||
| import { useRightSidebarStore } from '../../index' | ||
| import { createFullscreenToggle, createPdfRenderer } from './index' | ||
| import { downloadByURL } from '@/utils/common' | ||
|
|
||
| defineOptions({ name: 'DocumentPreview' }) | ||
|
|
||
| const { t } = useI18n({ useScope: 'global' }) | ||
| const viewType = useViewType() | ||
| const { knowledgeSource, closeRightSide } = useRightSidebarStore() | ||
| const { previewDocument, closePreview } = knowledgeSource | ||
| const { loading, error, render, destroy } = createPdfRenderer() | ||
|
|
@@ -63,11 +65,23 @@ onBeforeUnmount(() => { | |
| <MkIcon name="icon_window-new_outlined" size="18" /> | ||
| </el-button> | ||
| </MkTooltip> | ||
| <el-divider direction="vertical" class="mx-1!" /> | ||
| <!-- 关闭文档预览 --> | ||
| <el-button text @click="closeRightSide()"> | ||
| <MkIcon name="icon_close_outlined" size="18" /> | ||
| </el-button> | ||
| <!-- 嵌入模式下由返回按钮回到知识来源,不显示关闭 --> | ||
| <template v-if="viewType !== 'EMBED'"> | ||
| <el-divider direction="vertical" class="mx-1!" /> | ||
| <!-- 关闭文档预览 --> | ||
| <el-button text @click="closeRightSide()"> | ||
| <MkIcon name="icon_close_outlined" size="18" /> | ||
| </el-button> | ||
| </template> | ||
| <!-- 占位:嵌入脚本在 iframe 外层右上角叠加放大/还原与关闭按钮,空出这两个按钮的位置,避免遮挡下载与全屏 --> | ||
| <template v-else> | ||
| <el-button text tabindex="-1" class="invisible pointer-events-none ml-0!"> | ||
| <MkIcon name="icon_magnify_outlined" size="18" /> | ||
| </el-button> | ||
| <el-button text tabindex="-1" class="invisible pointer-events-none ml-0!"> | ||
| <MkIcon name="icon_close_outlined" size="18" /> | ||
| </el-button> | ||
| </template> | ||
| </div> | ||
| </div> | ||
| <div ref="viewerRef" class="document-preview-viewer relative min-h-0 flex-1 overflow-auto bg-white"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review of the diffPotential issues
Optimization suggestions
Minor
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my review of the added code:
Issues / Irregularities
pointer-events-nonewithinvisibleis redundant and semantically confusing.invisible(visibility: hidden) already prevents pointer events, so combining both pluspointer-events-noneadds noise without benefit.pointer-events-noneis not a standard Tailwind utility in all setups. Tailwind usespointer-events-none, but if this project's config deviates, it silently does nothing. Verify it exists in your Tailwind/utility-CSS build.ml-0!(important modifier) looks suspicious. In Tailwind v3 the important modifier is!ml-0; the trailing!syntax is Tailwind v4. Mixing conventions here suggests either a misconfiguration or an accidental typo — confirm which Tailwind version this repo targets. This is the most likely bug because if the syntax is wrong, the class won't be applied at all.Non-breaking space (
) inside the button instead of self-closing tag. Either use<el-button ... />(if Element Plus supports it) or place the icon directly without stray whitespace to keep markup clean.tabindex="-1"is good for removing from tab order, but these are placeholder buttons — using actual<el-button>elements rather than styled<span>/<div>placeholders creates empty focusable/interactive elements that could confuse assistive technology even witharia-hiddenabsent. Consider addingaria-hidden="true".Hardcoded duplication. The two placeholder buttons duplicate size/class strings. If the layout ignores these frequently, extract into a small local component (
<PlaceholderBtn :icon="...">) to reduce drift between the real and placeholder buttons.Comment is verbose/Chinese while the rest of the file appears English-commented (line 83 area). Consistency suggestion only.
Optimization Suggestions
aria-hidden="true"to both placeholder buttons.invisible ml-0(droppointer-events-noneunless you actually need to keep the element clickable-but-transparent for layout).ml-0!with the correct important syntax for your Tailwind version, or remove the important flag entirely if not needed.v-else, to avoid dead DOM in normal previews.