mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-07 17:05:38 +02:00
Merge pull request #17879 from ex37/master
Improve type definitions for the viewer
This commit is contained in:
commit
e08de772ff
17 changed files with 93 additions and 15 deletions
|
@ -16,7 +16,7 @@
|
||||||
"display-node_utils": ["./src/display/node_utils"],
|
"display-node_utils": ["./src/display/node_utils"],
|
||||||
"fluent-bundle": ["./node_modules/@fluent/bundle/esm/index.js"],
|
"fluent-bundle": ["./node_modules/@fluent/bundle/esm/index.js"],
|
||||||
"fluent-dom": ["./node_modules/@fluent/dom/esm/index.js"],
|
"fluent-dom": ["./node_modules/@fluent/dom/esm/index.js"],
|
||||||
"web-null_l10n": ["../web/genericl10n.js"]
|
"web-null_l10n": ["./web/genericl10n"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": ["src/pdf.js", "web/pdf_viewer.component.js"]
|
"files": ["src/pdf.js", "web/pdf_viewer.component.js"]
|
||||||
|
|
|
@ -13,8 +13,22 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
|
||||||
import { AnnotationEditorParamsType } from "pdfjs-lib";
|
import { AnnotationEditorParamsType } from "pdfjs-lib";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} AnnotationEditorParamsOptions
|
||||||
|
* @property {HTMLInputElement} editorFreeTextFontSize
|
||||||
|
* @property {HTMLInputElement} editorFreeTextColor
|
||||||
|
* @property {HTMLInputElement} editorInkColor
|
||||||
|
* @property {HTMLInputElement} editorInkThickness
|
||||||
|
* @property {HTMLInputElement} editorInkOpacity
|
||||||
|
* @property {HTMLButtonElement} editorStampAddImage
|
||||||
|
* @property {HTMLInputElement} editorFreeHighlightThickness
|
||||||
|
* @property {HTMLButtonElement} editorHighlightShowAll
|
||||||
|
*/
|
||||||
|
|
||||||
class AnnotationEditorParams {
|
class AnnotationEditorParams {
|
||||||
/**
|
/**
|
||||||
* @param {AnnotationEditorParamsOptions} options
|
* @param {AnnotationEditorParamsOptions} options
|
||||||
|
@ -25,6 +39,9 @@ class AnnotationEditorParams {
|
||||||
this.#bindListeners(options);
|
this.#bindListeners(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AnnotationEditorParamsOptions} options
|
||||||
|
*/
|
||||||
#bindListeners({
|
#bindListeners({
|
||||||
editorFreeTextFontSize,
|
editorFreeTextFontSize,
|
||||||
editorFreeTextColor,
|
editorFreeTextColor,
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./interfaces.js").IL10n} IL10n */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/api.js").PDFDocumentLoadingTask} PDFDocumentLoadingTask */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
animationStarted,
|
animationStarted,
|
||||||
apiPageLayoutToViewerModes,
|
apiPageLayoutToViewerModes,
|
||||||
|
@ -96,7 +102,9 @@ const PDFViewerApplication = {
|
||||||
settled: false,
|
settled: false,
|
||||||
},
|
},
|
||||||
appConfig: null,
|
appConfig: null,
|
||||||
|
/** @type {PDFDocumentProxy} */
|
||||||
pdfDocument: null,
|
pdfDocument: null,
|
||||||
|
/** @type {PDFDocumentLoadingTask} */
|
||||||
pdfLoadingTask: null,
|
pdfLoadingTask: null,
|
||||||
printService: null,
|
printService: null,
|
||||||
/** @type {PDFViewer} */
|
/** @type {PDFViewer} */
|
||||||
|
|
|
@ -43,14 +43,14 @@ class BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_dispatchEvent(count) {
|
_dispatchEvent(count) {
|
||||||
throw new Error("Not implemented: _dispatchEvent");
|
throw new Error("Not implemented: _dispatchEvent");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_bindLink(element, params) {
|
_bindLink(element, params) {
|
||||||
throw new Error("Not implemented: _bindLink");
|
throw new Error("Not implemented: _bindLink");
|
||||||
|
@ -71,7 +71,9 @@ class BaseTreeViewer {
|
||||||
/**
|
/**
|
||||||
* Prepend a button before a tree item which allows the user to collapse or
|
* Prepend a button before a tree item which allows the user to collapse or
|
||||||
* expand all tree items at that level; see `_toggleTreeItem`.
|
* expand all tree items at that level; see `_toggleTreeItem`.
|
||||||
* @private
|
* @param {HTMLDivElement} div
|
||||||
|
* @param {boolean|object} [hidden]
|
||||||
|
* @protected
|
||||||
*/
|
*/
|
||||||
_addToggleButton(div, hidden = false) {
|
_addToggleButton(div, hidden = false) {
|
||||||
const toggler = document.createElement("div");
|
const toggler = document.createElement("div");
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./interfaces.js").IL10n} IL10n */
|
||||||
|
|
||||||
class BaseExternalServices {
|
class BaseExternalServices {
|
||||||
constructor() {
|
constructor() {
|
||||||
if (this.constructor === BaseExternalServices) {
|
if (this.constructor === BaseExternalServices) {
|
||||||
|
@ -28,6 +30,9 @@ class BaseExternalServices {
|
||||||
|
|
||||||
reportTelemetry(data) {}
|
reportTelemetry(data) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Promise<IL10n>}
|
||||||
|
*/
|
||||||
async createL10n() {
|
async createL10n() {
|
||||||
throw new Error("Not implemented: createL10n");
|
throw new Error("Not implemented: createL10n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,15 @@
|
||||||
// Class name of element which can be grabbed.
|
// Class name of element which can be grabbed.
|
||||||
const CSS_CLASS_GRAB = "grab-to-pan-grab";
|
const CSS_CLASS_GRAB = "grab-to-pan-grab";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} GrabToPanOptions
|
||||||
|
* @property {HTMLElement} element
|
||||||
|
*/
|
||||||
|
|
||||||
class GrabToPan {
|
class GrabToPan {
|
||||||
/**
|
/**
|
||||||
* Construct a GrabToPan instance for a given HTML element.
|
* Construct a GrabToPan instance for a given HTML element.
|
||||||
* @param {Element} options.element
|
* @param {GrabToPanOptions} options
|
||||||
*/
|
*/
|
||||||
constructor({ element }) {
|
constructor({ element }) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./overlay_manager.js").OverlayManager} OverlayManager */
|
||||||
|
|
||||||
import { PasswordResponses } from "pdfjs-lib";
|
import { PasswordResponses } from "pdfjs-lib";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./download_manager.js").DownloadManager} DownloadManager */
|
||||||
|
|
||||||
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
import { getFilenameFromUrl } from "pdfjs-lib";
|
import { getFilenameFromUrl } from "pdfjs-lib";
|
||||||
import { waitOnEventOrTimeout } from "./event_utils.js";
|
import { waitOnEventOrTimeout } from "./event_utils.js";
|
||||||
|
@ -27,6 +31,7 @@ import { waitOnEventOrTimeout } from "./event_utils.js";
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFAttachmentViewerRenderParameters
|
* @typedef {Object} PDFAttachmentViewerRenderParameters
|
||||||
* @property {Object|null} attachments - A lookup table of attachment objects.
|
* @property {Object|null} attachments - A lookup table of attachment objects.
|
||||||
|
* @property {boolean} [keepRenderedCapability]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PDFAttachmentViewer extends BaseTreeViewer {
|
class PDFAttachmentViewer extends BaseTreeViewer {
|
||||||
|
@ -56,7 +61,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
async _dispatchEvent(attachmentsCount) {
|
async _dispatchEvent(attachmentsCount) {
|
||||||
this._renderedCapability.resolve();
|
this._renderedCapability.resolve();
|
||||||
|
@ -87,7 +92,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_bindLink(element, { content, filename }) {
|
_bindLink(element, { content, filename }) {
|
||||||
element.onclick = () => {
|
element.onclick = () => {
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
|
||||||
import { AnnotationEditorType, shadow } from "pdfjs-lib";
|
import { AnnotationEditorType, shadow } from "pdfjs-lib";
|
||||||
import { CursorTool, PresentationModeState } from "./ui_utils.js";
|
import { CursorTool, PresentationModeState } from "./ui_utils.js";
|
||||||
import { GrabToPan } from "./grab_to_pan.js";
|
import { GrabToPan } from "./grab_to_pan.js";
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces.js").IL10n} IL10n */
|
||||||
|
/** @typedef {import("./overlay_manager.js").OverlayManager} OverlayManager */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
|
||||||
import { getPageSizeInches, isPortraitOrientation } from "./ui_utils.js";
|
import { getPageSizeInches, isPortraitOrientation } from "./ui_utils.js";
|
||||||
import { PDFDateString } from "pdfjs-lib";
|
import { PDFDateString } from "pdfjs-lib";
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/optional_content_config.js").OptionalContentConfig} OptionalContentConfig */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
|
||||||
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +31,7 @@ import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
* @typedef {Object} PDFLayerViewerRenderParameters
|
* @typedef {Object} PDFLayerViewerRenderParameters
|
||||||
* @property {OptionalContentConfig|null} optionalContentConfig - An
|
* @property {OptionalContentConfig|null} optionalContentConfig - An
|
||||||
* {OptionalContentConfig} instance.
|
* {OptionalContentConfig} instance.
|
||||||
* @property {PDFDocument} pdfDocument - A {PDFDocument} instance.
|
* @property {PDFDocumentProxy} pdfDocument - A {PDFDocument} instance.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PDFLayerViewer extends BaseTreeViewer {
|
class PDFLayerViewer extends BaseTreeViewer {
|
||||||
|
@ -48,7 +54,7 @@ class PDFLayerViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_dispatchEvent(layersCount) {
|
_dispatchEvent(layersCount) {
|
||||||
this.eventBus.dispatch("layersloaded", {
|
this.eventBus.dispatch("layersloaded", {
|
||||||
|
@ -58,7 +64,7 @@ class PDFLayerViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_bindLink(element, { groupId, input }) {
|
_bindLink(element, { groupId, input }) {
|
||||||
const setVisibility = () => {
|
const setVisibility = () => {
|
||||||
|
@ -97,7 +103,7 @@ class PDFLayerViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_addToggleButton(div, { name = null }) {
|
_addToggleButton(div, { name = null }) {
|
||||||
super._addToggleButton(div, /* hidden = */ name === null);
|
super._addToggleButton(div, /* hidden = */ name === null);
|
||||||
|
|
|
@ -13,6 +13,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./download_manager.js").DownloadManager} DownloadManager */
|
||||||
|
/** @typedef {import("./interfaces.js").IPDFLinkService} IPDFLinkService */
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("../src/display/api.js").PDFDocumentProxy} PDFDocumentProxy */
|
||||||
|
|
||||||
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
import { SidebarView } from "./ui_utils.js";
|
import { SidebarView } from "./ui_utils.js";
|
||||||
|
|
||||||
|
@ -27,7 +34,7 @@ import { SidebarView } from "./ui_utils.js";
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFOutlineViewerRenderParameters
|
* @typedef {Object} PDFOutlineViewerRenderParameters
|
||||||
* @property {Array|null} outline - An array of outline objects.
|
* @property {Array|null} outline - An array of outline objects.
|
||||||
* @property {PDFDocument} pdfDocument - A {PDFDocument} instance.
|
* @property {PDFDocumentProxy} pdfDocument - A {PDFDocument} instance.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PDFOutlineViewer extends BaseTreeViewer {
|
class PDFOutlineViewer extends BaseTreeViewer {
|
||||||
|
@ -75,7 +82,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_dispatchEvent(outlineCount) {
|
_dispatchEvent(outlineCount) {
|
||||||
this._currentOutlineItemCapability = Promise.withResolvers();
|
this._currentOutlineItemCapability = Promise.withResolvers();
|
||||||
|
@ -98,7 +105,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_bindLink(
|
_bindLink(
|
||||||
element,
|
element,
|
||||||
|
@ -162,7 +169,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
_addToggleButton(div, { count, items }) {
|
_addToggleButton(div, { count, items }) {
|
||||||
let hidden = false;
|
let hidden = false;
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./pdf_viewer.js").PDFViewer} PDFViewer */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
normalizeWheelEventDelta,
|
normalizeWheelEventDelta,
|
||||||
PresentationModeState,
|
PresentationModeState,
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
/** @typedef {import("./interfaces.js").IPDFPrintServiceFactory} IPDFPrintServiceFactory */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
PixelsPerInch,
|
PixelsPerInch,
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
/** @typedef {import("./interfaces.js").IL10n} IL10n */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
docStyle,
|
docStyle,
|
||||||
PresentationModeState,
|
PresentationModeState,
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CursorTool,
|
CursorTool,
|
||||||
ScrollMode,
|
ScrollMode,
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {import("./event_utils.js").EventBus} EventBus */
|
||||||
|
|
||||||
import { AnnotationEditorType, ColorPicker, noContextMenu } from "pdfjs-lib";
|
import { AnnotationEditorType, ColorPicker, noContextMenu } from "pdfjs-lib";
|
||||||
import {
|
import {
|
||||||
DEFAULT_SCALE,
|
DEFAULT_SCALE,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue