-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add form read/write API #107
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,11 +123,11 @@ class PSPDFKitView extends React.Component { | |
UIManager.RCTPSPDFKitView.Commands.saveCurrentDocument, | ||
[] | ||
) | ||
} else if (Platform.OS === "ios"){ | ||
} else if (Platform.OS === "ios") { | ||
NativeModules.PSPDFKitViewManager.saveCurrentDocument(findNodeHandle(this.refs.pdfView)); | ||
} | ||
} | ||
|
||
/** | ||
* Gets all annotations of the given type from the page. | ||
* | ||
|
@@ -154,7 +154,7 @@ class PSPDFKitView extends React.Component { | |
); | ||
|
||
return promise | ||
} else if (Platform.OS === "ios"){ | ||
} else if (Platform.OS === "ios") { | ||
return NativeModules.PSPDFKitViewManager.getAnnotations(pageIndex, type, findNodeHandle(this.refs.pdfView)); | ||
} | ||
} | ||
|
@@ -171,8 +171,8 @@ class PSPDFKitView extends React.Component { | |
UIManager.RCTPSPDFKitView.Commands.addAnnotation, | ||
[annotation] | ||
); | ||
} else if (Platform.OS === "ios"){ | ||
NativeModules.PSPDFKitViewManager.addAnnotation(annotation, findNodeHandle(this.refs.pdfView)); | ||
} else if (Platform.OS === "ios") { | ||
NativeModules.PSPDFKitViewManager.addAnnotation(annotation, findNodeHandle(this.refs.pdfView)); | ||
} | ||
} | ||
|
||
|
@@ -198,7 +198,7 @@ class PSPDFKitView extends React.Component { | |
); | ||
|
||
return promise | ||
} else if (Platform.OS === "ios"){ | ||
} else if (Platform.OS === "ios") { | ||
return NativeModules.PSPDFKitViewManager.getAllUnsavedAnnotations(findNodeHandle(this.refs.pdfView)); | ||
} | ||
} | ||
|
@@ -215,8 +215,56 @@ class PSPDFKitView extends React.Component { | |
UIManager.RCTPSPDFKitView.Commands.addAnnotations, | ||
[annotations] | ||
); | ||
} else if (Platform.OS === "ios"){ | ||
NativeModules.PSPDFKitViewManager.addAnnotations(annotations, findNodeHandle(this.refs.pdfView)); | ||
} else if (Platform.OS === "ios") { | ||
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.'} | ||
* | ||
* @platform android | ||
*/ | ||
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), | ||
UIManager.RCTPSPDFKitView.Commands.getFormFieldValue, | ||
[requestId, fullyQualifiedName] | ||
); | ||
|
||
return promise; | ||
} | ||
} | ||
|
||
/** | ||
* Set the value of the form element of the fully qualified name. | ||
* | ||
* @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'. | ||
* @param fullyQualifiedName The fully qualified name of the form element. | ||
* | ||
* @platform android | ||
*/ | ||
setFormFieldValue = function (value, fullyQualifiedName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Order of parameters: why is the value parameter specified before target field fqn param? Is this a JS convention? |
||
if (Platform.OS === "android") { | ||
UIManager.dispatchViewManagerCommand( | ||
findNodeHandle(this.refs.pdfView), | ||
UIManager.RCTPSPDFKitView.Commands.setFormFieldValue, | ||
[fullyQualifiedName, value] | ||
); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about multi-selectable choice fields?