@fluid-topics/ft-viewer 2.1.10
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 +19 -0
- package/build/asset/components/FtAssetViewerComponent.d.ts +5 -0
- package/build/asset/components/FtAssetViewerComponent.js +4 -0
- package/build/asset/components/ft-asset-viewer-content-control.d.ts +5 -0
- package/build/asset/components/ft-asset-viewer-content-control.js +4 -0
- package/build/asset/components/ft-asset-viewer-content.d.ts +5 -0
- package/build/asset/components/ft-asset-viewer-content.js +4 -0
- package/build/asset/components/ft-asset-viewer-document-title.d.ts +5 -0
- package/build/asset/components/ft-asset-viewer-document-title.js +4 -0
- package/build/asset/components/ft-asset-viewer-filename.d.ts +5 -0
- package/build/asset/components/ft-asset-viewer-filename.js +4 -0
- package/build/asset/components/ft-asset-viewer-mime-type-icon.d.ts +5 -0
- package/build/asset/components/ft-asset-viewer-mime-type-icon.js +4 -0
- package/build/asset/components/ft-asset-viewer-title.d.ts +5 -0
- package/build/asset/components/ft-asset-viewer-title.js +4 -0
- package/build/asset/components/registration.d.ts +12 -0
- package/build/asset/components/registration.js +40 -0
- package/build/asset/ft-asset-viewer-context.d.ts +16 -0
- package/build/asset/ft-asset-viewer-context.js +59 -0
- package/build/asset/ft-asset-viewer-context.properties.d.ts +2 -0
- package/build/asset/ft-asset-viewer-context.properties.js +1 -0
- package/build/asset/index.d.ts +10 -0
- package/build/asset/index.js +10 -0
- package/build/asset/model/FtAssetViewerService.d.ts +6 -0
- package/build/asset/model/FtAssetViewerService.js +12 -0
- package/build/asset/model/FtAssetViewerStateManager.d.ts +14 -0
- package/build/asset/model/FtAssetViewerStateManager.js +47 -0
- package/build/asset/model/ft-asset-viewer.models.d.ts +0 -0
- package/build/asset/model/ft-asset-viewer.models.js +1 -0
- package/build/common/FtViewerComponent.d.ts +5 -0
- package/build/common/FtViewerComponent.js +3 -0
- package/build/common/ft-viewer-content-control.d.ts +35 -0
- package/build/common/ft-viewer-content-control.js +164 -0
- package/build/common/ft-viewer-content.d.ts +51 -0
- package/build/common/ft-viewer-content.js +274 -0
- package/build/common/ft-viewer-display-name.d.ts +9 -0
- package/build/common/ft-viewer-display-name.js +31 -0
- package/build/common/ft-viewer-document-title.d.ts +9 -0
- package/build/common/ft-viewer-document-title.js +31 -0
- package/build/common/ft-viewer-filename.d.ts +9 -0
- package/build/common/ft-viewer-filename.js +31 -0
- package/build/common/ft-viewer-mime-type-icon.d.ts +9 -0
- package/build/common/ft-viewer-mime-type-icon.js +29 -0
- package/build/common/ft-viewer.messages.d.ts +11 -0
- package/build/common/ft-viewer.messages.js +10 -0
- package/build/common/index.d.ts +1 -0
- package/build/common/index.js +1 -0
- package/build/common/model/FtViewerReduxStore.d.ts +14 -0
- package/build/common/model/FtViewerReduxStore.js +25 -0
- package/build/common/model/FtViewerStateManager.d.ts +8 -0
- package/build/common/model/FtViewerStateManager.js +13 -0
- package/build/common/model/ft-viewer.models.d.ts +44 -0
- package/build/common/model/ft-viewer.models.js +23 -0
- package/build/define.d.ts +1 -0
- package/build/define.js +3 -0
- package/build/definitions.d.ts +19 -0
- package/build/definitions.js +18 -0
- package/build/ft-viewer.light.js +650 -0
- package/build/ft-viewer.min.js +773 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/build/ud/components/FtUdViewerComponent.d.ts +5 -0
- package/build/ud/components/FtUdViewerComponent.js +4 -0
- package/build/ud/components/ft-ud-viewer-attachments.d.ts +16 -0
- package/build/ud/components/ft-ud-viewer-attachments.js +55 -0
- package/build/ud/components/ft-ud-viewer-attachments.styles.d.ts +2 -0
- package/build/ud/components/ft-ud-viewer-attachments.styles.js +14 -0
- package/build/ud/components/ft-ud-viewer-content-control.d.ts +5 -0
- package/build/ud/components/ft-ud-viewer-content-control.js +4 -0
- package/build/ud/components/ft-ud-viewer-content.d.ts +5 -0
- package/build/ud/components/ft-ud-viewer-content.js +4 -0
- package/build/ud/components/ft-ud-viewer-filename.d.ts +5 -0
- package/build/ud/components/ft-ud-viewer-filename.js +4 -0
- package/build/ud/components/ft-ud-viewer-mime-type-icon.d.ts +5 -0
- package/build/ud/components/ft-ud-viewer-mime-type-icon.js +4 -0
- package/build/ud/components/ft-ud-viewer-title.d.ts +5 -0
- package/build/ud/components/ft-ud-viewer-title.js +4 -0
- package/build/ud/components/registration.d.ts +16 -0
- package/build/ud/components/registration.js +62 -0
- package/build/ud/ft-ud-viewer-context.d.ts +13 -0
- package/build/ud/ft-ud-viewer-context.js +53 -0
- package/build/ud/ft-ud-viewer-context.properties.d.ts +3 -0
- package/build/ud/ft-ud-viewer-context.properties.js +1 -0
- package/build/ud/ft-ud-viewer.messages.d.ts +6 -0
- package/build/ud/ft-ud-viewer.messages.js +5 -0
- package/build/ud/index.d.ts +10 -0
- package/build/ud/index.js +10 -0
- package/build/ud/model/FtUdViewerService.d.ts +12 -0
- package/build/ud/model/FtUdViewerService.js +24 -0
- package/build/ud/model/FtUdViewerStateManager.d.ts +13 -0
- package/build/ud/model/FtUdViewerStateManager.js +58 -0
- package/build/ud/model/ft-ud-viewer.models.d.ts +6 -0
- package/build/ud/model/ft-ud-viewer.models.js +8 -0
- package/package.json +34 -0
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
declare const FtUdViewerComponent_base: import("./registration").FtUdViewerComponentType<typeof FtLitElementRedux>;
|
|
3
|
+
export declare class FtUdViewerComponent extends FtUdViewerComponent_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
import { FtDocumentAttachment, FtUnstructuredDocument } from "@fluid-topics/public-api";
|
|
3
|
+
import { FtBaseAttachments } from "@fluid-topics/ft-reader-attachments";
|
|
4
|
+
declare const FtUdViewerAttachments_base: import("./registration").FtUdViewerComponentType<typeof FtBaseAttachments & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>>;
|
|
5
|
+
export declare class FtUdViewerAttachments extends FtUdViewerAttachments_base {
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
document?: FtUnstructuredDocument;
|
|
8
|
+
constructor();
|
|
9
|
+
protected update(props: PropertyValues): void;
|
|
10
|
+
private updateAttachments;
|
|
11
|
+
protected canRender(): boolean;
|
|
12
|
+
protected getAttachmentDownloadLink(attachment: FtDocumentAttachment): string;
|
|
13
|
+
protected getAttachmentDownloadLinkAriaLabel(attachment: FtDocumentAttachment): string;
|
|
14
|
+
protected getAttachmentViewerLink(attachment: FtDocumentAttachment): string | undefined;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { redux, reduxEventListener, } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
9
|
+
import { FtBaseAttachments, generateAttachmentsStyles, } from "@fluid-topics/ft-reader-attachments";
|
|
10
|
+
import { FtUdViewerAttachmentsCssVariables } from "./ft-ud-viewer-attachments.styles";
|
|
11
|
+
import { toFtUdViewerComponent } from "./registration";
|
|
12
|
+
import { defaultViewerMessages, udViewerContext, } from "../ft-ud-viewer.messages";
|
|
13
|
+
import { FtUdViewerStoreEvents } from "../model/ft-ud-viewer.models";
|
|
14
|
+
export class FtUdViewerAttachments extends toFtUdViewerComponent(withI18n(FtBaseAttachments)) {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.addI18nContext(udViewerContext, defaultViewerMessages);
|
|
18
|
+
}
|
|
19
|
+
update(props) {
|
|
20
|
+
super.update(props);
|
|
21
|
+
if (props.has("document")) {
|
|
22
|
+
this.updateAttachments();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
updateAttachments() {
|
|
26
|
+
var _a;
|
|
27
|
+
if (this.document) {
|
|
28
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.getAttachments(this.document.id).then((attachments) => this.attachments = attachments);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.attachments = undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
canRender() {
|
|
35
|
+
return !!this.document && super.canRender();
|
|
36
|
+
}
|
|
37
|
+
getAttachmentDownloadLink(attachment) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getAttachmentDownloadLink(this.document.id, attachment.id)) !== null && _b !== void 0 ? _b : "";
|
|
40
|
+
}
|
|
41
|
+
getAttachmentDownloadLinkAriaLabel(attachment) {
|
|
42
|
+
return udViewerContext.messages.download(this.getAttachmentAriaLabel(attachment));
|
|
43
|
+
}
|
|
44
|
+
getAttachmentViewerLink(attachment) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.makeAbsolute((_b = attachment.viewerUrl) !== null && _b !== void 0 ? _b : "");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
FtUdViewerAttachments.styles = generateAttachmentsStyles(FtUdViewerAttachmentsCssVariables);
|
|
50
|
+
__decorate([
|
|
51
|
+
redux({ store: "viewer" })
|
|
52
|
+
], FtUdViewerAttachments.prototype, "document", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
reduxEventListener({ eventName: FtUdViewerStoreEvents.udAttachmentsUpdate })
|
|
55
|
+
], FtUdViewerAttachments.prototype, "updateAttachments", null);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { designSystemVariables, FtCssVariableFactory, } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
export const FtUdViewerAttachmentsCssVariables = {
|
|
3
|
+
itemsGap: FtCssVariableFactory.create("--ft-ud-viewer-attachments-items-gap", "", "SIZE", "8px"),
|
|
4
|
+
itemPadding: FtCssVariableFactory.create("--ft-ud-viewer-attachments-item-padding", "", "SIZE", "8px"),
|
|
5
|
+
itemBorderWidth: FtCssVariableFactory.create("--ft-ud-viewer-attachments-item-border-width", "", "SIZE", "1px"),
|
|
6
|
+
itemBorderColor: FtCssVariableFactory.extend("--ft-ud-viewer-attachments-item-border-color", "", designSystemVariables.colorOutline),
|
|
7
|
+
itemBorderRadius: FtCssVariableFactory.extend("--ft-ud-viewer-attachments-item-border-radius", "", designSystemVariables.borderRadiusS),
|
|
8
|
+
itemBackgroundColor: FtCssVariableFactory.extend("--ft-ud-viewer-attachments-item-background-color", "", designSystemVariables.colorSurface),
|
|
9
|
+
itemTextColor: FtCssVariableFactory.extend("--ft-ud-viewer-attachments-item-text-color", "", designSystemVariables.colorOnSurfaceMedium),
|
|
10
|
+
itemHoverBackgroundColor: FtCssVariableFactory.extend("--ft-ud-viewer-attachments-item-hover-background-color", "", designSystemVariables.colorPrimary),
|
|
11
|
+
itemHoverTextColor: FtCssVariableFactory.extend("--ft-ud-viewer-attachments-item-hover-text-color", "", designSystemVariables.colorOnSurfaceHigh),
|
|
12
|
+
fileFormatIconSize: FtCssVariableFactory.create("--ft-ud-viewer-attachments-file-format-icon-size", "", "SIZE", "30px"),
|
|
13
|
+
downloadIconSize: FtCssVariableFactory.create("--ft-ud-viewer-attachments-down-icon-size", "", "SIZE", "20px"),
|
|
14
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerContentControl } from "../../common/ft-viewer-content-control";
|
|
2
|
+
declare const FtUdViewerContentControl_base: import("./registration").FtUdViewerComponentType<typeof FtViewerContentControl>;
|
|
3
|
+
export declare class FtUdViewerContentControl extends FtUdViewerContentControl_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerFilename } from "../../common/ft-viewer-filename";
|
|
2
|
+
declare const FtUdViewerFilename_base: import("./registration").FtUdViewerComponentType<typeof FtViewerFilename>;
|
|
3
|
+
export declare class FtUdViewerFilename extends FtUdViewerFilename_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerMimeTypeIcon } from "../../common/ft-viewer-mime-type-icon";
|
|
2
|
+
declare const FtUdViewerMimeTypeIcon_base: import("./registration").FtUdViewerComponentType<typeof FtViewerMimeTypeIcon>;
|
|
3
|
+
export declare class FtUdViewerMimeTypeIcon extends FtUdViewerMimeTypeIcon_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerDocumentTitle } from "../../common/ft-viewer-document-title";
|
|
2
|
+
declare const FtUdViewerTitle_base: import("./registration").FtUdViewerComponentType<typeof FtViewerDocumentTitle>;
|
|
3
|
+
export declare class FtUdViewerTitle extends FtUdViewerTitle_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Constructor, FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import type { FtUdViewerStateManager as FtUdViewerStateManagerInternal } from "../model/FtUdViewerStateManager";
|
|
3
|
+
import { FtUdViewerResourceRequests } from "../model/ft-ud-viewer.models";
|
|
4
|
+
import { FtViewerComponent } from "../../common/FtViewerComponent";
|
|
5
|
+
import { FtUdViewerService } from "../model/FtUdViewerService";
|
|
6
|
+
export type FtUdViewerStateManager = FtUdViewerStateManagerInternal;
|
|
7
|
+
export declare const udViewerStateManagerContext: {
|
|
8
|
+
__context__: FtUdViewerStateManagerInternal;
|
|
9
|
+
};
|
|
10
|
+
export interface FtUdViewerComponentInterface extends FtViewerComponent {
|
|
11
|
+
viewerStateManager?: FtUdViewerStateManager;
|
|
12
|
+
neededUdvRequests: FtUdViewerResourceRequests[];
|
|
13
|
+
service?: FtUdViewerService;
|
|
14
|
+
}
|
|
15
|
+
export type FtUdViewerComponentType<T extends Constructor<FtLitElementRedux>> = T & Constructor<FtUdViewerComponentInterface>;
|
|
16
|
+
export declare const toFtUdViewerComponent: <T extends Constructor<FtLitElementRedux>>(c: T) => FtUdViewerComponentType<T>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { applyMixinOnce, hasChanged, } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { state } from "lit/decorators.js";
|
|
9
|
+
import { consume, createContext, } from "@lit/context";
|
|
10
|
+
export const udViewerStateManagerContext = createContext(Symbol("ud-viewer-state-manager"));
|
|
11
|
+
export const toFtUdViewerComponent = applyMixinOnce(Symbol("toFtUdViewerComponent"), function (ReduxClass) {
|
|
12
|
+
class FtUdViewerComponentClass extends ReduxClass {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.neededUdvRequests = [];
|
|
16
|
+
}
|
|
17
|
+
get service() {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.service;
|
|
20
|
+
}
|
|
21
|
+
willUpdate(props) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
super.willUpdate(props);
|
|
24
|
+
if (props.has("viewerStateManager")) {
|
|
25
|
+
this.unregisterFromUdvStateManager(props.get("viewerStateManager"));
|
|
26
|
+
this.registerToUdvStateManager(this.viewerStateManager);
|
|
27
|
+
}
|
|
28
|
+
if (props.has("neededUdvRequests")) {
|
|
29
|
+
(_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.unregisterComponent(this, (_b = props.get("neededUdvRequests")) !== null && _b !== void 0 ? _b : []);
|
|
30
|
+
(_c = this.viewerStateManager) === null || _c === void 0 ? void 0 : _c.registerComponent(this, this.neededUdvRequests);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
registerToUdvStateManager(stateManager) {
|
|
34
|
+
if (stateManager) {
|
|
35
|
+
stateManager.registerComponent(this, this.neededUdvRequests);
|
|
36
|
+
this.addStore(stateManager.store, "viewer");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
unregisterFromUdvStateManager(stateManager) {
|
|
40
|
+
if (stateManager) {
|
|
41
|
+
stateManager.unregisterComponent(this, this.neededUdvRequests);
|
|
42
|
+
this.removeStore("viewer");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
super.connectedCallback();
|
|
47
|
+
this.registerToUdvStateManager(this.viewerStateManager);
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback();
|
|
51
|
+
this.unregisterFromUdvStateManager(this.viewerStateManager);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
__decorate([
|
|
55
|
+
consume({ context: udViewerStateManagerContext, subscribe: true }),
|
|
56
|
+
state()
|
|
57
|
+
], FtUdViewerComponentClass.prototype, "viewerStateManager", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
state({ hasChanged })
|
|
60
|
+
], FtUdViewerComponentClass.prototype, "neededUdvRequests", void 0);
|
|
61
|
+
return FtUdViewerComponentClass;
|
|
62
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
import { FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtUdViewerContextProperties } from "./ft-ud-viewer-context.properties";
|
|
4
|
+
import { FtUdViewerStateManager } from "./model/FtUdViewerStateManager";
|
|
5
|
+
export declare class FtUdViewerContext extends FtLitElementRedux implements FtUdViewerContextProperties {
|
|
6
|
+
documentId?: string;
|
|
7
|
+
viewerStateManager: FtUdViewerStateManager;
|
|
8
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
9
|
+
protected willUpdate(props: PropertyValues<FtUdViewerContext>): void;
|
|
10
|
+
private initStateManager;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
onAuthenticationChange(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import { provide } from "@lit/context";
|
|
10
|
+
import { FtLitElementRedux, randomId, reduxEventListener, } from "@fluid-topics/ft-wc-utils";
|
|
11
|
+
import { FtUdViewerStateManager } from "./model/FtUdViewerStateManager";
|
|
12
|
+
import { udViewerStateManagerContext } from "./components/registration";
|
|
13
|
+
import { AuthenticationChangeEvent, ftAppInfoStore, } from "@fluid-topics/ft-app-context";
|
|
14
|
+
import { FtViewerLoadedEvent } from "../common";
|
|
15
|
+
export class FtUdViewerContext extends FtLitElementRedux {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.viewerStateManager = FtUdViewerStateManager.build(this.id || randomId(6));
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `
|
|
22
|
+
<slot></slot>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
willUpdate(props) {
|
|
26
|
+
super.willUpdate(props);
|
|
27
|
+
if (props.has("documentId")) {
|
|
28
|
+
this.initStateManager();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async initStateManager() {
|
|
32
|
+
const state = await this.viewerStateManager.setDocumentId(this.documentId);
|
|
33
|
+
if (this.documentId) {
|
|
34
|
+
this.dispatchEvent(new FtViewerLoadedEvent(state));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
this.addStore(ftAppInfoStore);
|
|
40
|
+
}
|
|
41
|
+
onAuthenticationChange() {
|
|
42
|
+
this.viewerStateManager.reload();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
__decorate([
|
|
46
|
+
property()
|
|
47
|
+
], FtUdViewerContext.prototype, "documentId", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
provide({ context: udViewerStateManagerContext })
|
|
50
|
+
], FtUdViewerContext.prototype, "viewerStateManager", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
reduxEventListener({ eventName: AuthenticationChangeEvent.eventName })
|
|
53
|
+
], FtUdViewerContext.prototype, "onAuthenticationChange", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export interface FtUdViewerMessages extends I18nMessages {
|
|
3
|
+
download(label: string): string;
|
|
4
|
+
}
|
|
5
|
+
export declare const udViewerContext: I18nMessageContext<FtUdViewerMessages>;
|
|
6
|
+
export declare const defaultViewerMessages: DefaultI18nMessages<FtUdViewerMessages>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./ft-ud-viewer-context.properties";
|
|
2
|
+
export * from "./ft-ud-viewer-context";
|
|
3
|
+
export * from "./model/ft-ud-viewer.models";
|
|
4
|
+
export * from "./components/registration";
|
|
5
|
+
export * from "./components/ft-ud-viewer-content";
|
|
6
|
+
export * from "./components/ft-ud-viewer-content-control";
|
|
7
|
+
export * from "./components/ft-ud-viewer-filename";
|
|
8
|
+
export * from "./components/ft-ud-viewer-title";
|
|
9
|
+
export * from "./components/ft-ud-viewer-mime-type-icon";
|
|
10
|
+
export * from "./components/ft-ud-viewer-attachments";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./ft-ud-viewer-context.properties";
|
|
2
|
+
export * from "./ft-ud-viewer-context";
|
|
3
|
+
export * from "./model/ft-ud-viewer.models";
|
|
4
|
+
export * from "./components/registration";
|
|
5
|
+
export * from "./components/ft-ud-viewer-content";
|
|
6
|
+
export * from "./components/ft-ud-viewer-content-control";
|
|
7
|
+
export * from "./components/ft-ud-viewer-filename";
|
|
8
|
+
export * from "./components/ft-ud-viewer-title";
|
|
9
|
+
export * from "./components/ft-ud-viewer-mime-type-icon";
|
|
10
|
+
export * from "./components/ft-ud-viewer-attachments";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
|
+
import { FtPublicationRatingSummary, FtRatingType } from "@fluid-topics/public-api";
|
|
3
|
+
export declare class FtUdViewerService extends FtServiceWithCache {
|
|
4
|
+
getDocument(documentId: string): Promise<import("@fluid-topics/public-api").FtUnstructuredDocument>;
|
|
5
|
+
getAttachments(documentId: string): Promise<import("@fluid-topics/public-api").FtDocumentAttachment[]>;
|
|
6
|
+
getAttachmentDownloadLink(documentId: string, id: string): string;
|
|
7
|
+
makeAbsolute(endpoint: string): string;
|
|
8
|
+
getDocumentRating(documentId: string): Promise<FtPublicationRatingSummary | undefined>;
|
|
9
|
+
rateDocument(documentId: string, type: FtRatingType, value: number): Promise<void>;
|
|
10
|
+
unrateDocument(documentId: string): Promise<void>;
|
|
11
|
+
sendDocumentFeedback(documentId: string, message: string): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
|
+
export class FtUdViewerService extends FtServiceWithCache {
|
|
3
|
+
getDocument(documentId) {
|
|
4
|
+
return this.cache.get(documentId, () => this.api.getUnstructuredDocument(documentId));
|
|
5
|
+
}
|
|
6
|
+
getAttachments(documentId) {
|
|
7
|
+
return this.cache.get(`${documentId}-attachments`, () => this.api.getUdAttachments(documentId));
|
|
8
|
+
}
|
|
9
|
+
getAttachmentDownloadLink(documentId, id) {
|
|
10
|
+
return this.makeAbsolute(`${this.api.endpoints.khub.documents.documentId(documentId).attachments.attachmentId(id).content}?download=true&locationValue=viewer`);
|
|
11
|
+
}
|
|
12
|
+
makeAbsolute(endpoint) {
|
|
13
|
+
return this.api.makeAbsolute(endpoint);
|
|
14
|
+
}
|
|
15
|
+
async getDocumentRating(documentId) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
async rateDocument(documentId, type, value) {
|
|
19
|
+
}
|
|
20
|
+
async unrateDocument(documentId) {
|
|
21
|
+
}
|
|
22
|
+
async sendDocumentFeedback(documentId, message) {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FtViewerReduxStore } from "../../common/model/FtViewerReduxStore";
|
|
2
|
+
import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
|
|
3
|
+
import { FtUdViewerService } from "./FtUdViewerService";
|
|
4
|
+
export declare class FtUdViewerStateManager extends FtViewerStateManager {
|
|
5
|
+
store: FtViewerReduxStore;
|
|
6
|
+
service: FtUdViewerService;
|
|
7
|
+
static build(viewerId: string): FtUdViewerStateManager;
|
|
8
|
+
constructor(store: FtViewerReduxStore, service: FtUdViewerService);
|
|
9
|
+
load(): Promise<import("../..").FtViewerState>;
|
|
10
|
+
clear(): void;
|
|
11
|
+
reload(): Promise<import("../..").FtViewerState>;
|
|
12
|
+
setDocumentId(documentId: string | undefined): Promise<import("../..").FtViewerState>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FtViewerFileOrigin } from "../../common/model/ft-viewer.models";
|
|
2
|
+
import { createViewerStore, } from "../../common/model/FtViewerReduxStore";
|
|
3
|
+
import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
|
|
4
|
+
import { FtUdViewerService } from "./FtUdViewerService";
|
|
5
|
+
import { FtAssetHolderType } from "@fluid-topics/public-api";
|
|
6
|
+
import { FluidTopicsApiProvider } from "@fluid-topics/ft-app-context";
|
|
7
|
+
export class FtUdViewerStateManager extends FtViewerStateManager {
|
|
8
|
+
static build(viewerId) {
|
|
9
|
+
return new FtUdViewerStateManager(createViewerStore(viewerId), new FtUdViewerService());
|
|
10
|
+
}
|
|
11
|
+
constructor(store, service) {
|
|
12
|
+
super(store);
|
|
13
|
+
this.store = store;
|
|
14
|
+
this.service = service;
|
|
15
|
+
store.actions.origin(FtViewerFileOrigin.UNSTRUCTURED_DOCUMENT);
|
|
16
|
+
}
|
|
17
|
+
async load() {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const { documentId } = this.store.getState();
|
|
20
|
+
if (documentId) {
|
|
21
|
+
const document = await this.service.getDocument(documentId);
|
|
22
|
+
this.store.actions.document({
|
|
23
|
+
type: FtAssetHolderType.UNSTRUCTURED_DOCUMENT,
|
|
24
|
+
id: document.id,
|
|
25
|
+
lang: (_a = document.lang) !== null && _a !== void 0 ? _a : "en-US",
|
|
26
|
+
title: document.title,
|
|
27
|
+
metadata: document.metadata,
|
|
28
|
+
portalUrl: document.viewerUrl,
|
|
29
|
+
});
|
|
30
|
+
const api = await FluidTopicsApiProvider.await();
|
|
31
|
+
this.store.actions.descriptor({
|
|
32
|
+
id: document.id,
|
|
33
|
+
portalUrl: document.viewerUrl,
|
|
34
|
+
filename: document.filename,
|
|
35
|
+
fingerprint: document.lastEdition,
|
|
36
|
+
displayName: document.title,
|
|
37
|
+
alt: (_b = document.description) !== null && _b !== void 0 ? _b : document.title,
|
|
38
|
+
mimeType: document.mimeType,
|
|
39
|
+
size: 0,
|
|
40
|
+
viewableInCurrentBrowser: document.viewableInCurrentBrowser,
|
|
41
|
+
contentUrl: api.makeAbsolute(document.contentApiEndpoint),
|
|
42
|
+
});
|
|
43
|
+
this.store.actions.watermark(document.watermark);
|
|
44
|
+
}
|
|
45
|
+
return this.store.getState();
|
|
46
|
+
}
|
|
47
|
+
clear() {
|
|
48
|
+
this.store.clearKeeping("documentId", "origin");
|
|
49
|
+
}
|
|
50
|
+
reload() {
|
|
51
|
+
this.clear();
|
|
52
|
+
return this.load();
|
|
53
|
+
}
|
|
54
|
+
setDocumentId(documentId) {
|
|
55
|
+
this.store.actions.documentId(documentId);
|
|
56
|
+
return this.reload();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var FtUdViewerResourceRequests;
|
|
2
|
+
(function (FtUdViewerResourceRequests) {
|
|
3
|
+
FtUdViewerResourceRequests["RATING"] = "RATING";
|
|
4
|
+
})(FtUdViewerResourceRequests || (FtUdViewerResourceRequests = {}));
|
|
5
|
+
export var FtUdViewerStoreEvents;
|
|
6
|
+
(function (FtUdViewerStoreEvents) {
|
|
7
|
+
FtUdViewerStoreEvents["udAttachmentsUpdate"] = "ud-attachments-update";
|
|
8
|
+
})(FtUdViewerStoreEvents || (FtUdViewerStoreEvents = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluid-topics/ft-viewer",
|
|
3
|
+
"version": "2.1.10",
|
|
4
|
+
"description": "File viewer components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Lit"
|
|
7
|
+
],
|
|
8
|
+
"author": "Fluid Topics <devtopics@antidot.net>",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"main": "build/index.js",
|
|
11
|
+
"web": "build/ft-viewer.min.js",
|
|
12
|
+
"typings": "build/index",
|
|
13
|
+
"files": [
|
|
14
|
+
"build/**/*.js",
|
|
15
|
+
"build/**/*.ts"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@fluid-topics/ft-content-watermark": "2.1.10",
|
|
23
|
+
"@fluid-topics/ft-i18n": "2.1.10",
|
|
24
|
+
"@fluid-topics/ft-reader-attachments": "2.1.10",
|
|
25
|
+
"@fluid-topics/ft-wc-utils": "2.1.10",
|
|
26
|
+
"@fluid-topics/public-api": "1.0.129",
|
|
27
|
+
"@lit/context": "1.1.6",
|
|
28
|
+
"lit": "3.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@fluid-topics/ft-wc-test-utils": "2.1.10"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "2e92a83b868bd3944d7f807c6d232e06c63d12fa"
|
|
34
|
+
}
|