ngx-doc-viewer 15.0.1 → 21.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@ Documents that are publicly available can be shown in an iframe using the google
6
6
 
7
7
  Pdf files and word document that are not publicly available can be shown using the mammoth viewer or pdf viewer by passing an objectUrl.
8
8
 
9
- <a href="https://angular-doc-viewer.firebaseapp.com/">View demo</a>
9
+ <a href="https://angular-doc-viewer.web.app/">View demo</a>
10
10
 
11
11
  <a href="https://github.com/Marcelh1983/document-viewer/blob/main/packages/ngx-doc-viewer/changelog.md">Changes</a>
12
12
 
@@ -37,6 +37,8 @@ export class AppModule {}
37
37
  ></ngx-doc-viewer>
38
38
  ```
39
39
 
40
+ The component now shows an internal loading overlay while external viewers such as Google Docs Viewer and Office Online are initializing, so viewer switches do not appear as a blank panel.
41
+
40
42
  To
41
43
 
42
44
  #### API:
@@ -52,7 +54,76 @@ Input:
52
54
  - all: adds an overlay to the whole iframe, which makes nothing in the document clickable/selectable
53
55
  - popout: adds an overlay over googles popout button or office popout and menu which disables just this button/menu but keeps giving the possibility to select text. The popout button is still visible (for google during a few seconds) but not clickable.
54
56
  - popout-hide: see popup, instead of an transparent overlay a white one. This really hides the button but you'll see a white block while loading for the google viewer.
55
- - overrideLocalhost: documents from the assets folder are not publicly available and therefor won't show in an external viewer (google, office). If the site is already published to public server, then pass that url and if will replace localhost by the other url. Like: overrideLocalhost="https://angular-doc-viewer.firebaseapp.com/"
57
+ - overrideLocalhost: documents from the assets folder are not publicly available and therefor won't show in an external viewer (google, office). If the site is already published to public server, then pass that url and if will replace localhost by the other url. Like: overrideLocalhost="https://angular-doc-viewer.web.app/"
58
+ - loadingText: fallback text shown in the built-in loading overlay. Defaults to `Loading document...`
59
+ - errorTextOverride: fallback text shown in the built-in error overlay. Defaults to the runtime error message.
60
+ - retryButtonText: text used by the built-in retry button in the default error overlay. Defaults to `Retry`
61
+ - googleFinalRetryDelay: waits this many milliseconds and retries Google once more before showing the error overlay. Defaults to `0`
62
+ - officeAutoRetry: automatically retries the Office viewer once after `officeRetryDelay`. Defaults to `false`
63
+ - officeRetryDelay: delay in milliseconds before the one-time Office auto retry. Defaults to `3000`
64
+ - officeReloadButtonText: text shown in the persistent Office reload button. Defaults to `↻`
65
+ - officeReloadButtonTitle: tooltip/title for the persistent Office reload button. Defaults to `Reload document`
66
+ - secondaryActionText: optional text for a built-in secondary error action button, for example `Open source` or `Download`
67
+ - secondaryActionMode: controls the built-in secondary action behavior. Supported values: `open` or `download`. Defaults to `open`
68
+
69
+ For custom loading markup in Angular, project an `ng-template` named `loadingContent`.
70
+ The template receives `$implicit` and `state` with:
71
+ - `viewer`
72
+ - `url`
73
+ - `phase`
74
+ - `errorText`
75
+ - `retry()`
76
+ - `actionUrl`
77
+
78
+ ```html
79
+ <ngx-doc-viewer [url]="doc" viewer="office">
80
+ <ng-template #loadingContent let-state>
81
+ <div style="display:flex;gap:8px;align-items:center;">
82
+ <span class="spinner"></span>
83
+ <span>Preparing {{ state.viewer }} preview...</span>
84
+ </div>
85
+ </ng-template>
86
+ </ngx-doc-viewer>
87
+ ```
88
+
89
+ To replace the persistent Office reload control, project an `ng-template` named `officeReloadContent`:
90
+
91
+ ```html
92
+ <ngx-doc-viewer [url]="doc" viewer="office">
93
+ <ng-template #officeReloadContent let-state>
94
+ <span>Reload</span>
95
+ </ng-template>
96
+ </ngx-doc-viewer>
97
+ ```
98
+
99
+ For custom error markup in Angular, project an `ng-template` named `errorContent`.
100
+ It receives the same context and can call `retry()` directly:
101
+
102
+ ```html
103
+ <ngx-doc-viewer [url]="doc" viewer="office">
104
+ <ng-template #errorContent let-state>
105
+ <div style="text-align:center;">
106
+ <div>Preview unavailable for {{ state.viewer }}.</div>
107
+ <div>{{ state.actionUrl }}</div>
108
+ <button type="button" (click)="state.retry()">Retry</button>
109
+ <a [href]="state.actionUrl" target="_blank" rel="noreferrer">Open source</a>
110
+ </div>
111
+ </ng-template>
112
+ </ngx-doc-viewer>
113
+ ```
114
+
115
+ If you want to keep the default error layout but replace just the actions area, project an `ng-template` named `errorActions`:
116
+
117
+ ```html
118
+ <ngx-doc-viewer [url]="doc" viewer="office" retryButtonText="Try again">
119
+ <ng-template #errorActions let-state>
120
+ <div style="margin-top: 14px; display: flex; gap: 8px; justify-content: center;">
121
+ <button type="button" (click)="state.retry()">Try again</button>
122
+ <a [href]="state.actionUrl" target="_blank" rel="noreferrer">Open source</a>
123
+ </div>
124
+ </ng-template>
125
+ </ngx-doc-viewer>
126
+ ```
56
127
 
57
128
  There are some issues loading document in the google viewer. See: https://stackoverflow.com/questions/40414039/google-docs-viewer-returning-204-responses-no-longer-working-alternatives. If loading pdf's and Word documents, seems to work now with this hack let me know via a Github issue.
58
129
 
@@ -61,7 +132,16 @@ There are some issues loading document in the google viewer. See: https://stacko
61
132
  - googleMaxChecks = 5 | max number of retries
62
133
  Output:
63
134
 
64
- - loaded: google only, notifies when iframe is loaded. Can be used to show progress while loading
135
+ - loaded: emitted when the current iframe is ready. Can be used to hook into custom loading or telemetry flows.
136
+ - loading: emitted when the viewer enters the `loading` phase. Payload includes `viewer`, `url`, `phase`, `errorText`, `retry()`, and `actionUrl`.
137
+ - error: emitted when the viewer enters the `error` phase. Payload includes `viewer`, `url`, `phase`, `errorText`, `retry()`, and `actionUrl`.
138
+ - phaseChange: emitted whenever the internal phase changes to `idle`, `loading`, `ready`, or `error`.
139
+
140
+ ### Recent behavior improvements
141
+
142
+ - External viewer switches now remount the iframe cleanly when changing between viewers such as Google and Office.
143
+ - A built-in loading overlay is shown while remote viewers are loading.
144
+ - Mammoth rendering now refreshes correctly when switching from an iframe-based viewer back to inline document rendering.
65
145
 
66
146
  ### File type support
67
147
 
@@ -90,9 +170,8 @@ Google Drive viewer helps you preview over 15 different file types, listed below
90
170
  - PostScript (.EPS, .PS)
91
171
  - TrueType (.TTF)
92
172
  - XML Paper Specification (.XPS)
93
- - Archive file types (.ZIP and .RAR)
94
173
 
95
- <a href="https://gist.githubusercontent.com/tzmartin/1cf85dc3d975f94cfddc04bc0dd399be/raw/d4263c8faf7b68f4bbfd33b386ec33ed2bc11e7d/embedded-file-viewer.md">Source</a>
174
+ > **Note:** Archive files (.ZIP, .RAR) are **not** supported by the Google Docs embedded viewer despite some community sources claiming otherwise. For the current official list of supported formats, see the [Google Drive Help Center](https://support.google.com/drive/answer/2423485).
96
175
 
97
176
  #### url
98
177