react-pdf-editor-1 1.2.45 → 1.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -27,13 +27,15 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
27
27
  mode = _ref.mode,
28
28
  container = _ref.container,
29
29
  iframeSrc = _ref.iframeSrc,
30
+ role = _ref.role,
30
31
  onFileFailed = _ref.onFileFailed,
31
32
  defaultAnnotationEditorMode = _ref.defaultAnnotationEditorMode,
32
33
  initialAnnotations = _ref.initialAnnotations,
33
34
  notarySeal = _ref.notarySeal,
34
35
  initialSigners = _ref.initialSigners,
35
36
  modifiedUiElements = _ref.modifiedUiElements,
36
- textTagDefaults = _ref.textTagDefaults;
37
+ textTagDefaults = _ref.textTagDefaults,
38
+ hideUndoRedoButtons = _ref.hideUndoRedoButtons;
37
39
  var _useState = (0, _react.useState)(false),
38
40
  _useState2 = _slicedToArray(_useState, 2),
39
41
  internalIsReady = _useState2[0],
@@ -104,7 +106,9 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
104
106
  modifiedUiElements: modifiedUiElements,
105
107
  authInfo: authInfo,
106
108
  defaultAnnotationEditorMode: defaultAnnotationEditorMode,
107
- textTagDefaults: textTagDefaults
109
+ textTagDefaults: textTagDefaults,
110
+ hideUndoRedoButtons: hideUndoRedoButtons,
111
+ role: role
108
112
  };
109
113
 
110
114
  // Set up a function to send the message
@@ -238,36 +242,54 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
238
242
  }, [container, files]);
239
243
  (0, _react.useEffect)(function () {
240
244
  document.addEventListener('click', function () {
245
+ var iframe = document.getElementById('webviewer-1');
246
+ if (!iframe) {
247
+ return;
248
+ }
241
249
  // @ts-ignore
242
- var iframeWin = document.getElementById('webviewer-1').contentWindow;
243
- iframeWin.postMessage('clickedOutside', window.location.origin);
250
+ var iframeWin = iframe.contentWindow;
251
+ iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage('clickedOutside', window.location.origin);
244
252
  });
245
253
  document.addEventListener('visibilitychange', handleVisibilityChange);
246
254
  return function () {
247
255
  document.removeEventListener('visibilitychange', handleVisibilityChange);
248
256
  };
249
257
  }, []);
250
- var download = function download() {
258
+ (0, _react.useEffect)(function () {
251
259
  var _document;
260
+ if (typeof hideUndoRedoButtons === 'undefined') {
261
+ return;
262
+ }
263
+ if (!internalIsReady) {
264
+ return;
265
+ }
252
266
  // @ts-ignore
253
267
  var iframeWin = (_document = document) === null || _document === void 0 || (_document = _document.getElementById('webviewer-1')) === null || _document === void 0 ? void 0 : _document.contentWindow;
268
+ iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
269
+ hideUndoRedoButtons: hideUndoRedoButtons
270
+ }, window.location.origin);
271
+ }, [hideUndoRedoButtons, internalIsReady]);
272
+ var download = function download() {
273
+ var _document2;
274
+ // @ts-ignore
275
+ var iframeWin = (_document2 = document) === null || _document2 === void 0 || (_document2 = _document2.getElementById('webviewer-1')) === null || _document2 === void 0 ? void 0 : _document2.contentWindow;
254
276
  iframeWin.postMessage({
255
277
  type: 'download'
256
278
  }, window.location.origin);
257
279
  };
258
280
  var toggleFullScreenThumbnails = function toggleFullScreenThumbnails(enable) {
259
- var _document2;
281
+ var _document3;
260
282
  // @ts-ignore
261
- var iframeWin = (_document2 = document) === null || _document2 === void 0 || (_document2 = _document2.getElementById('webviewer-1')) === null || _document2 === void 0 ? void 0 : _document2.contentWindow;
283
+ var iframeWin = (_document3 = document) === null || _document3 === void 0 || (_document3 = _document3.getElementById('webviewer-1')) === null || _document3 === void 0 ? void 0 : _document3.contentWindow;
262
284
  iframeWin.postMessage({
263
285
  type: 'toggle-full-screen-thumbnails',
264
286
  enable: enable
265
287
  }, window.location.origin);
266
288
  };
267
289
  var toggleSearchbar = function toggleSearchbar(enable) {
268
- var _document3;
290
+ var _document4;
269
291
  // @ts-ignore
270
- var iframeWin = (_document3 = document) === null || _document3 === void 0 || (_document3 = _document3.getElementById('webviewer-1')) === null || _document3 === void 0 ? void 0 : _document3.contentWindow;
292
+ var iframeWin = (_document4 = document) === null || _document4 === void 0 || (_document4 = _document4.getElementById('webviewer-1')) === null || _document4 === void 0 ? void 0 : _document4.contentWindow;
271
293
  iframeWin.postMessage({
272
294
  type: 'toggle-searchbar',
273
295
  enable: enable
@@ -279,7 +301,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
279
301
  while (1) switch (_context.prev = _context.next) {
280
302
  case 0:
281
303
  return _context.abrupt("return", new Promise(function (resolve, reject) {
282
- var _document4;
304
+ var _document5;
283
305
  var listener = function listener(event) {
284
306
  if (event.data.type === 'request-buffer-completed') {
285
307
  resolve(event.data.message); // Resolve the promise with the result
@@ -294,7 +316,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
294
316
  window.addEventListener('message', listener);
295
317
 
296
318
  // @ts-ignore
297
- var iframeWin = (_document4 = document) === null || _document4 === void 0 || (_document4 = _document4.getElementById('webviewer-1')) === null || _document4 === void 0 ? void 0 : _document4.contentWindow;
319
+ var iframeWin = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow;
298
320
 
299
321
  // Sending the extract-pages message to the iframe
300
322
  iframeWin.postMessage({
@@ -318,7 +340,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
318
340
  while (1) switch (_context2.prev = _context2.next) {
319
341
  case 0:
320
342
  return _context2.abrupt("return", new Promise(function (resolve, reject) {
321
- var _document5;
343
+ var _document6;
322
344
  var listener = function listener(event) {
323
345
  if (!event || !event.data) return;
324
346
  if (event.data.type === 'finalize-document') {
@@ -336,7 +358,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
336
358
 
337
359
  // Optionally nudge the iframe if it supports being prompted to finalize
338
360
  // @ts-ignore
339
- var iframeWin = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow;
361
+ var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow;
340
362
  iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
341
363
  type: 'finalize-document'
342
364
  }, window.location.origin);
@@ -352,29 +374,29 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
352
374
  };
353
375
  }();
354
376
  var toggleSignatureModal = function toggleSignatureModal(enable) {
355
- var _document6;
377
+ var _document7;
356
378
  // @ts-ignore
357
- var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow;
379
+ var iframeWin = (_document7 = document) === null || _document7 === void 0 || (_document7 = _document7.getElementById('webviewer-1')) === null || _document7 === void 0 ? void 0 : _document7.contentWindow;
358
380
  iframeWin.postMessage({
359
381
  type: 'toggle-signature-modal',
360
382
  enable: enable
361
383
  }, window.location.origin);
362
384
  };
363
385
  var setThumbnailZoom = function setThumbnailZoom(value) {
364
- var _document7;
386
+ var _document8;
365
387
  // @ts-ignore
366
- var iframeWin = (_document7 = document) === null || _document7 === void 0 || (_document7 = _document7.getElementById('webviewer-1')) === null || _document7 === void 0 ? void 0 : _document7.contentWindow;
388
+ var iframeWin = (_document8 = document) === null || _document8 === void 0 || (_document8 = _document8.getElementById('webviewer-1')) === null || _document8 === void 0 ? void 0 : _document8.contentWindow;
367
389
  iframeWin.postMessage({
368
390
  type: 'set-thumbnail-zoom',
369
391
  value: value
370
392
  }, window.location.origin);
371
393
  };
372
394
  var setAuthInfo = function setAuthInfo(_ref4) {
373
- var _document8;
395
+ var _document9;
374
396
  var token = _ref4.token,
375
397
  refreshToken = _ref4.refreshToken;
376
398
  // @ts-ignore
377
- var iframeWin = (_document8 = document) === null || _document8 === void 0 || (_document8 = _document8.getElementById('webviewer-1')) === null || _document8 === void 0 ? void 0 : _document8.contentWindow;
399
+ var iframeWin = (_document9 = document) === null || _document9 === void 0 || (_document9 = _document9.getElementById('webviewer-1')) === null || _document9 === void 0 ? void 0 : _document9.contentWindow;
378
400
  iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
379
401
  type: 'set-auth-info',
380
402
  authInfo: {
@@ -389,7 +411,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
389
411
  while (1) switch (_context3.prev = _context3.next) {
390
412
  case 0:
391
413
  return _context3.abrupt("return", new Promise(function (resolve, reject) {
392
- var _document9;
414
+ var _document10;
393
415
  var listener = function listener(event) {
394
416
  if (event.data.type === 'split-pages-completed' && event.data.success) {
395
417
  resolve(event.data.message); // Resolve the promise with the result
@@ -404,7 +426,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
404
426
  window.addEventListener('message', listener);
405
427
 
406
428
  // @ts-ignore
407
- var iframeWin = (_document9 = document) === null || _document9 === void 0 || (_document9 = _document9.getElementById('webviewer-1')) === null || _document9 === void 0 ? void 0 : _document9.contentWindow;
429
+ var iframeWin = (_document10 = document) === null || _document10 === void 0 || (_document10 = _document10.getElementById('webviewer-1')) === null || _document10 === void 0 ? void 0 : _document10.contentWindow;
408
430
 
409
431
  // Sending the extract-pages message to the iframe
410
432
  iframeWin.postMessage({
@@ -427,7 +449,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
427
449
  while (1) switch (_context4.prev = _context4.next) {
428
450
  case 0:
429
451
  return _context4.abrupt("return", new Promise(function (resolve, reject) {
430
- var _document10;
452
+ var _document11;
431
453
  var listener = function listener(event) {
432
454
  if (event.data.type === 'merge-files-completed' && event.data.success) {
433
455
  resolve(event.data.message); // Resolve the promise with the result
@@ -442,7 +464,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
442
464
  window.addEventListener('message', listener);
443
465
 
444
466
  // @ts-ignore
445
- var iframeWin = (_document10 = document) === null || _document10 === void 0 || (_document10 = _document10.getElementById('webviewer-1')) === null || _document10 === void 0 ? void 0 : _document10.contentWindow;
467
+ var iframeWin = (_document11 = document) === null || _document11 === void 0 || (_document11 = _document11.getElementById('webviewer-1')) === null || _document11 === void 0 ? void 0 : _document11.contentWindow;
446
468
 
447
469
  // Sending the extract-pages message to the iframe
448
470
  iframeWin.postMessage({
@@ -466,7 +488,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
466
488
  while (1) switch (_context5.prev = _context5.next) {
467
489
  case 0:
468
490
  return _context5.abrupt("return", new Promise(function (resolve, reject) {
469
- var _document11;
491
+ var _document12;
470
492
  var listener = function listener(event) {
471
493
  if (event.data.type === 'remove-chat-history-completed' && event.data.success) {
472
494
  resolve(event.data.message); // Resolve the promise with the result
@@ -481,7 +503,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
481
503
  window.addEventListener('message', listener);
482
504
 
483
505
  // @ts-ignore
484
- var iframeWin = (_document11 = document) === null || _document11 === void 0 || (_document11 = _document11.getElementById('webviewer-1')) === null || _document11 === void 0 ? void 0 : _document11.contentWindow;
506
+ var iframeWin = (_document12 = document) === null || _document12 === void 0 || (_document12 = _document12.getElementById('webviewer-1')) === null || _document12 === void 0 ? void 0 : _document12.contentWindow;
485
507
 
486
508
  // Sending the extract-pages message to the iframe
487
509
  iframeWin.postMessage({
@@ -504,7 +526,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
504
526
  while (1) switch (_context6.prev = _context6.next) {
505
527
  case 0:
506
528
  return _context6.abrupt("return", new Promise(function (resolve, reject) {
507
- var _document12;
529
+ var _document13;
508
530
  var listener = function listener(event) {
509
531
  if (event.data.type === 'combine-files-completed' && event.data.success) {
510
532
  resolve(event.data.message); // Resolve the promise with the result
@@ -519,7 +541,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
519
541
  window.addEventListener('message', listener);
520
542
 
521
543
  // @ts-ignore
522
- var iframeWin = (_document12 = document) === null || _document12 === void 0 || (_document12 = _document12.getElementById('webviewer-1')) === null || _document12 === void 0 ? void 0 : _document12.contentWindow;
544
+ var iframeWin = (_document13 = document) === null || _document13 === void 0 || (_document13 = _document13.getElementById('webviewer-1')) === null || _document13 === void 0 ? void 0 : _document13.contentWindow;
523
545
 
524
546
  // Sending the extract-pages message to the iframe
525
547
  iframeWin.postMessage({
@@ -543,7 +565,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
543
565
  while (1) switch (_context7.prev = _context7.next) {
544
566
  case 0:
545
567
  return _context7.abrupt("return", new Promise(function (resolve, reject) {
546
- var _document13;
568
+ var _document14;
547
569
  var listener = function listener(event) {
548
570
  if (event.data.type === 'extract-pages-completed' && event.data.success) {
549
571
  resolve(event.data.result); // Resolve the promise with the result
@@ -558,7 +580,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
558
580
  window.addEventListener('message', listener);
559
581
 
560
582
  // @ts-ignore
561
- var iframeWin = (_document13 = document) === null || _document13 === void 0 || (_document13 = _document13.getElementById('webviewer-1')) === null || _document13 === void 0 ? void 0 : _document13.contentWindow;
583
+ var iframeWin = (_document14 = document) === null || _document14 === void 0 || (_document14 = _document14.getElementById('webviewer-1')) === null || _document14 === void 0 ? void 0 : _document14.contentWindow;
562
584
 
563
585
  // Sending the extract-pages message to the iframe
564
586
  iframeWin.postMessage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-pdf-editor-1",
3
- "version": "1.2.45",
3
+ "version": "1.2.47",
4
4
  "description": "## Core",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.d.ts CHANGED
@@ -11,6 +11,7 @@ declare module 'pdf_editor_aleon35_react_plugin' {
11
11
  general?: ("zoom" | "search" | "download" | "thumbnails" | "panel-toggle")[];
12
12
  editing?: ("remove" | "rotation" | "extract" | "move")[];
13
13
  };
14
+ role?: string;
14
15
  container: React.MutableRefObject<HTMLElement | null> | (HTMLElement | null);
15
16
  locale?: "en" | "es" | "ru",
16
17
  mode?: "split" | "regular",
package/src/index.js CHANGED
@@ -12,6 +12,7 @@ export const useCreateIframeAndLoadViewer = ({
12
12
  mode,
13
13
  container,
14
14
  iframeSrc,
15
+ role,
15
16
  onFileFailed,
16
17
  defaultAnnotationEditorMode,
17
18
  initialAnnotations,
@@ -56,7 +57,7 @@ export const useCreateIframeAndLoadViewer = ({
56
57
  // When the iframe is loaded, post the file to it
57
58
  iframe.onload = function() {
58
59
  const targetOrigin = window.location.origin;
59
- const message = { files, fileName, tools, locale, licenseKey, mode, uuid, customData, initialAnnotations, notarySeal, initialSigners, modifiedUiElements, authInfo, defaultAnnotationEditorMode, textTagDefaults, hideUndoRedoButtons };
60
+ const message = { files, fileName, tools, locale, licenseKey, mode, uuid, customData, initialAnnotations, notarySeal, initialSigners, modifiedUiElements, authInfo, defaultAnnotationEditorMode, textTagDefaults, hideUndoRedoButtons, role };
60
61
 
61
62
  // Set up a function to send the message
62
63
  const sendMessage = () => {
@@ -186,9 +187,13 @@ export const useCreateIframeAndLoadViewer = ({
186
187
 
187
188
  useEffect(() => {
188
189
  document.addEventListener('click', function() {
190
+ const iframe = document.getElementById('webviewer-1');
191
+ if (!iframe) {
192
+ return;
193
+ }
189
194
  // @ts-ignore
190
- var iframeWin = document.getElementById('webviewer-1').contentWindow;
191
- iframeWin.postMessage('clickedOutside', window.location.origin);
195
+ const iframeWin = iframe.contentWindow;
196
+ iframeWin?.postMessage('clickedOutside', window.location.origin);
192
197
  });
193
198
  document.addEventListener('visibilitychange', handleVisibilityChange);
194
199
  return () => {