forked from PSPDFKit/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
707 lines (655 loc) · 24.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// Copyright © 2018-2019 PSPDFKit GmbH. All rights reserved.
//
// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
// This notice may not be removed from this file.
//
import PropTypes from "prop-types";
import React from "react";
import {
requireNativeComponent,
Platform,
findNodeHandle,
NativeModules,
UIManager,
} from "react-native";
class PSPDFKitView extends React.Component {
_nextRequestId = 1;
_requestMap = new Map();
render() {
if (Platform.OS === "ios" || Platform.OS === "android") {
const onCloseButtonPressedHandler = this.props.onCloseButtonPressed
? (event) => {
this.props.onCloseButtonPressed(event.nativeEvent);
}
: null;
return (
<RCTPSPDFKitView
ref="pdfView"
fragmentTag="PSPDFKitView.FragmentTag"
{...this.props}
onCloseButtonPressed={onCloseButtonPressedHandler}
onStateChanged={this._onStateChanged}
onDocumentSaved={this._onDocumentSaved}
onDocumentSaveFailed={this._onDocumentSaveFailed}
onDocumentLoadFailed={this._onDocumentLoadFailed}
onAnnotationTapped={this._onAnnotationTapped}
onAnnotationsChanged={this._onAnnotationsChanged}
onNavigationButtonClicked={this._onNavigationButtonClicked}
onDataReturned={this._onDataReturned}
/>
);
} else {
return null;
}
}
_onStateChanged = (event) => {
if (this.props.onStateChanged) {
this.props.onStateChanged(event.nativeEvent);
}
};
_onDocumentSaved = (event) => {
if (this.props.onDocumentSaved) {
this.props.onDocumentSaved(event.nativeEvent);
}
};
_onDocumentSaveFailed = (event) => {
if (this.props.onDocumentSaveFailed) {
this.props.onDocumentSaveFailed(event.nativeEvent);
}
};
_onDocumentLoadFailed = (event) => {
if (this.props.onDocumentLoadFailed) {
this.props.onDocumentLoadFailed(event.nativeEvent);
}
};
_onAnnotationTapped = (event) => {
if (this.props.onAnnotationTapped) {
this.props.onAnnotationTapped(event.nativeEvent);
}
};
_onAnnotationsChanged = (event) => {
if (this.props.onAnnotationsChanged) {
this.props.onAnnotationsChanged(event.nativeEvent);
}
};
_onNavigationButtonClicked = (event) => {
if (this.props.onNavigationButtonClicked) {
this.props.onNavigationButtonClicked(event.nativeEvent);
}
};
_onDataReturned = (event) => {
let { requestId, result, error } = event.nativeEvent;
let promise = this._requestMap[requestId];
if (result != undefined) {
promise.resolve(result);
} else {
promise.reject(error);
}
this._requestMap.delete(requestId);
};
/**
* Enters the annotation creation mode, showing the annotation creation toolbar.
*/
enterAnnotationCreationMode = function () {
if (Platform.OS === "android") {
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.enterAnnotationCreationMode,
[]
);
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.enterAnnotationCreationMode(
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Exits the currently active mode, hiding all toolbars.
*/
exitCurrentlyActiveMode = function () {
if (Platform.OS === "android") {
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.exitCurrentlyActiveMode,
[]
);
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.exitCurrentlyActiveMode(
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Saves the currently opened document.
*
* Returns a promise resolving to true if the document was saved, and false otherwise.
*/
saveCurrentDocument = function () {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.saveCurrentDocument,
[requestId]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.saveCurrentDocument(
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Gets all annotations of the given type from the page.
*
* @param pageIndex The page to get the annotations for.
* @param type The type of annotations to get (See here for types https://pspdfkit.com/guides/server/current/api/json-format/) or null to get all annotations.
*
* Returns a promise resolving an array with the following structure:
* {'annotations' : [instantJson]}
*/
getAnnotations = function (pageIndex, type) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands.getAnnotations,
[requestId, pageIndex, type]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.getAnnotations(
pageIndex,
type,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Adds a new annotation to the current document.
*
* @param annotation InstantJson of the annotation to add.
*
* Returns a promise resolving to true if the annotation was added. Otherwise, returns false if an error has occurred.
*/
addAnnotation = function (annotation) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands.addAnnotation,
[requestId, annotation]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.addAnnotation(
annotation,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Removes an existing annotation from the current document.
*
* @param annotation InstantJson of the annotation to remove.
*
* Returns a promise resolving to true if the annotation was removed. Otherwise, returns false if the annotation couldn't be found.
*/
removeAnnotation = function (annotation) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands.removeAnnotation,
[requestId, annotation]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.removeAnnotation(
annotation,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Gets all unsaved changes to annotations.
*
* Returns a promise resolving to document instant json (https://pspdfkit.com/guides/android/current/importing-exporting/instant-json/#instant-document-json-api-a56628).
*/
getAllUnsavedAnnotations = function () {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.getAllUnsavedAnnotations,
[requestId]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.getAllUnsavedAnnotations(
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Gets all annotations of the given type.
*
* @param type The type of annotations to get (See here for types https://pspdfkit.com/guides/server/current/api/json-format/) or null to get all annotations.
*
* Returns a promise resolving an array with the following structure:
* {'annotations' : [instantJson]}
*/
getAllAnnotations = function (type) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.getAllAnnotations,
[requestId, type]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.getAllAnnotations(
type,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Applies the passed in document instant json.
*
* @param annotations The document instant json to apply.
*
* Returns a promise resolving to true if the annotation was added.
*/
addAnnotations = function (annotations) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands.addAnnotations,
[requestId, annotations]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.addAnnotations(
annotations,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Gets the value of the form element of the fully qualified name.
*
* @param fullyQualifiedName The fully qualified name of the form element.
*
* Returns a promise resolving a dictionary with the following structure:
* {'formElement' : value} or {'error' : 'Failed to get the form field value.'}
*/
getFormFieldValue = function (fullyQualifiedName) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.getFormFieldValue,
[requestId, fullyQualifiedName]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.getFormFieldValue(
fullyQualifiedName,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Set the value of the form element of the fully qualified name.
*
* @param fullyQualifiedName The fully qualified name of the form element.
* @param value The string value form element. For button form elements pass 'selected' or 'deselected'. For choice form elements, pass the index of the choice to select, for example '1'.
*
* Returns a promise resolving to true if the value was set, and false otherwise.
*/
setFormFieldValue = function (fullyQualifiedName, value) {
if (Platform.OS === "android") {
let requestId = this._nextRequestId++;
let requestMap = this._requestMap;
// We create a promise here that will be resolved once onDataReturned is called.
let promise = new Promise(function (resolve, reject) {
requestMap[requestId] = { resolve: resolve, reject: reject };
});
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.pdfView),
this._getViewManagerConfig("RCTPSPDFKitView").Commands
.setFormFieldValue,
[requestId, fullyQualifiedName, value]
);
return promise;
} else if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.setFormFieldValue(
value,
fullyQualifiedName,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Set the left bar button items for the specified view mode.
* Note: The same button item cannot be added to both the left and right bar button items simultaneously.
*
* @param items The list of bar button items. See the full list of button items here: https://pspdfkit.com/api/ios/Classes/PSPDFViewController.html#/Toolbar%20button%20items
* @param viewMode The optional view mode. Can be 'document', 'thumbnails', 'documentEditor' or `null`. If `null` is passed, bar button items for all view modes are set.
* @param animated The animated flag.
*
* @platform ios
*/
setLeftBarButtonItems = function (items, viewMode, animated) {
if (Platform.OS === "ios") {
NativeModules.PSPDFKitViewManager.setLeftBarButtonItems(
items,
viewMode,
animated,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Get the left bar button items for the specified view mode.
*
* @param viewMode The optional view mode. Can be 'document', 'thumbnails', 'documentEditor' or `null`. If `null` is passed, bar button items for the current view mode are returned.
*
* Returns a promise resolving an array with the following structure:
* ['outlineButtonItem', 'searchButtonItem'] or a dictionary with the following error {'error' : 'Failed to get the left bar button items.'}
* @platform ios
*/
getLeftBarButtonItemsForViewMode = function (viewMode) {
if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.getLeftBarButtonItemsForViewMode(
viewMode,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Set the right bar button items for the specified view mode.
* Note: The same button item cannot be added to both the left and right bar button items simultaneously.
*
* @param items The list of bar button items. See the full list of button items here: https://pspdfkit.com/api/ios/Classes/PSPDFViewController.html#/Toolbar%20button%20items
* @param viewMode The optional view mode. Can be 'document', 'thumbnails', 'documentEditor' or `null`. If `null` is passed, bar button items for all view modes are set.
* @param animated The animated flag.
*
* @platform ios
*/
setRightBarButtonItems = function (items, viewMode, animated) {
if (Platform.OS === "ios") {
NativeModules.PSPDFKitViewManager.setRightBarButtonItems(
items,
viewMode,
animated,
findNodeHandle(this.refs.pdfView)
);
}
};
/**
* Get the right bar button items for the specified view mode.
*
* @param viewMode The optional view mode. Can be 'document', 'thumbnails', 'documentEditor' or `null`. If `null` is passed, bar button items for the current view mode are returned.
*
* Returns a promise resolving an array with the following structure:
* ['annotationButtonItem', 'documentEditorButtonItem'] or a dictionary with the following error {'error' : 'Failed to get the right bar button items.'}
* @platform ios
*/
getRightBarButtonItemsForViewMode = function (viewMode) {
if (Platform.OS === "ios") {
return NativeModules.PSPDFKitViewManager.getRightBarButtonItemsForViewMode(
viewMode,
findNodeHandle(this.refs.pdfView)
);
}
};
_getViewManagerConfig = (viewManagerName) => {
const version = NativeModules.PlatformConstants.reactNativeVersion.minor;
if (version >= 58) {
return UIManager.getViewManagerConfig(viewManagerName);
} else {
return UIManager[viewManagerName];
}
};
}
PSPDFKitView.propTypes = {
/**
* Path to the PDF file that should be displayed.
*/
document: PropTypes.string,
/**
* Configuration object, to customize the appearance and behavior of PSPDFKit.
* See https://pspdfkit.com/guides/ios/current/getting-started/pspdfconfiguration/ for more information.
*
* Note: On iOS, set `useParentNavigationBar` to `true`, to use the parent navigation bar instead of creating its own,
* if the view is already contained in a navigation controller (like when using NavigatorIOS, react-native-navigation, ...).
*/
configuration: PropTypes.object,
/**
* Page index of the document that will be shown.
*/
pageIndex: PropTypes.number,
/**
* Controls wheter a navigation bar is created and shown or not. Defaults to showing a navigation bar (false).
*
* @platform ios
*/
hideNavigationBar: PropTypes.bool,
/**
* Whether the close button should be shown in the navigation bar. Disabled by default.
* Will call `onCloseButtonPressed` if it was provided, when tapped.
* If `onCloseButtonPressed` was not provided, PSPDFKitView will be automatically dismissed.
*
* @platform ios
*/
showCloseButton: PropTypes.bool,
/**
* Controls wheter or not the default action for tapped annotations is processed. Defaults to processing the action (false).
*/
disableDefaultActionForTappedAnnotations: PropTypes.bool,
/**
* Controls whether or not the document will be automatically saved. Defaults to automatically saving (false).
*/
disableAutomaticSaving: PropTypes.bool,
/**
* Controls the author name that is set for new annotations.
* If not set and the user hasn't specified it before the user will be asked and the result will be saved.
* The value set here will be persisted and the user will not be asked even if this is not set the next time.
*/
annotationAuthorName: PropTypes.string,
/**
* Callback that is called when the user tapped the close button.
* If you provide this function, you need to handle dismissal yourself.
* If you don't provide this function, PSPDFKitView will be automatically dismissed.
*
* @platform ios
*/
onCloseButtonPressed: PropTypes.func,
/**
* Callback that is called when the document is saved.
*/
onDocumentSaved: PropTypes.func,
/**
* Callback that is called when the document fails to save.
* Returns a string error with the error message.
* {
* error: "Error message",
* }
*/
onDocumentSaveFailed: PropTypes.func,
/**
* Callback that is called when an annotation is added, changed, or removed.
* Returns an object with the following structure:
* {
* change: "changed"|"added"|"removed",
* annotations: [instantJson]
* }
*/
onAnnotationTapped: PropTypes.func,
/**
* Callback that is called when an annotation is added, changed, or removed.
* Returns an object with the following structure:
* {
* change: "changed"|"added"|"removed",
* annotations: [instantJson]
* }
*/
onAnnotationsChanged: PropTypes.func,
/**
* Callback that is called when the state of the PSPDFKitView changes.
* Returns an object with the following structure:
* {
* documentLoaded: bool,
* currentPageIndex: int,
* pageCount: int,
* annotationCreationActive: bool,
* annotationEditingActive: bool,
* textSelectionActive: bool,
* formEditingActive: bool,
* }
*
*/
onStateChanged: PropTypes.func,
/**
* fragmentTag: A tag used to identify a single PdfFragment in the view hierarchy.
* This needs to be unique in the view hierarchy.
*
* @platform android
*/
fragmentTag: PropTypes.string,
/**
* menuItemGrouping: Can be used to specfiy a custom grouping for the menu items in the annotation creation toolbar.
*/
menuItemGrouping: PropTypes.array,
/**
* leftBarButtonItems: Can be used to specfiy an array of the left button items.
* Note: The same button item cannot be added to both the left and right bar button items simultaneously.
* The full list of button items: https://pspdfkit.com/api/ios/Classes/PSPDFViewController.html#/Toolbar%20button%20items
*
* @platform ios
*/
leftBarButtonItems: PropTypes.array,
/**
* rightBarButtonItems: Can be used to specfiy an array of the right button items.
* Note: The same button item cannot be added to both the left and right bar button items simultaneously.
* The full list of button items: https://pspdfkit.com/api/ios/Classes/PSPDFViewController.html#/Toolbar%20button%20items
*
* @platform ios
*/
rightBarButtonItems: PropTypes.array,
/**
* toolbarTitle: Can be used to specfiy a custom toolbar title on iOS by setting the `title` property of the `PSPDFViewController`.
* Note: You need to set `showDocumentLabel`, `useParentNavigationBar`, and `allowToolbarTitleChange` to false in your Configuration before setting the custom title.
* See `ConfiguredPDFViewComponent` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
*
* @platform ios
*/
toolbarTitle: PropTypes.string,
/**
* showNavigationButtonInToolbar: When set to true the toolbar integrated into the PSPDFKitView will display a back button in the top left corner.
*
* @platform android
*/
showNavigationButtonInToolbar: PropTypes.bool,
/**
* onNavigationButtonClicked: When showNavigationButtonInToolbar is set to true this will notify you when the back button is clicked.
*
* @platform android
*/
onNavigationButtonClicked: PropTypes.func,
/**
* availableFontNames: Can be used to specfiy the available font names in the font picker.
*
* Note on iOS: You need to set the desired font family names as `UIFontDescriptor`. See https://developer.apple.com/documentation/uikit/uifontdescriptor?language=objc
* See `CustomFontPicker` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
*
*/
availableFontNames: PropTypes.array,
/**
* selectedFontName: Can be used to specfiy the current selected font in the font picker.
*
* Note on iOS: You need to set the desired font family name as `UIFontDescriptor`. See https://developer.apple.com/documentation/uikit/uifontdescriptor?language=objc
* See `CustomFontPicker` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
*
* Note on Android: This is the default font that is selected, if the users changes the font that will become the new default.
*/
selectedFontName: PropTypes.string,
/**
* showDownloadableFonts: Can be used to show or hide the downloadable fonts section in the font picker. Defaults to showing a the downloadable fonts (true).
* See `CustomFontPicker` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
*
* @platform ios
*/
showDownloadableFonts: PropTypes.bool,
};
if (Platform.OS === "ios" || Platform.OS === "android") {
var RCTPSPDFKitView = requireNativeComponent(
"RCTPSPDFKitView",
PSPDFKitView,
{
nativeOnly: {
testID: true,
accessibilityComponentType: true,
renderToHardwareTextureAndroid: true,
accessibilityLabel: true,
accessibilityLiveRegion: true,
importantForAccessibility: true,
onLayout: true,
nativeID: true,
},
}
);
module.exports = PSPDFKitView;
}