diff --git a/package.json b/package.json index a4afc39f5..a2c001c9c 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,6 @@ "xlsx": "^0.18.5", "jszip": "^3.10.1", "plyr": "^3.7.8", - "pdfjs-dist": "~3.6.172", "screenfull": "^6.0.2", "less-bundle-promise": "^1.0.11", "ng-alain-codelyzer": "^0.0.1", diff --git a/packages/abc/ng-package.json b/packages/abc/ng-package.json index 36f602464..0adf244fd 100644 --- a/packages/abc/ng-package.json +++ b/packages/abc/ng-package.json @@ -13,7 +13,6 @@ "jszip", "xlsx", "plyr", - "pdfjs-dist", "@github/hotkey", "ngx-countdown", "@yelon/theme", diff --git a/packages/abc/pdf/demo/design.md b/packages/abc/pdf/demo/design.md index 73d6ff962..e2f2c4df5 100644 --- a/packages/abc/pdf/demo/design.md +++ b/packages/abc/pdf/demo/design.md @@ -193,7 +193,7 @@ export class DemoComponent implements OnInit { }; loadOutline(): void { - this.comp.pdf?.getOutline().then(outline => { + this.comp.pdf?.getOutline().then((outline: NzSafeAny) => { this.outlineList = outline; }); } diff --git a/packages/abc/pdf/index.en-US.md b/packages/abc/pdf/index.en-US.md index e44114a5a..8dfdbc78c 100644 --- a/packages/abc/pdf/index.en-US.md +++ b/packages/abc/pdf/index.en-US.md @@ -15,10 +15,14 @@ pdf.js libary is lazy loading by default,you can change the default root CDN p **Use local path** +```bash +yarn add pdfjs-dist +``` + ```json // angular.json { - "glob": "**/(build,web)/**", + "glob": "{build,web}/**", "input": "./node_modules/pdfjs-dist/", "ignore": ["*.js.map", "*.d.ts"], "output": "assets/pdfjs/" diff --git a/packages/abc/pdf/index.zh-CN.md b/packages/abc/pdf/index.zh-CN.md index 0c0275b5e..fce83622f 100644 --- a/packages/abc/pdf/index.zh-CN.md +++ b/packages/abc/pdf/index.zh-CN.md @@ -15,10 +15,14 @@ module: import { PdfModule } from '@yelon/abc/pdf'; **使用本地路径** +```bash +yarn add pdfjs-dist +``` + ```json // angular.json { - "glob": "**/(build,web)/**", + "glob": "{build,web}/**", "input": "./node_modules/pdfjs-dist/", "ignore": ["*.js.map", "*.d.ts"], "output": "assets/pdfjs/" diff --git a/packages/abc/pdf/pdf.component.ts b/packages/abc/pdf/pdf.component.ts index 76c321318..c85889d1a 100644 --- a/packages/abc/pdf/pdf.component.ts +++ b/packages/abc/pdf/pdf.component.ts @@ -22,11 +22,11 @@ import { import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { fromEvent, timer, debounceTime, filter } from 'rxjs'; -import type { PDFDocumentLoadingTask, PDFDocumentProxy } from 'pdfjs-dist'; -import type { EventBus } from 'pdfjs-dist/types/web/event_utils'; -import type { PDFFindController } from 'pdfjs-dist/types/web/pdf_find_controller'; -import type { PDFLinkService } from 'pdfjs-dist/types/web/pdf_link_service'; -import type { PDFViewer } from 'pdfjs-dist/types/web/pdf_viewer'; +// import type { PDFDocumentLoadingTask, PDFDocumentProxy } from 'pdfjs-dist'; +// import type { EventBus } from 'pdfjs-dist/types/web/event_utils'; +// import type { PDFFindController } from 'pdfjs-dist/types/web/pdf_find_controller'; +// import type { PDFLinkService } from 'pdfjs-dist/types/web/pdf_link_service'; +// import type { PDFViewer } from 'pdfjs-dist/types/web/pdf_viewer'; import { YunzaiConfigService } from '@yelon/util/config'; import { BooleanInput, InputBoolean, InputNumber, NumberInput, ZoneOutside } from '@yelon/util/decorator'; @@ -36,6 +36,16 @@ import type { NzSafeAny } from 'ng-zorro-antd/core/types'; import { PDF_DEFULAT_CONFIG } from './pdf.config'; import { PdfChangeEvent, PdfChangeEventType, PdfExternalLinkTarget, PdfTextLayerMode, PdfZoomScale } from './pdf.types'; +// TODO: Although pdfjs-dist is an optional dependency on canvas +// will be installed automatically when the dependency is installed by default; +// This requires a higher environment and often fails to install +type PDFDocumentLoadingTask = NzSafeAny; +type PDFDocumentProxy = NzSafeAny; +type EventBus = NzSafeAny; +type PDFFindController = NzSafeAny; +type PDFLinkService = NzSafeAny; +type PDFViewer = NzSafeAny; + const CSS_UNITS: number = 96.0 / 72.0; const BORDER_WIDTH = 9; @@ -43,7 +53,7 @@ const BORDER_WIDTH = 9; selector: 'pdf', exportAs: 'pdf', template: ` - +
@@ -325,7 +335,7 @@ export class PdfComponent implements OnChanges, AfterViewInit, OnDestroy { const currentViewer = this.pageViewer; if (!currentViewer) return; - this._pdf!.getPage(currentViewer.currentPageNumber).then(page => { + this._pdf!.getPage(currentViewer.currentPageNumber).then((page: NzSafeAny) => { const { _rotation, _zoom } = this; const rotation = _rotation || page.rotate; const viewportWidth = diff --git a/packages/abc/pdf/pdf.types.ts b/packages/abc/pdf/pdf.types.ts index 152d20f92..80cf635b2 100644 --- a/packages/abc/pdf/pdf.types.ts +++ b/packages/abc/pdf/pdf.types.ts @@ -1,7 +1,9 @@ -import type { PDFDocumentProxy } from 'pdfjs-dist'; +// import type { PDFDocumentProxy } from 'pdfjs-dist'; import type { NzSafeAny } from 'ng-zorro-antd/core/types'; +type PDFDocumentProxy = NzSafeAny; + export type PdfChangeEventType = | 'loaded' | 'load-progress' diff --git a/src/app/global-config.module.ts b/src/app/global-config.module.ts index 4669bc411..4b49e6d20 100644 --- a/src/app/global-config.module.ts +++ b/src/app/global-config.module.ts @@ -33,9 +33,9 @@ const yunzaiConfig: YunzaiConfig = { qr: { lib: '/assets/qrious/qrious.min.js' }, - pdf: { - lib: '/assets/pdfjs/' - }, + // pdf: { + // lib: '/assets/pdfjs/' + // }, media: { urls: ['assets/plyr/plyr.min.js', 'assets/plyr/plyr.css'], options: {