Skip to content

Commit

Permalink
Update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Mar 3, 2024
1 parent 46610fa commit d5906ba
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 124 deletions.
331 changes: 247 additions & 84 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.

3 changes: 2 additions & 1 deletion build/pdf.worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52829,6 +52829,7 @@ class LinkAnnotation extends Annotation {
annotationGlobals
} = params;
this.data.annotationType = AnnotationType.LINK;
this.data.noHTML = false;
const quadPoints = getQuadPoints(dict, this.rectangle);
if (quadPoints) {
this.data.quadPoints = quadPoints;
Expand Down Expand Up @@ -57273,7 +57274,7 @@ if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" &&
;// CONCATENATED MODULE: ./src/pdf.worker.js

const pdfjsVersion = "4.1.0";
const pdfjsBuild = "1bd6af6";
const pdfjsBuild = "dd3adc8";

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.

20 changes: 10 additions & 10 deletions web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,12 @@
}
}

#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker::before{
:is(#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker > .editorParamsSlider[disabled]){
opacity:0.4;
}

#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker::before,
#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker::after{
content:"";
width:8px;
aspect-ratio:1;
Expand All @@ -2239,20 +2244,15 @@
background-color:var(--example-color);
}

#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker::after{
width:24px;
}

#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker .editorParamsSlider{
width:unset;
height:14px;
}

#highlightParamsToolbarContainer #editorHighlightThickness .thicknessPicker::after{
content:"";
width:24px;
aspect-ratio:1;
display:block;
border-radius:100%;
background-color:var(--example-color);
}

:root{
--viewer-container-height:0;
--pdfViewer-padding-bottom:0;
Expand Down
72 changes: 48 additions & 24 deletions web/viewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,16 +1577,9 @@ class AltTextManager {
}
}
#close() {
this.#eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "editing",
subtype: this.#currentEditor.editorType,
data: this.#telemetryData || {
action: "alt_text_cancel",
alt_text_keyboard: !this.#hasUsedPointer
}
}
this.#currentEditor._reportTelemetry(this.#telemetryData || {
action: "alt_text_cancel",
alt_text_keyboard: !this.#hasUsedPointer
});
this.#telemetryData = null;
this.#removeOnClickListeners();
Expand Down Expand Up @@ -2103,6 +2096,9 @@ const PDFViewerApplication = {
_isCtrlKeyDown: false,
_nimbusDataPromise: null,
_caretBrowsing: null,
_isScrolling: false,
_lastScrollTop: 0,
_lastScrollLeft: 0,
async initialize(appConfig) {
let l10nPromise;
this.appConfig = appConfig;
Expand Down Expand Up @@ -2446,6 +2442,42 @@ const PDFViewerApplication = {
} else {
this._hideViewBookmark();
}
if (!("onscrollend" in document.documentElement)) {
return;
}
const {
mainContainer
} = appConfig;
({
scrollTop: this._lastScrollTop,
scrollLeft: this._lastScrollLeft
} = mainContainer);
const scroll = () => {
if (this._lastScrollTop === mainContainer.scrollTop && this._lastScrollLeft === mainContainer.scrollLeft) {
return;
}
mainContainer.removeEventListener("scroll", scroll, {
passive: true
});
this._isScrolling = true;
const scrollend = () => {
({
scrollTop: this._lastScrollTop,
scrollLeft: this._lastScrollLeft
} = mainContainer);
this._isScrolling = false;
mainContainer.addEventListener("scroll", scroll, {
passive: true
});
mainContainer.removeEventListener("scrollend", scrollend);
mainContainer.removeEventListener("blur", scrollend);
};
mainContainer.addEventListener("scrollend", scrollend);
mainContainer.addEventListener("blur", scrollend);
};
mainContainer.addEventListener("scroll", scroll, {
passive: true
});
},
get externalServices() {
return (0,pdfjs_lib__WEBPACK_IMPORTED_MODULE_1__.shadow)(this, "externalServices", new web_external_services__WEBPACK_IMPORTED_MODULE_4__.ExternalServices());
Expand Down Expand Up @@ -2710,7 +2742,8 @@ const PDFViewerApplication = {
this.externalServices.reportTelemetry({
type: "editing",
data: {
type: "save"
type: "save",
stats: this.pdfDocument?.annotationStorage.editorStats
}
});
}
Expand Down Expand Up @@ -3102,14 +3135,6 @@ const PDFViewerApplication = {
annotationStorage.onAnnotationEditor = typeStr => {
this._hasAnnotationEditors = !!typeStr;
this.setTitle();
if (typeStr) {
this.externalServices.reportTelemetry({
type: "editing",
data: {
type: typeStr
}
});
}
};
},
setInitialView(storedHash, {
Expand Down Expand Up @@ -3194,7 +3219,8 @@ const PDFViewerApplication = {
this.externalServices.reportTelemetry({
type: "editing",
data: {
type: "print"
type: "print",
stats: this.pdfDocument?.annotationStorage.editorStats
}
});
}
Expand Down Expand Up @@ -3838,7 +3864,7 @@ function webViewerWheel(evt) {
const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
evt.preventDefault();
if (zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
if (PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
return;
}
const previousScale = pdfViewer.currentScale;
Expand Down Expand Up @@ -3873,8 +3899,6 @@ function webViewerWheel(evt) {
}
}
PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
} else {
setZoomDisabledTimeout();
}
}
function webViewerTouchStart(evt) {
Expand Down Expand Up @@ -14985,7 +15009,7 @@ _app_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (a


const pdfjsVersion = "4.1.0";
const pdfjsBuild = "1bd6af6";
const pdfjsBuild = "dd3adc8";
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 d5906ba

Please sign in to comment.