@rhc-office/sdk 6.6.385 → 6.6.387
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/dist/api/annotation-tool.d.ts +1 -0
- package/dist/api/annotation-tool.d.ts.map +1 -1
- package/dist/browser/document-viewer.js +1 -1
- package/dist/browser/document-viewer.js.map +1 -1
- package/dist/index.js +269 -234
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/viewer/DocumentSDK.d.ts +1 -0
- package/dist/viewer/DocumentSDK.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api/annotation-tool.ts +1 -0
- package/src/viewer/DocumentSDK.ts +102 -3
|
@@ -71,6 +71,7 @@ export declare class DocumentSDK implements IDocumentSDK {
|
|
|
71
71
|
readonly createKVField: IDocumentSDK['createKVField'];
|
|
72
72
|
private readonly mountReader;
|
|
73
73
|
private applyReaderRuntimeConfig;
|
|
74
|
+
private syncReaderRuntimeConfig;
|
|
74
75
|
private restoreReaderRuntimeConfig;
|
|
75
76
|
private readonly bindNativeReaderEvents;
|
|
76
77
|
private readonly cleanupNativeEventForwarders;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentSDK.d.ts","sourceRoot":"","sources":["../../src/viewer/DocumentSDK.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,qBAAqB,CAAC;AA+CzE,UAAU,yBAAyB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"DocumentSDK.d.ts","sourceRoot":"","sources":["../../src/viewer/DocumentSDK.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,qBAAqB,CAAC;AA+CzE,UAAU,yBAAyB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB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F,OAAO,CAAC,QAAQ,CAAC,eAAe,CAE9B;IAEF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAOhC;IAEF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAMjC;CACH;AAED,eAAO,MAAM,oBAAoB,GAAI,UAAU,yBAAyB,KAAG,YAE1E,CAAC"}
|
package/package.json
CHANGED
|
@@ -57,14 +57,21 @@ type ReaderHostRuntimeKind = 'server' | 'browser-static' | 'mobile-webview' | 'd
|
|
|
57
57
|
|
|
58
58
|
interface ReaderHostRuntimeConfig {
|
|
59
59
|
hostKind?: ReaderHostRuntimeKind | (string & {});
|
|
60
|
+
embedOptions?: {
|
|
61
|
+
canDownload?: boolean;
|
|
62
|
+
canOpenNewFile?: boolean;
|
|
63
|
+
canPrint?: boolean;
|
|
64
|
+
};
|
|
60
65
|
server?: {
|
|
61
66
|
baseUrl?: string;
|
|
62
67
|
paths?: Record<string, string | undefined>;
|
|
63
68
|
};
|
|
64
69
|
identity?: {
|
|
70
|
+
feature?: string;
|
|
65
71
|
sessionUser?: string;
|
|
66
72
|
sessionUserId?: string;
|
|
67
73
|
};
|
|
74
|
+
sessionData?: string;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
type NativeReaderEventName = 'documentLoaded' | 'documentStateChange' | 'documentError';
|
|
@@ -114,7 +121,9 @@ const createReaderPayload = (
|
|
|
114
121
|
const normalizeSessionUserIdentity = (
|
|
115
122
|
sessionUser: Parameters<IDocumentSDK['setSessionUser']>[0] | undefined,
|
|
116
123
|
sessionUserId: Parameters<IDocumentSDK['setSessionUserId']>[0] | undefined,
|
|
117
|
-
):
|
|
124
|
+
):
|
|
125
|
+
| Pick<NonNullable<ReaderHostRuntimeConfig['identity']>, 'sessionUser' | 'sessionUserId'>
|
|
126
|
+
| undefined => {
|
|
118
127
|
if (!sessionUser) {
|
|
119
128
|
return undefined;
|
|
120
129
|
}
|
|
@@ -141,6 +150,43 @@ const normalizeSessionUserIdentity = (
|
|
|
141
150
|
};
|
|
142
151
|
};
|
|
143
152
|
|
|
153
|
+
const normalizeReaderHostActivationFeature = (viewMode: string): string => {
|
|
154
|
+
const normalizedViewMode = viewMode
|
|
155
|
+
.trim()
|
|
156
|
+
.replace(/[-_\s]/g, '')
|
|
157
|
+
.toLowerCase();
|
|
158
|
+
|
|
159
|
+
if (normalizedViewMode === 'annotation') {
|
|
160
|
+
return 'ANNOTATION';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (normalizedViewMode === 'digitalsign') {
|
|
164
|
+
return 'DIGITAL_SIGN';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return 'VIEW';
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const normalizeEmbedRuntimeOptions = (
|
|
171
|
+
configuration: NormalizedReaderEmbedOptions,
|
|
172
|
+
): ReaderHostRuntimeConfig['embedOptions'] | undefined => {
|
|
173
|
+
const embedOptions: NonNullable<ReaderHostRuntimeConfig['embedOptions']> = {};
|
|
174
|
+
|
|
175
|
+
if (configuration.canOpenNewFile !== undefined) {
|
|
176
|
+
embedOptions.canOpenNewFile = configuration.canOpenNewFile;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (configuration.canPrint !== undefined) {
|
|
180
|
+
embedOptions.canPrint = configuration.canPrint;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (configuration.canDownload !== undefined) {
|
|
184
|
+
embedOptions.canDownload = configuration.canDownload;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return Object.keys(embedOptions).length > 0 ? embedOptions : undefined;
|
|
188
|
+
};
|
|
189
|
+
|
|
144
190
|
const resolveContainerElement = (container: string | HTMLDivElement): HTMLDivElement => {
|
|
145
191
|
if (typeof container === 'string') {
|
|
146
192
|
const element = document.getElementById(container);
|
|
@@ -348,14 +394,17 @@ export class DocumentSDK implements IDocumentSDK {
|
|
|
348
394
|
|
|
349
395
|
readonly setSessionUser: IDocumentSDK['setSessionUser'] = (userNameOrInfo): void => {
|
|
350
396
|
this.sessionUser = userNameOrInfo;
|
|
397
|
+
this.syncReaderRuntimeConfig();
|
|
351
398
|
};
|
|
352
399
|
|
|
353
400
|
readonly setSessionUserId: IDocumentSDK['setSessionUserId'] = (userId): void => {
|
|
354
401
|
this.sessionUserId = userId;
|
|
402
|
+
this.syncReaderRuntimeConfig();
|
|
355
403
|
};
|
|
356
404
|
|
|
357
405
|
readonly setSessionData: IDocumentSDK['setSessionData'] = (sessionData): void => {
|
|
358
406
|
this.sessionData = sessionData;
|
|
407
|
+
this.syncReaderRuntimeConfig();
|
|
359
408
|
};
|
|
360
409
|
|
|
361
410
|
readonly isReaderReady: IDocumentSDK['isReaderReady'] = (): boolean => {
|
|
@@ -554,13 +603,20 @@ export class DocumentSDK implements IDocumentSDK {
|
|
|
554
603
|
configuration: NormalizedReaderEmbedOptions,
|
|
555
604
|
): void {
|
|
556
605
|
this.restoreReaderRuntimeConfig();
|
|
557
|
-
const
|
|
606
|
+
const sessionIdentity = normalizeSessionUserIdentity(this.sessionUser, this.sessionUserId);
|
|
607
|
+
const identity: NonNullable<ReaderHostRuntimeConfig['identity']> = {
|
|
608
|
+
feature: normalizeReaderHostActivationFeature(configuration.viewMode),
|
|
609
|
+
...(sessionIdentity ?? {}),
|
|
610
|
+
};
|
|
611
|
+
const embedOptions = normalizeEmbedRuntimeOptions(configuration);
|
|
558
612
|
const readerHost: ReaderHostRuntimeConfig = {
|
|
559
613
|
hostKind: 'server',
|
|
614
|
+
...(embedOptions ? { embedOptions } : {}),
|
|
560
615
|
server: {
|
|
561
616
|
baseUrl: configuration.appUrl,
|
|
562
617
|
},
|
|
563
|
-
|
|
618
|
+
identity,
|
|
619
|
+
...(this.sessionData !== undefined ? { sessionData: this.sessionData } : {}),
|
|
564
620
|
};
|
|
565
621
|
|
|
566
622
|
const runtimeElement = readerElement as ReaderRuntimeElement;
|
|
@@ -575,6 +631,49 @@ export class DocumentSDK implements IDocumentSDK {
|
|
|
575
631
|
browserGlobal[READER_RUNTIME_GLOBAL_KEY] = readerHost;
|
|
576
632
|
}
|
|
577
633
|
|
|
634
|
+
private syncReaderRuntimeConfig(): void {
|
|
635
|
+
if (!this.readerElement || !this.normalizedConfiguration) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const runtimeElement = this.readerElement as ReaderRuntimeElement;
|
|
640
|
+
const currentRuntime = runtimeElement[READER_RUNTIME_PROPERTY_KEY];
|
|
641
|
+
if (!currentRuntime) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const sessionIdentity = normalizeSessionUserIdentity(this.sessionUser, this.sessionUserId);
|
|
646
|
+
const restIdentity = { ...(currentRuntime.identity ?? {}) };
|
|
647
|
+
delete restIdentity.sessionUser;
|
|
648
|
+
delete restIdentity.sessionUserId;
|
|
649
|
+
const identity: NonNullable<ReaderHostRuntimeConfig['identity']> = {
|
|
650
|
+
...restIdentity,
|
|
651
|
+
feature: normalizeReaderHostActivationFeature(this.normalizedConfiguration.viewMode),
|
|
652
|
+
...(sessionIdentity ?? {}),
|
|
653
|
+
};
|
|
654
|
+
const nextRuntime: ReaderHostRuntimeConfig = {
|
|
655
|
+
...currentRuntime,
|
|
656
|
+
identity,
|
|
657
|
+
...(this.sessionData !== undefined ? { sessionData: this.sessionData } : {}),
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
runtimeElement[READER_RUNTIME_PROPERTY_KEY] = nextRuntime;
|
|
661
|
+
(globalThis as ReaderRuntimeBrowserGlobal)[READER_RUNTIME_GLOBAL_KEY] = nextRuntime;
|
|
662
|
+
|
|
663
|
+
if (!this.isReady) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
void this.bridge
|
|
668
|
+
.request('extension', 'updateReaderRuntimeConfig', {
|
|
669
|
+
identity,
|
|
670
|
+
...(this.sessionData !== undefined ? { sessionData: this.sessionData } : {}),
|
|
671
|
+
})
|
|
672
|
+
.catch((error: unknown) => {
|
|
673
|
+
this.reportAdapterError(error);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
578
677
|
private restoreReaderRuntimeConfig(): void {
|
|
579
678
|
if (!this.runtimeRestoreState) {
|
|
580
679
|
return;
|