@lingshugroup/web-plus 1.7.9 → 1.7.10
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/lib/index.css +1 -1
- package/lib/index.css.br +0 -0
- package/lib/index.css.gz +0 -0
- package/lib/packages/ls-components/components/preview_pdf/Pdf.vue/index.cjs +1 -1
- package/lib/packages/ls-components/components/preview_pdf/Pdf.vue/index.js +2 -2
- package/lib/packages/ls-components/components/preview_pdf/Pdf.vue/index2.cjs +1 -1
- package/lib/packages/ls-components/components/preview_pdf/Pdf.vue/index2.js +64 -63
- package/lib/packages/ls-components/components/preview_pdf/Pdf.vue/index2.js.br +0 -0
- package/lib/packages/ls-components/components/preview_pdf/Pdf.vue/index2.js.gz +0 -0
- package/lib/packages/ls-components/components/preview_pdf/composable/index.cjs +1 -1
- package/lib/packages/ls-components/components/preview_pdf/composable/index.js +58 -58
- package/lib/packages/ls-components/components/preview_pdf/composable/index.js.br +0 -0
- package/lib/packages/ls-components/components/preview_pdf/composable/index.js.gz +0 -0
- package/lib/types/components/preview_pdf/Pdf.vue.d.ts +1 -0
- package/lib/types/components/preview_pdf/composable.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.css.br
CHANGED
|
Binary file
|
package/lib/index.css.gz
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=;/* empty css */;/* empty css */const t=,/* empty css */u=t.default(e.default,[["__scopeId","data-v-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=;/* empty css */;/* empty css */const t=,/* empty css */u=t.default(e.default,[["__scopeId","data-v-083051d7"]]);exports.default=u;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./index2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import t from "../../../../../_virtual/_plugin-vue_export-helper/index.js";
|
|
4
|
-
const
|
|
4
|
+
const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-083051d7"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
p as default
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var n=(p,m)=>D(p,"name",{value:m,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});;/* empty css */;/* empty css */;/* empty css */const e=require("vue"),
|
|
1
|
+
"use strict";var D=Object.defineProperty;var n=(p,m)=>D(p,"name",{value:m,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});;/* empty css */;/* empty css */;/* empty css */const e=require("vue"),M=,/* empty css */T=,/* empty css */h=,/* empty css */$=,/* empty css */I=,/* empty css */F={class:"opt-wrap"},j={key:0,class:"page-wrap"},O={class:"num-wrap"},U={key:1,class:"size-wrap"},A={class:"num-wrap"},G={class:"pdf-content"},H={key:1,class:"infinite-list-wrapper",style:{overflow:"auto"}},J=["infinite-scroll-disabled"],K=e.defineComponent({name:"LSPdf"}),Q=e.defineComponent({...K,props:{source:{},onClose:{},showSize:{type:Boolean,default:!0},cMapUrlPath:{}},emits:["annotation","highlight","loaded","textLoaded","annotationLoaded","xfaLoaded","loadComplete","loadError","update:source"],setup(p,{emit:m}){const v=M.useNamespace("pdf"),E=v.b(),_=e.ref(void 0),l=e.ref(1),a=e.ref(0),t=e.ref(1),c=e.ref(!0),C=e.ref(!1),r=p,k=m;e.watch(()=>r.source,()=>{V()},{immediate:!0,deep:!0});const B=e.computed(()=>c.value?"取消分页":"分页展示");async function V(){if(r.source)try{const{pdf:s,processLoadingTask:o,pages:i}=T.usePDF(r.source,r.cMapUrlPath,{onError:d});await o(r.source),_.value=s.value,a.value=i.value,g()}catch{d()}finally{C.value=!0}}n(V,"initPdf");const b=n(()=>{C.value=!1,r.onClose&&r.onClose(),k("update:source")},"closeFunc");function P(){l.value>1&&l.value--}n(P,"prevPdf");function w(){l.value<a.value&&l.value++}n(w,"nextPdf");function N(s){s===0?t.value=t.value>.25?t.value-.25:t.value:t.value=t.value<2?t.value+.25:t.value}n(N,"scalePdf");const y=e.ref(!1),u=e.ref(0),S=n(()=>{if(u.value>=a.value){y.value=!0;return}u.value++},"load");function L(){c.value=!c.value,c.value||(y.value=!1,u.value=a.value>10?10:a.value)}n(L,"changePagition");function g(){k("loadComplete")}n(g,"loadComplete");function d(){k("loadError")}return n(d,"loadError"),(s,o)=>{const i=e.resolveComponent("LSButton"),x=e.resolveComponent("LSIcon"),z=$.ElScrollbar,q=I.ElInfiniteScroll;return e.unref(C)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(E))},[e.createElementVNode("div",F,[e.unref(c)?(e.openBlock(),e.createElementBlock("div",j,[e.createVNode(i,{type:"primary",size:"small",disabled:e.unref(l)==1,onClick:P},{default:e.withCtx(()=>o[2]||(o[2]=[e.createTextVNode("上一页")])),_:1},8,["disabled"]),e.createElementVNode("span",O,e.toDisplayString(e.unref(l))+" / "+e.toDisplayString(e.unref(a)),1),e.createVNode(i,{type:"primary",size:"small",disabled:e.unref(l)==e.unref(a),onClick:w},{default:e.withCtx(()=>o[3]||(o[3]=[e.createTextVNode("下一页")])),_:1},8,["disabled"])])):e.createCommentVNode("",!0),s.showSize?(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(i,{type:"primary",icon:"Minus",size:"small",disabled:e.unref(t)==.25,onClick:o[0]||(o[0]=f=>N(0))},null,8,["disabled"]),e.createElementVNode("span",A,e.toDisplayString(e.unref(t)*100)+"%",1),e.createVNode(i,{type:"primary",icon:"Plus",size:"small",disabled:e.unref(t)==2,onClick:o[1]||(o[1]=f=>N(1))},null,8,["disabled"])])):e.createCommentVNode("",!0),e.createVNode(i,{type:"primary",size:"small",onClick:L},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(B)),1)]),_:1}),e.createElementVNode("span",{class:e.normalizeClass([e.unref(v).e("btn"),e.unref(v).e("close")]),onClick:b},[e.createVNode(x,{name:"Close",size:26})],2)]),e.createElementVNode("div",G,[e.unref(c)?(e.openBlock(),e.createBlock(h.default,e.mergeProps({key:0},s.$attrs,{pdf:e.unref(_),page:e.unref(l),scale:e.unref(t),onLoadComplete:g,onLoadError:d}),null,16,["pdf","page","scale"])):(e.openBlock(),e.createElementBlock("div",H,[e.createVNode(z,{height:"calc(100vh - 48px)"},{default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("ul",{"infinite-scroll-disabled":e.unref(y),class:"infinite-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(u),f=>(e.openBlock(),e.createElementBlock("li",{key:f,class:"infinite-list-item"},[e.createVNode(h.default,e.mergeProps({ref_for:!0},s.$attrs,{pdf:e.unref(_),page:f,scale:e.unref(t),onLoadComplete:g,onLoadError:d}),null,16,["pdf","page","scale"])]))),128))],8,J)),[[q,S]])]),_:1})]))])],2)):e.createCommentVNode("",!0)}}});exports.default=Q;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var l = (
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var l = (h, k) => K(h, "name", { value: k, configurable: !0 });
|
|
3
3
|
/* empty css */
|
|
4
4
|
/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { defineComponent as
|
|
6
|
+
import { defineComponent as D, ref as s, watch as Q, computed as R, resolveComponent as N, unref as e, openBlock as n, createElementBlock as p, normalizeClass as $, createElementVNode as m, createVNode as i, withCtx as C, createTextVNode as S, toDisplayString as g, createCommentVNode as x, createBlock as W, mergeProps as M, withDirectives as X, Fragment as Y, renderList as Z } from "vue";
|
|
7
7
|
import { useNamespace as ee } from "../../_hooks/useNamespace/index.js";
|
|
8
8
|
import { usePDF as oe } from "../composable/index.js";
|
|
9
|
-
import
|
|
9
|
+
import V from "../pdfs/PdfItem.vue/index.js";
|
|
10
10
|
import { ElScrollbar as te } from "../../../../../node_modules/.pnpm/element-plus@2.8.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/scrollbar/index/index.js";
|
|
11
11
|
import { ElInfiniteScroll as le } from "../../../../../node_modules/.pnpm/element-plus@2.8.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/infinite-scroll/index/index.js";
|
|
12
|
-
const
|
|
12
|
+
const ae = { class: "opt-wrap" }, se = {
|
|
13
13
|
key: 0,
|
|
14
14
|
class: "page-wrap"
|
|
15
15
|
}, ne = { class: "num-wrap" }, ie = {
|
|
@@ -19,69 +19,70 @@ const se = { class: "opt-wrap" }, ae = {
|
|
|
19
19
|
key: 1,
|
|
20
20
|
class: "infinite-list-wrapper",
|
|
21
21
|
style: { overflow: "auto" }
|
|
22
|
-
}, de = ["infinite-scroll-disabled"], pe =
|
|
22
|
+
}, de = ["infinite-scroll-disabled"], pe = D({
|
|
23
23
|
name: "LSPdf"
|
|
24
|
-
}), we = /* @__PURE__ */
|
|
24
|
+
}), we = /* @__PURE__ */ D({
|
|
25
25
|
...pe,
|
|
26
26
|
props: {
|
|
27
27
|
source: {},
|
|
28
28
|
onClose: {},
|
|
29
|
-
showSize: { type: Boolean, default: !0 }
|
|
29
|
+
showSize: { type: Boolean, default: !0 },
|
|
30
|
+
cMapUrlPath: {}
|
|
30
31
|
},
|
|
31
32
|
emits: ["annotation", "highlight", "loaded", "textLoaded", "annotationLoaded", "xfaLoaded", "loadComplete", "loadError", "update:source"],
|
|
32
|
-
setup(
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
() =>
|
|
33
|
+
setup(h, { emit: k }) {
|
|
34
|
+
const b = ee("pdf"), F = b.b(), w = s(void 0), a = s(1), r = s(0), o = s(1), f = s(!0), L = s(!1), c = h, P = k;
|
|
35
|
+
Q(
|
|
36
|
+
() => c.source,
|
|
36
37
|
() => {
|
|
37
|
-
|
|
38
|
+
T();
|
|
38
39
|
},
|
|
39
40
|
{
|
|
40
41
|
immediate: !0,
|
|
41
42
|
deep: !0
|
|
42
43
|
}
|
|
43
44
|
);
|
|
44
|
-
const
|
|
45
|
-
async function
|
|
46
|
-
if (
|
|
45
|
+
const I = R(() => f.value ? "取消分页" : "分页展示");
|
|
46
|
+
async function T() {
|
|
47
|
+
if (c.source)
|
|
47
48
|
try {
|
|
48
|
-
const { pdf:
|
|
49
|
+
const { pdf: u, processLoadingTask: t, pages: d } = oe(c.source, c.cMapUrlPath, {
|
|
49
50
|
onError: _
|
|
50
51
|
});
|
|
51
|
-
await t(
|
|
52
|
+
await t(c.source), w.value = u.value, r.value = d.value, E();
|
|
52
53
|
} catch {
|
|
53
54
|
_();
|
|
54
55
|
} finally {
|
|
55
56
|
L.value = !0;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
l(
|
|
59
|
-
const
|
|
60
|
-
L.value = !1,
|
|
59
|
+
l(T, "initPdf");
|
|
60
|
+
const U = /* @__PURE__ */ l(() => {
|
|
61
|
+
L.value = !1, c.onClose && c.onClose(), P("update:source");
|
|
61
62
|
}, "closeFunc");
|
|
62
|
-
function
|
|
63
|
-
|
|
63
|
+
function j() {
|
|
64
|
+
a.value > 1 && a.value--;
|
|
64
65
|
}
|
|
65
|
-
l(
|
|
66
|
-
function
|
|
67
|
-
|
|
66
|
+
l(j, "prevPdf");
|
|
67
|
+
function O() {
|
|
68
|
+
a.value < r.value && a.value++;
|
|
68
69
|
}
|
|
69
|
-
l(
|
|
70
|
-
function B(
|
|
71
|
-
|
|
70
|
+
l(O, "nextPdf");
|
|
71
|
+
function B(u) {
|
|
72
|
+
u === 0 ? o.value = o.value > 0.25 ? o.value - 0.25 : o.value : o.value = o.value < 2 ? o.value + 0.25 : o.value;
|
|
72
73
|
}
|
|
73
74
|
l(B, "scalePdf");
|
|
74
|
-
const z =
|
|
75
|
+
const z = s(!1), v = s(0), q = /* @__PURE__ */ l(() => {
|
|
75
76
|
if (v.value >= r.value) {
|
|
76
77
|
z.value = !0;
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
v.value++;
|
|
80
81
|
}, "load");
|
|
81
|
-
function
|
|
82
|
-
|
|
82
|
+
function A() {
|
|
83
|
+
f.value = !f.value, f.value || (z.value = !1, v.value = r.value > 10 ? 10 : r.value);
|
|
83
84
|
}
|
|
84
|
-
l(
|
|
85
|
+
l(A, "changePagition");
|
|
85
86
|
function E() {
|
|
86
87
|
P("loadComplete");
|
|
87
88
|
}
|
|
@@ -89,31 +90,31 @@ const se = { class: "opt-wrap" }, ae = {
|
|
|
89
90
|
function _() {
|
|
90
91
|
P("loadError");
|
|
91
92
|
}
|
|
92
|
-
return l(_, "loadError"), (
|
|
93
|
-
const
|
|
94
|
-
return e(L) ? (n(),
|
|
93
|
+
return l(_, "loadError"), (u, t) => {
|
|
94
|
+
const d = N("LSButton"), G = N("LSIcon"), H = te, J = le;
|
|
95
|
+
return e(L) ? (n(), p("div", {
|
|
95
96
|
key: 0,
|
|
96
|
-
class: $(e(
|
|
97
|
+
class: $(e(F))
|
|
97
98
|
}, [
|
|
98
|
-
m("div",
|
|
99
|
-
e(
|
|
100
|
-
i(
|
|
99
|
+
m("div", ae, [
|
|
100
|
+
e(f) ? (n(), p("div", se, [
|
|
101
|
+
i(d, {
|
|
101
102
|
type: "primary",
|
|
102
103
|
size: "small",
|
|
103
|
-
disabled: e(
|
|
104
|
-
onClick:
|
|
104
|
+
disabled: e(a) == 1,
|
|
105
|
+
onClick: j
|
|
105
106
|
}, {
|
|
106
107
|
default: C(() => t[2] || (t[2] = [
|
|
107
108
|
S("上一页")
|
|
108
109
|
])),
|
|
109
110
|
_: 1
|
|
110
111
|
}, 8, ["disabled"]),
|
|
111
|
-
m("span", ne, g(e(
|
|
112
|
-
i(
|
|
112
|
+
m("span", ne, g(e(a)) + " / " + g(e(r)), 1),
|
|
113
|
+
i(d, {
|
|
113
114
|
type: "primary",
|
|
114
115
|
size: "small",
|
|
115
|
-
disabled: e(
|
|
116
|
-
onClick:
|
|
116
|
+
disabled: e(a) == e(r),
|
|
117
|
+
onClick: O
|
|
117
118
|
}, {
|
|
118
119
|
default: C(() => t[3] || (t[3] = [
|
|
119
120
|
S("下一页")
|
|
@@ -121,8 +122,8 @@ const se = { class: "opt-wrap" }, ae = {
|
|
|
121
122
|
_: 1
|
|
122
123
|
}, 8, ["disabled"])
|
|
123
124
|
])) : x("", !0),
|
|
124
|
-
|
|
125
|
-
i(
|
|
125
|
+
u.showSize ? (n(), p("div", ie, [
|
|
126
|
+
i(d, {
|
|
126
127
|
type: "primary",
|
|
127
128
|
icon: "Minus",
|
|
128
129
|
size: "small",
|
|
@@ -130,7 +131,7 @@ const se = { class: "opt-wrap" }, ae = {
|
|
|
130
131
|
onClick: t[0] || (t[0] = (y) => B(0))
|
|
131
132
|
}, null, 8, ["disabled"]),
|
|
132
133
|
m("span", re, g(e(o) * 100) + "%", 1),
|
|
133
|
-
i(
|
|
134
|
+
i(d, {
|
|
134
135
|
type: "primary",
|
|
135
136
|
icon: "Plus",
|
|
136
137
|
size: "small",
|
|
@@ -138,45 +139,45 @@ const se = { class: "opt-wrap" }, ae = {
|
|
|
138
139
|
onClick: t[1] || (t[1] = (y) => B(1))
|
|
139
140
|
}, null, 8, ["disabled"])
|
|
140
141
|
])) : x("", !0),
|
|
141
|
-
i(
|
|
142
|
+
i(d, {
|
|
142
143
|
type: "primary",
|
|
143
144
|
size: "small",
|
|
144
|
-
onClick:
|
|
145
|
+
onClick: A
|
|
145
146
|
}, {
|
|
146
147
|
default: C(() => [
|
|
147
|
-
S(g(e(
|
|
148
|
+
S(g(e(I)), 1)
|
|
148
149
|
]),
|
|
149
150
|
_: 1
|
|
150
151
|
}),
|
|
151
152
|
m("span", {
|
|
152
|
-
class: $([e(
|
|
153
|
-
onClick:
|
|
153
|
+
class: $([e(b).e("btn"), e(b).e("close")]),
|
|
154
|
+
onClick: U
|
|
154
155
|
}, [
|
|
155
|
-
i(
|
|
156
|
+
i(G, {
|
|
156
157
|
name: "Close",
|
|
157
158
|
size: 26
|
|
158
159
|
})
|
|
159
160
|
], 2)
|
|
160
161
|
]),
|
|
161
162
|
m("div", ce, [
|
|
162
|
-
e(
|
|
163
|
+
e(f) ? (n(), W(V, M({ key: 0 }, u.$attrs, {
|
|
163
164
|
pdf: e(w),
|
|
164
|
-
page: e(
|
|
165
|
+
page: e(a),
|
|
165
166
|
scale: e(o),
|
|
166
167
|
onLoadComplete: E,
|
|
167
168
|
onLoadError: _
|
|
168
|
-
}), null, 16, ["pdf", "page", "scale"])) : (n(),
|
|
169
|
-
i(
|
|
169
|
+
}), null, 16, ["pdf", "page", "scale"])) : (n(), p("div", ue, [
|
|
170
|
+
i(H, { height: "calc(100vh - 48px)" }, {
|
|
170
171
|
default: C(() => [
|
|
171
|
-
X((n(),
|
|
172
|
+
X((n(), p("ul", {
|
|
172
173
|
"infinite-scroll-disabled": e(z),
|
|
173
174
|
class: "infinite-list"
|
|
174
175
|
}, [
|
|
175
|
-
(n(!0),
|
|
176
|
+
(n(!0), p(Y, null, Z(e(v), (y) => (n(), p("li", {
|
|
176
177
|
key: y,
|
|
177
178
|
class: "infinite-list-item"
|
|
178
179
|
}, [
|
|
179
|
-
i(
|
|
180
|
+
i(V, M({ ref_for: !0 }, u.$attrs, {
|
|
180
181
|
pdf: e(w),
|
|
181
182
|
page: y,
|
|
182
183
|
scale: e(o),
|
|
@@ -185,7 +186,7 @@ const se = { class: "opt-wrap" }, ae = {
|
|
|
185
186
|
}), null, 16, ["pdf", "page", "scale"])
|
|
186
187
|
]))), 128))
|
|
187
188
|
], 8, de)), [
|
|
188
|
-
[
|
|
189
|
+
[J, q]
|
|
189
190
|
])
|
|
190
191
|
]),
|
|
191
192
|
_: 1
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var c=(s,b)=>N(s,"name",{value:b,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("pdfjs-dist"),O=require("../../../../../node_modules/.pnpm/pdfjs-dist@4.8.69/node_modules/pdfjs-dist/build/pdf.worker.min/index.cjs"),f=require("vue"),h=require("../pdfs/destination/index.cjs"),I=require("../pdfs/miscellaneous/index.cjs");function q(s){P.GlobalWorkerOptions.workerSrc=s}c(q,"configWorker");function A(s,b,i={onProgress:void 0,onPassword:void 0,onError:void 0,password:""}){var S;(S=P.GlobalWorkerOptions)!=null&&S.workerSrc||q(O.default);const D=f.shallowRef(),l=f.shallowRef(),k=f.shallowRef(0),R=f.shallowRef({});function g(u){l.value&&l.value.destroy();const o=P.getDocument({url:u,cMapUrl:b,cMapPacked:!0});if(i.onProgress&&(o.onProgress=i.onProgress),i.onPassword)o.onPassword=i.onPassword;else if(i.password){const e=c(r=>{r(i.password??"")},"onPassword");o.onPassword=e}return o.promise.then(async e=>{l.value=e,D.value=e.loadingTask,k.value=e.numPages;const r=await e.getMetadata(),a=await e.getAttachments(),n=await e.getJSActions(),d=await e.getOutline();R.value={metadata:r,attachments:a,javascript:n,outline:d}},e=>{typeof i.onError=="function"&&i.onError(e)})}c(g,"processLoadingTask");async function U(u){var t;const o=await((t=D.value)==null?void 0:t.promise);if(!o)return null;const e=await h.getDestinationArray(o,u),r=await h.getDestinationRef(o,e);if(!r||!e)return null;const a=await o.getPageIndex(r),n=e[1].name,d=e.slice(2),v=h.isSpecLike(d)?h.getLocation(n,d):null;return{pageIndex:a,location:v??{type:"Fit",spec:[]}}}c(U,"getPDFDestination");async function x(u="filename"){var n;if(!l.value)throw new Error("Current PDFDocumentProxy have not loaded yet");const o=await((n=l.value)==null?void 0:n.saveDocument()),e=new Blob([o],{type:"application/pdf"}),r=URL.createObjectURL(e),a=document.createElement("a");document.body.appendChild(a),a.href=r,a.download=u,a.style.display="none",a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},10)}c(x,"download");async function E(u=150,o="filename"){var C,T;if(!l.value)throw new Error("Current PDFDocumentProxy have not loaded yet");const e=await((C=l.value)==null?void 0:C.saveDocument()),a=await P.getDocument(e.buffer).promise,n=u/72,d=96/72,v=await I.createIframe(),t=v.contentWindow;t.document.title=o;const F=[...Array(a.numPages).keys()].map(p=>p+1);for(const p of F){const y=await a.getPage(p),m=y.getViewport({scale:1});p===1&&I.addStylesToIframe(t,m.width*n/d,m.height*n/d);const w=document.createElement("canvas");w.width=m.width*n,w.height=m.height*n;const L=w.cloneNode();t==null||t.document.body.appendChild(L),await(y==null?void 0:y.render({canvasContext:w.getContext("2d"),intent:"print",transform:[n,0,0,n,0,0],viewport:m}).promise),(T=L.getContext("2d"))==null||T.drawImage(w,0,0)}t==null||t.focus(),t==null||t.print(),document.body.removeChild(v)}return c(E,"print"),f.isRef(s)?(s.value&&g(s.value),f.watch(s,()=>{s.value&&g(s.value)})):s&&g(s),{pdf:D,pages:k,info:R,print:E,download:x,getPDFDestination:U,processLoadingTask:g}}c(A,"usePDF");exports.usePDF=A;
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
var
|
|
2
|
-
var c = (r,
|
|
3
|
-
import { GlobalWorkerOptions as
|
|
4
|
-
import
|
|
5
|
-
import { shallowRef as y, isRef as
|
|
6
|
-
import { getDestinationArray as
|
|
7
|
-
import { createIframe as
|
|
8
|
-
function
|
|
9
|
-
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var c = (r, h) => F(r, "name", { value: h, configurable: !0 });
|
|
3
|
+
import { GlobalWorkerOptions as T, getDocument as S } from "pdfjs-dist";
|
|
4
|
+
import N from "../../../../../node_modules/.pnpm/pdfjs-dist@4.8.69/node_modules/pdfjs-dist/build/pdf.worker.min/index.js";
|
|
5
|
+
import { shallowRef as y, isRef as A, watch as O } from "vue";
|
|
6
|
+
import { getDestinationArray as j, getDestinationRef as M, isSpecLike as B, getLocation as _ } from "../pdfs/destination/index.js";
|
|
7
|
+
import { createIframe as G, addStylesToIframe as J } from "../pdfs/miscellaneous/index.js";
|
|
8
|
+
function V(r) {
|
|
9
|
+
T.workerSrc = r;
|
|
10
10
|
}
|
|
11
|
-
c(
|
|
12
|
-
function
|
|
11
|
+
c(V, "configWorker");
|
|
12
|
+
function Y(r, h, i = {
|
|
13
13
|
onProgress: void 0,
|
|
14
14
|
onPassword: void 0,
|
|
15
15
|
onError: void 0,
|
|
16
16
|
password: ""
|
|
17
17
|
}) {
|
|
18
|
-
var
|
|
19
|
-
(
|
|
20
|
-
const
|
|
18
|
+
var k;
|
|
19
|
+
(k = T) != null && k.workerSrc || V(N);
|
|
20
|
+
const P = y(), l = y(), b = y(0), D = y({});
|
|
21
21
|
function w(d) {
|
|
22
22
|
l.value && l.value.destroy();
|
|
23
|
-
const o =
|
|
23
|
+
const o = S({
|
|
24
24
|
url: d,
|
|
25
|
-
cMapUrl:
|
|
25
|
+
cMapUrl: h,
|
|
26
26
|
cMapPacked: !0
|
|
27
27
|
});
|
|
28
|
-
if (
|
|
29
|
-
o.onPassword =
|
|
30
|
-
else if (
|
|
31
|
-
const e = /* @__PURE__ */ c((
|
|
32
|
-
i
|
|
28
|
+
if (i.onProgress && (o.onProgress = i.onProgress), i.onPassword)
|
|
29
|
+
o.onPassword = i.onPassword;
|
|
30
|
+
else if (i.password) {
|
|
31
|
+
const e = /* @__PURE__ */ c((s) => {
|
|
32
|
+
s(i.password ?? "");
|
|
33
33
|
}, "onPassword");
|
|
34
34
|
o.onPassword = e;
|
|
35
35
|
}
|
|
36
36
|
return o.promise.then(
|
|
37
37
|
async (e) => {
|
|
38
|
-
l.value = e,
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
metadata:
|
|
38
|
+
l.value = e, P.value = e.loadingTask, b.value = e.numPages;
|
|
39
|
+
const s = await e.getMetadata(), a = await e.getAttachments(), n = await e.getJSActions(), u = await e.getOutline();
|
|
40
|
+
D.value = {
|
|
41
|
+
metadata: s,
|
|
42
42
|
attachments: a,
|
|
43
43
|
javascript: n,
|
|
44
44
|
outline: u
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
47
|
(e) => {
|
|
48
|
-
typeof
|
|
48
|
+
typeof i.onError == "function" && i.onError(e);
|
|
49
49
|
}
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
c(w, "processLoadingTask");
|
|
53
|
-
async function
|
|
53
|
+
async function x(d) {
|
|
54
54
|
var t;
|
|
55
|
-
const o = await ((t =
|
|
55
|
+
const o = await ((t = P.value) == null ? void 0 : t.promise);
|
|
56
56
|
if (!o) return null;
|
|
57
|
-
const e = await
|
|
58
|
-
if (!
|
|
59
|
-
const a = await o.getPageIndex(
|
|
60
|
-
return { pageIndex: a, location:
|
|
57
|
+
const e = await j(o, d), s = await M(o, e);
|
|
58
|
+
if (!s || !e) return null;
|
|
59
|
+
const a = await o.getPageIndex(s), n = e[1].name, u = e.slice(2), g = B(u) ? _(n, u) : null;
|
|
60
|
+
return { pageIndex: a, location: g ?? { type: "Fit", spec: [] } };
|
|
61
61
|
}
|
|
62
|
-
c(
|
|
63
|
-
async function
|
|
62
|
+
c(x, "getPDFDestination");
|
|
63
|
+
async function I(d = "filename") {
|
|
64
64
|
var n;
|
|
65
65
|
if (!l.value) throw new Error("Current PDFDocumentProxy have not loaded yet");
|
|
66
|
-
const o = await ((n = l.value) == null ? void 0 : n.saveDocument()), e = new Blob([o], { type: "application/pdf" }),
|
|
67
|
-
document.body.appendChild(a), a.href =
|
|
68
|
-
URL.revokeObjectURL(
|
|
66
|
+
const o = await ((n = l.value) == null ? void 0 : n.saveDocument()), e = new Blob([o], { type: "application/pdf" }), s = URL.createObjectURL(e), a = document.createElement("a");
|
|
67
|
+
document.body.appendChild(a), a.href = s, a.download = d, a.style.display = "none", a.click(), setTimeout(() => {
|
|
68
|
+
URL.revokeObjectURL(s), document.body.removeChild(a);
|
|
69
69
|
}, 10);
|
|
70
70
|
}
|
|
71
|
-
c(
|
|
72
|
-
async function
|
|
73
|
-
var
|
|
71
|
+
c(I, "download");
|
|
72
|
+
async function U(d = 150, o = "filename") {
|
|
73
|
+
var C, L;
|
|
74
74
|
if (!l.value) throw new Error("Current PDFDocumentProxy have not loaded yet");
|
|
75
|
-
const e = await ((
|
|
75
|
+
const e = await ((C = l.value) == null ? void 0 : C.saveDocument()), a = await S(e.buffer).promise, n = d / 72, u = 96 / 72, g = await G(), t = g.contentWindow;
|
|
76
76
|
t.document.title = o;
|
|
77
|
-
const
|
|
78
|
-
for (const
|
|
79
|
-
const v = await a.getPage(
|
|
80
|
-
|
|
77
|
+
const E = [...Array(a.numPages).keys()].map((p) => p + 1);
|
|
78
|
+
for (const p of E) {
|
|
79
|
+
const v = await a.getPage(p), m = v.getViewport({ scale: 1 });
|
|
80
|
+
p === 1 && J(
|
|
81
81
|
t,
|
|
82
82
|
m.width * n / u,
|
|
83
83
|
m.height * n / u
|
|
84
84
|
);
|
|
85
85
|
const f = document.createElement("canvas");
|
|
86
86
|
f.width = m.width * n, f.height = m.height * n;
|
|
87
|
-
const
|
|
88
|
-
t == null || t.document.body.appendChild(
|
|
87
|
+
const R = f.cloneNode();
|
|
88
|
+
t == null || t.document.body.appendChild(R), await (v == null ? void 0 : v.render({
|
|
89
89
|
canvasContext: f.getContext("2d"),
|
|
90
90
|
intent: "print",
|
|
91
91
|
transform: [n, 0, 0, n, 0, 0],
|
|
92
92
|
viewport: m
|
|
93
|
-
}).promise), (
|
|
93
|
+
}).promise), (L = R.getContext("2d")) == null || L.drawImage(f, 0, 0);
|
|
94
94
|
}
|
|
95
|
-
t == null || t.focus(), t == null || t.print(), document.body.removeChild(
|
|
95
|
+
t == null || t.focus(), t == null || t.print(), document.body.removeChild(g);
|
|
96
96
|
}
|
|
97
|
-
return c(
|
|
97
|
+
return c(U, "print"), A(r) ? (r.value && w(r.value), O(r, () => {
|
|
98
98
|
r.value && w(r.value);
|
|
99
99
|
})) : r && w(r), {
|
|
100
|
-
pdf:
|
|
101
|
-
pages:
|
|
102
|
-
info:
|
|
103
|
-
print:
|
|
104
|
-
download:
|
|
105
|
-
getPDFDestination:
|
|
100
|
+
pdf: P,
|
|
101
|
+
pages: b,
|
|
102
|
+
info: D,
|
|
103
|
+
print: U,
|
|
104
|
+
download: I,
|
|
105
|
+
getPDFDestination: x,
|
|
106
106
|
processLoadingTask: w
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
c(
|
|
109
|
+
c(Y, "usePDF");
|
|
110
110
|
export {
|
|
111
|
-
|
|
111
|
+
Y as usePDF
|
|
112
112
|
};
|
|
Binary file
|
|
Binary file
|
|
@@ -19,7 +19,7 @@ import { PDFDocumentLoadingTask } from 'pdfjs-dist/types/src/display/api';
|
|
|
19
19
|
* @param {UsePDFParameters} options
|
|
20
20
|
* UsePDF object parameters
|
|
21
21
|
*/
|
|
22
|
-
export declare function usePDF(src: PDFSrc | Ref<PDFSrc>, options?: PDFOptions): {
|
|
22
|
+
export declare function usePDF(src: PDFSrc | Ref<PDFSrc>, cMapUrlPath: string, options?: PDFOptions): {
|
|
23
23
|
pdf: ShallowRef< PDFDocumentLoadingTask | undefined, PDFDocumentLoadingTask | undefined>;
|
|
24
24
|
pages: ShallowRef<number, number>;
|
|
25
25
|
info: ShallowRef<{}, {}> | ShallowRef<PDFInfo, PDFInfo>;
|