Use shorter arrow functions where possible
For arrow functions that are both simple and short, we can avoid using explicit `return` to shorten them even further without hurting readability. For the `gulp mozcentral` build-target this reduces the overall size of the output by just under 1 kilo-byte (which isn't a lot but still can't hurt).
This commit is contained in:
parent
6e46304357
commit
9dfe9c552c
@ -4824,9 +4824,7 @@ class StampAnnotation extends MarkupAnnotation {
|
|||||||
|
|
||||||
const jpegBufferPromise = canvas
|
const jpegBufferPromise = canvas
|
||||||
.convertToBlob({ type: "image/jpeg", quality: 1 })
|
.convertToBlob({ type: "image/jpeg", quality: 1 })
|
||||||
.then(blob => {
|
.then(blob => blob.arrayBuffer());
|
||||||
return blob.arrayBuffer();
|
|
||||||
});
|
|
||||||
|
|
||||||
const xobjectName = Name.get("XObject");
|
const xobjectName = Name.get("XObject");
|
||||||
const imageName = Name.get("Image");
|
const imageName = Name.get("Image");
|
||||||
|
@ -691,9 +691,9 @@ async function createBuiltInCMap(name, fetchBuiltInCMap) {
|
|||||||
const cMap = new CMap(true);
|
const cMap = new CMap(true);
|
||||||
|
|
||||||
if (compressionType === CMapCompressionType.BINARY) {
|
if (compressionType === CMapCompressionType.BINARY) {
|
||||||
return new BinaryCMapReader().process(cMapData, cMap, useCMap => {
|
return new BinaryCMapReader().process(cMapData, cMap, useCMap =>
|
||||||
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
|
extendCMap(cMap, fetchBuiltInCMap, useCMap)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
if (compressionType === CMapCompressionType.NONE) {
|
if (compressionType === CMapCompressionType.NONE) {
|
||||||
const lexer = new Lexer(new Stream(cMapData));
|
const lexer = new Lexer(new Stream(cMapData));
|
||||||
|
@ -2093,9 +2093,7 @@ class Font {
|
|||||||
endOffset: 0,
|
endOffset: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
locaEntries.sort((a, b) => {
|
locaEntries.sort((a, b) => a.offset - b.offset);
|
||||||
return a.offset - b.offset;
|
|
||||||
});
|
|
||||||
// Now the offsets are sorted, calculate the end offset of each glyph.
|
// Now the offsets are sorted, calculate the end offset of each glyph.
|
||||||
// The last loca entry's endOffset is not calculated since it's the end
|
// The last loca entry's endOffset is not calculated since it's the end
|
||||||
// of the data and will be stored on the previous entry's endOffset.
|
// of the data and will be stored on the previous entry's endOffset.
|
||||||
@ -2103,9 +2101,7 @@ class Font {
|
|||||||
locaEntries[i].endOffset = locaEntries[i + 1].offset;
|
locaEntries[i].endOffset = locaEntries[i + 1].offset;
|
||||||
}
|
}
|
||||||
// Re-sort so glyphs aren't out of order.
|
// Re-sort so glyphs aren't out of order.
|
||||||
locaEntries.sort((a, b) => {
|
locaEntries.sort((a, b) => a.index - b.index);
|
||||||
return a.index - b.index;
|
|
||||||
});
|
|
||||||
// Calculate the endOffset of the "first" glyph correctly when there are
|
// Calculate the endOffset of the "first" glyph correctly when there are
|
||||||
// *multiple* empty ones at the start of the data (fixes issue14618.pdf).
|
// *multiple* empty ones at the start of the data (fixes issue14618.pdf).
|
||||||
for (i = 0; i < numGlyphs; i++) {
|
for (i = 0; i < numGlyphs; i++) {
|
||||||
|
@ -344,10 +344,9 @@ async function incrementalUpdate({
|
|||||||
|
|
||||||
// Add a ref for the new xref and sort them
|
// Add a ref for the new xref and sort them
|
||||||
newRefs.push({ ref: refForXrefTable, data: "" });
|
newRefs.push({ ref: refForXrefTable, data: "" });
|
||||||
newRefs = newRefs.sort((a, b) => {
|
newRefs = newRefs.sort(
|
||||||
// compare the refs
|
(a, b) => /* compare the refs */ a.ref.num - b.ref.num
|
||||||
return a.ref.num - b.ref.num;
|
);
|
||||||
});
|
|
||||||
|
|
||||||
const xrefTableData = [[0, 1, 0xffff]];
|
const xrefTableData = [[0, 1, 0xffff]];
|
||||||
const indexes = [0, 1];
|
const indexes = [0, 1];
|
||||||
|
@ -771,19 +771,13 @@ class PDFDocumentProxy {
|
|||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
// For testing purposes.
|
// For testing purposes.
|
||||||
Object.defineProperty(this, "getXFADatasets", {
|
Object.defineProperty(this, "getXFADatasets", {
|
||||||
value: () => {
|
value: () => this._transport.getXFADatasets(),
|
||||||
return this._transport.getXFADatasets();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, "getXRefPrevValue", {
|
Object.defineProperty(this, "getXRefPrevValue", {
|
||||||
value: () => {
|
value: () => this._transport.getXRefPrevValue(),
|
||||||
return this._transport.getXRefPrevValue();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, "getAnnotArray", {
|
Object.defineProperty(this, "getAnnotArray", {
|
||||||
value: pageIndex => {
|
value: pageIndex => this._transport.getAnnotArray(pageIndex),
|
||||||
return this._transport.getAnnotArray(pageIndex);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1628,9 +1622,7 @@ class PDFPageProxy {
|
|||||||
if (this._transport._htmlForXfa) {
|
if (this._transport._htmlForXfa) {
|
||||||
// TODO: We need to revisit this once the XFA foreground patch lands and
|
// TODO: We need to revisit this once the XFA foreground patch lands and
|
||||||
// only do this for non-foreground XFA.
|
// only do this for non-foreground XFA.
|
||||||
return this.getXfa().then(xfa => {
|
return this.getXfa().then(xfa => XfaText.textContent(xfa));
|
||||||
return XfaText.textContent(xfa);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
const readableStream = this.streamTextContent(params);
|
const readableStream = this.streamTextContent(params);
|
||||||
|
|
||||||
@ -2358,21 +2350,16 @@ class WorkerTransport {
|
|||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
// For testing purposes.
|
// For testing purposes.
|
||||||
Object.defineProperty(this, "getXFADatasets", {
|
Object.defineProperty(this, "getXFADatasets", {
|
||||||
value: () => {
|
value: () =>
|
||||||
return this.messageHandler.sendWithPromise("GetXFADatasets", null);
|
this.messageHandler.sendWithPromise("GetXFADatasets", null),
|
||||||
},
|
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, "getXRefPrevValue", {
|
Object.defineProperty(this, "getXRefPrevValue", {
|
||||||
value: () => {
|
value: () =>
|
||||||
return this.messageHandler.sendWithPromise("GetXRefPrevValue", null);
|
this.messageHandler.sendWithPromise("GetXRefPrevValue", null),
|
||||||
},
|
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, "getAnnotArray", {
|
Object.defineProperty(this, "getAnnotArray", {
|
||||||
value: pageIndex => {
|
value: pageIndex =>
|
||||||
return this.messageHandler.sendWithPromise("GetAnnotArray", {
|
this.messageHandler.sendWithPromise("GetAnnotArray", { pageIndex }),
|
||||||
pageIndex,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2737,9 +2724,7 @@ class WorkerTransport {
|
|||||||
|
|
||||||
this.fontLoader
|
this.fontLoader
|
||||||
.bind(font)
|
.bind(font)
|
||||||
.catch(reason => {
|
.catch(() => messageHandler.sendWithPromise("FontFallback", { id }))
|
||||||
return messageHandler.sendWithPromise("FontFallback", { id });
|
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (!params.fontExtraProperties && font.data) {
|
if (!params.fontExtraProperties && font.data) {
|
||||||
// Immediately release the `font.data` property once the font
|
// Immediately release the `font.data` property once the font
|
||||||
@ -3013,9 +2998,7 @@ class WorkerTransport {
|
|||||||
getOptionalContentConfig() {
|
getOptionalContentConfig() {
|
||||||
return this.messageHandler
|
return this.messageHandler
|
||||||
.sendWithPromise("GetOptionalContentConfig", null)
|
.sendWithPromise("GetOptionalContentConfig", null)
|
||||||
.then(results => {
|
.then(results => new OptionalContentConfig(results));
|
||||||
return new OptionalContentConfig(results);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPermissions() {
|
getPermissions() {
|
||||||
@ -3192,9 +3175,7 @@ class RenderTask {
|
|||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
// For testing purposes.
|
// For testing purposes.
|
||||||
Object.defineProperty(this, "getOperatorList", {
|
Object.defineProperty(this, "getOperatorList", {
|
||||||
value: () => {
|
value: () => this.#internalRenderTask.operatorList,
|
||||||
return this.#internalRenderTask.operatorList;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,9 +483,9 @@ class DOMStandardFontDataFactory extends BaseStandardFontDataFactory {
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
_fetchData(url) {
|
_fetchData(url) {
|
||||||
return fetchData(url, /* type = */ "arraybuffer").then(data => {
|
return fetchData(url, /* type = */ "arraybuffer").then(
|
||||||
return new Uint8Array(data);
|
data => new Uint8Array(data)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,9 +147,8 @@ class PDFFetchStreamReader {
|
|||||||
this._reader = response.body.getReader();
|
this._reader = response.body.getReader();
|
||||||
this._headersCapability.resolve();
|
this._headersCapability.resolve();
|
||||||
|
|
||||||
const getResponseHeader = name => {
|
const getResponseHeader = name => response.headers.get(name);
|
||||||
return response.headers.get(name);
|
|
||||||
};
|
|
||||||
const { allowRangeRequests, suggestedLength } =
|
const { allowRangeRequests, suggestedLength } =
|
||||||
validateRangeRequestCapabilities({
|
validateRangeRequestCapabilities({
|
||||||
getResponseHeader,
|
getResponseHeader,
|
||||||
|
@ -279,9 +279,8 @@ class PDFNetworkStreamFullRequestReader {
|
|||||||
const fullRequestXhrId = this._fullRequestId;
|
const fullRequestXhrId = this._fullRequestId;
|
||||||
const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
|
const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
|
||||||
|
|
||||||
const getResponseHeader = name => {
|
const getResponseHeader = name => fullRequestXhr.getResponseHeader(name);
|
||||||
return fullRequestXhr.getResponseHeader(name);
|
|
||||||
};
|
|
||||||
const { allowRangeRequests, suggestedLength } =
|
const { allowRangeRequests, suggestedLength } =
|
||||||
validateRangeRequestCapabilities({
|
validateRangeRequestCapabilities({
|
||||||
getResponseHeader,
|
getResponseHeader,
|
||||||
|
@ -326,11 +326,11 @@ class PDFNodeStreamFullReader extends BaseFullReader {
|
|||||||
this._headersCapability.resolve();
|
this._headersCapability.resolve();
|
||||||
this._setReadableStream(response);
|
this._setReadableStream(response);
|
||||||
|
|
||||||
const getResponseHeader = name => {
|
// Make sure that headers name are in lower case, as mentioned
|
||||||
// Make sure that headers name are in lower case, as mentioned
|
// here: https://nodejs.org/api/http.html#http_message_headers.
|
||||||
// here: https://nodejs.org/api/http.html#http_message_headers.
|
const getResponseHeader = name =>
|
||||||
return this._readableStream.headers[name.toLowerCase()];
|
this._readableStream.headers[name.toLowerCase()];
|
||||||
};
|
|
||||||
const { allowRangeRequests, suggestedLength } =
|
const { allowRangeRequests, suggestedLength } =
|
||||||
validateRangeRequestCapabilities({
|
validateRangeRequestCapabilities({
|
||||||
getResponseHeader,
|
getResponseHeader,
|
||||||
|
@ -141,9 +141,7 @@ class Sandbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function QuickJSSandbox() {
|
function QuickJSSandbox() {
|
||||||
return ModuleLoader().then(module => {
|
return ModuleLoader().then(module => new Sandbox(window, module));
|
||||||
return new Sandbox(window, module);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { QuickJSSandbox };
|
export { QuickJSSandbox };
|
||||||
|
@ -212,66 +212,26 @@ class Util extends PDFObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
mmmm: data => {
|
mmmm: data => this._months[data.month],
|
||||||
return this._months[data.month];
|
mmm: data => this._months[data.month].substring(0, 3),
|
||||||
},
|
mm: data => (data.month + 1).toString().padStart(2, "0"),
|
||||||
mmm: data => {
|
m: data => (data.month + 1).toString(),
|
||||||
return this._months[data.month].substring(0, 3);
|
dddd: data => this._days[data.dayOfWeek],
|
||||||
},
|
ddd: data => this._days[data.dayOfWeek].substring(0, 3),
|
||||||
mm: data => {
|
dd: data => data.day.toString().padStart(2, "0"),
|
||||||
return (data.month + 1).toString().padStart(2, "0");
|
d: data => data.day.toString(),
|
||||||
},
|
yyyy: data => data.year.toString(),
|
||||||
m: data => {
|
yy: data => (data.year % 100).toString().padStart(2, "0"),
|
||||||
return (data.month + 1).toString();
|
HH: data => data.hours.toString().padStart(2, "0"),
|
||||||
},
|
H: data => data.hours.toString(),
|
||||||
dddd: data => {
|
hh: data => (1 + ((data.hours + 11) % 12)).toString().padStart(2, "0"),
|
||||||
return this._days[data.dayOfWeek];
|
h: data => (1 + ((data.hours + 11) % 12)).toString(),
|
||||||
},
|
MM: data => data.minutes.toString().padStart(2, "0"),
|
||||||
ddd: data => {
|
M: data => data.minutes.toString(),
|
||||||
return this._days[data.dayOfWeek].substring(0, 3);
|
ss: data => data.seconds.toString().padStart(2, "0"),
|
||||||
},
|
s: data => data.seconds.toString(),
|
||||||
dd: data => {
|
tt: data => (data.hours < 12 ? "am" : "pm"),
|
||||||
return data.day.toString().padStart(2, "0");
|
t: data => (data.hours < 12 ? "a" : "p"),
|
||||||
},
|
|
||||||
d: data => {
|
|
||||||
return data.day.toString();
|
|
||||||
},
|
|
||||||
yyyy: data => {
|
|
||||||
return data.year.toString();
|
|
||||||
},
|
|
||||||
yy: data => {
|
|
||||||
return (data.year % 100).toString().padStart(2, "0");
|
|
||||||
},
|
|
||||||
HH: data => {
|
|
||||||
return data.hours.toString().padStart(2, "0");
|
|
||||||
},
|
|
||||||
H: data => {
|
|
||||||
return data.hours.toString();
|
|
||||||
},
|
|
||||||
hh: data => {
|
|
||||||
return (1 + ((data.hours + 11) % 12)).toString().padStart(2, "0");
|
|
||||||
},
|
|
||||||
h: data => {
|
|
||||||
return (1 + ((data.hours + 11) % 12)).toString();
|
|
||||||
},
|
|
||||||
MM: data => {
|
|
||||||
return data.minutes.toString().padStart(2, "0");
|
|
||||||
},
|
|
||||||
M: data => {
|
|
||||||
return data.minutes.toString();
|
|
||||||
},
|
|
||||||
ss: data => {
|
|
||||||
return data.seconds.toString().padStart(2, "0");
|
|
||||||
},
|
|
||||||
s: data => {
|
|
||||||
return data.seconds.toString();
|
|
||||||
},
|
|
||||||
tt: data => {
|
|
||||||
return data.hours < 12 ? "am" : "pm";
|
|
||||||
},
|
|
||||||
t: data => {
|
|
||||||
return data.hours < 12 ? "a" : "p";
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -237,9 +237,10 @@ describe("FreeText Editor", () => {
|
|||||||
await clearAll(page);
|
await clearAll(page);
|
||||||
|
|
||||||
for (const n of [0, 1, 2]) {
|
for (const n of [0, 1, 2]) {
|
||||||
const hasEditor = await page.evaluate(sel => {
|
const hasEditor = await page.evaluate(
|
||||||
return !!document.querySelector(sel);
|
sel => !!document.querySelector(sel),
|
||||||
}, getEditorSelector(n));
|
getEditorSelector(n)
|
||||||
|
);
|
||||||
|
|
||||||
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
|
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
|
||||||
}
|
}
|
||||||
|
@ -942,14 +942,10 @@ describe("api", function () {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const loadingTask1 = getDocument(basicApiGetDocumentParams);
|
const loadingTask1 = getDocument(basicApiGetDocumentParams);
|
||||||
const promise1 = loadingTask1.promise.then(pdfDoc => {
|
const promise1 = loadingTask1.promise.then(pdfDoc => pdfDoc.numPages);
|
||||||
return pdfDoc.numPages;
|
|
||||||
});
|
|
||||||
|
|
||||||
const loadingTask2 = getDocument(tracemonkeyGetDocumentParams);
|
const loadingTask2 = getDocument(tracemonkeyGetDocumentParams);
|
||||||
const promise2 = loadingTask2.promise.then(pdfDoc => {
|
const promise2 = loadingTask2.promise.then(pdfDoc => pdfDoc.numPages);
|
||||||
return pdfDoc.numPages;
|
|
||||||
});
|
|
||||||
|
|
||||||
const [numPages1, numPages2] = await Promise.all([promise1, promise2]);
|
const [numPages1, numPages2] = await Promise.all([promise1, promise2]);
|
||||||
expect(numPages1).toEqual(3);
|
expect(numPages1).toEqual(3);
|
||||||
@ -3901,9 +3897,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
currentImgData.data.every((value, index) => {
|
currentImgData.data.every(
|
||||||
return value === firstImgData.data[index];
|
(value, index) => value === firstImgData.data[index]
|
||||||
})
|
)
|
||||||
).toEqual(true);
|
).toEqual(true);
|
||||||
|
|
||||||
if (i === NUM_PAGES_THRESHOLD) {
|
if (i === NUM_PAGES_THRESHOLD) {
|
||||||
|
@ -377,9 +377,7 @@ describe("CFFCompiler", function () {
|
|||||||
bytes = new Uint8Array(bytes);
|
bytes = new Uint8Array(bytes);
|
||||||
return new CFFParser(
|
return new CFFParser(
|
||||||
{
|
{
|
||||||
getBytes: () => {
|
getBytes: () => bytes,
|
||||||
return bytes;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
SEAC_ANALYSIS_ENABLED
|
SEAC_ANALYSIS_ENABLED
|
||||||
|
@ -24,9 +24,7 @@ import { MessageHandler } from "../../src/shared/message_handler.js";
|
|||||||
describe("message_handler", function () {
|
describe("message_handler", function () {
|
||||||
// Sleep function to wait for sometime, similar to setTimeout but faster.
|
// Sleep function to wait for sometime, similar to setTimeout but faster.
|
||||||
function sleep(ticks) {
|
function sleep(ticks) {
|
||||||
return Promise.resolve().then(() => {
|
return Promise.resolve().then(() => ticks && sleep(ticks - 1));
|
||||||
return ticks && sleep(ticks - 1);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("sendWithStream", function () {
|
describe("sendWithStream", function () {
|
||||||
|
@ -62,9 +62,7 @@ describe("node_stream", function () {
|
|||||||
const [start, end] = request.headers.range
|
const [start, end] = request.headers.range
|
||||||
.split("=")[1]
|
.split("=")[1]
|
||||||
.split("-")
|
.split("-")
|
||||||
.map(x => {
|
.map(x => Number(x));
|
||||||
return Number(x);
|
|
||||||
});
|
|
||||||
const stream = fs.createReadStream(filePath, { start, end });
|
const stream = fs.createReadStream(filePath, { start, end });
|
||||||
response.writeHead(206, {
|
response.writeHead(206, {
|
||||||
"Content-Type": "application/pdf",
|
"Content-Type": "application/pdf",
|
||||||
|
@ -121,9 +121,7 @@ function testSearch({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalMatches = matchesPerPage.reduce((a, b) => {
|
const totalMatches = matchesPerPage.reduce((a, b) => a + b);
|
||||||
return a + b;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (updateFindControlState) {
|
if (updateFindControlState) {
|
||||||
eventBus.on(
|
eventBus.on(
|
||||||
|
@ -52,9 +52,9 @@ describe("Scripting", function () {
|
|||||||
send_queue.set(command, { command, value });
|
send_queue.set(command, { command, value });
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line no-unsanitized/method
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
const promise = import(sandboxBundleSrc).then(pdfjsSandbox => {
|
const promise = import(sandboxBundleSrc).then(pdfjsSandbox =>
|
||||||
return pdfjsSandbox.QuickJSSandbox();
|
pdfjsSandbox.QuickJSSandbox()
|
||||||
});
|
);
|
||||||
sandbox = {
|
sandbox = {
|
||||||
createSandbox(data) {
|
createSandbox(data) {
|
||||||
promise.then(sbx => sbx.create(data));
|
promise.then(sbx => sbx.create(data));
|
||||||
|
@ -1764,9 +1764,7 @@ const PDFViewerApplication = {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
/* Avoid breaking printing; ignoring errors. */
|
/* Avoid breaking printing; ignoring errors. */
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => this.pdfDocument?.annotationStorage.print);
|
||||||
return this.pdfDocument?.annotationStorage.print;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.printService) {
|
if (this.printService) {
|
||||||
// There is no way to suppress beforePrint/afterPrint events,
|
// There is no way to suppress beforePrint/afterPrint events,
|
||||||
|
@ -54,9 +54,7 @@ function addLinkAttributes(link, { url, target, rel, enabled = true } = {}) {
|
|||||||
} else {
|
} else {
|
||||||
link.href = "";
|
link.href = "";
|
||||||
link.title = `Disabled: ${url}`;
|
link.title = `Disabled: ${url}`;
|
||||||
link.onclick = () => {
|
link.onclick = () => false;
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetStr = ""; // LinkTarget.NONE
|
let targetStr = ""; // LinkTarget.NONE
|
||||||
|
@ -30,13 +30,9 @@ class PDFScriptingManagerComponents extends PDFScriptingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options.externalServices ||= {
|
options.externalServices ||= {
|
||||||
createScripting: () => {
|
createScripting: () => new GenericScripting(options.sandboxBundleSrc),
|
||||||
return new GenericScripting(options.sandboxBundleSrc);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
options.docProperties ||= pdfDocument => {
|
|
||||||
return docProperties(pdfDocument);
|
|
||||||
};
|
};
|
||||||
|
options.docProperties ||= pdfDocument => docProperties(pdfDocument);
|
||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,20 +206,18 @@ function parseQueryString(query) {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InvisibleCharactersRegExp = /[\x00-\x1F]/g;
|
const InvisibleCharsRegExp = /[\x00-\x1F]/g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} str
|
* @param {string} str
|
||||||
* @param {boolean} [replaceInvisible]
|
* @param {boolean} [replaceInvisible]
|
||||||
*/
|
*/
|
||||||
function removeNullCharacters(str, replaceInvisible = false) {
|
function removeNullCharacters(str, replaceInvisible = false) {
|
||||||
if (!InvisibleCharactersRegExp.test(str)) {
|
if (!InvisibleCharsRegExp.test(str)) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
if (replaceInvisible) {
|
if (replaceInvisible) {
|
||||||
return str.replaceAll(InvisibleCharactersRegExp, m => {
|
return str.replaceAll(InvisibleCharsRegExp, m => (m === "\x00" ? "" : " "));
|
||||||
return m === "\x00" ? "" : " ";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return str.replaceAll("\x00", "");
|
return str.replaceAll("\x00", "");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user