@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/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
File viewer components
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ft-viewer
|
|
7
|
+
yarn add @fluid-topics/ft-viewer
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ft-viewer"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ft-viewer foo="bar"></ft-viewer> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
declare const FtAssetViewerComponent_base: import("./registration").FtAssetViewerComponentType<typeof FtLitElementRedux>;
|
|
3
|
+
export declare class FtAssetViewerComponent extends FtAssetViewerComponent_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerContentControl } from "../../common/ft-viewer-content-control";
|
|
2
|
+
declare const FtAssetViewerContentControl_base: import("./registration").FtAssetViewerComponentType<typeof FtViewerContentControl>;
|
|
3
|
+
export declare class FtAssetViewerContentControl extends FtAssetViewerContentControl_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerContent } from "../../common/ft-viewer-content";
|
|
2
|
+
declare const FtAssetViewerContent_base: import("./registration").FtAssetViewerComponentType<typeof FtViewerContent>;
|
|
3
|
+
export declare class FtAssetViewerContent extends FtAssetViewerContent_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerDocumentTitle } from "../../common/ft-viewer-document-title";
|
|
2
|
+
declare const FtAssetViewerDocumentTitle_base: import("./registration").FtAssetViewerComponentType<typeof FtViewerDocumentTitle>;
|
|
3
|
+
export declare class FtAssetViewerDocumentTitle extends FtAssetViewerDocumentTitle_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerFilename } from "../../common/ft-viewer-filename";
|
|
2
|
+
declare const FtAssetViewerFilename_base: import("./registration").FtAssetViewerComponentType<typeof FtViewerFilename>;
|
|
3
|
+
export declare class FtAssetViewerFilename extends FtAssetViewerFilename_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerMimeTypeIcon } from "../../common/ft-viewer-mime-type-icon";
|
|
2
|
+
declare const FtAssetViewerMimeTypeIcon_base: import("./registration").FtAssetViewerComponentType<typeof FtViewerMimeTypeIcon>;
|
|
3
|
+
export declare class FtAssetViewerMimeTypeIcon extends FtAssetViewerMimeTypeIcon_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FtViewerDisplayName } from "../../common/ft-viewer-display-name";
|
|
2
|
+
declare const FtAssetViewerTitle_base: import("./registration").FtAssetViewerComponentType<typeof FtViewerDisplayName>;
|
|
3
|
+
export declare class FtAssetViewerTitle extends FtAssetViewerTitle_base {
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Constructor, FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtViewerComponent } from "../../common/FtViewerComponent";
|
|
3
|
+
import type { FtAssetViewerStateManager as FtAssetViewerStateManagerInternal } from "../model/FtAssetViewerStateManager";
|
|
4
|
+
export type FtAssetViewerStateManager = FtAssetViewerStateManagerInternal;
|
|
5
|
+
export declare const assetViewerStateManagerContext: {
|
|
6
|
+
__context__: FtAssetViewerStateManagerInternal;
|
|
7
|
+
};
|
|
8
|
+
export interface FtAssetViewerComponentInterface extends FtViewerComponent {
|
|
9
|
+
viewerStateManager?: FtAssetViewerStateManager;
|
|
10
|
+
}
|
|
11
|
+
export type FtAssetViewerComponentType<T extends Constructor<FtLitElementRedux>> = T & Constructor<FtAssetViewerComponentInterface>;
|
|
12
|
+
export declare const toFtAssetViewerComponent: <T extends Constructor<FtLitElementRedux>>(c: T) => FtAssetViewerComponentType<T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
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, } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { state } from "lit/decorators.js";
|
|
9
|
+
import { consume, createContext, } from "@lit/context";
|
|
10
|
+
export const assetViewerStateManagerContext = createContext(Symbol("asset-viewer-state-manager"));
|
|
11
|
+
export const toFtAssetViewerComponent = applyMixinOnce(Symbol("toFtAssetViewerComponent"), function (ReduxClass) {
|
|
12
|
+
class FtAssetViewerComponentClass extends ReduxClass {
|
|
13
|
+
willUpdate(props) {
|
|
14
|
+
super.willUpdate(props);
|
|
15
|
+
if (props.has("viewerStateManager")) {
|
|
16
|
+
if (this.viewerStateManager) {
|
|
17
|
+
this.addStore(this.viewerStateManager.store, "viewer");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.removeStore("viewer");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
if (this.viewerStateManager) {
|
|
27
|
+
this.addStore(this.viewerStateManager.store, "viewer");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
disconnectedCallback() {
|
|
31
|
+
super.disconnectedCallback();
|
|
32
|
+
this.removeStore("viewer");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
consume({ context: assetViewerStateManagerContext, subscribe: true }),
|
|
37
|
+
state()
|
|
38
|
+
], FtAssetViewerComponentClass.prototype, "viewerStateManager", void 0);
|
|
39
|
+
return FtAssetViewerComponentClass;
|
|
40
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
import { FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtAssetViewerContextProperties } from "./ft-asset-viewer-context.properties";
|
|
4
|
+
import { FtAssetViewerStateManager } from "./model/FtAssetViewerStateManager";
|
|
5
|
+
import { FtViewerFileOrigin } from "../common";
|
|
6
|
+
export declare class FtAssetViewerContext extends FtLitElementRedux implements FtAssetViewerContextProperties {
|
|
7
|
+
documentId?: string;
|
|
8
|
+
assetId?: string;
|
|
9
|
+
origin?: FtViewerFileOrigin;
|
|
10
|
+
viewerStateManager: FtAssetViewerStateManager;
|
|
11
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
protected willUpdate(props: PropertyValues<FtAssetViewerContext>): void;
|
|
13
|
+
private initStateManager;
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
onAuthenticationChange(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { FtLitElementRedux, randomId, reduxEventListener, } from "@fluid-topics/ft-wc-utils";
|
|
9
|
+
import { provide } from "@lit/context";
|
|
10
|
+
import { assetViewerStateManagerContext } from "./components/registration";
|
|
11
|
+
import { FtAssetViewerStateManager } from "./model/FtAssetViewerStateManager";
|
|
12
|
+
import { property } from "lit/decorators.js";
|
|
13
|
+
import { FtViewerLoadedEvent } from "../common";
|
|
14
|
+
import { AuthenticationChangeEvent, ftAppInfoStore, } from "@fluid-topics/ft-app-context";
|
|
15
|
+
export class FtAssetViewerContext extends FtLitElementRedux {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.viewerStateManager = FtAssetViewerStateManager.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") || props.has("assetId") || props.has("origin")) {
|
|
28
|
+
this.initStateManager();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async initStateManager() {
|
|
32
|
+
const state = await this.viewerStateManager.init(this.documentId, this.assetId, this.origin);
|
|
33
|
+
if (this.documentId && this.assetId && this.origin) {
|
|
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
|
+
], FtAssetViewerContext.prototype, "documentId", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property()
|
|
50
|
+
], FtAssetViewerContext.prototype, "assetId", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property()
|
|
53
|
+
], FtAssetViewerContext.prototype, "origin", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
provide({ context: assetViewerStateManagerContext })
|
|
56
|
+
], FtAssetViewerContext.prototype, "viewerStateManager", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
reduxEventListener({ eventName: AuthenticationChangeEvent.eventName })
|
|
59
|
+
], FtAssetViewerContext.prototype, "onAuthenticationChange", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./components/registration";
|
|
2
|
+
export * from "./ft-asset-viewer-context.properties";
|
|
3
|
+
export * from "./ft-asset-viewer-context";
|
|
4
|
+
export * from "./components/registration";
|
|
5
|
+
export * from "./components/ft-asset-viewer-content";
|
|
6
|
+
export * from "./components/ft-asset-viewer-content-control";
|
|
7
|
+
export * from "./components/ft-asset-viewer-filename";
|
|
8
|
+
export * from "./components/ft-asset-viewer-title";
|
|
9
|
+
export * from "./components/ft-asset-viewer-mime-type-icon";
|
|
10
|
+
export * from "./components/ft-asset-viewer-document-title";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./components/registration";
|
|
2
|
+
export * from "./ft-asset-viewer-context.properties";
|
|
3
|
+
export * from "./ft-asset-viewer-context";
|
|
4
|
+
export * from "./components/registration";
|
|
5
|
+
export * from "./components/ft-asset-viewer-content";
|
|
6
|
+
export * from "./components/ft-asset-viewer-content-control";
|
|
7
|
+
export * from "./components/ft-asset-viewer-filename";
|
|
8
|
+
export * from "./components/ft-asset-viewer-title";
|
|
9
|
+
export * from "./components/ft-asset-viewer-mime-type-icon";
|
|
10
|
+
export * from "./components/ft-asset-viewer-document-title";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
|
+
import { FtViewerFileOrigin } from "../../common";
|
|
3
|
+
import { FtAssetDescriptor } from "@fluid-topics/public-api";
|
|
4
|
+
export declare class FtAssetViewerService extends FtServiceWithCache {
|
|
5
|
+
getAsset(mapId: string, assetId: string, origin: FtViewerFileOrigin): Promise<FtAssetDescriptor>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FtServiceWithCache } from "@fluid-topics/ft-app-context";
|
|
2
|
+
import { FtViewerFileOrigin } from "../../common";
|
|
3
|
+
export class FtAssetViewerService extends FtServiceWithCache {
|
|
4
|
+
getAsset(mapId, assetId, origin) {
|
|
5
|
+
const loaders = {
|
|
6
|
+
[FtViewerFileOrigin.MAP_ATTACHMENT]: () => this.api.getMapAttachment(mapId, assetId),
|
|
7
|
+
[FtViewerFileOrigin.UD_ATTACHMENT]: () => this.api.getUdAttachment(mapId, assetId),
|
|
8
|
+
[FtViewerFileOrigin.RESOURCE]: () => this.api.getMapResource(mapId, assetId),
|
|
9
|
+
};
|
|
10
|
+
return this.cache.get(assetId, loaders[origin]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FtViewerReduxStore } from "../../common/model/FtViewerReduxStore";
|
|
2
|
+
import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
|
|
3
|
+
import { FtViewerFileOrigin } from "../../common";
|
|
4
|
+
import { FtAssetViewerService } from "./FtAssetViewerService";
|
|
5
|
+
export declare class FtAssetViewerStateManager extends FtViewerStateManager {
|
|
6
|
+
store: FtViewerReduxStore;
|
|
7
|
+
service: FtAssetViewerService;
|
|
8
|
+
static build(viewerId: string): FtAssetViewerStateManager;
|
|
9
|
+
constructor(store: FtViewerReduxStore, service: FtAssetViewerService);
|
|
10
|
+
load(): Promise<void>;
|
|
11
|
+
clear(): void;
|
|
12
|
+
reload(): Promise<void>;
|
|
13
|
+
init(documentId: string | undefined, assetId: string | undefined, origin: FtViewerFileOrigin | undefined): Promise<import("../..").FtViewerState>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createViewerStore, } from "../../common/model/FtViewerReduxStore";
|
|
2
|
+
import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
|
|
3
|
+
import { FtAssetViewerService } from "./FtAssetViewerService";
|
|
4
|
+
export class FtAssetViewerStateManager extends FtViewerStateManager {
|
|
5
|
+
static build(viewerId) {
|
|
6
|
+
return new FtAssetViewerStateManager(createViewerStore(viewerId), new FtAssetViewerService());
|
|
7
|
+
}
|
|
8
|
+
constructor(store, service) {
|
|
9
|
+
super(store);
|
|
10
|
+
this.store = store;
|
|
11
|
+
this.service = service;
|
|
12
|
+
}
|
|
13
|
+
async load() {
|
|
14
|
+
const { documentId, assetId, origin } = this.store.getState();
|
|
15
|
+
if (documentId && assetId && origin) {
|
|
16
|
+
const asset = await this.service.getAsset(documentId, assetId, origin);
|
|
17
|
+
this.store.actions.document(asset.holder);
|
|
18
|
+
this.store.actions.descriptor({
|
|
19
|
+
id: asset.id,
|
|
20
|
+
portalUrl: asset.portalUrl,
|
|
21
|
+
filename: asset.filename,
|
|
22
|
+
fingerprint: asset.fingerprint,
|
|
23
|
+
displayName: asset.displayName,
|
|
24
|
+
alt: asset.displayName,
|
|
25
|
+
mimeType: asset.mimeType,
|
|
26
|
+
size: asset.size,
|
|
27
|
+
viewableInCurrentBrowser: asset.viewableInCurrentBrowser,
|
|
28
|
+
contentUrl: asset.contentUrl,
|
|
29
|
+
});
|
|
30
|
+
this.store.actions.watermark(asset.watermark);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
clear() {
|
|
34
|
+
this.store.clearKeeping("documentId", "assetId", "origin");
|
|
35
|
+
}
|
|
36
|
+
reload() {
|
|
37
|
+
this.clear();
|
|
38
|
+
return this.load();
|
|
39
|
+
}
|
|
40
|
+
async init(documentId, assetId, origin) {
|
|
41
|
+
this.store.actions.documentId(documentId);
|
|
42
|
+
this.store.actions.assetId(assetId);
|
|
43
|
+
this.store.actions.origin(origin);
|
|
44
|
+
await this.reload();
|
|
45
|
+
return this.store.getState();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FtViewerComponent } from "./FtViewerComponent";
|
|
2
|
+
import { FtFileDescriptor, FtViewerContentControls } from "./model/ft-viewer.models";
|
|
3
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
4
|
+
import { nothing, PropertyValues } from "lit";
|
|
5
|
+
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
6
|
+
import { FtTooltip } from "@fluid-topics/ft-tooltip";
|
|
7
|
+
type ControlDefintion = {
|
|
8
|
+
ariaLabel: () => string;
|
|
9
|
+
icon: FtIcons;
|
|
10
|
+
disabled?: () => boolean;
|
|
11
|
+
run: () => void;
|
|
12
|
+
};
|
|
13
|
+
declare const FtViewerContentControl_base: typeof FtViewerComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtLitElementWithConditionalVisibilityInterface>;
|
|
14
|
+
export declare class FtViewerContentControl extends FtViewerContentControl_base {
|
|
15
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
tabindex: number | null;
|
|
18
|
+
role: string | null;
|
|
19
|
+
ariaLabel: string | null;
|
|
20
|
+
control: FtViewerContentControls;
|
|
21
|
+
descriptor?: FtFileDescriptor;
|
|
22
|
+
zoom: number | undefined;
|
|
23
|
+
rotation: number;
|
|
24
|
+
protected controlDefinitions: Record<FtViewerContentControls, ControlDefintion>;
|
|
25
|
+
static styles: import("lit").CSSResult;
|
|
26
|
+
protected render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
27
|
+
protected willUpdate(props: PropertyValues): void;
|
|
28
|
+
onI18nUpdate(context: string): void;
|
|
29
|
+
private updateAriaLabel;
|
|
30
|
+
tooltip?: FtTooltip;
|
|
31
|
+
connectedCallback(): void;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
private modifyContent;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
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 { FtViewerComponent } from "./FtViewerComponent";
|
|
8
|
+
import { property, query, } from "lit/decorators.js";
|
|
9
|
+
import { FtViewerContentControls, } from "./model/ft-viewer.models";
|
|
10
|
+
import { designSystemVariables, redux, withConditionalVisibility, } from "@fluid-topics/ft-wc-utils";
|
|
11
|
+
import { css, html, nothing, } from "lit";
|
|
12
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
13
|
+
import { FtIcon, FtIcons, } from "@fluid-topics/ft-icon";
|
|
14
|
+
import { FtTooltip } from "@fluid-topics/ft-tooltip";
|
|
15
|
+
import { defaultViewerMessages, viewerContext, } from "./ft-viewer.messages";
|
|
16
|
+
export class FtViewerContentControl extends withConditionalVisibility(withI18n(FtViewerComponent)) {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.disabled = false;
|
|
20
|
+
this.tabindex = 0;
|
|
21
|
+
this.role = "button";
|
|
22
|
+
this.ariaLabel = "";
|
|
23
|
+
this.control = FtViewerContentControls.FIT_TO_CONTAINER;
|
|
24
|
+
this.controlDefinitions = {
|
|
25
|
+
[FtViewerContentControls.FIT_TO_CONTAINER]: {
|
|
26
|
+
ariaLabel: () => viewerContext.messages.fitToContainerAriaLabel(),
|
|
27
|
+
icon: FtIcons.ZOOM_FULLSCREEN,
|
|
28
|
+
run: () => { var _a; return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(undefined); },
|
|
29
|
+
},
|
|
30
|
+
[FtViewerContentControls.ZOOM_REAL_SIZE]: {
|
|
31
|
+
ariaLabel: () => viewerContext.messages.zoomRealSizeAriaLabel(),
|
|
32
|
+
icon: FtIcons.ZOOM_REALSIZE,
|
|
33
|
+
run: () => { var _a; return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(1); },
|
|
34
|
+
},
|
|
35
|
+
[FtViewerContentControls.ZOOM_IN]: {
|
|
36
|
+
ariaLabel: () => viewerContext.messages.zoomInAriaLabel(),
|
|
37
|
+
icon: FtIcons.ZOOM_IN,
|
|
38
|
+
disabled: () => { var _a; return ((_a = this.zoom) !== null && _a !== void 0 ? _a : 1) > 20; },
|
|
39
|
+
run: () => { var _a, _b; return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(((_b = this.zoom) !== null && _b !== void 0 ? _b : 1) * 1.2); },
|
|
40
|
+
},
|
|
41
|
+
[FtViewerContentControls.ZOOM_OUT]: {
|
|
42
|
+
ariaLabel: () => viewerContext.messages.zoomOutAriaLabel(),
|
|
43
|
+
icon: FtIcons.ZOOM_OUT,
|
|
44
|
+
disabled: () => { var _a; return ((_a = this.zoom) !== null && _a !== void 0 ? _a : 1) < 0.05; },
|
|
45
|
+
run: () => { var _a, _b; return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(((_b = this.zoom) !== null && _b !== void 0 ? _b : 1) / 1.2); },
|
|
46
|
+
},
|
|
47
|
+
[FtViewerContentControls.ROTATE_LEFT]: {
|
|
48
|
+
ariaLabel: () => viewerContext.messages.rotateLeftAriaLabel(),
|
|
49
|
+
icon: FtIcons.ARROW_ROTATE_LEFT,
|
|
50
|
+
run: () => { var _a; return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setRotation(this.rotation - 90); },
|
|
51
|
+
},
|
|
52
|
+
[FtViewerContentControls.ROTATE_RIGHT]: {
|
|
53
|
+
ariaLabel: () => viewerContext.messages.rotateRightAriaLabel(),
|
|
54
|
+
icon: FtIcons.ARROW_ROTATE_RIGHT,
|
|
55
|
+
run: () => { var _a; return (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setRotation(this.rotation + 90); },
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
this.modifyContent = () => {
|
|
59
|
+
var _a;
|
|
60
|
+
(_a = this.controlDefinitions[this.control]) === null || _a === void 0 ? void 0 : _a.run();
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
render() {
|
|
64
|
+
var _a;
|
|
65
|
+
return this.isVisible ? html `
|
|
66
|
+
<slot>
|
|
67
|
+
<ft-tooltip text="${this.ariaLabel}">
|
|
68
|
+
<ft-icon value="${(_a = this.controlDefinitions[this.control]) === null || _a === void 0 ? void 0 : _a.icon}"></ft-icon>
|
|
69
|
+
</ft-tooltip>
|
|
70
|
+
</slot>
|
|
71
|
+
` : nothing;
|
|
72
|
+
}
|
|
73
|
+
willUpdate(props) {
|
|
74
|
+
var _a, _b, _c, _d;
|
|
75
|
+
super.willUpdate(props);
|
|
76
|
+
this.updateAriaLabel();
|
|
77
|
+
this.disabled = (_c = (_b = (_a = this.controlDefinitions[this.control]) === null || _a === void 0 ? void 0 : _a.disabled) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false;
|
|
78
|
+
this.isVisible = !!((_d = this.descriptor) === null || _d === void 0 ? void 0 : _d.viewableInCurrentBrowser) && this.descriptor.mimeType.startsWith("image/");
|
|
79
|
+
}
|
|
80
|
+
onI18nUpdate(context) {
|
|
81
|
+
super.onI18nUpdate(context);
|
|
82
|
+
this.updateAriaLabel();
|
|
83
|
+
}
|
|
84
|
+
updateAriaLabel() {
|
|
85
|
+
var _a;
|
|
86
|
+
this.ariaLabel = (_a = this.controlDefinitions[this.control]) === null || _a === void 0 ? void 0 : _a.ariaLabel();
|
|
87
|
+
}
|
|
88
|
+
connectedCallback() {
|
|
89
|
+
super.connectedCallback();
|
|
90
|
+
this.addI18nContext(viewerContext, defaultViewerMessages);
|
|
91
|
+
this.updateComplete.then(() => { var _a; return (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.setupFor(this); });
|
|
92
|
+
this.addEventListener("click", this.modifyContent);
|
|
93
|
+
}
|
|
94
|
+
disconnectedCallback() {
|
|
95
|
+
super.disconnectedCallback();
|
|
96
|
+
this.removeEventListener("click", this.modifyContent);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
FtViewerContentControl.elementDefinitions = {
|
|
100
|
+
"ft-icon": FtIcon,
|
|
101
|
+
"ft-tooltip": FtTooltip,
|
|
102
|
+
};
|
|
103
|
+
FtViewerContentControl.styles = css `
|
|
104
|
+
:host {
|
|
105
|
+
display: inline-block;
|
|
106
|
+
opacity: 1;
|
|
107
|
+
filter: grayscale(0);
|
|
108
|
+
transition: opacity 0.2s ease-in-out, filter 0.2s ease-in-out;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:host([disabled]) {
|
|
113
|
+
opacity: 0.8;
|
|
114
|
+
filter: grayscale(1);
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
cursor: inherit;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
ft-icon {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
width: 40px;
|
|
124
|
+
height: 40px;
|
|
125
|
+
border-radius: 50%;
|
|
126
|
+
background-color: ${designSystemVariables.colorPrimary};
|
|
127
|
+
color: ${designSystemVariables.colorOnPrimary};
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host:hover, :host:focus-within {
|
|
133
|
+
ft-icon {
|
|
134
|
+
background-color: hsl(from ${designSystemVariables.colorPrimary} h s calc(l + 30));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
__decorate([
|
|
139
|
+
property({ type: Boolean, reflect: true })
|
|
140
|
+
], FtViewerContentControl.prototype, "disabled", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
property({ reflect: true })
|
|
143
|
+
], FtViewerContentControl.prototype, "tabindex", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
property({ reflect: true })
|
|
146
|
+
], FtViewerContentControl.prototype, "role", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ reflect: true, attribute: "aria-label" })
|
|
149
|
+
], FtViewerContentControl.prototype, "ariaLabel", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property()
|
|
152
|
+
], FtViewerContentControl.prototype, "control", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
redux({ store: "viewer" })
|
|
155
|
+
], FtViewerContentControl.prototype, "descriptor", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
redux({ store: "viewer", selector: ({ contentModifiers }) => contentModifiers.zoom })
|
|
158
|
+
], FtViewerContentControl.prototype, "zoom", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
redux({ store: "viewer", selector: ({ contentModifiers }) => contentModifiers.rotation })
|
|
161
|
+
], FtViewerContentControl.prototype, "rotation", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
query("ft-tooltip")
|
|
164
|
+
], FtViewerContentControl.prototype, "tooltip", void 0);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FtViewerComponent } from "./FtViewerComponent";
|
|
2
|
+
import { PropertyValues } from "lit";
|
|
3
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
4
|
+
import { FtFileDescriptor } from "./model/ft-viewer.models";
|
|
5
|
+
import { FtWatermark } from "@fluid-topics/public-api";
|
|
6
|
+
type ViewerType = "none" | "image" | "video" | "pdf" | "inline-svg" | "iframe";
|
|
7
|
+
declare const FtViewerContent_base: typeof FtViewerComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtLitElementWithConditionalVisibilityInterface>;
|
|
8
|
+
export declare class FtViewerContent extends FtViewerContent_base {
|
|
9
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
10
|
+
descriptor?: FtFileDescriptor;
|
|
11
|
+
viewerType: ViewerType;
|
|
12
|
+
inlineSvgAllowed: boolean;
|
|
13
|
+
zoom: number | undefined;
|
|
14
|
+
rotation: number;
|
|
15
|
+
watermark?: FtWatermark;
|
|
16
|
+
static styles: import("lit").CSSResult;
|
|
17
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
private renderContent;
|
|
19
|
+
/***************************************
|
|
20
|
+
* Image/SVG viewer *
|
|
21
|
+
***************************************/
|
|
22
|
+
image?: HTMLImageElement;
|
|
23
|
+
svg?: SVGSVGElement;
|
|
24
|
+
imageViewer?: HTMLDivElement;
|
|
25
|
+
imageContainer?: HTMLDivElement;
|
|
26
|
+
initialImageHeight?: number;
|
|
27
|
+
initialImageWidth?: number;
|
|
28
|
+
imageHeight?: number;
|
|
29
|
+
imageWidth?: number;
|
|
30
|
+
svgContent?: string;
|
|
31
|
+
protected renderImageViewer(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
protected onImageLoad(): void;
|
|
33
|
+
protected onSvgLoad(): void;
|
|
34
|
+
private getImageToViewerRatio;
|
|
35
|
+
/***************************************
|
|
36
|
+
* Video viewer *
|
|
37
|
+
***************************************/
|
|
38
|
+
protected renderVideoViewer(): import("lit-html").TemplateResult<1>;
|
|
39
|
+
/***************************************
|
|
40
|
+
* PDF viewer *
|
|
41
|
+
***************************************/
|
|
42
|
+
protected renderPdfViewer(): import("lit-html").TemplateResult<1>;
|
|
43
|
+
/***************************************
|
|
44
|
+
* Iframe viewer *
|
|
45
|
+
***************************************/
|
|
46
|
+
protected renderIframeViewer(url: string | undefined): import("lit-html").TemplateResult<1>;
|
|
47
|
+
protected willUpdate(props: PropertyValues<FtViewerContent>): void;
|
|
48
|
+
protected updated(props: PropertyValues<FtViewerContent>): void;
|
|
49
|
+
protected contentAvailableCallback(props: PropertyValues<FtViewerContent>): void;
|
|
50
|
+
}
|
|
51
|
+
export {};
|