@@ -62,9 +62,8 @@ class PSPDFKitView extends React.Component {
6262
6363 /**
6464 * Enters the annotation creation mode, showing the annotation creation toolbar.
65- *
6665 */
67- enterAnnotationCreationMode = function ( ) {
66+ enterAnnotationCreationMode = function ( ) {
6867 UIManager . dispatchViewManagerCommand (
6968 findNodeHandle ( this . refs . pdfView ) ,
7069 UIManager . RCTPSPDFKitView . Commands . enterAnnotationCreationMode ,
@@ -73,9 +72,9 @@ class PSPDFKitView extends React.Component {
7372 } ;
7473
7574 /**
76- * Exits the currently active mode, hiding all toolbars.
75+ * Exits the currently active mode, hiding all active sub- toolbars.
7776 */
78- exitCurrentlyActiveMode = function ( ) {
77+ exitCurrentlyActiveMode = function ( ) {
7978 UIManager . dispatchViewManagerCommand (
8079 findNodeHandle ( this . refs . pdfView ) ,
8180 UIManager . RCTPSPDFKitView . Commands . exitCurrentlyActiveMode ,
@@ -86,7 +85,7 @@ class PSPDFKitView extends React.Component {
8685 /**
8786 * Saves the currently opened document.
8887 */
89- saveCurrentDocument = function ( ) {
88+ saveCurrentDocument = function ( ) {
9089 UIManager . dispatchViewManagerCommand (
9190 findNodeHandle ( this . refs . pdfView ) ,
9291 UIManager . RCTPSPDFKitView . Commands . saveCurrentDocument ,
@@ -95,19 +94,19 @@ class PSPDFKitView extends React.Component {
9594 } ;
9695
9796 /**
98- * Gets all annotations of the given type from the page.
97+ * Gets all annotations from a specific page.
9998 *
10099 * @param pageIndex The page to get the annotations for.
101100 *
102- * Returns a promise resolving an array with the following structure:
101+ * @returns a promise resolving an array with the following structure:
103102 * {'annotations' : [instantJson]}
104103 */
105- getAnnotations = function ( pageIndex ) {
104+ getAnnotations = function ( pageIndex ) {
106105 let requestId = this . _nextRequestId ++ ;
107106 let requestMap = this . _requestMap ;
108107
109108 // We create a promise here that will be resolved once onDataReturned is called.
110- let promise = new Promise ( function ( resolve , reject ) {
109+ let promise = new Promise ( function ( resolve , reject ) {
111110 requestMap [ requestId ] = { resolve : resolve , reject : reject } ;
112111 } ) ;
113112
@@ -123,15 +122,66 @@ class PSPDFKitView extends React.Component {
123122 /**
124123 * Adds a new annotation to the current document.
125124 *
126- * @param annotation InstantJson of the annotation to add.
125+ * @param annotation InstantJson of the annotation to add with the format of
126+ * https://pspdfkit.com/guides/windows/current/importing-exporting/instant-json/#instant-annotation-json-api
127127 */
128- addAnnotation = function ( annotation ) {
128+ addAnnotation = function ( annotation ) {
129129 UIManager . dispatchViewManagerCommand (
130130 findNodeHandle ( this . refs . pdfView ) ,
131131 UIManager . RCTPSPDFKitView . Commands . addAnnotation ,
132132 [ annotation ]
133133 ) ;
134134 } ;
135+
136+ /**
137+ * Gets toolbar items currently shown.
138+ *
139+ * @return Receives an array of https://pspdfkit.com/api/web/PSPDFKit.ToolbarItem.html.
140+ */
141+ getToolbarItems = function ( ) {
142+ let requestId = this . _nextRequestId ++ ;
143+ let requestMap = this . _requestMap ;
144+
145+ // We create a promise here that will be resolved once onDataReturned is called.
146+ let promise = new Promise ( function ( resolve , reject ) {
147+ requestMap [ requestId ] = { resolve : resolve , reject : reject } ;
148+ } ) ;
149+
150+ UIManager . dispatchViewManagerCommand (
151+ findNodeHandle ( this . refs . pdfView ) ,
152+ UIManager . RCTPSPDFKitView . Commands . getToolbarItems ,
153+ [ requestId ]
154+ ) ;
155+
156+ return promise ;
157+ } ;
158+
159+ /**
160+ * Set toolbar items currently shown.
161+ *
162+ * Receives an array of https://pspdfkit.com/api/web/PSPDFKit.ToolbarItem.html.
163+ * Default toolbar items are provided for simple usage
164+ * https://pspdfkit.com/api/web/PSPDFKit.html#.defaultToolbarItems.
165+ * For more advance features please refer to
166+ * https://pspdfkit.com/guides/web/current/customizing-the-interface/customizing-the-toolbar/.
167+ */
168+ setToolbarItems = function ( toolbarItems ) {
169+ let requestId = this . _nextRequestId ++ ;
170+ let requestMap = this . _requestMap ;
171+
172+ // We create a promise here that will be resolved once onDataReturned is called.
173+ let promise = new Promise ( function ( resolve , reject ) {
174+ requestMap [ requestId ] = { resolve : resolve , reject : reject } ;
175+ } ) ;
176+
177+ UIManager . dispatchViewManagerCommand (
178+ findNodeHandle ( this . refs . pdfView ) ,
179+ UIManager . RCTPSPDFKitView . Commands . setToolbarItems ,
180+ [ requestId , toolbarItems ]
181+ ) ;
182+
183+ return promise ;
184+ } ;
135185}
136186
137187PSPDFKitView . propTypes = {
@@ -159,7 +209,7 @@ PSPDFKitView.propTypes = {
159209 ...ViewPropTypes
160210} ;
161211
162- var RCTPSPDFKitView = requireNativeComponent (
212+ const RCTPSPDFKitView = requireNativeComponent (
163213 "RCTPSPDFKitView" ,
164214 PSPDFKitView ,
165215 { }
0 commit comments