@rhc-office/sdk 6.6.266 → 6.6.351
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 +1 -5
- package/dist/api/annotation-tool.d.ts +162 -102
- package/dist/api/annotation-tool.d.ts.map +1 -1
- package/dist/api/callbacks.d.ts +32 -6
- package/dist/api/callbacks.d.ts.map +1 -1
- package/dist/api/document-sdk.d.ts +6 -5
- package/dist/api/document-sdk.d.ts.map +1 -1
- package/dist/api/document-tool.d.ts +16 -11
- package/dist/api/document-tool.d.ts.map +1 -1
- package/dist/api/menu-visibility.d.ts +6 -1
- package/dist/api/menu-visibility.d.ts.map +1 -1
- package/dist/api/page-arrange-tool.d.ts +28 -0
- package/dist/api/page-arrange-tool.d.ts.map +1 -0
- package/dist/api/security-tool.d.ts +21 -0
- package/dist/api/security-tool.d.ts.map +1 -0
- package/dist/api/ui-tool.d.ts +19 -0
- package/dist/api/ui-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.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +730 -501
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/tools/AnnotationToolImpl.d.ts +25 -0
- package/dist/tools/AnnotationToolImpl.d.ts.map +1 -0
- package/dist/tools/CryptoToolImpl.d.ts +9 -0
- package/dist/tools/CryptoToolImpl.d.ts.map +1 -0
- package/dist/tools/DigitalSignToolImpl.d.ts +27 -0
- package/dist/tools/DigitalSignToolImpl.d.ts.map +1 -0
- package/dist/tools/DocumentToolImpl.d.ts +1 -0
- package/dist/tools/DocumentToolImpl.d.ts.map +1 -1
- package/dist/tools/PageArrangeToolImpl.d.ts +21 -0
- package/dist/tools/PageArrangeToolImpl.d.ts.map +1 -0
- package/dist/tools/SecurityToolImpl.d.ts +12 -0
- package/dist/tools/SecurityToolImpl.d.ts.map +1 -0
- package/dist/tools/SignServerToolImpl.d.ts +19 -0
- package/dist/tools/SignServerToolImpl.d.ts.map +1 -0
- package/dist/tools/SymbologyToolImpl.d.ts +8 -0
- package/dist/tools/SymbologyToolImpl.d.ts.map +1 -0
- package/dist/tools/TemplateSignToolImpl.d.ts +13 -0
- package/dist/tools/TemplateSignToolImpl.d.ts.map +1 -0
- package/dist/tools/UIToolImpl.d.ts +13 -0
- package/dist/tools/UIToolImpl.d.ts.map +1 -1
- package/dist/tools/index.d.ts +8 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/viewer/AdapterProtocol.d.ts +3 -1
- package/dist/viewer/AdapterProtocol.d.ts.map +1 -1
- package/dist/viewer/BridgeToolAdapter.d.ts +1 -0
- package/dist/viewer/BridgeToolAdapter.d.ts.map +1 -1
- package/dist/viewer/DocumentSDK.d.ts +7 -5
- package/dist/viewer/DocumentSDK.d.ts.map +1 -1
- package/dist/viewer/ReaderBridgeClient.d.ts +3 -0
- package/dist/viewer/ReaderBridgeClient.d.ts.map +1 -1
- package/dist/viewer/ReaderConfiguration.d.ts +0 -1
- package/dist/viewer/ReaderConfiguration.d.ts.map +1 -1
- package/dist/viewer/ReaderStateStore.d.ts +2 -0
- package/dist/viewer/ReaderStateStore.d.ts.map +1 -1
- package/dist/viewer/SdkCallbackRegistry.d.ts +5 -2
- package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/annotation-tool.ts +232 -146
- package/src/api/callbacks.ts +48 -7
- package/src/api/document-sdk.ts +9 -5
- package/src/api/document-tool.ts +25 -13
- package/src/api/menu-visibility.ts +10 -1
- package/src/api/page-arrange-tool.ts +67 -0
- package/src/api/security-tool.ts +32 -0
- package/src/api/ui-tool.ts +33 -0
- package/src/index.ts +3 -0
- package/src/tools/AnnotationToolImpl.ts +169 -0
- package/src/tools/CryptoToolImpl.ts +27 -0
- package/src/tools/DigitalSignToolImpl.ts +166 -0
- package/src/tools/DocumentToolImpl.ts +32 -6
- package/src/tools/PageArrangeToolImpl.ts +99 -0
- package/src/tools/SecurityToolImpl.ts +48 -0
- package/src/tools/SignServerToolImpl.ts +92 -0
- package/src/tools/SymbologyToolImpl.ts +34 -0
- package/src/tools/TemplateSignToolImpl.ts +51 -0
- package/src/tools/UIToolImpl.ts +98 -12
- package/src/tools/index.ts +8 -1
- package/src/viewer/AdapterProtocol.ts +4 -0
- package/src/viewer/BridgeToolAdapter.ts +11 -2
- package/src/viewer/DocumentSDK.ts +71 -144
- package/src/viewer/ReaderBridgeClient.ts +9 -0
- package/src/viewer/ReaderConfiguration.ts +0 -2
- package/src/viewer/ReaderStateStore.ts +13 -1
- package/src/viewer/SdkCallbackRegistry.ts +84 -6
- package/dist/tools/Phase1ToolPlaceholder.d.ts +0 -5
- package/dist/tools/Phase1ToolPlaceholder.d.ts.map +0 -1
- package/src/tools/Phase1ToolPlaceholder.ts +0 -35
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PageArrangeAction,
|
|
3
|
+
PageArrangeCommitResult,
|
|
4
|
+
PageArrangeDocumentFormat,
|
|
5
|
+
PageArrangeExtractResult,
|
|
6
|
+
PageArrangePageSize,
|
|
7
|
+
PageArrangeQuarterTurn,
|
|
8
|
+
PageArrangeTransactionSnapshot,
|
|
9
|
+
} from '@rhc-office/schema';
|
|
10
|
+
|
|
11
|
+
export interface PageArrangeNewPageOptions {
|
|
12
|
+
rotation?: PageArrangeQuarterTurn;
|
|
13
|
+
size?: PageArrangePageSize;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PageArrangeImportDocumentOptions {
|
|
17
|
+
format: PageArrangeDocumentFormat;
|
|
18
|
+
insertIndex?: number;
|
|
19
|
+
pageIndices?: number[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PageArrangeToolResult =
|
|
23
|
+
| PageArrangeTransactionSnapshot
|
|
24
|
+
| PageArrangeCommitResult
|
|
25
|
+
| PageArrangeExtractResult;
|
|
26
|
+
|
|
27
|
+
export interface PageArrangeTool {
|
|
28
|
+
getSnapshot(): Promise<PageArrangeTransactionSnapshot>;
|
|
29
|
+
|
|
30
|
+
execute(action: PageArrangeAction): Promise<PageArrangeToolResult>;
|
|
31
|
+
|
|
32
|
+
newPage(
|
|
33
|
+
index?: number,
|
|
34
|
+
options?: PageArrangeNewPageOptions,
|
|
35
|
+
): Promise<PageArrangeTransactionSnapshot>;
|
|
36
|
+
|
|
37
|
+
deletePages(pageIndices: number[]): Promise<PageArrangeTransactionSnapshot>;
|
|
38
|
+
|
|
39
|
+
duplicatePages(
|
|
40
|
+
pageIndices: number[],
|
|
41
|
+
insertIndex?: number,
|
|
42
|
+
): Promise<PageArrangeTransactionSnapshot>;
|
|
43
|
+
|
|
44
|
+
rotateLeft(pageIndices: number[]): Promise<PageArrangeTransactionSnapshot>;
|
|
45
|
+
|
|
46
|
+
rotateRight(pageIndices: number[]): Promise<PageArrangeTransactionSnapshot>;
|
|
47
|
+
|
|
48
|
+
clearContent(pageIndices: number[]): Promise<PageArrangeTransactionSnapshot>;
|
|
49
|
+
|
|
50
|
+
moveBefore(pageIndices: number[], targetIndex: number): Promise<PageArrangeTransactionSnapshot>;
|
|
51
|
+
|
|
52
|
+
moveAfter(pageIndices: number[], targetIndex: number): Promise<PageArrangeTransactionSnapshot>;
|
|
53
|
+
|
|
54
|
+
importDocument(
|
|
55
|
+
data: Uint8Array | ArrayBuffer,
|
|
56
|
+
options: PageArrangeImportDocumentOptions,
|
|
57
|
+
): Promise<PageArrangeTransactionSnapshot>;
|
|
58
|
+
|
|
59
|
+
extractPages(
|
|
60
|
+
pageIndices: number[],
|
|
61
|
+
suggestedFileName?: string,
|
|
62
|
+
): Promise<PageArrangeExtractResult>;
|
|
63
|
+
|
|
64
|
+
undo(): Promise<PageArrangeTransactionSnapshot>;
|
|
65
|
+
|
|
66
|
+
commit(): Promise<PageArrangeCommitResult>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type DocumentSecurityPermissionId =
|
|
2
|
+
| 'print'
|
|
3
|
+
| 'documentAssembly'
|
|
4
|
+
| 'contentCopy'
|
|
5
|
+
| 'accessibilityExtraction'
|
|
6
|
+
| 'pageExtraction'
|
|
7
|
+
| 'annotation'
|
|
8
|
+
| 'formFill'
|
|
9
|
+
| 'signing'
|
|
10
|
+
| 'templatePage';
|
|
11
|
+
|
|
12
|
+
export interface DocumentSecuritySettings {
|
|
13
|
+
print: boolean;
|
|
14
|
+
documentAssembly: boolean;
|
|
15
|
+
contentCopy: boolean;
|
|
16
|
+
accessibilityExtraction: boolean;
|
|
17
|
+
pageExtraction: boolean;
|
|
18
|
+
annotation: boolean;
|
|
19
|
+
formFill: boolean;
|
|
20
|
+
signing: boolean;
|
|
21
|
+
templatePage: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type DocumentSecurityUpdate = Partial<DocumentSecuritySettings>;
|
|
25
|
+
|
|
26
|
+
export interface SecurityTool {
|
|
27
|
+
getSecuritySettings(): Promise<DocumentSecuritySettings>;
|
|
28
|
+
setSecuritySettings(update: DocumentSecurityUpdate): Promise<DocumentSecuritySettings>;
|
|
29
|
+
isSecuritySettingsLocalEditable(): Promise<boolean>;
|
|
30
|
+
setSecuritySettingsLocalEditable(editable: boolean): Promise<boolean>;
|
|
31
|
+
openSecuritySettingsDialog(): void;
|
|
32
|
+
}
|
package/src/api/ui-tool.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { RibbonMenuItemVisibility, MenuActionButtonStyle } from './menu-visibility';
|
|
2
2
|
import { IWatermark } from './watermark';
|
|
3
3
|
|
|
4
|
+
export interface RibbonMenuState {
|
|
5
|
+
visible?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface RibbonMenuItemState extends RibbonMenuState {
|
|
10
|
+
config?: RibbonMenuItemVisibility;
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
export interface UITool {
|
|
5
14
|
showToolbarMenu(): void;
|
|
6
15
|
|
|
@@ -44,14 +53,38 @@ export interface UITool {
|
|
|
44
53
|
|
|
45
54
|
hideRibbonTitleBar(): void;
|
|
46
55
|
|
|
56
|
+
showRibbonTabs(): void;
|
|
57
|
+
|
|
58
|
+
hideRibbonTabs(): void;
|
|
59
|
+
|
|
47
60
|
selectRibbonMenu(menuId: string): void;
|
|
48
61
|
|
|
62
|
+
setupRibbonMenuTab(menuId: string, state: RibbonMenuState): void;
|
|
63
|
+
|
|
64
|
+
showRibbonMenuTab(menuId: string): void;
|
|
65
|
+
|
|
66
|
+
hideRibbonMenuTab(menuId: string): void;
|
|
67
|
+
|
|
68
|
+
enableRibbonMenuTab(menuId: string): void;
|
|
69
|
+
|
|
70
|
+
disableRibbonMenuTab(menuId: string): void;
|
|
71
|
+
|
|
72
|
+
setupRibbonMenuItemState(menuId: string, state: RibbonMenuItemState): void;
|
|
73
|
+
|
|
74
|
+
enableRibbonMenuItem(menuId: string, config?: RibbonMenuItemVisibility): void;
|
|
75
|
+
|
|
76
|
+
disableRibbonMenuItem(menuId: string, config?: RibbonMenuItemVisibility): void;
|
|
77
|
+
|
|
49
78
|
setRibbonMenuButtonStyle(buttonId: string, buttonStyle: MenuActionButtonStyle): void;
|
|
50
79
|
|
|
51
80
|
setWatermark(fields: IWatermark | unknown): void;
|
|
52
81
|
|
|
53
82
|
setCompactMode(compact: boolean): void;
|
|
54
83
|
|
|
84
|
+
setRulerVisible(visible: boolean): void;
|
|
85
|
+
|
|
86
|
+
toggleSidebar(): void;
|
|
87
|
+
|
|
55
88
|
enterBookViewMode(callback?: () => void): void;
|
|
56
89
|
|
|
57
90
|
exitBookViewMode(): void;
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './api/document-tool';
|
|
|
6
6
|
export * from './api/annotation-tool';
|
|
7
7
|
export * from './api/ui-tool';
|
|
8
8
|
export * from './api/page-tool';
|
|
9
|
+
export * from './api/page-arrange-tool';
|
|
9
10
|
export * from './api/find-tool';
|
|
10
11
|
export * from './api/sign-tool';
|
|
11
12
|
export * from './api/sign-server';
|
|
@@ -15,5 +16,7 @@ export * from './api/symbology-tool';
|
|
|
15
16
|
export * from './api/template-sign';
|
|
16
17
|
export * from './api/pdf-formfiller';
|
|
17
18
|
export * from './api/crypto-tool';
|
|
19
|
+
export * from './api/security-tool';
|
|
18
20
|
export * from './api/document-sdk';
|
|
21
|
+
export * from './tools';
|
|
19
22
|
export * from './viewer';
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnnotationEventCallback,
|
|
3
|
+
AnnotationMode,
|
|
4
|
+
AnnotationRecord,
|
|
5
|
+
AnnotationTool,
|
|
6
|
+
} from '../api/annotation-tool';
|
|
7
|
+
import {
|
|
8
|
+
createBridgeToolAdapter,
|
|
9
|
+
type BridgeToolAdapterContext,
|
|
10
|
+
type BridgeToolDescriptor,
|
|
11
|
+
} from '../viewer/BridgeToolAdapter';
|
|
12
|
+
import type { ReaderStateSnapshot } from '../viewer/ReaderStateStore';
|
|
13
|
+
|
|
14
|
+
const isAnnotationRecord = (value: unknown): value is AnnotationRecord => {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) && 'id' in value;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getPublishedAnnotations = (state: ReaderStateSnapshot): AnnotationRecord[] => {
|
|
19
|
+
return (
|
|
20
|
+
state.annotations?.filter(isAnnotationRecord).map((annotation) => ({ ...annotation })) ?? []
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const normalizeAnnotationMode = (mode?: string): AnnotationMode => {
|
|
25
|
+
switch (mode) {
|
|
26
|
+
case 'select':
|
|
27
|
+
case 'pen':
|
|
28
|
+
case 'eraser':
|
|
29
|
+
case 'line':
|
|
30
|
+
case 'arrow':
|
|
31
|
+
case 'rectangle':
|
|
32
|
+
case 'circle':
|
|
33
|
+
case 'text-highlight':
|
|
34
|
+
case 'text-underline':
|
|
35
|
+
case 'text-strikethrough':
|
|
36
|
+
case 'text-squiggly':
|
|
37
|
+
case 'text-note':
|
|
38
|
+
case 'stamp':
|
|
39
|
+
return mode;
|
|
40
|
+
case 'none':
|
|
41
|
+
default:
|
|
42
|
+
return 'none';
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const ANNOTATION_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
47
|
+
addAnnotationEventCallback: {
|
|
48
|
+
kind: 'callbackRegister',
|
|
49
|
+
callback: (callbacks, args) => {
|
|
50
|
+
const callback = args[0];
|
|
51
|
+
if (typeof callback === 'function') {
|
|
52
|
+
callbacks.annotationEvents.push(callback as AnnotationEventCallback);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
isInAnnotationMode: {
|
|
57
|
+
kind: 'stateGetter',
|
|
58
|
+
state: (state) => state.annotationEnabled,
|
|
59
|
+
},
|
|
60
|
+
getAnnotationMode: {
|
|
61
|
+
kind: 'stateGetter',
|
|
62
|
+
state: (state) => normalizeAnnotationMode(state.annotationMode),
|
|
63
|
+
},
|
|
64
|
+
getAnnotations: {
|
|
65
|
+
kind: 'stateGetter',
|
|
66
|
+
state: (state) => getPublishedAnnotations(state),
|
|
67
|
+
},
|
|
68
|
+
getAnnotationsCount: {
|
|
69
|
+
kind: 'stateGetter',
|
|
70
|
+
state: (state) => getPublishedAnnotations(state).length,
|
|
71
|
+
},
|
|
72
|
+
openAnnotationView: { kind: 'command' },
|
|
73
|
+
closeAnnotationView: { kind: 'command' },
|
|
74
|
+
saveAnnotations: { kind: 'callbackQuery' },
|
|
75
|
+
clearAnnotations: { kind: 'command', returnsResult: true },
|
|
76
|
+
undoAnnotation: { kind: 'command', returnsResult: true },
|
|
77
|
+
redoAnnotation: { kind: 'command', returnsResult: true },
|
|
78
|
+
canUndoAnnotation: { kind: 'query' },
|
|
79
|
+
canRedoAnnotation: { kind: 'query' },
|
|
80
|
+
selectAnnotationTool: { kind: 'command' },
|
|
81
|
+
selectAnnotationStamp: { kind: 'command' },
|
|
82
|
+
setAnnotationPenColor: { kind: 'command' },
|
|
83
|
+
setAnnotationPenWidth: { kind: 'command' },
|
|
84
|
+
setAnnotationPenStyle: { kind: 'command' },
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export class AnnotationToolImpl implements AnnotationTool {
|
|
88
|
+
private readonly adapter: AnnotationTool;
|
|
89
|
+
|
|
90
|
+
constructor(context: BridgeToolAdapterContext) {
|
|
91
|
+
this.adapter = createBridgeToolAdapter<AnnotationTool>(
|
|
92
|
+
'annotation',
|
|
93
|
+
ANNOTATION_TOOL_DESCRIPTOR,
|
|
94
|
+
context,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
openAnnotationView: AnnotationTool['openAnnotationView'] = (options) => {
|
|
99
|
+
return this.adapter.openAnnotationView(options);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
closeAnnotationView: AnnotationTool['closeAnnotationView'] = () => {
|
|
103
|
+
return this.adapter.closeAnnotationView();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
saveAnnotations: AnnotationTool['saveAnnotations'] = (saveCallback) => {
|
|
107
|
+
return this.adapter.saveAnnotations(saveCallback);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
clearAnnotations: AnnotationTool['clearAnnotations'] = () => {
|
|
111
|
+
return this.adapter.clearAnnotations();
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
undoAnnotation: AnnotationTool['undoAnnotation'] = () => {
|
|
115
|
+
return this.adapter.undoAnnotation();
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
redoAnnotation: AnnotationTool['redoAnnotation'] = () => {
|
|
119
|
+
return this.adapter.redoAnnotation();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
canUndoAnnotation: AnnotationTool['canUndoAnnotation'] = () => {
|
|
123
|
+
return this.adapter.canUndoAnnotation();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
canRedoAnnotation: AnnotationTool['canRedoAnnotation'] = () => {
|
|
127
|
+
return this.adapter.canRedoAnnotation();
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
selectAnnotationTool: AnnotationTool['selectAnnotationTool'] = (tool, options) => {
|
|
131
|
+
return this.adapter.selectAnnotationTool(tool, options);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
selectAnnotationStamp: AnnotationTool['selectAnnotationStamp'] = (stamp) => {
|
|
135
|
+
return this.adapter.selectAnnotationStamp(stamp);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
setAnnotationPenColor: AnnotationTool['setAnnotationPenColor'] = (hexColor) => {
|
|
139
|
+
return this.adapter.setAnnotationPenColor(hexColor);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
setAnnotationPenWidth: AnnotationTool['setAnnotationPenWidth'] = (penWidth) => {
|
|
143
|
+
return this.adapter.setAnnotationPenWidth(penWidth);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
setAnnotationPenStyle: AnnotationTool['setAnnotationPenStyle'] = (options) => {
|
|
147
|
+
return this.adapter.setAnnotationPenStyle(options);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
isInAnnotationMode: AnnotationTool['isInAnnotationMode'] = () => {
|
|
151
|
+
return this.adapter.isInAnnotationMode();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
getAnnotationMode: AnnotationTool['getAnnotationMode'] = () => {
|
|
155
|
+
return this.adapter.getAnnotationMode();
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
getAnnotations: AnnotationTool['getAnnotations'] = () => {
|
|
159
|
+
return this.adapter.getAnnotations();
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
getAnnotationsCount: AnnotationTool['getAnnotationsCount'] = () => {
|
|
163
|
+
return this.adapter.getAnnotationsCount();
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
addAnnotationEventCallback: AnnotationTool['addAnnotationEventCallback'] = (callback) => {
|
|
167
|
+
return this.adapter.addAnnotationEventCallback(callback);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CryptoTool } from '../api/crypto-tool';
|
|
2
|
+
import {
|
|
3
|
+
createBridgeToolAdapter,
|
|
4
|
+
type BridgeToolAdapterContext,
|
|
5
|
+
type BridgeToolDescriptor,
|
|
6
|
+
} from '../viewer/BridgeToolAdapter';
|
|
7
|
+
|
|
8
|
+
const CRYPTO_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
9
|
+
configSecurityProvider: { kind: 'command' },
|
|
10
|
+
getSecurityProviders: { kind: 'query' },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export class CryptoToolImpl implements CryptoTool {
|
|
14
|
+
private readonly adapter: CryptoTool;
|
|
15
|
+
|
|
16
|
+
constructor(context: BridgeToolAdapterContext) {
|
|
17
|
+
this.adapter = createBridgeToolAdapter<CryptoTool>('crypto', CRYPTO_TOOL_DESCRIPTOR, context);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
configSecurityProvider: CryptoTool['configSecurityProvider'] = (providers) => {
|
|
21
|
+
return this.adapter.configSecurityProvider(providers);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
getSecurityProviders: CryptoTool['getSecurityProviders'] = () => {
|
|
25
|
+
return this.adapter.getSecurityProviders();
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { DigitalSignatureRetrieveCallback, DigitalSignCallback } from '../api/callbacks';
|
|
2
|
+
import type { DigitalSignTool } from '../api/sign-tool';
|
|
3
|
+
import {
|
|
4
|
+
createBridgeToolAdapter,
|
|
5
|
+
type BridgeToolAdapterContext,
|
|
6
|
+
type BridgeToolDescriptor,
|
|
7
|
+
} from '../viewer/BridgeToolAdapter';
|
|
8
|
+
import type { ReaderStateSnapshot } from '../viewer/ReaderStateStore';
|
|
9
|
+
|
|
10
|
+
const getPublishedDigitalSignatures = (state: ReaderStateSnapshot): unknown[] => {
|
|
11
|
+
return state.digitalSignatures ? [...state.digitalSignatures] : [];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const DIGITAL_SIGN_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
15
|
+
addDigitalSignatureRetrieveCallback: {
|
|
16
|
+
kind: 'callbackRegister',
|
|
17
|
+
callback: (callbacks, args) => {
|
|
18
|
+
const callback = args[0];
|
|
19
|
+
if (typeof callback === 'function') {
|
|
20
|
+
callbacks.digitalSignatureRetrieve.push(callback as DigitalSignatureRetrieveCallback);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
addDigitalSignatureParseCallback: {
|
|
25
|
+
kind: 'callbackRegister',
|
|
26
|
+
callback: (callbacks, args) => {
|
|
27
|
+
const callback = args[0];
|
|
28
|
+
if (typeof callback === 'function') {
|
|
29
|
+
callbacks.digitalSignatureParse.push(callback as DigitalSignatureRetrieveCallback);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
addDigitalSignCallback: {
|
|
34
|
+
kind: 'callbackRegister',
|
|
35
|
+
callback: (callbacks, args) => {
|
|
36
|
+
const callback = args[0];
|
|
37
|
+
if (typeof callback === 'function') {
|
|
38
|
+
callbacks.digitalSign.push(callback as DigitalSignCallback);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
setCryptoProvider: { kind: 'command' },
|
|
43
|
+
setSealSource: { kind: 'command' },
|
|
44
|
+
setDefaultStampPassword: { kind: 'command' },
|
|
45
|
+
setDefaultSealPassword: { kind: 'command' },
|
|
46
|
+
setDefaultKeystorePassword: { kind: 'command' },
|
|
47
|
+
setDefaultUSBKeyPassword: { kind: 'command' },
|
|
48
|
+
setupExternalSealServer: { kind: 'command' },
|
|
49
|
+
setDigitalSignOptions: { kind: 'command' },
|
|
50
|
+
setExternalDigitalSignOptions: { kind: 'command' },
|
|
51
|
+
setPDFDigitalSignCaptionOptions: { kind: 'command' },
|
|
52
|
+
addDigitalSignature: { kind: 'callbackQuery' },
|
|
53
|
+
addDigitalSignatureBySelectedSearchHighlight: { kind: 'command' },
|
|
54
|
+
listDigitalSignatures: { kind: 'callbackQuery' },
|
|
55
|
+
getDigitalSignatures: {
|
|
56
|
+
kind: 'stateGetter',
|
|
57
|
+
state: (state) => getPublishedDigitalSignatures(state),
|
|
58
|
+
},
|
|
59
|
+
getDigitalSignaturesCount: {
|
|
60
|
+
kind: 'stateGetter',
|
|
61
|
+
state: (state) => getPublishedDigitalSignatures(state).length,
|
|
62
|
+
},
|
|
63
|
+
enableDigitalSignatureInfoView: { kind: 'command' },
|
|
64
|
+
enableDigitalSignatureRevocation: { kind: 'command' },
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export class DigitalSignToolImpl implements DigitalSignTool {
|
|
68
|
+
private readonly adapter: DigitalSignTool;
|
|
69
|
+
|
|
70
|
+
constructor(context: BridgeToolAdapterContext) {
|
|
71
|
+
this.adapter = createBridgeToolAdapter<DigitalSignTool>(
|
|
72
|
+
'digitalSign',
|
|
73
|
+
DIGITAL_SIGN_TOOL_DESCRIPTOR,
|
|
74
|
+
context,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
addDigitalSignatureRetrieveCallback: DigitalSignTool['addDigitalSignatureRetrieveCallback'] = (
|
|
79
|
+
callback,
|
|
80
|
+
) => {
|
|
81
|
+
return this.adapter.addDigitalSignatureRetrieveCallback(callback);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
addDigitalSignatureParseCallback: DigitalSignTool['addDigitalSignatureParseCallback'] = (
|
|
85
|
+
callback,
|
|
86
|
+
) => {
|
|
87
|
+
return this.adapter.addDigitalSignatureParseCallback(callback);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
setCryptoProvider: DigitalSignTool['setCryptoProvider'] = (usage, provider, configuration) => {
|
|
91
|
+
return this.adapter.setCryptoProvider(usage, provider, configuration);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
setSealSource: DigitalSignTool['setSealSource'] = (source) => {
|
|
95
|
+
return this.adapter.setSealSource(source);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
setDefaultStampPassword: DigitalSignTool['setDefaultStampPassword'] = (stampPassword) => {
|
|
99
|
+
return this.adapter.setDefaultStampPassword(stampPassword);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
setDefaultSealPassword: DigitalSignTool['setDefaultSealPassword'] = (sealPassword) => {
|
|
103
|
+
return this.adapter.setDefaultSealPassword(sealPassword);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
setDefaultKeystorePassword: DigitalSignTool['setDefaultKeystorePassword'] = (pkPassword) => {
|
|
107
|
+
return this.adapter.setDefaultKeystorePassword(pkPassword);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
setDefaultUSBKeyPassword: DigitalSignTool['setDefaultUSBKeyPassword'] = (pkPassword) => {
|
|
111
|
+
return this.adapter.setDefaultUSBKeyPassword(pkPassword);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
addDigitalSignCallback: DigitalSignTool['addDigitalSignCallback'] = (callback) => {
|
|
115
|
+
return this.adapter.addDigitalSignCallback(callback);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
setupExternalSealServer: DigitalSignTool['setupExternalSealServer'] = (options) => {
|
|
119
|
+
return this.adapter.setupExternalSealServer(options);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
setDigitalSignOptions: DigitalSignTool['setDigitalSignOptions'] = (options) => {
|
|
123
|
+
return this.adapter.setDigitalSignOptions(options);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
setExternalDigitalSignOptions: DigitalSignTool['setExternalDigitalSignOptions'] = (options) => {
|
|
127
|
+
return this.adapter.setExternalDigitalSignOptions(options);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
setPDFDigitalSignCaptionOptions: DigitalSignTool['setPDFDigitalSignCaptionOptions'] = (
|
|
131
|
+
options,
|
|
132
|
+
) => {
|
|
133
|
+
return this.adapter.setPDFDigitalSignCaptionOptions(options);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
addDigitalSignature: DigitalSignTool['addDigitalSignature'] = (options, callback) => {
|
|
137
|
+
return this.adapter.addDigitalSignature(options, callback);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
addDigitalSignatureBySelectedSearchHighlight: DigitalSignTool['addDigitalSignatureBySelectedSearchHighlight'] =
|
|
141
|
+
(options) => {
|
|
142
|
+
return this.adapter.addDigitalSignatureBySelectedSearchHighlight(options);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
listDigitalSignatures: DigitalSignTool['listDigitalSignatures'] = (callback) => {
|
|
146
|
+
return this.adapter.listDigitalSignatures(callback);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
getDigitalSignatures: DigitalSignTool['getDigitalSignatures'] = () => {
|
|
150
|
+
return this.adapter.getDigitalSignatures();
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
getDigitalSignaturesCount: DigitalSignTool['getDigitalSignaturesCount'] = () => {
|
|
154
|
+
return this.adapter.getDigitalSignaturesCount();
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
enableDigitalSignatureInfoView: DigitalSignTool['enableDigitalSignatureInfoView'] = (enabled) => {
|
|
158
|
+
return this.adapter.enableDigitalSignatureInfoView(enabled);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
enableDigitalSignatureRevocation: DigitalSignTool['enableDigitalSignatureRevocation'] = (
|
|
162
|
+
enabled,
|
|
163
|
+
) => {
|
|
164
|
+
return this.adapter.enableDigitalSignatureRevocation(enabled);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DocumentClosedCallback,
|
|
3
|
+
DocumentContentResult,
|
|
4
|
+
DocumentOpenedCallback,
|
|
5
|
+
DocumentSavedCallback,
|
|
6
|
+
} from '../api/callbacks';
|
|
7
|
+
import type { DocumentTool, IFileSaveOptions, IFileSaveResult } from '../api/document-tool';
|
|
8
|
+
import { RHC_OFFICE_READER_ID_ATTRIBUTE } from '../viewer/AdapterProtocol';
|
|
3
9
|
import {
|
|
4
10
|
createBridgeToolAdapter,
|
|
5
11
|
type BridgeToolAdapterContext,
|
|
6
12
|
type BridgeToolDescriptor,
|
|
7
13
|
} from '../viewer/BridgeToolAdapter';
|
|
8
14
|
|
|
15
|
+
type ReaderElementWithSaveAs = HTMLElement & {
|
|
16
|
+
saveAs?: (options?: IFileSaveOptions) => Promise<IFileSaveResult>;
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
const DOCUMENT_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
10
20
|
addDocumentOpenedCallback: {
|
|
11
21
|
kind: 'callbackRegister',
|
|
12
22
|
callback: (callbacks, args) => {
|
|
13
23
|
const callback = args[0];
|
|
14
24
|
if (typeof callback === 'function') {
|
|
15
|
-
callbacks.documentOpened.push(callback as
|
|
25
|
+
callbacks.documentOpened.push(callback as DocumentOpenedCallback);
|
|
16
26
|
}
|
|
17
27
|
},
|
|
18
28
|
},
|
|
@@ -48,8 +58,7 @@ const DOCUMENT_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
|
48
58
|
getDocumentContent: {
|
|
49
59
|
kind: 'callbackQuery',
|
|
50
60
|
mapCallbackResult: (result) => {
|
|
51
|
-
|
|
52
|
-
return [content?.fileCacheId, content?.fileBuffer];
|
|
61
|
+
return [result as DocumentContentResult];
|
|
53
62
|
},
|
|
54
63
|
},
|
|
55
64
|
closeDocument: { kind: 'callbackQuery' },
|
|
@@ -68,7 +77,7 @@ const DOCUMENT_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
|
68
77
|
export class DocumentToolImpl implements DocumentTool {
|
|
69
78
|
private readonly adapter: DocumentTool;
|
|
70
79
|
|
|
71
|
-
constructor(context: BridgeToolAdapterContext) {
|
|
80
|
+
constructor(private readonly context: BridgeToolAdapterContext) {
|
|
72
81
|
this.adapter = createBridgeToolAdapter<DocumentTool>(
|
|
73
82
|
'document',
|
|
74
83
|
DOCUMENT_TOOL_DESCRIPTOR,
|
|
@@ -129,6 +138,23 @@ export class DocumentToolImpl implements DocumentTool {
|
|
|
129
138
|
};
|
|
130
139
|
|
|
131
140
|
saveAs: DocumentTool['saveAs'] = (options) => {
|
|
141
|
+
const readerId = this.context.bridge.getReaderId();
|
|
142
|
+
if (!readerId) {
|
|
143
|
+
return Promise.resolve({
|
|
144
|
+
success: false,
|
|
145
|
+
action: 'save-as',
|
|
146
|
+
filename: options?.filename,
|
|
147
|
+
error: 'Reader is not mounted or does not expose saveAs.',
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const readerElement = document.querySelector(
|
|
152
|
+
`[${RHC_OFFICE_READER_ID_ATTRIBUTE}="${readerId}"]`,
|
|
153
|
+
) as ReaderElementWithSaveAs | null;
|
|
154
|
+
if (typeof readerElement?.saveAs === 'function') {
|
|
155
|
+
return readerElement.saveAs(options);
|
|
156
|
+
}
|
|
157
|
+
|
|
132
158
|
return this.adapter.saveAs(options);
|
|
133
159
|
};
|
|
134
160
|
|