@work-zhanguo/light-file-preview 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,12 +12,13 @@
12
12
 
13
13
  ## 项目简介
14
14
 
15
- - 当前版本:`0.0.13`
15
+ - 当前版本:`0.0.14`
16
16
  - 适用场景:业务系统附件预览、在线查看、弹窗预览、新页面预览
17
17
  - 支持 Vue 3、Vue 2 适配入口,以及非 Vue 项目的 standalone 产物
18
18
 
19
19
  最近更新:
20
20
 
21
+ - `0.0.14`:优化 `xlsx` 空白区域填充,移除未声明的表头/首列固定效果,并为 `PDF`、`DOCX` 增加默认分页与全部展示切换
21
22
  - `0.0.13`:修复弹窗失败后同文件无法重试、运行时配置更新不生效的问题,补充 README 示例图与发包说明
22
23
  - `0.0.12`:修复 `xlsx` 部分单元格背景色、文字颜色和边框颜色未正确展示的问题,补充 `theme / tint / indexed` 颜色解析
23
24
  - `0.0.11`:修复 `xlsx` 图片拉伸和底色覆盖问题,优化单元格内容的对齐、换行和数值展示
@@ -0,0 +1,110 @@
1
+ import { defineComponent as P, ref as i, computed as L, watch as _, onMounted as N, onBeforeUnmount as T, openBlock as p, createElementBlock as d, createElementVNode as n, toDisplayString as v, normalizeClass as b, Fragment as B, createCommentVNode as m } from "vue";
2
+ import { r as D } from "./text-Bqxn_tMI.js";
3
+ const R = { class: "lfp-document" }, $ = {
4
+ key: 0,
5
+ class: "lfp-page-toolbar"
6
+ }, H = { class: "lfp-page-toolbar__meta" }, S = { class: "lfp-page-toolbar__status" }, V = { class: "lfp-page-toolbar__actions" }, A = ["disabled"], O = { class: "lfp-page-toolbar__pager" }, U = ["disabled"], z = /* @__PURE__ */ P({
7
+ __name: "DocxRenderer",
8
+ props: {
9
+ source: {}
10
+ },
11
+ emits: ["loading", "error"],
12
+ setup(h, { emit: y }) {
13
+ const x = h, u = y, l = i(null), o = i(0), a = i(1), s = i("paged"), f = new AbortController(), C = L(() => o.value ? s.value === "paged" ? `第 ${a.value} / ${o.value} 页` : `共 ${o.value} 页` : "");
14
+ function w() {
15
+ if (!l.value)
16
+ return [];
17
+ const t = l.value.querySelector(".docx-wrapper");
18
+ if (!t)
19
+ return [];
20
+ const e = Array.from(t.children).filter(
21
+ (r) => r instanceof HTMLElement && (r.tagName === "SECTION" || r.classList.contains("docx"))
22
+ );
23
+ return e.length ? e : [t];
24
+ }
25
+ function c() {
26
+ const t = w();
27
+ o.value = t.length || 1, a.value = Math.min(Math.max(a.value, 1), o.value), t.forEach((e, r) => {
28
+ e.classList.add("lfp-docx-page"), e.dataset.page = String(r + 1), e.hidden = s.value === "paged" && r !== a.value - 1;
29
+ });
30
+ }
31
+ function g(t) {
32
+ s.value = t;
33
+ }
34
+ function M() {
35
+ a.value = Math.max(a.value - 1, 1);
36
+ }
37
+ function k() {
38
+ a.value = Math.min(a.value + 1, o.value);
39
+ }
40
+ async function E() {
41
+ u("loading", !0);
42
+ try {
43
+ const t = await D(x.source, f.signal), { renderAsync: e } = await import("./docx-preview-BV-bQyiM.js");
44
+ if (!l.value)
45
+ return;
46
+ l.value.innerHTML = "", await e(t, l.value, void 0, {
47
+ className: "lfp-docx-content",
48
+ ignoreWidth: !1,
49
+ ignoreHeight: !1,
50
+ useBase64URL: !0
51
+ }), c();
52
+ } catch (t) {
53
+ u("error", t instanceof Error ? t : new Error("DOCX 预览失败"));
54
+ } finally {
55
+ u("loading", !1);
56
+ }
57
+ }
58
+ return _(s, () => {
59
+ c();
60
+ }), _(a, () => {
61
+ s.value === "paged" && c();
62
+ }), N(() => {
63
+ E();
64
+ }), T(() => {
65
+ f.abort(), l.value && (l.value.innerHTML = "");
66
+ }), (t, e) => (p(), d("div", R, [
67
+ o.value ? (p(), d("div", $, [
68
+ n("div", H, [
69
+ e[2] || (e[2] = n("span", { class: "lfp-page-toolbar__title" }, "Word 视图", -1)),
70
+ n("span", S, v(C.value), 1)
71
+ ]),
72
+ n("div", V, [
73
+ n("button", {
74
+ class: b(["lfp-button is-ghost lfp-page-toolbar__toggle", { "is-active": s.value === "paged" }]),
75
+ type: "button",
76
+ onClick: e[0] || (e[0] = (r) => g("paged"))
77
+ }, " 分页 ", 2),
78
+ n("button", {
79
+ class: b(["lfp-button is-ghost lfp-page-toolbar__toggle", { "is-active": s.value === "all" }]),
80
+ type: "button",
81
+ onClick: e[1] || (e[1] = (r) => g("all"))
82
+ }, " 全部 ", 2),
83
+ s.value === "paged" && o.value > 1 ? (p(), d(B, { key: 0 }, [
84
+ n("button", {
85
+ class: "lfp-button is-ghost lfp-page-toolbar__nav",
86
+ type: "button",
87
+ disabled: a.value <= 1,
88
+ onClick: M
89
+ }, " 上一页 ", 8, A),
90
+ n("span", O, v(a.value) + " / " + v(o.value), 1),
91
+ n("button", {
92
+ class: "lfp-button is-ghost lfp-page-toolbar__nav",
93
+ type: "button",
94
+ disabled: a.value >= o.value,
95
+ onClick: k
96
+ }, " 下一页 ", 8, U)
97
+ ], 64)) : m("", !0)
98
+ ])
99
+ ])) : m("", !0),
100
+ n("div", {
101
+ ref_key: "containerRef",
102
+ ref: l,
103
+ class: "lfp-docx"
104
+ }, null, 512)
105
+ ]));
106
+ }
107
+ });
108
+ export {
109
+ z as default
110
+ };