pdfjs-viewer-element 2.6.4 → 2.7.0
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 +69 -20
- package/dist/pdfjs-viewer-element.js +96 -123
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -10,13 +10,24 @@ Supported in all [major browsers](https://caniuse.com/custom-elementsv1), and wo
|
|
|
10
10
|
See [demo pages](https://github.com/alekswebnet/pdfjs-viewer-element/tree/master/demo) for various usecases.
|
|
11
11
|
See [live examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo) of usage with frameworks.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
# Features
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
- Simple PDF.js viewer integration to any web application
|
|
16
|
+
- PDF.js viewer options and parameters support, access to the viewer application instance
|
|
17
|
+
- Ability to customize viewer styles and themes
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## How it works
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
**⚠️ This is an important part, please read this firstly !!!**
|
|
22
|
+
|
|
23
|
+
**You should download and place the PDF.js prebuilt files in the project.**
|
|
24
|
+
|
|
25
|
+
`pdfjs-viewer-element` requires PDF.js [prebuilt](http://mozilla.github.io/pdf.js/getting_started/), that includes the generic build of PDF.js and the viewer.
|
|
26
|
+
|
|
27
|
+
The prebuilt comes with each PDF.js release.
|
|
28
|
+
All v4 and v3 [releases](https://github.com/mozilla/pdf.js/releases) are supported.
|
|
29
|
+
|
|
30
|
+
Then specify the path to the directory with the `viewer-path` property (`/pdfjs` by default) and PDF file URL with `src` property (should refer to the [same origin](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#can-i-load-a-pdf-from-another-server-cross-domain-request)).
|
|
20
31
|
|
|
21
32
|
## Status
|
|
22
33
|
|
|
@@ -60,7 +71,7 @@ Using browser:
|
|
|
60
71
|
## Usage
|
|
61
72
|
|
|
62
73
|
```html
|
|
63
|
-
<pdfjs-viewer-element src="/file.pdf" viewer-path="/pdfjs-4.
|
|
74
|
+
<pdfjs-viewer-element src="/file.pdf" viewer-path="/pdfjs-4.10.38-dist"></pdfjs-viewer-element>
|
|
64
75
|
```
|
|
65
76
|
|
|
66
77
|
## Attributes
|
|
@@ -69,27 +80,39 @@ Using browser:
|
|
|
69
80
|
|
|
70
81
|
`viewer-path` - Path to PDF.js [prebuilt](http://mozilla.github.io/pdf.js/getting_started/)
|
|
71
82
|
|
|
72
|
-
`
|
|
83
|
+
`page` - Page number.
|
|
84
|
+
|
|
85
|
+
`nameddest` - Go to a named destination.
|
|
86
|
+
|
|
87
|
+
`search` - Search text.
|
|
88
|
+
|
|
89
|
+
`phrase` - Search by phrase, `true` to enable.
|
|
90
|
+
|
|
91
|
+
`zoom` - Zoom level.
|
|
92
|
+
|
|
93
|
+
`pagemode` - Page mode, `thumbs | bookmarks | attachments | layers | none`.
|
|
94
|
+
|
|
95
|
+
`disable-worker` - Disables the worker, `true` to enable.
|
|
73
96
|
|
|
74
|
-
`text-layer` -
|
|
97
|
+
`text-layer` - Disables or reveals the text layer that is used for text selection, `off | visible | shadow | hover`.
|
|
75
98
|
|
|
76
|
-
`
|
|
99
|
+
`disable-font-face` - Disables standard `@font-face` font loading and uses the internal font renderer instead, `true` to enable.
|
|
77
100
|
|
|
78
|
-
`
|
|
101
|
+
`disable-range` - Disables HTTP range requests when fetching the document, `true` to enable.
|
|
79
102
|
|
|
80
|
-
`
|
|
103
|
+
`disable-stream` - Disables streaming when fetching the document, `true` to enable.
|
|
81
104
|
|
|
82
|
-
`
|
|
105
|
+
`disable-auto-fetch`- Disables auto fetching of the document; only gets necessary data to display the current view. Note: streaming also needs to be disabled for this to have any effect, `true` to enable.
|
|
83
106
|
|
|
84
|
-
`
|
|
107
|
+
`verbosity`- Specifies the verbosity level of console messages. `0` - only errors, `1` - warnings and errors, `5` - warnings, errors and information messages.
|
|
85
108
|
|
|
86
|
-
`
|
|
109
|
+
`locale` - Specifies which language to use in the viewer UI, `en-US | ...`. [Available locales](https://github.com/mozilla/pdf.js/tree/master/l10n)
|
|
87
110
|
|
|
88
|
-
`viewer-css-theme` - Apply automatic, light, or dark theme `AUTOMATIC | LIGHT | DARK`
|
|
111
|
+
`viewer-css-theme` - Apply automatic, light, or dark theme, `AUTOMATIC | LIGHT | DARK`
|
|
89
112
|
|
|
90
|
-
`viewer-extra-styles` - Add your CSS rules to the viewer application
|
|
113
|
+
`viewer-extra-styles` - Add your CSS rules to the viewer application, pass a string with styles.
|
|
91
114
|
|
|
92
|
-
`viewer-extra-styles-urls` - Add external CSS files to the viewer application
|
|
115
|
+
`viewer-extra-styles-urls` - Add external CSS files to the viewer application, pass an array with URLs.
|
|
93
116
|
|
|
94
117
|
Play with attributes on [Api docs page](https://alekswebnet.github.io/pdfjs-viewer-element/#api).
|
|
95
118
|
|
|
@@ -100,19 +123,19 @@ Use `viewer-css-theme` attribute to set light or dark theme manually:
|
|
|
100
123
|
```html
|
|
101
124
|
<pdfjs-viewer-element
|
|
102
125
|
src="/file.pdf"
|
|
103
|
-
viewer-path="/pdfjs-4.
|
|
126
|
+
viewer-path="/pdfjs-4.10.38-dist"
|
|
104
127
|
viewer-css-theme="DARK">
|
|
105
128
|
</pdfjs-viewer-element>
|
|
106
129
|
```
|
|
107
130
|
|
|
108
|
-
## Viewer
|
|
131
|
+
## Viewer custom styles
|
|
109
132
|
|
|
110
133
|
You can add your own CSS rules to the viewer application using `viewer-extra-styles` or `viewer-extra-styles-urls` attribute:
|
|
111
134
|
|
|
112
135
|
```html
|
|
113
136
|
<pdfjs-viewer-element
|
|
114
137
|
src="/file.pdf"
|
|
115
|
-
viewer-path="/pdfjs-4.
|
|
138
|
+
viewer-path="/pdfjs-4.10.38-dist"
|
|
116
139
|
viewer-extra-styles="#toolbarViewerMiddle { display: none; }"
|
|
117
140
|
viewer-extra-styles-urls="['/demo/viewer-custom-theme.css']">
|
|
118
141
|
</pdfjs-viewer-element>
|
|
@@ -145,7 +168,7 @@ Build your own theme with viewer's custom variables and `viewer-extra-styles-url
|
|
|
145
168
|
`initialize` - using this method you can access PDFViewerApplication and use methods and events of PDF.js default viewer
|
|
146
169
|
|
|
147
170
|
```html
|
|
148
|
-
<pdfjs-viewer-element viewer-path="/pdfjs-4.
|
|
171
|
+
<pdfjs-viewer-element viewer-path="/pdfjs-4.10.38-dist"></pdfjs-viewer-element>
|
|
149
172
|
```
|
|
150
173
|
|
|
151
174
|
```javascript
|
|
@@ -156,5 +179,31 @@ const viewerApp = await viewer.initialize()
|
|
|
156
179
|
viewerApp.open({ data: pdfData })
|
|
157
180
|
```
|
|
158
181
|
|
|
182
|
+
## Server configuration
|
|
183
|
+
|
|
184
|
+
Since v4 PDF.js requires `.mjs` files support, make sure your server has it.
|
|
185
|
+
|
|
186
|
+
In case of `nginx` this may causes to errors, see https://github.com/mozilla/pdf.js/issues/17296
|
|
187
|
+
|
|
188
|
+
Add `.mjs` files support for `nginx` example:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
server {
|
|
192
|
+
# ...
|
|
193
|
+
|
|
194
|
+
location / {
|
|
195
|
+
root /usr/share/nginx/html;
|
|
196
|
+
index index.html;
|
|
197
|
+
|
|
198
|
+
location ~* \.mjs$ {
|
|
199
|
+
types {
|
|
200
|
+
text/javascript mjs;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
|
|
159
208
|
## License
|
|
160
209
|
[MIT](http://opensource.org/licenses/MIT)
|
|
@@ -1,154 +1,127 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
new MutationObserver((n, t) => {
|
|
8
|
-
Array.from(e.querySelectorAll(m)).forEach((i) => {
|
|
9
|
-
s(i), t.disconnect();
|
|
10
|
-
});
|
|
11
|
-
}).observe(e, {
|
|
12
|
-
childList: !0,
|
|
13
|
-
subtree: !0
|
|
14
|
-
});
|
|
15
|
-
}), g = {
|
|
16
|
-
trailing: !0
|
|
17
|
-
};
|
|
18
|
-
function v(m, e = 25, s = {}) {
|
|
19
|
-
if (s = { ...g, ...s }, !Number.isFinite(e))
|
|
20
|
-
throw new TypeError("Expected `wait` to be a finite number");
|
|
21
|
-
let r, n, t = [], i, a;
|
|
22
|
-
const o = (l, h) => (i = b(m, l, h), i.finally(() => {
|
|
23
|
-
if (i = null, s.trailing && a && !n) {
|
|
24
|
-
const u = o(l, a);
|
|
25
|
-
return a = null, u;
|
|
26
|
-
}
|
|
27
|
-
}), i);
|
|
28
|
-
return function(...l) {
|
|
29
|
-
return i ? (s.trailing && (a = l), i) : new Promise((h) => {
|
|
30
|
-
const u = !n && s.leading;
|
|
31
|
-
clearTimeout(n), n = setTimeout(() => {
|
|
32
|
-
n = null;
|
|
33
|
-
const d = s.leading ? r : o(this, l);
|
|
34
|
-
for (const y of t)
|
|
35
|
-
y(d);
|
|
36
|
-
t = [];
|
|
37
|
-
}, e), u ? (r = o(this, l), h(r)) : t.push(h);
|
|
1
|
+
const y = (p, t) => new Promise((o) => {
|
|
2
|
+
let s = t.querySelector(p);
|
|
3
|
+
s ? o(s) : new MutationObserver((r, e) => {
|
|
4
|
+
Array.from(t.querySelectorAll(p)).forEach((i) => {
|
|
5
|
+
o(i), e.disconnect();
|
|
38
6
|
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return await m.apply(e, s);
|
|
43
|
-
}
|
|
44
|
-
const c = {
|
|
45
|
-
viewerPath: "/pdfjs",
|
|
46
|
-
viewerEntry: "/web/viewer.html",
|
|
47
|
-
src: "",
|
|
48
|
-
page: "",
|
|
49
|
-
search: "",
|
|
50
|
-
phrase: "",
|
|
51
|
-
zoom: "",
|
|
52
|
-
pagemode: "none",
|
|
53
|
-
locale: "",
|
|
54
|
-
textLayer: "",
|
|
55
|
-
viewerCssTheme: "AUTOMATIC",
|
|
56
|
-
viewerExtraStyles: "",
|
|
57
|
-
viewerExtraStylesUrls: "",
|
|
58
|
-
nameddest: ""
|
|
59
|
-
}, w = {
|
|
60
|
-
AUTOMATIC: 0,
|
|
61
|
-
// Default value.
|
|
62
|
-
LIGHT: 1,
|
|
63
|
-
DARK: 2
|
|
64
|
-
}, A = ["src", "viewer-path", "locale", "text-layer", "viewer-css-theme", "viewer-extra-styles", "viewer-extra-styles-urls"];
|
|
65
|
-
class p extends HTMLElement {
|
|
7
|
+
}).observe(t, { childList: !0, subtree: !0 });
|
|
8
|
+
}), T = { trailing: !0 }, S = "/pdfjs", D = "/web/viewer.html", A = "", C = "", P = "", k = "", R = "", V = "none", F = "", O = "", L = "", I = "", j = "", q = "", M = "", W = "", v = "AUTOMATIC", $ = "", z = "", H = "", b = { AUTOMATIC: 0, LIGHT: 1, DARK: 2 }, N = ["src", "viewer-path", "disable-worker", "text-layer", "disable-font-face", "disable-range", "disable-stream", "disable-auto-fetch", "verbosity", "locale", "viewer-css-theme", "viewer-extra-styles", "viewer-extra-styles-urls"];
|
|
9
|
+
class x extends HTMLElement {
|
|
66
10
|
constructor() {
|
|
67
|
-
super(), this.onIframeReady =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
11
|
+
super(), this.onIframeReady = function(s, r = 25, e = {}) {
|
|
12
|
+
if (e = { ...T, ...e }, !Number.isFinite(r))
|
|
13
|
+
throw new TypeError("Expected `wait` to be a finite number");
|
|
14
|
+
let i, n, a, l, h = [];
|
|
15
|
+
const f = (c, m) => (a = async function(d, u, w) {
|
|
16
|
+
return await d.apply(u, w);
|
|
17
|
+
}(s, c, m), a.finally(() => {
|
|
18
|
+
if (a = null, e.trailing && l && !n) {
|
|
19
|
+
const d = f(c, l);
|
|
20
|
+
return l = null, d;
|
|
21
|
+
}
|
|
22
|
+
}), a);
|
|
23
|
+
return function(...c) {
|
|
24
|
+
return a ? (e.trailing && (l = c), a) : new Promise((m) => {
|
|
25
|
+
const d = !n && e.leading;
|
|
26
|
+
clearTimeout(n), n = setTimeout(() => {
|
|
27
|
+
n = null;
|
|
28
|
+
const u = e.leading ? i : f(this, c);
|
|
29
|
+
for (const w of h)
|
|
30
|
+
w(u);
|
|
31
|
+
h = [];
|
|
32
|
+
}, r), d ? (i = f(this, c), m(i)) : h.push(m);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}(async (s) => {
|
|
36
|
+
await y("iframe", this.shadowRoot), s();
|
|
37
|
+
}, 0, { leading: !0 }), this.setViewerExtraStyles = (s, r = "extra") => {
|
|
38
|
+
var i, n, a, l, h;
|
|
39
|
+
if (!s)
|
|
40
|
+
return void ((n = (i = this.iframe.contentDocument) == null ? void 0 : i.head.querySelector(`style[${r}]`)) == null ? void 0 : n.remove());
|
|
41
|
+
if (((l = (a = this.iframe.contentDocument) == null ? void 0 : a.head.querySelector(`style[${r}]`)) == null ? void 0 : l.innerHTML) === s)
|
|
73
42
|
return;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!r)
|
|
81
|
-
return;
|
|
82
|
-
r.replace(/'|]|\[/g, "").split(",").map((t) => t.trim()).forEach((t) => {
|
|
83
|
-
var o, l;
|
|
84
|
-
if ((o = this.iframe.contentDocument) == null ? void 0 : o.head.querySelector(`link[href="${t}"]`))
|
|
43
|
+
const e = document.createElement("style");
|
|
44
|
+
e.innerHTML = s, e.setAttribute(r, ""), (h = this.iframe.contentDocument) == null || h.head.appendChild(e);
|
|
45
|
+
}, this.injectExtraStylesLinks = (s) => {
|
|
46
|
+
s && s.replace(/'|]|\[/g, "").split(",").map((r) => r.trim()).forEach((r) => {
|
|
47
|
+
var n, a;
|
|
48
|
+
if ((n = this.iframe.contentDocument) == null ? void 0 : n.head.querySelector(`link[href="${r}"]`))
|
|
85
49
|
return;
|
|
86
|
-
const
|
|
87
|
-
|
|
50
|
+
const i = document.createElement("link");
|
|
51
|
+
i.rel = "stylesheet", i.href = r, (a = this.iframe.contentDocument) == null || a.head.appendChild(i);
|
|
88
52
|
});
|
|
89
|
-
}, this.initialize = () => new Promise(async (
|
|
90
|
-
var
|
|
91
|
-
await
|
|
92
|
-
var
|
|
93
|
-
await ((i = (
|
|
53
|
+
}, this.initialize = () => new Promise(async (s) => {
|
|
54
|
+
var r;
|
|
55
|
+
await y("iframe", this.shadowRoot), (r = this.iframe) == null || r.addEventListener("load", async () => {
|
|
56
|
+
var e, i, n;
|
|
57
|
+
await ((i = (e = this.iframe.contentWindow) == null ? void 0 : e.PDFViewerApplication) == null ? void 0 : i.initializedPromise), s((n = this.iframe.contentWindow) == null ? void 0 : n.PDFViewerApplication);
|
|
94
58
|
}, { once: !0 });
|
|
95
59
|
});
|
|
96
|
-
const
|
|
97
|
-
|
|
60
|
+
const t = this.attachShadow({ mode: "open" }), o = document.createElement("template");
|
|
61
|
+
o.innerHTML = `
|
|
98
62
|
<style>:host{width:100%;display:block;overflow:hidden}:host iframe{height:100%}</style>
|
|
99
63
|
<iframe frameborder="0" width="100%" loading="lazy"></iframe>
|
|
100
|
-
`,
|
|
64
|
+
`, t.appendChild(o.content.cloneNode(!0));
|
|
101
65
|
}
|
|
102
66
|
static get observedAttributes() {
|
|
103
|
-
return ["src", "viewer-path", "
|
|
67
|
+
return ["src", "viewer-path", "page", "search", "phrase", "zoom", "pagemode", "disable-worker", "text-layer", "disable-font-face", "disable-range", "disable-stream", "disable-auto-fetch", "verbosity", "locale", "viewer-css-theme", "viewer-extra-styles", "viewer-extra-styles-urls", "nameddest"];
|
|
104
68
|
}
|
|
105
69
|
connectedCallback() {
|
|
106
70
|
this.iframe = this.shadowRoot.querySelector("iframe"), document.addEventListener("webviewerloaded", async () => {
|
|
107
|
-
var
|
|
108
|
-
this.setCssTheme(this.getCssThemeOption()), this.injectExtraStylesLinks(this.getAttribute("viewer-extra-styles-urls") ??
|
|
71
|
+
var t, o, s, r, e, i, n, a;
|
|
72
|
+
this.setCssTheme(this.getCssThemeOption()), this.injectExtraStylesLinks(this.getAttribute("viewer-extra-styles-urls") ?? z), this.setViewerExtraStyles(this.getAttribute("viewer-extra-styles") ?? $), this.getAttribute("src") !== A && ((o = (t = this.iframe.contentWindow) == null ? void 0 : t.PDFViewerApplicationOptions) == null || o.set("defaultUrl", "")), (r = (s = this.iframe.contentWindow) == null ? void 0 : s.PDFViewerApplicationOptions) == null || r.set("disablePreferences", !0), (i = (e = this.iframe.contentWindow) == null ? void 0 : e.PDFViewerApplicationOptions) == null || i.set("pdfBugEnabled", !0), (a = (n = this.iframe.contentWindow) == null ? void 0 : n.PDFViewerApplicationOptions) == null || a.set("eventBusDispatchToDOM", !0);
|
|
109
73
|
});
|
|
110
74
|
}
|
|
111
|
-
attributeChangedCallback(
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this.onIframeReady(() => this.mountViewer(this.getIframeSrc()));
|
|
75
|
+
attributeChangedCallback(t) {
|
|
76
|
+
N.includes(t) ? this.onIframeReady(() => this.mountViewer(this.getIframeSrc())) : this.onIframeReady(() => {
|
|
77
|
+
this.iframe.src = this.getIframeSrc();
|
|
78
|
+
});
|
|
119
79
|
}
|
|
120
80
|
getIframeSrc() {
|
|
121
|
-
const
|
|
122
|
-
return
|
|
81
|
+
const t = this.getFullPath(this.getAttribute("src") || A), o = this.getFullPath(this.getAttribute("viewer-path") || S), s = this.getAttribute("page") || C, r = this.getAttribute("search") || P, e = this.getAttribute("phrase") || k, i = this.getAttribute("zoom") || R, n = this.getAttribute("pagemode") || V, a = this.getAttribute("disable-worker") || O, l = this.getAttribute("text-layer") || L, h = this.getAttribute("disable-font-face") || I, f = this.getAttribute("disable-range") || j, c = this.getAttribute("disable-stream") || q, m = this.getAttribute("disable-auto-fetch") || M, d = this.getAttribute("verbosity") || W, u = this.getAttribute("locale") || F, w = this.getAttribute("viewer-css-theme") || v, E = !!(this.getAttribute("viewer-extra-styles") || $), g = this.getAttribute("nameddest") || H;
|
|
82
|
+
return `
|
|
83
|
+
${o}${D}?file=
|
|
84
|
+
${encodeURIComponent(t)}#page=${s}&zoom=${i}&pagemode=${n}&search=${r}&phrase=${e}&textLayer=
|
|
85
|
+
${l}&disableWorker=
|
|
86
|
+
${a}&disableFontFace=
|
|
87
|
+
${h}&disableRange=
|
|
88
|
+
${f}&disableStream=
|
|
89
|
+
${c}&disableAutoFetch=
|
|
90
|
+
${m}&verbosity=
|
|
91
|
+
${d}
|
|
92
|
+
${u ? "&locale=" + u : ""}&viewerCssTheme=
|
|
93
|
+
${w}&viewerExtraStyles=
|
|
94
|
+
${E}
|
|
95
|
+
${g ? "&nameddest=" + g : ""}`;
|
|
123
96
|
}
|
|
124
|
-
mountViewer(
|
|
125
|
-
|
|
97
|
+
mountViewer(t) {
|
|
98
|
+
t && this.iframe && (this.shadowRoot.replaceChild(this.iframe.cloneNode(), this.iframe), this.iframe = this.shadowRoot.querySelector("iframe"), this.iframe.src = t);
|
|
126
99
|
}
|
|
127
|
-
getFullPath(
|
|
128
|
-
return
|
|
100
|
+
getFullPath(t) {
|
|
101
|
+
return t.startsWith("/") ? `${window.location.origin}${t}` : t;
|
|
129
102
|
}
|
|
130
103
|
getCssThemeOption() {
|
|
131
|
-
const
|
|
132
|
-
return Object.keys(
|
|
104
|
+
const t = this.getAttribute("viewer-css-theme");
|
|
105
|
+
return Object.keys(b).includes(t) ? b[t] : b[v];
|
|
133
106
|
}
|
|
134
|
-
setCssTheme(
|
|
135
|
-
var s, r
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
107
|
+
setCssTheme(t) {
|
|
108
|
+
var o, s, r;
|
|
109
|
+
if (t === b.DARK) {
|
|
110
|
+
const e = (o = this.iframe.contentDocument) == null ? void 0 : o.styleSheets[0], i = (e == null ? void 0 : e.cssRules) || [], n = Object.keys(i).filter((a) => {
|
|
138
111
|
var l;
|
|
139
|
-
return ((l = i[Number(
|
|
140
|
-
}).map((
|
|
112
|
+
return ((l = i[Number(a)]) == null ? void 0 : l.conditionText) === "(prefers-color-scheme: dark)";
|
|
113
|
+
}).map((a) => i[Number(a)].cssText.split(`@media (prefers-color-scheme: dark) {
|
|
141
114
|
`)[1].split(`
|
|
142
115
|
}`)[0]);
|
|
143
|
-
this.setViewerExtraStyles(
|
|
116
|
+
this.setViewerExtraStyles(n.join(""), "theme");
|
|
144
117
|
} else
|
|
145
|
-
(
|
|
118
|
+
(r = (s = this.iframe.contentDocument) == null ? void 0 : s.head.querySelector("style[theme]")) == null || r.remove();
|
|
146
119
|
}
|
|
147
120
|
}
|
|
148
|
-
window.customElements.get("pdfjs-viewer-element") || (window.PdfjsViewerElement =
|
|
121
|
+
window.customElements.get("pdfjs-viewer-element") || (window.PdfjsViewerElement = x, window.customElements.define("pdfjs-viewer-element", x));
|
|
149
122
|
export {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
123
|
+
x as PdfjsViewerElement,
|
|
124
|
+
b as ViewerCssTheme,
|
|
125
|
+
x as default,
|
|
126
|
+
N as hardRefreshAttributes
|
|
154
127
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfjs-viewer-element",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Oleksandr Shevchuk",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"pdfjs",
|
|
12
12
|
"pdf viewer",
|
|
13
13
|
"pdfjs viewer",
|
|
14
|
-
"web component"
|
|
14
|
+
"web component",
|
|
15
|
+
"pdfjs viewer element",
|
|
16
|
+
"pdf"
|
|
15
17
|
],
|
|
16
18
|
"main": "./dist/pdfjs-viewer-element.js",
|
|
17
19
|
"module": "./dist/pdfjs-viewer-element.js",
|
|
@@ -30,15 +32,19 @@
|
|
|
30
32
|
"types"
|
|
31
33
|
],
|
|
32
34
|
"devDependencies": {
|
|
35
|
+
"@awlsn/pdfjs-full": "^4.2.392",
|
|
36
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
33
37
|
"@types/node": "^18.19.31",
|
|
34
38
|
"@vitest/browser": "^1.5.0",
|
|
35
39
|
"jsdom": "^22.1.0",
|
|
36
|
-
"perfect-debounce": "^1.0.0",
|
|
37
40
|
"typescript": "^4.9.5",
|
|
38
41
|
"vite": "^5.2.9",
|
|
39
42
|
"vitest": "^1.5.0",
|
|
40
43
|
"webdriverio": "^8.36.1"
|
|
41
44
|
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"perfect-debounce": "^1.0.0"
|
|
47
|
+
},
|
|
42
48
|
"scripts": {
|
|
43
49
|
"dev": "vite",
|
|
44
50
|
"build": "tsc && vite build",
|