@contrail/documents 1.0.89 → 1.0.91

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.
@@ -2,4 +2,5 @@ import { DocumentElement } from './types/document-element';
2
2
  export declare class DocumentElementPropertyBindingHandler {
3
3
  static bindPropertiesToElements(elements: Array<DocumentElement>, model: any): void;
4
4
  static bindPropertiesToElement(element: DocumentElement, model: any): void;
5
+ static isContentTypeWebViewable(contentType: string): boolean;
5
6
  }
@@ -9,7 +9,7 @@ class DocumentElementPropertyBindingHandler {
9
9
  });
10
10
  }
11
11
  static bindPropertiesToElement(element, model) {
12
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
12
+ var _a, _b, _c, _d, _e, _f, _g;
13
13
  const localModel = Object.assign({}, model);
14
14
  if (!element.propertyBindings) {
15
15
  return;
@@ -28,19 +28,23 @@ class DocumentElementPropertyBindingHandler {
28
28
  if (((_b = (_a = element.propertyBindings) === null || _a === void 0 ? void 0 : _a.url) === null || _b === void 0 ? void 0 : _b.indexOf("viewable")) !== -1 && isImage) {
29
29
  element.alternateUrls = {};
30
30
  let highResUrl = ((_c = model === null || model === void 0 ? void 0 : model.viewable) === null || _c === void 0 ? void 0 : _c.largeViewableDownloadUrl) || ((_d = model === null || model === void 0 ? void 0 : model.viewable) === null || _d === void 0 ? void 0 : _d.largeViewableUrl);
31
- let originalFile = (_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.primaryFileUrl;
32
- const content = (_f = model === null || model === void 0 ? void 0 : model.viewable) === null || _f === void 0 ? void 0 : _f.content;
31
+ let originalFile;
32
+ let viewableObject;
33
+ const content = (_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.content;
33
34
  if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
34
35
  const primaryContent = content.find((c) => { var _a; return (c === null || c === void 0 ? void 0 : c.id) === ((_a = model === null || model === void 0 ? void 0 : model.viewable) === null || _a === void 0 ? void 0 : _a.primaryViewableId); });
35
- if ((primaryContent === null || primaryContent === void 0 ? void 0 : primaryContent.contentType) === 'image/svg+xml') {
36
- highResUrl = primaryContent.primaryFileUrl;
37
- }
38
- if (primaryContent === null || primaryContent === void 0 ? void 0 : primaryContent.primaryFileUrl) {
39
- originalFile = primaryContent === null || primaryContent === void 0 ? void 0 : primaryContent.primaryFileUrl;
40
- }
36
+ viewableObject = primaryContent;
41
37
  }
42
- else if (((_g = model === null || model === void 0 ? void 0 : model.viewable) === null || _g === void 0 ? void 0 : _g.contentType) === 'image/svg+xml') {
43
- highResUrl = (_h = model === null || model === void 0 ? void 0 : model.viewable) === null || _h === void 0 ? void 0 : _h.primaryFileUrl;
38
+ else {
39
+ viewableObject = model === null || model === void 0 ? void 0 : model.viewable;
40
+ }
41
+ const contentType = viewableObject === null || viewableObject === void 0 ? void 0 : viewableObject.contentType;
42
+ const primaryFileUrl = viewableObject === null || viewableObject === void 0 ? void 0 : viewableObject.primaryFileUrl;
43
+ if (contentType === 'image/svg+xml') {
44
+ highResUrl = primaryFileUrl;
45
+ }
46
+ if (this.isContentTypeWebViewable(contentType)) {
47
+ originalFile = primaryFileUrl;
44
48
  }
45
49
  if (highResUrl) {
46
50
  element.alternateUrls.highResolution = highResUrl;
@@ -48,7 +52,7 @@ class DocumentElementPropertyBindingHandler {
48
52
  if (originalFile) {
49
53
  element.alternateUrls.originalFile = originalFile;
50
54
  }
51
- let lowResUrl = ((_j = model === null || model === void 0 ? void 0 : model.viewable) === null || _j === void 0 ? void 0 : _j.smallViewableDownloadUrl) || ((_k = model === null || model === void 0 ? void 0 : model.viewable) === null || _k === void 0 ? void 0 : _k.smallViewableUrl);
55
+ let lowResUrl = ((_f = model === null || model === void 0 ? void 0 : model.viewable) === null || _f === void 0 ? void 0 : _f.smallViewableDownloadUrl) || ((_g = model === null || model === void 0 ? void 0 : model.viewable) === null || _g === void 0 ? void 0 : _g.smallViewableUrl);
52
56
  if (lowResUrl) {
53
57
  element.alternateUrls.lowResolution = lowResUrl;
54
58
  }
@@ -57,5 +61,11 @@ class DocumentElementPropertyBindingHandler {
57
61
  this.bindPropertiesToElements(element.elements, localModel);
58
62
  }
59
63
  }
64
+ static isContentTypeWebViewable(contentType) {
65
+ if (!contentType) {
66
+ return false;
67
+ }
68
+ return (contentType === null || contentType === void 0 ? void 0 : contentType.indexOf('image')) > -1 && (contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase().indexOf('tiff')) < 0;
69
+ }
60
70
  }
61
71
  exports.DocumentElementPropertyBindingHandler = DocumentElementPropertyBindingHandler;
@@ -1,4 +1,5 @@
1
1
  export interface DocumentNavigationEvent {
2
- eventType: string;
3
- navigationType: string;
2
+ eventType?: string;
3
+ navigationType?: string;
4
+ data?: any;
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.0.89",
3
+ "version": "1.0.91",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",