feat(ui): 预览栏新增查看源码按钮
手机端 #fs-viewer 早有眼睛钮,桌面端预览栏只有下载和刷新:md / html / svg 这类渲染过的内容想看原文只能去终端开文件。 做法是渲染时把原文挂到节点的 __src,show() 带进 pvToolbar 的 o.source; 只有带 source 的类型才显示 #pv-src,点了在 #pv-body 里挂一个 pre 并隐藏预览 节点,再点移除。只做查看不做复制——桌面端选中即可复制,多一个按钮只是噪声。 超过 2MB 截断显示,避免大文件塞 pre 把面板卡住。 html/svg 顺手用同一份文本:r 只能读一次,svg 改为先取文本再自己包 blob。 代码类预览本身就是 .pv-pre,源码面板加 pv-src-pre 以便区分两套节点。
This commit is contained in:
@@ -503,6 +503,10 @@
|
||||
</button>
|
||||
</span>
|
||||
<span class="pv-actions">
|
||||
<!-- 源码钮:只在当前内容有源文本时出现(md/文本/代码/html/svg),点了在预览与原文间切换 -->
|
||||
<button class="icon-btn hidden" id="pv-src" title="查看源码" aria-label="查看源码">
|
||||
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||
</button>
|
||||
<button class="icon-btn hidden" id="pv-download" title="下载文件" aria-label="下载文件">
|
||||
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user