File tree Expand file tree Collapse file tree 4 files changed +32
-3
lines changed
Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class PSPDFKitView extends React.Component {
2929 { ...this . props }
3030 onCloseButtonPressed = { onCloseButtonPressedHandler }
3131 onStateChanged = { this . _onStateChanged }
32+ onDocumentSaved = { this . _onDocumentSaved }
3233 />
3334 ) ;
3435 } else {
@@ -41,6 +42,12 @@ class PSPDFKitView extends React.Component {
4142 this . props . onStateChanged ( event . nativeEvent ) ;
4243 }
4344 } ;
45+
46+ _onDocumentSaved = ( event ) => {
47+ if ( this . props . onDocumentSaved ) {
48+ this . props . onDocumentSaved ( event . nativeEvent ) ;
49+ }
50+ } ;
4451
4552 /**
4653 * Enters the annotation creation mode, showing the annotation creation toolbar.
@@ -108,6 +115,12 @@ PSPDFKitView.propTypes = {
108115 * @platform ios
109116 */
110117 onCloseButtonPressed : PropTypes . func ,
118+ /**
119+ * Callback that is called when the document is saved.
120+ *
121+ * @platform ios
122+ */
123+ onDocumentSaved : PropTypes . func ,
111124 /**
112125 * Callback that is called when the state of the PSPDFKitView changes.
113126 * Returns an object with the following structure:
Original file line number Diff line number Diff line change 1717
1818@property (nonatomic , readonly ) PSPDFViewController *pdfController;
1919@property (nonatomic ) BOOL hideNavigationBar;
20-
2120@property (nonatomic , readonly ) UIBarButtonItem *closeButton;
2221@property (nonatomic , copy ) RCTBubblingEventBlock onCloseButtonPressed;
22+ @property (nonatomic , copy ) RCTBubblingEventBlock onDocumentSaved;
2323
2424@end
Original file line number Diff line number Diff line change 1010#import " RCTPSPDFKitView.h"
1111#import < React/RCTUtils.h>
1212
13- @interface RCTPSPDFKitView ()
13+ @interface RCTPSPDFKitView ()<PSPDFDocumentDelegate>
1414
1515@property (nonatomic , nullable ) UIViewController *topController;
1616
@@ -97,4 +97,12 @@ - (UIViewController *)pspdf_parentViewController {
9797 return nil ;
9898}
9999
100+ #pragma mark - PSPDFDocumentDelegate
101+
102+ - (void )pdfDocumentDidSave : (nonnull PSPDFDocument *)document {
103+ if (self.onDocumentSaved ) {
104+ self.onDocumentSaved (@{});
105+ }
106+ }
107+
100108@end
Original file line number Diff line number Diff line change 99
1010#import " RCTPSPDFKitViewManager.h"
1111#import " RCTConvert+PSPDFConfiguration.h"
12+ #import " RCTConvert+PSPDFDocument.h"
1213#import " RCTPSPDFKitView.h"
1314
1415@import PSPDFKit;
@@ -18,7 +19,12 @@ @implementation RCTPSPDFKitViewManager
1819
1920RCT_EXPORT_MODULE ()
2021
21- RCT_REMAP_VIEW_PROPERTY(document, pdfController.document, PSPDFDocument)
22+ RCT_CUSTOM_VIEW_PROPERTY(document, pdfController.document, RCTPSPDFKitView) {
23+ if (json) {
24+ view.pdfController .document = [RCTConvert PSPDFDocument: json];
25+ view.pdfController .document .delegate = (id <PSPDFDocumentDelegate>)view;
26+ }
27+ }
2228
2329RCT_REMAP_VIEW_PROPERTY (pageIndex, pdfController.pageIndex, NSUInteger )
2430
@@ -42,6 +48,8 @@ @implementation RCTPSPDFKitViewManager
4248
4349RCT_EXPORT_VIEW_PROPERTY (onCloseButtonPressed, RCTBubblingEventBlock)
4450
51+ RCT_EXPORT_VIEW_PROPERTY(onDocumentSaved, RCTBubblingEventBlock)
52+
4553- (UIView *)view {
4654 return [[RCTPSPDFKitView alloc ] init ];
4755}
You can’t perform that action at this time.
0 commit comments