@rhc-office/sdk 6.6.268 → 6.6.363

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.
Files changed (78) hide show
  1. package/README.md +1 -5
  2. package/dist/api/annotation-tool.d.ts +187 -102
  3. package/dist/api/annotation-tool.d.ts.map +1 -1
  4. package/dist/api/callbacks.d.ts +32 -6
  5. package/dist/api/callbacks.d.ts.map +1 -1
  6. package/dist/api/document-sdk.d.ts +6 -5
  7. package/dist/api/document-sdk.d.ts.map +1 -1
  8. package/dist/api/document-tool.d.ts +19 -11
  9. package/dist/api/document-tool.d.ts.map +1 -1
  10. package/dist/api/menu-visibility.d.ts +6 -1
  11. package/dist/api/menu-visibility.d.ts.map +1 -1
  12. package/dist/api/page-arrange-tool.d.ts +28 -0
  13. package/dist/api/page-arrange-tool.d.ts.map +1 -0
  14. package/dist/api/security-tool.d.ts +21 -0
  15. package/dist/api/security-tool.d.ts.map +1 -0
  16. package/dist/api/ui-tool.d.ts +19 -0
  17. package/dist/api/ui-tool.d.ts.map +1 -1
  18. package/dist/browser/document-viewer.js +1 -1
  19. package/dist/browser/document-viewer.js.map +1 -1
  20. package/dist/index.d.ts +2 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +469 -359
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.umd.cjs +1 -1
  25. package/dist/index.umd.cjs.map +1 -1
  26. package/dist/tools/AnnotationToolImpl.d.ts +8 -27
  27. package/dist/tools/AnnotationToolImpl.d.ts.map +1 -1
  28. package/dist/tools/DigitalSignToolImpl.d.ts.map +1 -1
  29. package/dist/tools/DocumentToolImpl.d.ts.map +1 -1
  30. package/dist/tools/PageArrangeToolImpl.d.ts +21 -0
  31. package/dist/tools/PageArrangeToolImpl.d.ts.map +1 -0
  32. package/dist/tools/SecurityToolImpl.d.ts +12 -0
  33. package/dist/tools/SecurityToolImpl.d.ts.map +1 -0
  34. package/dist/tools/UIToolImpl.d.ts +13 -0
  35. package/dist/tools/UIToolImpl.d.ts.map +1 -1
  36. package/dist/tools/index.d.ts +2 -1
  37. package/dist/tools/index.d.ts.map +1 -1
  38. package/dist/viewer/AdapterProtocol.d.ts +3 -1
  39. package/dist/viewer/AdapterProtocol.d.ts.map +1 -1
  40. package/dist/viewer/BridgeToolAdapter.d.ts +1 -0
  41. package/dist/viewer/BridgeToolAdapter.d.ts.map +1 -1
  42. package/dist/viewer/DocumentSDK.d.ts +10 -4
  43. package/dist/viewer/DocumentSDK.d.ts.map +1 -1
  44. package/dist/viewer/ReaderBridgeClient.d.ts +3 -0
  45. package/dist/viewer/ReaderBridgeClient.d.ts.map +1 -1
  46. package/dist/viewer/ReaderConfiguration.d.ts +0 -1
  47. package/dist/viewer/ReaderConfiguration.d.ts.map +1 -1
  48. package/dist/viewer/ReaderStateStore.d.ts +2 -0
  49. package/dist/viewer/ReaderStateStore.d.ts.map +1 -1
  50. package/dist/viewer/SdkCallbackRegistry.d.ts +2 -2
  51. package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/src/api/annotation-tool.ts +257 -140
  54. package/src/api/callbacks.ts +48 -7
  55. package/src/api/document-sdk.ts +9 -5
  56. package/src/api/document-tool.ts +28 -13
  57. package/src/api/menu-visibility.ts +10 -1
  58. package/src/api/page-arrange-tool.ts +67 -0
  59. package/src/api/security-tool.ts +32 -0
  60. package/src/api/ui-tool.ts +33 -0
  61. package/src/index.ts +2 -0
  62. package/src/tools/AnnotationToolImpl.ts +84 -163
  63. package/src/tools/DigitalSignToolImpl.ts +13 -2
  64. package/src/tools/DocumentToolImpl.ts +8 -4
  65. package/src/tools/PageArrangeToolImpl.ts +99 -0
  66. package/src/tools/SecurityToolImpl.ts +48 -0
  67. package/src/tools/UIToolImpl.ts +98 -12
  68. package/src/tools/index.ts +2 -1
  69. package/src/viewer/AdapterProtocol.ts +4 -0
  70. package/src/viewer/BridgeToolAdapter.ts +11 -2
  71. package/src/viewer/DocumentSDK.ts +120 -30
  72. package/src/viewer/ReaderBridgeClient.ts +9 -0
  73. package/src/viewer/ReaderConfiguration.ts +0 -2
  74. package/src/viewer/ReaderStateStore.ts +13 -1
  75. package/src/viewer/SdkCallbackRegistry.ts +75 -6
  76. package/dist/tools/Phase1ToolPlaceholder.d.ts +0 -5
  77. package/dist/tools/Phase1ToolPlaceholder.d.ts.map +0 -1
  78. package/src/tools/Phase1ToolPlaceholder.ts +0 -35
@@ -10,8 +10,17 @@ export interface RibbonMenuItemVisibility {
10
10
  [propName: string]: ViewVisibility;
11
11
  }
12
12
 
13
- export interface MenuActionButtonStyle {
13
+ export interface RibbonMenuButtonContentStyle {
14
14
  type: 'Icon' | 'Label' | 'ToolTip';
15
15
  content: string;
16
16
  iconContentType?: 'application/svg' | 'url';
17
+ showLabel?: boolean;
17
18
  }
19
+
20
+ export interface RibbonMenuButtonLabelVisibilityStyle {
21
+ showLabel: boolean;
22
+ }
23
+
24
+ export type MenuActionButtonStyle =
25
+ | RibbonMenuButtonContentStyle
26
+ | RibbonMenuButtonLabelVisibilityStyle;
@@ -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
+ }
@@ -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 { AnnotationTool, IDigitalAnnotationInfo } from '../api/annotation-tool';
2
- import type { AnnotationEventCallback } from '../api/callbacks';
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,38 @@ const ANNOTATION_TOOL_DESCRIPTOR: BridgeToolDescriptor = {
16
53
  }
17
54
  },
18
55
  },
19
- addAnnotationPersistCallback: {
20
- kind: 'callbackRegister',
21
- callback: (callbacks, args) => {
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
- addAnnotationRetrieveCallback: {
29
- kind: 'callbackRegister',
30
- callback: (callbacks, args) => {
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
- addDigitalAnnotationRetrieveCallback: {
38
- kind: 'callbackRegister',
39
- callback: (callbacks, args) => {
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
- isInAnnotationMode: {
68
+ getAnnotationsCount: {
49
69
  kind: 'stateGetter',
50
- state: (state) => state.annotationEnabled,
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
- saveTextAnnotations: { kind: 'command' },
66
- clearAnnotations: { kind: 'command' },
67
- clearTextAnnotations: { kind: 'command' },
68
- undoAnnotation: { kind: 'command' },
69
- redoAnnotation: { kind: 'command' },
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
- showAnnotationColorPicker: { kind: 'command' },
72
- setAnnotationPenType: { kind: 'command' },
73
- appendAnnotations: { kind: 'callbackQuery' },
74
- batchAppendAnnotations: { kind: 'callbackQuery' },
81
+ selectAnnotationStamp: { kind: 'command' },
82
+ getCustomStamps: { kind: 'query' },
83
+ addCustomTextStamp: { kind: 'query' },
84
+ addCustomImageStamp: { kind: 'query' },
75
85
  setAnnotationPenColor: { kind: 'command' },
76
86
  setAnnotationPenWidth: { kind: 'command' },
77
- setAnnotationPenThickness: { kind: 'command' },
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' },
87
+ setAnnotationPenStyle: { kind: 'command' },
87
88
  };
88
89
 
89
90
  export class AnnotationToolImpl implements AnnotationTool {
@@ -97,58 +98,22 @@ export class AnnotationToolImpl implements AnnotationTool {
97
98
  );
98
99
  }
99
100
 
100
- setToolSource: AnnotationTool['setToolSource'] = (source) => {
101
- return this.adapter.setToolSource(source);
102
- };
103
-
104
101
  openAnnotationView: AnnotationTool['openAnnotationView'] = (options) => {
105
102
  return this.adapter.openAnnotationView(options);
106
103
  };
107
104
 
108
- closeAnnotationView: AnnotationTool['closeAnnotationView'] = (saveModifications) => {
109
- return this.adapter.closeAnnotationView(saveModifications);
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);
105
+ closeAnnotationView: AnnotationTool['closeAnnotationView'] = () => {
106
+ return this.adapter.closeAnnotationView();
134
107
  };
135
108
 
136
109
  saveAnnotations: AnnotationTool['saveAnnotations'] = (saveCallback) => {
137
110
  return this.adapter.saveAnnotations(saveCallback);
138
111
  };
139
112
 
140
- saveTextAnnotations: AnnotationTool['saveTextAnnotations'] = () => {
141
- return this.adapter.saveTextAnnotations();
142
- };
143
-
144
113
  clearAnnotations: AnnotationTool['clearAnnotations'] = () => {
145
114
  return this.adapter.clearAnnotations();
146
115
  };
147
116
 
148
- clearTextAnnotations: AnnotationTool['clearTextAnnotations'] = () => {
149
- return this.adapter.clearTextAnnotations();
150
- };
151
-
152
117
  undoAnnotation: AnnotationTool['undoAnnotation'] = () => {
153
118
  return this.adapter.undoAnnotation();
154
119
  };
@@ -157,62 +122,52 @@ export class AnnotationToolImpl implements AnnotationTool {
157
122
  return this.adapter.redoAnnotation();
158
123
  };
159
124
 
160
- selectAnnotationTool: AnnotationTool['selectAnnotationTool'] = (tool) => {
161
- return this.adapter.selectAnnotationTool(tool);
162
- };
163
-
164
- showAnnotationColorPicker: AnnotationTool['showAnnotationColorPicker'] = () => {
165
- return this.adapter.showAnnotationColorPicker();
166
- };
167
-
168
- setAnnotationPenType: AnnotationTool['setAnnotationPenType'] = (penType) => {
169
- return this.adapter.setAnnotationPenType(penType);
125
+ canUndoAnnotation: AnnotationTool['canUndoAnnotation'] = () => {
126
+ return this.adapter.canUndoAnnotation();
170
127
  };
171
128
 
172
- appendAnnotations: AnnotationTool['appendAnnotations'] = (inkData, callback) => {
173
- return this.adapter.appendAnnotations(inkData, callback);
129
+ canRedoAnnotation: AnnotationTool['canRedoAnnotation'] = () => {
130
+ return this.adapter.canRedoAnnotation();
174
131
  };
175
132
 
176
- batchAppendAnnotations: AnnotationTool['batchAppendAnnotations'] = (inkData, callback) => {
177
- return this.adapter.batchAppendAnnotations(inkData, callback);
133
+ selectAnnotationTool: AnnotationTool['selectAnnotationTool'] = (tool, options) => {
134
+ return this.adapter.selectAnnotationTool(tool, options);
178
135
  };
179
136
 
180
- setAnnotationPenColor: AnnotationTool['setAnnotationPenColor'] = (hexColor) => {
181
- return this.adapter.setAnnotationPenColor(hexColor);
137
+ selectAnnotationStamp: AnnotationTool['selectAnnotationStamp'] = (stamp) => {
138
+ return this.adapter.selectAnnotationStamp(stamp);
182
139
  };
183
140
 
184
- setAnnotationPenWidth: AnnotationTool['setAnnotationPenWidth'] = (penWidth) => {
185
- return this.adapter.setAnnotationPenWidth(penWidth);
141
+ getCustomStamps: AnnotationTool['getCustomStamps'] = () => {
142
+ return this.adapter.getCustomStamps();
186
143
  };
187
144
 
188
- setAnnotationPenThickness: AnnotationTool['setAnnotationPenThickness'] = (thickness) => {
189
- return this.adapter.setAnnotationPenThickness(thickness);
145
+ addCustomTextStamp: AnnotationTool['addCustomTextStamp'] = (input) => {
146
+ return this.adapter.addCustomTextStamp(input);
190
147
  };
191
148
 
192
- enableAnnotationsInfoView: AnnotationTool['enableAnnotationsInfoView'] = (enabled) => {
193
- return this.adapter.enableAnnotationsInfoView(enabled);
149
+ addCustomImageStamp: AnnotationTool['addCustomImageStamp'] = (input) => {
150
+ return this.adapter.addCustomImageStamp(input);
194
151
  };
195
152
 
196
- enableAnnotationsDeletion: AnnotationTool['enableAnnotationsDeletion'] = (enabled) => {
197
- return this.adapter.enableAnnotationsDeletion(enabled);
153
+ setAnnotationPenColor: AnnotationTool['setAnnotationPenColor'] = (hexColor) => {
154
+ return this.adapter.setAnnotationPenColor(hexColor);
198
155
  };
199
156
 
200
- enableAnnotationsDeletionOnlyByAuthor: AnnotationTool['enableAnnotationsDeletionOnlyByAuthor'] = (
201
- onlyByAuthor,
202
- ) => {
203
- return this.adapter.enableAnnotationsDeletionOnlyByAuthor(onlyByAuthor);
157
+ setAnnotationPenWidth: AnnotationTool['setAnnotationPenWidth'] = (penWidth) => {
158
+ return this.adapter.setAnnotationPenWidth(penWidth);
204
159
  };
205
160
 
206
- listDigitalStamps: AnnotationTool['listDigitalStamps'] = () => {
207
- return this.adapter.listDigitalStamps();
161
+ setAnnotationPenStyle: AnnotationTool['setAnnotationPenStyle'] = (options) => {
162
+ return this.adapter.setAnnotationPenStyle(options);
208
163
  };
209
164
 
210
165
  isInAnnotationMode: AnnotationTool['isInAnnotationMode'] = () => {
211
166
  return this.adapter.isInAnnotationMode();
212
167
  };
213
168
 
214
- listAnnotations: AnnotationTool['listAnnotations'] = (options) => {
215
- return this.adapter.listAnnotations(options);
169
+ getAnnotationMode: AnnotationTool['getAnnotationMode'] = () => {
170
+ return this.adapter.getAnnotationMode();
216
171
  };
217
172
 
218
173
  getAnnotations: AnnotationTool['getAnnotations'] = () => {
@@ -223,41 +178,7 @@ export class AnnotationToolImpl implements AnnotationTool {
223
178
  return this.adapter.getAnnotationsCount();
224
179
  };
225
180
 
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
181
  addAnnotationEventCallback: AnnotationTool['addAnnotationEventCallback'] = (callback) => {
247
182
  return this.adapter.addAnnotationEventCallback(callback);
248
183
  };
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
184
  }
@@ -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: { kind: 'stateGetter', state: () => [] },
51
- getDigitalSignaturesCount: { kind: 'stateGetter', state: () => 0 },
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 { DocumentClosedCallback, DocumentSavedCallback } from '../api/callbacks';
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 (status: string, error: string) => void);
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
- const content = result as { fileCacheId?: string; fileBuffer?: ArrayBuffer };
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
+ }