Commit e536b2c1 authored by Fred Chasen's avatar Fred Chasen

Merge branch 'master' into 'reduce-tests-warnings'

# Conflicts:
#   src/chunker/chunker.test.js
parents def94b37 b578719d
Pipeline #403 passed with stage
in 3 minutes and 7 seconds
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.js]
charset = utf-8
indent_style = tab
indent_size = 2
......@@ -78,7 +78,7 @@ USER node
WORKDIR $DIRECTORY
COPY --chown=node:node package.json $DIRECTORY
COPY --chown=node:node package.json package-lock.json $DIRECTORY/
RUN npm install
RUN npm install ghostscript4js
......
......@@ -3778,7 +3778,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
......@@ -3799,12 +3800,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -3819,17 +3822,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -3946,7 +3952,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
......@@ -3958,6 +3965,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -3972,6 +3980,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -3979,12 +3988,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......@@ -4003,6 +4014,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -4083,7 +4095,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
......@@ -4095,6 +4108,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -4180,7 +4194,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -4216,6 +4231,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -4235,6 +4251,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -4278,12 +4295,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
......
......@@ -25,6 +25,7 @@
"chalk": "^2.4.2",
"eslint": "^6.5.1",
"express": "^4.17.1",
"ghostscript4js": "^3.1.1",
"jest": "^24.9.0",
"jest-image-snapshot": "^2.11.0",
"puppeteer": "^2.0.0",
......@@ -48,7 +49,7 @@
"pretest": "npm run build",
"prepublishOnly": "npm run build && npm run compile && npm run legacy",
"watch": "./node_modules/.bin/rollup -w -c",
"lint": "./node_modules/.bin/eslint -c .eslintrc.js src; exit 0",
"lint": "./node_modules/.bin/eslint -c .eslintrc.js src",
"docker": "docker build -t pagedmedia/pagedjs . && docker run -it --security-opt 'seccomp=seccomp.json' -v $(pwd)/specs:/home/node/pagedjs/specs pagedmedia/pagedjs npm test"
},
"repository": {
......@@ -58,8 +59,5 @@
"files": [
"dist",
"lib"
],
"optionalDependencies": {
"ghostscript4js": "^3.1.1"
}
]
}
import Chunker from './chunker.js';
/* global describe, it, expect */
import Chunker from "./chunker.js";
describe('Chunker', () => {
describe("Chunker", () => {
it('should create a page area', async () => {
let chunker = new Chunker();
chunker.setup();
expect(chunker.pagesArea.classList).toContain('pagedjs_pages');
})
it("should create a page area", async () => {
let chunker = new Chunker();
chunker.setup();
expect(chunker.pagesArea.classList).toContain("pagedjs_pages");
});
})
});
......@@ -80,7 +80,7 @@ class Page {
// page.dataset.pageNumber = index;
page.dataset.pageNumber = index;
page.setAttribute('id', id);
page.setAttribute("id", id);
if (this.name) {
page.classList.add("pagedjs_" + this.name + "_page");
......
......@@ -92,6 +92,10 @@ class TargetCounters extends Handler {
let selector = UUID();
selected.setAttribute("data-" + target.variable, selector);
// TODO: handle other counter types (by query)
let pseudo = "";
if (split.length > 1) {
pseudo += "::" + split[1];
}
if (target.counter === "page") {
let pages = chunker.pagesArea.querySelectorAll(".pagedjs_page");
let pg = 0;
......@@ -109,15 +113,11 @@ class TargetCounters extends Handler {
}
}
let psuedo = "";
if (split.length > 1) {
psuedo += "::" + split[1];
}
this.styleSheet.insertRule(`[data-${target.variable}="${selector}"]${psuedo} { counter-reset: ${target.variable} ${pg}; }`, this.styleSheet.cssRules.length);
this.styleSheet.insertRule(`[data-${target.variable}="${selector}"]${pseudo} { counter-reset: ${target.variable} ${pg}; }`, this.styleSheet.cssRules.length);
} else {
let value = element.getAttribute(`data-counter-${target.counter}-value`);
if (value) {
this.styleSheet.insertRule(`[data-${target.variable}="${selector}"]${psuedo} { counter-reset: ${target.variable} ${target.variable} ${parseInt(value)}; }`, this.styleSheet.cssRules.length);
this.styleSheet.insertRule(`[data-${target.variable}="${selector}"]${pseudo} { counter-reset: ${target.variable} ${target.variable} ${parseInt(value)}; }`, this.styleSheet.cssRules.length);
}
}
}
......
......@@ -16,7 +16,7 @@ class Lists extends Handler {
var orderedLists = pageElement.getElementsByTagName("ol");
for (var list of orderedLists) {
if (list.hasChildNodes()) {
list.start = list.firstElementChild.dataset.itemNum;
list.start = list.firstElementChild.dataset.itemNum;
}
else {
list.parentNode.removeChild(list);
......
......@@ -57,25 +57,25 @@ class Hook {
return Promise.all(promises);
}
/**
/**
* Triggers a hook to run all functions synchronously
* @example this.content.trigger(args).then(function(){...});
* @return {Array} results
*/
triggerSync(){
var args = arguments;
var context = this.context;
var results = [];
triggerSync(){
var args = arguments;
var context = this.context;
var results = [];
this.hooks.forEach(function(task) {
var executing = task.apply(context, args);
this.hooks.forEach(function(task) {
var executing = task.apply(context, args);
results.push(executing);
});
results.push(executing);
});
return results;
}
return results;
}
// Adds a function to be run before a hook completes
list(){
......
......@@ -2,17 +2,17 @@ export default async function request(url, options={}) {
return new Promise(function(resolve, reject) {
let request = new XMLHttpRequest();
request.open(options.method || 'get', url, true);
request.open(options.method || "get", url, true);
for (let i in options.headers) {
request.setRequestHeader(i, options.headers[i]);
}
request.withCredentials = options.credentials=='include';
request.withCredentials = options.credentials === "include";
request.onload = () => {
// Chrome returns a status code of 0 for local files
const status = request.status === 0 && url.startsWith('file://') ? 200 : request.status;
// Chrome returns a status code of 0 for local files
const status = request.status === 0 && url.startsWith("file://") ? 200 : request.status;
resolve(new Response(request.responseText, {status}));
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment