Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PSPDFKitView extends React.Component {
{...this.props}
onCloseButtonPressed={onCloseButtonPressedHandler}
onStateChanged={this._onStateChanged}
onDocumentSaved={this._onDocumentSaved}
/>
);
} else {
Expand All @@ -41,6 +42,12 @@ class PSPDFKitView extends React.Component {
this.props.onStateChanged(event.nativeEvent);
}
};

_onDocumentSaved = (event) => {
if (this.props.onDocumentSaved) {
this.props.onDocumentSaved(event.nativeEvent);
}
};

/**
* Enters the annotation creation mode, showing the annotation creation toolbar.
Expand Down Expand Up @@ -108,6 +115,12 @@ PSPDFKitView.propTypes = {
* @platform ios
*/
onCloseButtonPressed: PropTypes.func,
/**
* Callback that is called when the document is saved.
*
* @platform ios
*/
onDocumentSaved: PropTypes.func,
/**
* Callback that is called when the state of the PSPDFKitView changes.
* Returns an object with the following structure:
Expand Down
2 changes: 1 addition & 1 deletion ios/RCTPSPDFKit/RCTPSPDFKitView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

@property (nonatomic, readonly) PSPDFViewController *pdfController;
@property (nonatomic) BOOL hideNavigationBar;

@property (nonatomic, readonly) UIBarButtonItem *closeButton;
@property (nonatomic, copy) RCTBubblingEventBlock onCloseButtonPressed;
@property (nonatomic, copy) RCTBubblingEventBlock onDocumentSaved;

@end
10 changes: 9 additions & 1 deletion ios/RCTPSPDFKit/RCTPSPDFKitView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "RCTPSPDFKitView.h"
#import <React/RCTUtils.h>

@interface RCTPSPDFKitView ()
@interface RCTPSPDFKitView ()<PSPDFDocumentDelegate>

@property (nonatomic, nullable) UIViewController *topController;

Expand Down Expand Up @@ -97,4 +97,12 @@ - (UIViewController *)pspdf_parentViewController {
return nil;
}

#pragma mark - PSPDFDocumentDelegate

- (void)pdfDocumentDidSave:(nonnull PSPDFDocument *)document {
if (self.onDocumentSaved) {
self.onDocumentSaved(@{});
}
}

@end
10 changes: 9 additions & 1 deletion ios/RCTPSPDFKit/RCTPSPDFKitViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import "RCTPSPDFKitViewManager.h"
#import "RCTConvert+PSPDFConfiguration.h"
#import "RCTConvert+PSPDFDocument.h"
#import "RCTPSPDFKitView.h"

@import PSPDFKit;
Expand All @@ -18,7 +19,12 @@ @implementation RCTPSPDFKitViewManager

RCT_EXPORT_MODULE()

RCT_REMAP_VIEW_PROPERTY(document, pdfController.document, PSPDFDocument)
RCT_CUSTOM_VIEW_PROPERTY(document, pdfController.document, RCTPSPDFKitView) {
if (json) {
view.pdfController.document = [RCTConvert PSPDFDocument:json];
view.pdfController.document.delegate = (id<PSPDFDocumentDelegate>)view;
}
}

RCT_REMAP_VIEW_PROPERTY(pageIndex, pdfController.pageIndex, NSUInteger)

Expand All @@ -42,6 +48,8 @@ @implementation RCTPSPDFKitViewManager

RCT_EXPORT_VIEW_PROPERTY(onCloseButtonPressed, RCTBubblingEventBlock)

RCT_EXPORT_VIEW_PROPERTY(onDocumentSaved, RCTBubblingEventBlock)

- (UIView *)view {
return [[RCTPSPDFKitView alloc] init];
}
Expand Down