diff --git a/examples/viewer.html b/examples/viewer.html
index f197528f4e82b18de068088bd16c36a5649cb66d..e63b6d1a6a6f98f9f13d1f0922bf90712d3e3391 100644
--- a/examples/viewer.html
+++ b/examples/viewer.html
@@ -42,10 +42,7 @@
.then(str => (new DOMParser()).parseFromString(str, "text/html"))
// Gather all stylesheets from html document
- let stylesheets = Array.from(html.querySelectorAll("link[rel='stylesheet']"));
- let hrefs = stylesheets.map((sheet) => {
- return sheet.href;
- });
+ let hrefs = previewer.removeStyles(html);
// Add a stylesheet url in params
let stylesheet = params && params.get("stylesheet") && decodeURIComponent(params.get("stylesheet"));
@@ -74,7 +71,7 @@
.pagedjs_page {
background-color: #fdfdfd;
- margin-bottom: 20px;
+ margin: 10px auto;
flex: none;
box-shadow: 0 0 0 1px rgba(0, 0,0,0.2);
}
diff --git a/package.json b/package.json
index 397ba14e830fbd88269f3f0eb7a1880777d422f6..1e4a0c1e28df3979b82d10eb8f24b529d0dfc1ab 100755
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"author": "Fred Chasen",
"license": "MIT",
"homepage": "https://pagedmedia.org",
- "main": "lib/paged.js",
+ "main": "lib/index.js",
"module": "src/index.js",
"browser": "dist/paged.js",
"dependencies": {
diff --git a/src/polyfill/previewer.js b/src/polyfill/previewer.js
index 3151e29b5f9cc3fae5c13c9d423fef8641e2dcb1..2fa27e37e6f675c824354bb3593a650567f73863 100644
--- a/src/polyfill/previewer.js
+++ b/src/polyfill/previewer.js
@@ -93,16 +93,16 @@ class Previewer {
return template.content;
}
- removeStyles() {
+ removeStyles(doc=document) {
// Get all stylesheets
- let stylesheets = Array.from(document.querySelectorAll("link[rel='stylesheet']"));
+ let stylesheets = Array.from(doc.querySelectorAll("link[rel='stylesheet']"));
let hrefs = stylesheets.map((sheet) => {
sheet.remove();
return sheet.href;
});
// Get inline styles
- let inlineStyles = Array.from(document.querySelectorAll("style:not([data-pagedjs-inserted-styles])"));
+ let inlineStyles = Array.from(doc.querySelectorAll("style:not([data-pagedjs-inserted-styles])"));
inlineStyles.forEach((inlineStyle) => {
let obj = {};
obj[window.location.href] = inlineStyle.textContent;