Skip to content

Commit

Permalink
Update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Feb 25, 2024
1 parent eebd31a commit 46610fa
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 98 deletions.
299 changes: 216 additions & 83 deletions build/pdf.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/pdf.sandbox.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.sandbox.mjs.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/pdf.worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class FeatureTest {
return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
}
}
const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
const hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));
class Util {
static makeHexColor(r, g, b) {
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
Expand Down Expand Up @@ -33525,7 +33525,7 @@ class PartialEvaluator {
if (!properties.composite) {
return new ToUnicodeMap(this._simpleFontToUnicode(properties));
}
if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo?.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
const {
registry,
ordering
Expand Down Expand Up @@ -57273,7 +57273,7 @@ if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" &&
;// CONCATENATED MODULE: ./src/pdf.worker.js

const pdfjsVersion = "4.1.0";
const pdfjsBuild = "4ac8ee8";
const pdfjsBuild = "1bd6af6";

var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
Expand Down
2 changes: 1 addition & 1 deletion build/pdf.worker.mjs.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@
transform:rotate(90deg) translateY(-100%);
}

.annotationLayer.disabled section,
.annotationLayer.disabled .popup{
pointer-events:none;
}

.annotationLayer canvas{
position:absolute;
width:100%;
Expand Down
58 changes: 52 additions & 6 deletions web/viewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,8 @@ const PDFViewerApplication = {
enablePrintAutoRotate: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePrintAutoRotate"),
maxCanvasPixels: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("maxCanvasPixels"),
enablePermissions: _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enablePermissions"),
pageColors
pageColors,
mlManager: this.mlManager
});
this.pdfViewer = pdfViewer;
pdfRenderingQueue.setViewer(pdfViewer);
Expand Down Expand Up @@ -2449,6 +2450,9 @@ const PDFViewerApplication = {
get externalServices() {
return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "externalServices", new web_external_services__WEBPACK_IMPORTED_MODULE_4__.ExternalServices());
},
get mlManager() {
return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "mlManager", _app_options_js__WEBPACK_IMPORTED_MODULE_2__.AppOptions.get("enableML") === true ? new web_external_services__WEBPACK_IMPORTED_MODULE_4__.MLManager() : null);
},
get initialized() {
return this._initializedCapability.settled;
},
Expand Down Expand Up @@ -4394,6 +4398,10 @@ const defaultOptions = {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
},
enableML: {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
},
enablePermissions: {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
Expand Down Expand Up @@ -4811,8 +4819,28 @@ class CaretBrowsingMode {
return;
}
const midY = rect.y + rect.height / 2;
const caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
if (caretPosition.offsetNode?.parentElement !== element) {
let caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
let parentElement = caretPosition.offsetNode?.parentElement;
if (parentElement && parentElement !== element) {
const elementsAtPoint = document.elementsFromPoint(caretX, midY);
const savedVisibilities = [];
for (const el of elementsAtPoint) {
if (el === element) {
break;
}
const {
style
} = el;
savedVisibilities.push([el, style.visibility]);
style.visibility = "hidden";
}
caretPosition = CaretBrowsingMode.#caretPositionFromPoint(caretX, midY);
parentElement = caretPosition.offsetNode?.parentElement;
for (const [el, visibility] of savedVisibilities) {
el.style.visibility = visibility;
}
}
if (parentElement !== element) {
if (select) {
selection.extend(element.firstChild, 0);
} else {
Expand Down Expand Up @@ -5263,6 +5291,7 @@ __webpack_async_result__();
__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ExternalServices: () => (/* binding */ ExternalServices),
/* harmony export */ MLManager: () => (/* binding */ MLManager),
/* harmony export */ Preferences: () => (/* binding */ Preferences),
/* harmony export */ initCom: () => (/* binding */ initCom)
/* harmony export */ });
Expand Down Expand Up @@ -5297,6 +5326,11 @@ class ExternalServices extends _external_services_js__WEBPACK_IMPORTED_MODULE_4_
return new _generic_scripting_js__WEBPACK_IMPORTED_MODULE_3__.GenericScripting(_app_options_js__WEBPACK_IMPORTED_MODULE_0__.AppOptions.get("sandboxBundleSrc"));
}
}
class MLManager {
async guess() {
return null;
}
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
Expand Down Expand Up @@ -9494,7 +9528,7 @@ class PDFPresentationMode {
this.#addWindowListeners();
this.#showControls();
this.contextMenuOpen = false;
window.getSelection().removeAllRanges();
document.getSelection().empty();
}
#exit() {
const pageNumber = this.pdfViewer.currentPageNumber;
Expand Down Expand Up @@ -11376,6 +11410,7 @@ class PDFViewer {
#containerTopLeft = null;
#copyCallbackBound = null;
#enablePermissions = false;
#mlManager = null;
#getAllTextInProgress = false;
#hiddenCopyElement = null;
#interruptCopyCondition = false;
Expand Down Expand Up @@ -11420,6 +11455,7 @@ class PDFViewer {
this.l10n ||= new web_null_l10n__WEBPACK_IMPORTED_MODULE_2__.GenericL10n();
this.#enablePermissions = options.enablePermissions || false;
this.pageColors = options.pageColors || null;
this.#mlManager = options.mlManager || null;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
this.renderingQueue = new _pdf_rendering_queue_js__WEBPACK_IMPORTED_MODULE_4__.PDFRenderingQueue();
Expand Down Expand Up @@ -11790,7 +11826,7 @@ class PDFViewer {
if (pdfDocument.isPureXfa) {
console.warn("Warning: XFA-editing is not implemented.");
} else if (isValidAnnotationEditorMode(mode)) {
this.#annotationEditorUIManager = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorUIManager(this.container, this.viewer, this.#altTextManager, this.eventBus, pdfDocument, this.pageColors, this.#annotationEditorHighlightColors);
this.#annotationEditorUIManager = new pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorUIManager(this.container, this.viewer, this.#altTextManager, this.eventBus, pdfDocument, this.pageColors, this.#annotationEditorHighlightColors, this.#mlManager);
this.eventBus.dispatch("annotationeditoruimanager", {
source: this,
uiManager: this.#annotationEditorUIManager
Expand Down Expand Up @@ -12940,6 +12976,7 @@ class BasePreferences {
defaultZoomValue: "",
disablePageLabels: false,
enableHighlightEditor: false,
enableML: false,
enablePermissions: false,
enablePrintAutoRotate: true,
enableScripting: true,
Expand Down Expand Up @@ -14143,6 +14180,15 @@ class Toolbar {
once: true
});
}
eventBus._on("showannotationeditorui", ({
mode
}) => {
switch (mode) {
case pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.AnnotationEditorType.HIGHLIGHT:
options.editorHighlightButton.click();
break;
}
});
this.reset();
}
#setAnnotationEditorUIManager(uiManager, parentContainer) {
Expand Down Expand Up @@ -14939,7 +14985,7 @@ _app_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (a


const pdfjsVersion = "4.1.0";
const pdfjsBuild = "4ac8ee8";
const pdfjsBuild = "1bd6af6";
const AppConstants = {
LinkTarget: _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__.LinkTarget,
RenderingStates: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates,
Expand Down
2 changes: 1 addition & 1 deletion web/viewer.mjs.map

Large diffs are not rendered by default.

0 comments on commit 46610fa

Please sign in to comment.