@rhc-office/sdk 6.6.268 → 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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +446 -360
- 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 +5 -27
- package/dist/tools/AnnotationToolImpl.d.ts.map +1 -1
- package/dist/tools/DigitalSignToolImpl.d.ts.map +1 -1
- 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/UIToolImpl.d.ts +13 -0
- package/dist/tools/UIToolImpl.d.ts.map +1 -1
- package/dist/tools/index.d.ts +2 -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 -4
- 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 +2 -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 +2 -0
- package/src/tools/AnnotationToolImpl.ts +71 -165
- package/src/tools/DigitalSignToolImpl.ts +13 -2
- package/src/tools/DocumentToolImpl.ts +8 -4
- package/src/tools/PageArrangeToolImpl.ts +99 -0
- package/src/tools/SecurityToolImpl.ts +48 -0
- package/src/tools/UIToolImpl.ts +98 -12
- package/src/tools/index.ts +2 -1
- package/src/viewer/AdapterProtocol.ts +4 -0
- package/src/viewer/BridgeToolAdapter.ts +11 -2
- package/src/viewer/DocumentSDK.ts +58 -30
- 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 +75 -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,6 +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';
|
|
19
21
|
export * from './tools';
|
|
20
22
|
export * from './viewer';
|
|
@@ -1,10 +1,47 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AnnotationEventCallback,
|
|
3
|
+
AnnotationMode,
|
|
4
|
+
AnnotationRecord,
|
|
5
|
+
AnnotationTool,
|
|
6
|
+
} from '../api/annotation-tool';
|
|
3
7
|
import {
|
|
4
8
|
createBridgeToolAdapter,
|
|
5
9
|
type BridgeToolAdapterContext,
|
|
6
10
|
type BridgeToolDescriptor,
|
|
7
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
|
+
};
|
|
8
45
|
|
|
9
46
|
const ANNOTATION_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
10
47
|
addAnnotationEventCallback: {
|
|
@@ -16,74 +53,35 @@ const ANNOTATION_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
|
16
53
|
}
|
|
17
54
|
},
|
|
18
55
|
},
|
|
19
|
-
|
|
20
|
-
kind: '
|
|
21
|
-
|
|
22
|
-
const callback = args[0];
|
|
23
|
-
if (typeof callback === 'function') {
|
|
24
|
-
callbacks.annotationPersist.push(callback as (event: unknown) => void);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
56
|
+
isInAnnotationMode: {
|
|
57
|
+
kind: 'stateGetter',
|
|
58
|
+
state: (state) => state.annotationEnabled,
|
|
27
59
|
},
|
|
28
|
-
|
|
29
|
-
kind: '
|
|
30
|
-
|
|
31
|
-
const callback = args[0];
|
|
32
|
-
if (typeof callback === 'function') {
|
|
33
|
-
callbacks.annotationRetrieve.push(callback as (event: unknown) => void);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
60
|
+
getAnnotationMode: {
|
|
61
|
+
kind: 'stateGetter',
|
|
62
|
+
state: (state) => normalizeAnnotationMode(state.annotationMode),
|
|
36
63
|
},
|
|
37
|
-
|
|
38
|
-
kind: '
|
|
39
|
-
|
|
40
|
-
const callback = args[0];
|
|
41
|
-
if (typeof callback === 'function') {
|
|
42
|
-
callbacks.digitalAnnotationRetrieve.push(
|
|
43
|
-
callback as (annotations: IDigitalAnnotationInfo[]) => void,
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
64
|
+
getAnnotations: {
|
|
65
|
+
kind: 'stateGetter',
|
|
66
|
+
state: (state) => getPublishedAnnotations(state),
|
|
47
67
|
},
|
|
48
|
-
|
|
68
|
+
getAnnotationsCount: {
|
|
49
69
|
kind: 'stateGetter',
|
|
50
|
-
state: (state) => state.
|
|
70
|
+
state: (state) => getPublishedAnnotations(state).length,
|
|
51
71
|
},
|
|
52
|
-
getAnnotations: { kind: 'stateGetter', state: () => [] },
|
|
53
|
-
getAnnotationsCount: { kind: 'stateGetter', state: () => 0 },
|
|
54
|
-
queryAnnotationsBy: { kind: 'stateGetter', state: () => [] },
|
|
55
|
-
setToolSource: { kind: 'command' },
|
|
56
72
|
openAnnotationView: { kind: 'command' },
|
|
57
73
|
closeAnnotationView: { kind: 'command' },
|
|
58
|
-
openTextAnnotationView: { kind: 'command' },
|
|
59
|
-
setTextAnnotationFontColor: { kind: 'command' },
|
|
60
|
-
setTextAnnotationFontSize: { kind: 'command' },
|
|
61
|
-
closeTextAnnotationView: { kind: 'command' },
|
|
62
|
-
createTextAnnotation: { kind: 'command' },
|
|
63
|
-
setPersistToDocument: { kind: 'command' },
|
|
64
74
|
saveAnnotations: { kind: 'callbackQuery' },
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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' },
|
|
70
80
|
selectAnnotationTool: { kind: 'command' },
|
|
71
|
-
|
|
72
|
-
setAnnotationPenType: { kind: 'command' },
|
|
73
|
-
appendAnnotations: { kind: 'callbackQuery' },
|
|
74
|
-
batchAppendAnnotations: { kind: 'callbackQuery' },
|
|
81
|
+
selectAnnotationStamp: { kind: 'command' },
|
|
75
82
|
setAnnotationPenColor: { kind: 'command' },
|
|
76
83
|
setAnnotationPenWidth: { kind: 'command' },
|
|
77
|
-
|
|
78
|
-
enableAnnotationsInfoView: { kind: 'command' },
|
|
79
|
-
enableAnnotationsDeletion: { kind: 'command' },
|
|
80
|
-
enableAnnotationsDeletionOnlyByAuthor: { kind: 'command' },
|
|
81
|
-
listDigitalStamps: { kind: 'command' },
|
|
82
|
-
listAnnotations: { kind: 'command' },
|
|
83
|
-
deleteAnnotationsBy: { kind: 'command' },
|
|
84
|
-
deleteAnnotationsById: { kind: 'command' },
|
|
85
|
-
addDigitalAnnotation: { kind: 'command' },
|
|
86
|
-
addInkAnnotationCallback: { kind: 'callbackRegister' },
|
|
84
|
+
setAnnotationPenStyle: { kind: 'command' },
|
|
87
85
|
};
|
|
88
86
|
|
|
89
87
|
export class AnnotationToolImpl implements AnnotationTool {
|
|
@@ -97,58 +95,22 @@ export class AnnotationToolImpl implements AnnotationTool {
|
|
|
97
95
|
);
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
setToolSource: AnnotationTool['setToolSource'] = (source) => {
|
|
101
|
-
return this.adapter.setToolSource(source);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
98
|
openAnnotationView: AnnotationTool['openAnnotationView'] = (options) => {
|
|
105
99
|
return this.adapter.openAnnotationView(options);
|
|
106
100
|
};
|
|
107
101
|
|
|
108
|
-
closeAnnotationView: AnnotationTool['closeAnnotationView'] = (
|
|
109
|
-
return this.adapter.closeAnnotationView(
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
openTextAnnotationView: AnnotationTool['openTextAnnotationView'] = () => {
|
|
113
|
-
return this.adapter.openTextAnnotationView();
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
setTextAnnotationFontColor: AnnotationTool['setTextAnnotationFontColor'] = (color) => {
|
|
117
|
-
return this.adapter.setTextAnnotationFontColor(color);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
setTextAnnotationFontSize: AnnotationTool['setTextAnnotationFontSize'] = (size) => {
|
|
121
|
-
return this.adapter.setTextAnnotationFontSize(size);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
closeTextAnnotationView: AnnotationTool['closeTextAnnotationView'] = (saveModifications) => {
|
|
125
|
-
return this.adapter.closeTextAnnotationView(saveModifications);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
createTextAnnotation: AnnotationTool['createTextAnnotation'] = (options) => {
|
|
129
|
-
return this.adapter.createTextAnnotation(options);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
setPersistToDocument: AnnotationTool['setPersistToDocument'] = (persist) => {
|
|
133
|
-
return this.adapter.setPersistToDocument(persist);
|
|
102
|
+
closeAnnotationView: AnnotationTool['closeAnnotationView'] = () => {
|
|
103
|
+
return this.adapter.closeAnnotationView();
|
|
134
104
|
};
|
|
135
105
|
|
|
136
106
|
saveAnnotations: AnnotationTool['saveAnnotations'] = (saveCallback) => {
|
|
137
107
|
return this.adapter.saveAnnotations(saveCallback);
|
|
138
108
|
};
|
|
139
109
|
|
|
140
|
-
saveTextAnnotations: AnnotationTool['saveTextAnnotations'] = () => {
|
|
141
|
-
return this.adapter.saveTextAnnotations();
|
|
142
|
-
};
|
|
143
|
-
|
|
144
110
|
clearAnnotations: AnnotationTool['clearAnnotations'] = () => {
|
|
145
111
|
return this.adapter.clearAnnotations();
|
|
146
112
|
};
|
|
147
113
|
|
|
148
|
-
clearTextAnnotations: AnnotationTool['clearTextAnnotations'] = () => {
|
|
149
|
-
return this.adapter.clearTextAnnotations();
|
|
150
|
-
};
|
|
151
|
-
|
|
152
114
|
undoAnnotation: AnnotationTool['undoAnnotation'] = () => {
|
|
153
115
|
return this.adapter.undoAnnotation();
|
|
154
116
|
};
|
|
@@ -157,24 +119,20 @@ export class AnnotationToolImpl implements AnnotationTool {
|
|
|
157
119
|
return this.adapter.redoAnnotation();
|
|
158
120
|
};
|
|
159
121
|
|
|
160
|
-
|
|
161
|
-
return this.adapter.
|
|
122
|
+
canUndoAnnotation: AnnotationTool['canUndoAnnotation'] = () => {
|
|
123
|
+
return this.adapter.canUndoAnnotation();
|
|
162
124
|
};
|
|
163
125
|
|
|
164
|
-
|
|
165
|
-
return this.adapter.
|
|
126
|
+
canRedoAnnotation: AnnotationTool['canRedoAnnotation'] = () => {
|
|
127
|
+
return this.adapter.canRedoAnnotation();
|
|
166
128
|
};
|
|
167
129
|
|
|
168
|
-
|
|
169
|
-
return this.adapter.
|
|
130
|
+
selectAnnotationTool: AnnotationTool['selectAnnotationTool'] = (tool, options) => {
|
|
131
|
+
return this.adapter.selectAnnotationTool(tool, options);
|
|
170
132
|
};
|
|
171
133
|
|
|
172
|
-
|
|
173
|
-
return this.adapter.
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
batchAppendAnnotations: AnnotationTool['batchAppendAnnotations'] = (inkData, callback) => {
|
|
177
|
-
return this.adapter.batchAppendAnnotations(inkData, callback);
|
|
134
|
+
selectAnnotationStamp: AnnotationTool['selectAnnotationStamp'] = (stamp) => {
|
|
135
|
+
return this.adapter.selectAnnotationStamp(stamp);
|
|
178
136
|
};
|
|
179
137
|
|
|
180
138
|
setAnnotationPenColor: AnnotationTool['setAnnotationPenColor'] = (hexColor) => {
|
|
@@ -185,34 +143,16 @@ export class AnnotationToolImpl implements AnnotationTool {
|
|
|
185
143
|
return this.adapter.setAnnotationPenWidth(penWidth);
|
|
186
144
|
};
|
|
187
145
|
|
|
188
|
-
|
|
189
|
-
return this.adapter.
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
enableAnnotationsInfoView: AnnotationTool['enableAnnotationsInfoView'] = (enabled) => {
|
|
193
|
-
return this.adapter.enableAnnotationsInfoView(enabled);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
enableAnnotationsDeletion: AnnotationTool['enableAnnotationsDeletion'] = (enabled) => {
|
|
197
|
-
return this.adapter.enableAnnotationsDeletion(enabled);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
enableAnnotationsDeletionOnlyByAuthor: AnnotationTool['enableAnnotationsDeletionOnlyByAuthor'] = (
|
|
201
|
-
onlyByAuthor,
|
|
202
|
-
) => {
|
|
203
|
-
return this.adapter.enableAnnotationsDeletionOnlyByAuthor(onlyByAuthor);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
listDigitalStamps: AnnotationTool['listDigitalStamps'] = () => {
|
|
207
|
-
return this.adapter.listDigitalStamps();
|
|
146
|
+
setAnnotationPenStyle: AnnotationTool['setAnnotationPenStyle'] = (options) => {
|
|
147
|
+
return this.adapter.setAnnotationPenStyle(options);
|
|
208
148
|
};
|
|
209
149
|
|
|
210
150
|
isInAnnotationMode: AnnotationTool['isInAnnotationMode'] = () => {
|
|
211
151
|
return this.adapter.isInAnnotationMode();
|
|
212
152
|
};
|
|
213
153
|
|
|
214
|
-
|
|
215
|
-
return this.adapter.
|
|
154
|
+
getAnnotationMode: AnnotationTool['getAnnotationMode'] = () => {
|
|
155
|
+
return this.adapter.getAnnotationMode();
|
|
216
156
|
};
|
|
217
157
|
|
|
218
158
|
getAnnotations: AnnotationTool['getAnnotations'] = () => {
|
|
@@ -223,41 +163,7 @@ export class AnnotationToolImpl implements AnnotationTool {
|
|
|
223
163
|
return this.adapter.getAnnotationsCount();
|
|
224
164
|
};
|
|
225
165
|
|
|
226
|
-
queryAnnotationsBy: AnnotationTool['queryAnnotationsBy'] = (query) => {
|
|
227
|
-
return this.adapter.queryAnnotationsBy(query);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
deleteAnnotationsBy: AnnotationTool['deleteAnnotationsBy'] = (query, prompt) => {
|
|
231
|
-
return this.adapter.deleteAnnotationsBy(query, prompt);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
deleteAnnotationsById: AnnotationTool['deleteAnnotationsById'] = (annotationIds, prompt) => {
|
|
235
|
-
return this.adapter.deleteAnnotationsById(annotationIds, prompt);
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
addDigitalAnnotation: AnnotationTool['addDigitalAnnotation'] = (options) => {
|
|
239
|
-
return this.adapter.addDigitalAnnotation(options);
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
addInkAnnotationCallback: AnnotationTool['addInkAnnotationCallback'] = (callback) => {
|
|
243
|
-
return this.adapter.addInkAnnotationCallback(callback);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
166
|
addAnnotationEventCallback: AnnotationTool['addAnnotationEventCallback'] = (callback) => {
|
|
247
167
|
return this.adapter.addAnnotationEventCallback(callback);
|
|
248
168
|
};
|
|
249
|
-
|
|
250
|
-
addAnnotationPersistCallback: AnnotationTool['addAnnotationPersistCallback'] = (callback) => {
|
|
251
|
-
return this.adapter.addAnnotationPersistCallback(callback);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
addAnnotationRetrieveCallback: AnnotationTool['addAnnotationRetrieveCallback'] = (callback) => {
|
|
255
|
-
return this.adapter.addAnnotationRetrieveCallback(callback);
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
addDigitalAnnotationRetrieveCallback: AnnotationTool['addDigitalAnnotationRetrieveCallback'] = (
|
|
259
|
-
callback,
|
|
260
|
-
) => {
|
|
261
|
-
return this.adapter.addDigitalAnnotationRetrieveCallback(callback);
|
|
262
|
-
};
|
|
263
169
|
}
|
|
@@ -5,6 +5,11 @@ import {
|
|
|
5
5
|
type BridgeToolAdapterContext,
|
|
6
6
|
type BridgeToolDescriptor,
|
|
7
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
|
+
};
|
|
8
13
|
|
|
9
14
|
const DIGITAL_SIGN_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
10
15
|
addDigitalSignatureRetrieveCallback: {
|
|
@@ -47,8 +52,14 @@ const DIGITAL_SIGN_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
|
47
52
|
addDigitalSignature: { kind: 'callbackQuery' },
|
|
48
53
|
addDigitalSignatureBySelectedSearchHighlight: { kind: 'command' },
|
|
49
54
|
listDigitalSignatures: { kind: 'callbackQuery' },
|
|
50
|
-
getDigitalSignatures: {
|
|
51
|
-
|
|
55
|
+
getDigitalSignatures: {
|
|
56
|
+
kind: 'stateGetter',
|
|
57
|
+
state: (state) => getPublishedDigitalSignatures(state),
|
|
58
|
+
},
|
|
59
|
+
getDigitalSignaturesCount: {
|
|
60
|
+
kind: 'stateGetter',
|
|
61
|
+
state: (state) => getPublishedDigitalSignatures(state).length,
|
|
62
|
+
},
|
|
52
63
|
enableDigitalSignatureInfoView: { kind: 'command' },
|
|
53
64
|
enableDigitalSignatureRevocation: { kind: 'command' },
|
|
54
65
|
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DocumentClosedCallback,
|
|
3
|
+
DocumentContentResult,
|
|
4
|
+
DocumentOpenedCallback,
|
|
5
|
+
DocumentSavedCallback,
|
|
6
|
+
} from '../api/callbacks';
|
|
2
7
|
import type { DocumentTool, IFileSaveOptions, IFileSaveResult } from '../api/document-tool';
|
|
3
8
|
import { RHC_OFFICE_READER_ID_ATTRIBUTE } from '../viewer/AdapterProtocol';
|
|
4
9
|
import {
|
|
@@ -17,7 +22,7 @@ const DOCUMENT_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
|
17
22
|
callback: (callbacks, args) => {
|
|
18
23
|
const callback = args[0];
|
|
19
24
|
if (typeof callback === 'function') {
|
|
20
|
-
callbacks.documentOpened.push(callback as
|
|
25
|
+
callbacks.documentOpened.push(callback as DocumentOpenedCallback);
|
|
21
26
|
}
|
|
22
27
|
},
|
|
23
28
|
},
|
|
@@ -53,8 +58,7 @@ const DOCUMENT_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
|
|
|
53
58
|
getDocumentContent: {
|
|
54
59
|
kind: 'callbackQuery',
|
|
55
60
|
mapCallbackResult: (result) => {
|
|
56
|
-
|
|
57
|
-
return [content?.fileCacheId, content?.fileBuffer];
|
|
61
|
+
return [result as DocumentContentResult];
|
|
58
62
|
},
|
|
59
63
|
},
|
|
60
64
|
closeDocument: { kind: 'callbackQuery' },
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { PageArrangeTool } from '../api/page-arrange-tool';
|
|
2
|
+
import {
|
|
3
|
+
createBridgeToolAdapter,
|
|
4
|
+
type BridgeToolAdapterContext,
|
|
5
|
+
type BridgeToolDescriptor,
|
|
6
|
+
} from '../viewer/BridgeToolAdapter';
|
|
7
|
+
|
|
8
|
+
const createPageArrangeToolDescriptor = (): BridgeToolDescriptor => ({
|
|
9
|
+
clearContent: { kind: 'command', returnsResult: true },
|
|
10
|
+
commit: { kind: 'command', returnsResult: true },
|
|
11
|
+
deletePages: { kind: 'command', returnsResult: true },
|
|
12
|
+
duplicatePages: { kind: 'command', returnsResult: true },
|
|
13
|
+
execute: { kind: 'command', returnsResult: true },
|
|
14
|
+
extractPages: { kind: 'command', returnsResult: true },
|
|
15
|
+
getSnapshot: { kind: 'query' },
|
|
16
|
+
importDocument: { kind: 'command', returnsResult: true },
|
|
17
|
+
moveAfter: { kind: 'command', returnsResult: true },
|
|
18
|
+
moveBefore: { kind: 'command', returnsResult: true },
|
|
19
|
+
newPage: { kind: 'command', returnsResult: true },
|
|
20
|
+
rotateLeft: { kind: 'command', returnsResult: true },
|
|
21
|
+
rotateRight: { kind: 'command', returnsResult: true },
|
|
22
|
+
undo: { kind: 'command', returnsResult: true },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const normalizePageArrangeBytes = (data: Uint8Array | ArrayBuffer): Uint8Array => {
|
|
26
|
+
if (data instanceof Uint8Array) {
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return new Uint8Array(data);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export class PageArrangeToolImpl implements PageArrangeTool {
|
|
34
|
+
private readonly adapter: PageArrangeTool;
|
|
35
|
+
|
|
36
|
+
constructor(context: BridgeToolAdapterContext) {
|
|
37
|
+
this.adapter = createBridgeToolAdapter<PageArrangeTool>(
|
|
38
|
+
'pageArrange',
|
|
39
|
+
createPageArrangeToolDescriptor(),
|
|
40
|
+
context,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getSnapshot: PageArrangeTool['getSnapshot'] = () => {
|
|
45
|
+
return this.adapter.getSnapshot();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
execute: PageArrangeTool['execute'] = (action) => {
|
|
49
|
+
return this.adapter.execute(action);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
newPage: PageArrangeTool['newPage'] = (index, options) => {
|
|
53
|
+
return this.adapter.newPage(index, options);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
deletePages: PageArrangeTool['deletePages'] = (pageIndices) => {
|
|
57
|
+
return this.adapter.deletePages(pageIndices);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
duplicatePages: PageArrangeTool['duplicatePages'] = (pageIndices, insertIndex) => {
|
|
61
|
+
return this.adapter.duplicatePages(pageIndices, insertIndex);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
rotateLeft: PageArrangeTool['rotateLeft'] = (pageIndices) => {
|
|
65
|
+
return this.adapter.rotateLeft(pageIndices);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
rotateRight: PageArrangeTool['rotateRight'] = (pageIndices) => {
|
|
69
|
+
return this.adapter.rotateRight(pageIndices);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
clearContent: PageArrangeTool['clearContent'] = (pageIndices) => {
|
|
73
|
+
return this.adapter.clearContent(pageIndices);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
moveBefore: PageArrangeTool['moveBefore'] = (pageIndices, targetIndex) => {
|
|
77
|
+
return this.adapter.moveBefore(pageIndices, targetIndex);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
moveAfter: PageArrangeTool['moveAfter'] = (pageIndices, targetIndex) => {
|
|
81
|
+
return this.adapter.moveAfter(pageIndices, targetIndex);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
importDocument: PageArrangeTool['importDocument'] = (data, options) => {
|
|
85
|
+
return this.adapter.importDocument(normalizePageArrangeBytes(data), options);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
extractPages: PageArrangeTool['extractPages'] = (pageIndices, suggestedFileName) => {
|
|
89
|
+
return this.adapter.extractPages(pageIndices, suggestedFileName);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
undo: PageArrangeTool['undo'] = () => {
|
|
93
|
+
return this.adapter.undo();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
commit: PageArrangeTool['commit'] = () => {
|
|
97
|
+
return this.adapter.commit();
|
|
98
|
+
};
|
|
99
|
+
}
|