Module: alfresco/preview/AlfDocumentPreview

alfresco/preview/AlfDocumentPreview

This module can be used to easily preview content from an Alfresco Repository. Typically this will be a child widget of an AlfDocument that can be used to retrieve all of the data required to generate the preview. In order to retrieve the data it will also be necesssary to include a DocumentService on the page.

By default there are a number of "plugins" that handle specific previews (e.g. HTML5 video and audio, images, PDF.js renderings, etc) and it is possible to either override, remove, add or re-configure plugins using the widgetsForPluginsOverrides attribute.

The dimensions of the previewer can generally be controlled using the [heightMode] module:alfresco/preview/AlfDocumentPreview#heightMode attribute. However, it is entirely dependant upon each plugin as to whether they honour this setting. For example the Audio plugin will ignore it as the dimensions are not important.

Author:
  • Dave Draper
License:
Source:

Mixes In

Members

apiVersion :number

The Alfresco repository features multiple rendition REST APIs. Up to and including version 5.1 of Alfresco supports the "version zero" REST API (also known as Share Services API) for Renditions. In addition post 5.1 there is a "version one" Public Rendition API also. Set this value to 1 to use the new version one API, else the classic v0 API will be used and Share Services AMP must be applied to the repository.
Type:
  • number
Since:
  • 1.0.60
Default Value:
  • 0
Source:

avoidCachedThumbnail :boolean

MNT-9235: This flag identifies whether content of current node modified. That means that the cached thumbnail is no more valid and it should be updated
Type:
  • boolean
Default Value:
  • false
Source:

cssRequirements :object[]

An array of the CSS files to use with this widget.
Type:
  • object[]
Default Value:
  • [{cssFile:"./css/AlfDocumentPreview.css"}]
Source:

heightMode

This function attempts to set an appropriate height for the previewer. There are 3 different modes of controlling the height:

  • "AUTO" will attempt to ensure that the previewer takes up the complete vertical space in the client from where it starts. This makes sense to use if you have a single previewer on a page.
  • Any positive number (note: not as a string) will set an explicit height that won't change as the browser resizes
  • Any negative number will result in that amount being deducted from the browser window height and this will change as the browser is resized. This can be useful for setting the previewer in a dialog.

Default Value:
  • "AUTO"
Source:

i18nRequirements :object[]

An array of the i18n files to use with this widget.
Type:
  • object[]
Default Value:
  • [{i18nFile: "./i18n/AlfDocumentPreview.properties"}]
Source:

mimeType :string

The mimeType of the node to display, needed to decide what plugin that should be used.
Type:
  • string
Source:

name :string

The file name representing root container
Type:
  • string
Source:

nodeRef :string

Noderef to the content to display
Type:
  • string
Source:

plugin :object

Type:
  • object
Default Value:
  • null
Source:

pluginConditions :object[]

A json representation of the .get.config.xml file. This is evaluated on the client side since we need the plugins to make sure it is supported the user's browser and browser plugins.
Type:
  • object[]
Source:

pluginConditionsOverrides :object[]

Type:
  • object[]
Since:
  • 1.0.56
Default Value:
  • null
Source:

plugins :object

Space for preview "plugins" to register themselves in. To provide a 3rd party plugin: 1. Create a javascript file and make it define a javascript class that defines a "plugin class" in this namespace. 2. Override this component's .get.head.ftl file and make sure your javascript file (and its resources) are included. 3. Override this component's .get.config.xml and define for which mimeTypes or thumbnails it shall be used. 4. To make sure your plugin works in the browser, define a report() method that returns nothing if the browser is supported and otherwise a string with a message saying the reason the plugin can't be used in the browser. 5. Define a display() method that will display the browser plugin or simply return a string of markup that shall be inserted.
Type:
  • object
Default Value:
  • null
Source:

proxy :string

The proxy to use for the rest api call for the node's content or thumbnails. I.e. "alfresco" (or "alfresco-noauth" for public content & pages). Can be set as null or empty value for URLs that do not require a specific proxy id endpoint.
Type:
  • string
Default Value:
  • "alfresco"
Source:

size :string

The size of the content
Type:
  • string
Default Value:
  • "0"
Source:

templateString :string

The HTML template to use for the widget.
Type:
  • string
Source:

thumbnailModification :object[]

Type:
  • object[]
Default Value:
  • null
Source:

thumbnails :object[]

A list of previews available for this node, needed to decide which plugin that should be used.
Type:
  • object[]
Default Value:
  • null
Source:

widgetsForPlugins :object[]

This is the default set of plugins for the previewer. These can be overridden in their entirety or changes to a subset can be made through configuration of the widgetsForPluginsOverrides attribute.
Type:
  • object[]
Source:

widgetsForPluginsOverrides :array

This configuration attribute can be set to specifically override individual plugins rather than replacing the entire default set. Each element in the array should contain an "id" attribute for the plugin and a name that maps to a plugin module. If the element contains the attribute "remove" set to true then any existing plugin with a matching ID will be removed, if the element contains an attribute "replace" set to true then the entire configuration of the existing plugin will be replaced. Otherwise the new configuration will be merged into the existing.
Type:
  • array
Default Value:
  • []
Source:

<inner> api :string

The base to the rest api call for the node's content or thumbnails, used when using an apiVersion of 0.
Type:
  • string
Default Value:
  • "api"
Source:

Methods

conditionsMatch(condition) → {boolean}

Checks if the conditions are fulfilled.
Parameters:
Name Type Description
condition object The condition to match gainst this components options
Source:
Returns:
true if conditions are fulfilled for plugins to be used.
Type
boolean

createPlugin()

Source:

doRefresh()

Refreshes component by metadataRefresh event
Source:

getContentUrl(download(Optional)) → {string}

Helper method for plugins to create url tp the node's content.
Parameters:
Name Type Description
download(Optional) Bbolean Default false. Set to true if the url shall be constructed so it forces the browser to download the document, rather than displaying it inside the browser.
Source:
Returns:
The "main" element holding the actual previewer.
Type
string

getPreviewerElement() → {element}

Makes it possible for plugins to get hold of the "previewer wrapper" HTMLElement. I.e. Useful for elements that use an "absolute" layout for their plugins (most likely flash), so they have an element in the Dom to position their own elements after.
Source:
Returns:
The "main" element holding the actual previewer.
Type
element

getThumbnailUrl(thumbnail, fileSuffix) → {String}

Helper method for plugins to create a url to the thumbnail's content.
Parameters:
Name Type Description
thumbnail String The thumbnail definition name
fileSuffix String (Optional) I.e. ".png" if shall be inserted in the url to make certain flash plugins understand the mimetype of the thumbnail.
Source:
Returns:
The url to the thumbnail content.
Type
String

onPreviewChanged(payload)

MNT-9235: Handles all the 'onPreviewChangedEvent' events
Parameters:
Name Type Description
payload object
Source:

postCreate()

Source:

setupPlugins()

Source:

setupPreview()

Will find a previewer and set it up if one existed
Source:

updatePluginConditions(condition)

This function is used to update the pluginConditions with additional condition data from an entry defined in pluginConditionsOverrides. This function is called from setupPlugins for each entry in the pluginConditionsOverrides array.
Parameters:
Name Type Description
condition object The plugin condition to update
Since:
  • 1.0.56
Source:

updatePluginConfiguration()

This function is used to add, update or remove individual plugins in the main list.
Source: