* refactor version 1 many todo
* split render from viewer
move alfresco render in content pack
* refactor part 2
* test fixed
* fix doc
* [AAE-10778] Fix lint issues
* [AAE-10778] Fix lint issue: remove duplicated declaration
* [AAE-10778] Fix lint issue: use flex shorthand rule
* [AAE-10778] Fix FormService and WidgetComponent imports
* [AAE-10778] Fix import FormModel, FormService, FormFieldModel from adf-core
* [AAE-10778] Implement missing oninit, onchanges and ondestroy
* [AAE-10778] Replace adf-viewer with adf-alfresco-viewer, update escape command to close the viewer
* [AAE-10778] Fix unit test: fix the class name to match the 'adf-viewer-render.image-viewer-scaling' get from the appConfigService
* [AAE-10778] Fix image-viewer unit tests: replace ContentService with UrlService
* [AAE-10778] Fix unit test 'should if the extension change extension Change event be fired': emit file extension when the filename extension change
* [AAE-10778] Fix unit test: expect for internalFileName value instead of display-name id because the display name logic has been moved to the alfresco-viewer.component
* [AAE-10778] Fix unit test: remove display name it because the unknown display name value is no longer handled after refactoring
* [AAE-10778] Fix e2e: [C260096] Should the Viewer able to accept a customToolbar
* [AAE-10778] Update selector to fix e2e: '[C362265] Should the Viewer be able to download a previous version of a file'
* [AAE-10778] Update selector to fix e2e: '[C260038] Should display first page, toolbar and pagination when opening a .pdf file'
* fix aftrer rebase
* fix unit test
* [AAE-10778] Add adf viewer component that is node agnostic, show adf-alfresco-viewer or adf-viewer into file-view-component if blob or node are set
* [AAE-10778] Update viewer export path
* [AAE-10778] Update selectors since have been updated in the viewer component
* [AAE-10778] Call adf-viewer from alfresco-viewer, project adf-alfresco-viewer content to adf-viewer
* [AAE-10778] Remove full screen unit tests from alfresco-viewer component becase that logic is handled in the viewer.component
* [AAE-10778] Export toolbar custom actions component
* [AAE-10778] Pass mimeType as input to adf-viewer to update mime icon
* [AAE-10778] Remove e2e because the custom name behaviour has been removed from the file-view.component (9f21b6dc69
\#diff-4b438dc59784dce9eb7634cfeca6d8db61362966343bd3d6895a3edafdf4cfd5L129)
* [AAE-10778] Use two-way binding for showViewer change to fix C260100
* [AAE-10778] Update prefix css selectors to adf-viewer because are related to the adf-viewer component
* [AAE-10778] Update prefix css selectors to adf-viewer in the unit tests because are related to the adf-viewer component
* [AAE-10778] Update the output name to showViewerChange to navigate to primary url after closing the viewer
* [AAE-10778] Pass right and left sidebar template context to viewer component (fix C362242)
* [AAE-10778] Add allowFullScreen input to disable/enable full screen behaviour
* [AAE-10778] Handle loading visualization only inside the viewer-render component
* [AAE-10778] PDF viewer: fix mat-progress-bar is not showed during the pdf loading, center progress bar
* [AAE-10778] Remove isLoading from unit tests because no longer exists
* [AAE-10778] Remove viewerType input from adf-viewer, viewerType will be handled by viewer-render
* [AAE-10778] Remove console.log
* [AAE-10778] Remove check full screen button is not displayed on the media file because is not needed anymore, we don't need to check for the fullscreen button in the viewer component
* [AAE-10778] Check for node rendtion before to assign to urlFileContent and mimeType
* [AAE-10778] Process Services Cloud: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS
* [AAE-10778] Core: rename file-viewer widget into base-viewer, base-viewer no longer accept nodeId, but will accept urlFile and blobFile
* [AAE-10778] Process Services: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS
* [AAE-10778] Base viewer widget: show viewer only if there's a file input
* [AAE-10778] Viewer component: check for fileName when urlFile is provided as Input
* [AAE-10778] Viewer component documentation
* [AAE-10778] Update upgrade guide with viewer changes
* [AAE-10778] Fix double quote lint issue after rebase
---------
Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
Co-authored-by: Amedeo Lepore <amedeo.lepore85@gmail.com>
8.4 KiB
Title, Added, Status, Last reviewed
Title | Added | Status | Last reviewed |
---|---|---|---|
Viewer Render component | v6.0.0 | Active | 2022-11-25 |
Viewer render component
Displays content from an ACS repository.
See it live: Viewer Quickstart
Contents
Basic usage
Using with file url:
<adf-viewer-render
[overlayMode]="true"
[urlFile]="'filename.pdf'">
</adf-viewer-render>
Using with file Blob
:
<adf-viewer-render
[overlayMode]="true"
[blobFile]="myBlobVar">
</adf-viewer-render>
Class members
Properties
Name | Type | Default value | Description |
---|---|---|---|
allowFullScreen | boolean |
true | Toggles the 'Full Screen' feature. |
allowThumbnails | boolean |
true | Toggles PDF thumbnails. |
blobFile | Blob |
Loads a Blob File | |
fileName | string |
Override Content filename. | |
isLoading | boolean |
false | Override loading status |
mimeType | string |
MIME type of the file content (when not determined by the filename extension). | |
readOnly | boolean |
true | Enable when where is possible the editing functionalities |
thumbnailsTemplate | TemplateRef <any> |
null | The template for the pdf thumbnails. |
tracks | Track [] |
[] | media subtitles for the media player |
urlFile | string |
"" | If you want to load an external file that does not come from ACS you can use this URL to specify where to load the file from. |
viewerType | string |
"unknown" | Override Content view type. Viewer to use with the urlFile address (pdf , image , media , text ). |
Events
Name | Type | Description |
---|---|---|
close | EventEmitter <boolean> |
Emitted when the img is submitted in the img viewer. |
extensionChange | EventEmitter <string> |
Emitted when the filename extension changes. |
submitFile | EventEmitter < Blob > |
Emitted when the img is submitted in the img viewer. |
Keyboard shortcuts
Name | Description |
---|---|
Esc | Close the viewer (overlay mode only). |
Left | Invoke 'Navigate before' action. |
Right | Invoke 'Navigate next' action. |
Ctrl+F | Activate full-screen mode. |
Details
The component controller class implementation might look like the following:
export class OverlayViewerComponent {
@Input()
showViewer: boolean = false;
nodeId: string;
showPreview(event) {
if (event.value.entry.isFile) {
this.nodeId = event.value.entry.id;
this.showViewer = true;
}
}
}
Custom file parameters
You can provide custom file parameters, for example a value for the mimeType
or displayName
when using URL values that have no file names or extensions:
<adf-viewer-render
[displayName]="fileName"
[allowGoBack]="false"
[mimeType]="mimeType"
[urlFile]="fileUrl">
</adf-viewer-render>
Supported file formats
The Viewer render component consists of separate Views that handle particular file types or type families based on either a file extension or a mime type:
- PDF View
- application/pdf
- Image View
- image/png
- image/jpeg
- image/gif
- image/bmp
- image/svg+xml
- *.png
- *.jpg
- *.jpeg
- *.gif
- *.bpm
- *.svg
- Text View
- text/plain
- text/csv
- text/xml
- text/html
- application/x-javascript
- *.txt
- *.xml
- *.js
- *.html
- *.json
- *.ts
- Media View
- video/mp4
- video/webm
- video/ogg
- audio/mpeg
- audio/ogg
- audio/wav
- *.wav
- *.mp4
- *.mp3
- *.webm
- *.ogg
Configuring PDF.js library
Configure your webpack-enabled application with the PDF.js library as follows.
- Install pdfjs-dist
npm install pdfjs-dist
- Update
vendors.ts
by appending the following code. This will enable the Viewer render component and compatibility mode for all browsers. It will also configure the web worker for the PDF.js library to render PDF files in the background:
// PDF.js
require('pdfjs-dist/web/compatibility.js');
const pdfjsLib = require('pdfjs-dist');
pdfjsLib.PDFJS.workerSrc = './pdf.worker.js';
require('pdfjs-dist/web/pdf_viewer.js');
- Update the
plugins
section of thewebpack.common.js
file with the following lines:
new CopyWebpackPlugin([
...
{
from: 'node_modules/pdfjs-dist/build/pdf.worker.js',
to: 'pdf.worker.js'
}
])
The Viewer render component should now be able to display PDF files.
Extending the Viewer
Internal extension mechanism
The Viewer supports dynamically-loaded viewer preview extensions, to know more about it Preview Extension component. This
Code extension mechanism]
You can define your own custom handler to handle other file formats that are not yet supported by
the Viewer render component. Below is an example that shows how to use the adf-viewer-render-extension
to handle 3D data files:
<adf-viewer-render [nodeId]="nodeId">
<adf-viewer-extension [supportedExtensions]="['obj','3ds']" #extension>
<ng-template let-urlFileContent="urlFileContent" let-extension="extension">
<threed-viewer
[urlFile]="urlFileContent"
[extension]="extension">
</threed-viewer>
</ng-template>
</adf-viewer-extension>
</adf-viewer-render>
Note: you need to add the ng2-3d-editor
dependency to your package.json
file to make the example above work.
You can define multiple adf-viewer-render-extension
templates if required:
<adf-viewer-render [nodeId]="nodeId">
<adf-viewer-extension [supportedExtensions]="['xls','xlsx']" #extension>
<ng-template let-urlFileContent="urlFileContent">
<my-custom-xls-component
urlFileContent="urlFileContent">
</my-custom-xls-component>
</ng-template>
</adf-viewer-extension>
<adf-viewer-render-extension [supportedExtensions]="['txt']" #extension>
<ng-template let-urlFileContent="urlFileContent" >
<my-custom-txt-component
urlFileContent="urlFileContent">
</my-custom-txt-component>
</ng-template>
</adf-viewer-render-extension>
</adf-viewer-render>
Custom layout
The Viewer render component lets you transclude custom content in several different places as explained in the sections below.
Custom zoom scaling
You can set a default zoom scaling value for pdf viewer by adding the following code in app.config.json
.
Note: For the pdf viewer the value has to be within the range of 25 - 1000.
"adf-viewer-render": { "pdf-viewer-scaling": 150 }
In the same way you can set a default zoom scaling value for the image viewer by adding the following code in app.config.json
.
"adf-viewer-render": { "image-viewer-scaling": 150 }
By default the viewer's zoom scaling is set to 100%.