react-pdf-editor-1 1.2.45 → 1.2.46

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
@@ -33,7 +33,8 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
33
33
  notarySeal = _ref.notarySeal,
34
34
  initialSigners = _ref.initialSigners,
35
35
  modifiedUiElements = _ref.modifiedUiElements,
36
- textTagDefaults = _ref.textTagDefaults;
36
+ textTagDefaults = _ref.textTagDefaults,
37
+ hideUndoRedoButtons = _ref.hideUndoRedoButtons;
37
38
  var _useState = (0, _react.useState)(false),
38
39
  _useState2 = _slicedToArray(_useState, 2),
39
40
  internalIsReady = _useState2[0],
@@ -104,7 +105,8 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
104
105
  modifiedUiElements: modifiedUiElements,
105
106
  authInfo: authInfo,
106
107
  defaultAnnotationEditorMode: defaultAnnotationEditorMode,
107
- textTagDefaults: textTagDefaults
108
+ textTagDefaults: textTagDefaults,
109
+ hideUndoRedoButtons: hideUndoRedoButtons
108
110
  };
109
111
 
110
112
  // Set up a function to send the message
@@ -238,36 +240,54 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
238
240
  }, [container, files]);
239
241
  (0, _react.useEffect)(function () {
240
242
  document.addEventListener('click', function () {
243
+ var iframe = document.getElementById('webviewer-1');
244
+ if (!iframe) {
245
+ return;
246
+ }
241
247
  // @ts-ignore
242
- var iframeWin = document.getElementById('webviewer-1').contentWindow;
243
- iframeWin.postMessage('clickedOutside', window.location.origin);
248
+ var iframeWin = iframe.contentWindow;
249
+ iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage('clickedOutside', window.location.origin);
244
250
  });
245
251
  document.addEventListener('visibilitychange', handleVisibilityChange);
246
252
  return function () {
247
253
  document.removeEventListener('visibilitychange', handleVisibilityChange);
248
254
  };
249
255
  }, []);
250
- var download = function download() {
256
+ (0, _react.useEffect)(function () {
251
257
  var _document;
258
+ if (typeof hideUndoRedoButtons === 'undefined') {
259
+ return;
260
+ }
261
+ if (!internalIsReady) {
262
+ return;
263
+ }
252
264
  // @ts-ignore
253
265
  var iframeWin = (_document = document) === null || _document === void 0 || (_document = _document.getElementById('webviewer-1')) === null || _document === void 0 ? void 0 : _document.contentWindow;
266
+ iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
267
+ hideUndoRedoButtons: hideUndoRedoButtons
268
+ }, window.location.origin);
269
+ }, [hideUndoRedoButtons, internalIsReady]);
270
+ var download = function download() {
271
+ var _document2;
272
+ // @ts-ignore
273
+ var iframeWin = (_document2 = document) === null || _document2 === void 0 || (_document2 = _document2.getElementById('webviewer-1')) === null || _document2 === void 0 ? void 0 : _document2.contentWindow;
254
274
  iframeWin.postMessage({
255
275
  type: 'download'
256
276
  }, window.location.origin);
257
277
  };
258
278
  var toggleFullScreenThumbnails = function toggleFullScreenThumbnails(enable) {
259
- var _document2;
279
+ var _document3;
260
280
  // @ts-ignore
261
- var iframeWin = (_document2 = document) === null || _document2 === void 0 || (_document2 = _document2.getElementById('webviewer-1')) === null || _document2 === void 0 ? void 0 : _document2.contentWindow;
281
+ var iframeWin = (_document3 = document) === null || _document3 === void 0 || (_document3 = _document3.getElementById('webviewer-1')) === null || _document3 === void 0 ? void 0 : _document3.contentWindow;
262
282
  iframeWin.postMessage({
263
283
  type: 'toggle-full-screen-thumbnails',
264
284
  enable: enable
265
285
  }, window.location.origin);
266
286
  };
267
287
  var toggleSearchbar = function toggleSearchbar(enable) {
268
- var _document3;
288
+ var _document4;
269
289
  // @ts-ignore
270
- var iframeWin = (_document3 = document) === null || _document3 === void 0 || (_document3 = _document3.getElementById('webviewer-1')) === null || _document3 === void 0 ? void 0 : _document3.contentWindow;
290
+ var iframeWin = (_document4 = document) === null || _document4 === void 0 || (_document4 = _document4.getElementById('webviewer-1')) === null || _document4 === void 0 ? void 0 : _document4.contentWindow;
271
291
  iframeWin.postMessage({
272
292
  type: 'toggle-searchbar',
273
293
  enable: enable
@@ -279,7 +299,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
279
299
  while (1) switch (_context.prev = _context.next) {
280
300
  case 0:
281
301
  return _context.abrupt("return", new Promise(function (resolve, reject) {
282
- var _document4;
302
+ var _document5;
283
303
  var listener = function listener(event) {
284
304
  if (event.data.type === 'request-buffer-completed') {
285
305
  resolve(event.data.message); // Resolve the promise with the result
@@ -294,7 +314,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
294
314
  window.addEventListener('message', listener);
295
315
 
296
316
  // @ts-ignore
297
- var iframeWin = (_document4 = document) === null || _document4 === void 0 || (_document4 = _document4.getElementById('webviewer-1')) === null || _document4 === void 0 ? void 0 : _document4.contentWindow;
317
+ var iframeWin = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow;
298
318
 
299
319
  // Sending the extract-pages message to the iframe
300
320
  iframeWin.postMessage({
@@ -318,7 +338,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
318
338
  while (1) switch (_context2.prev = _context2.next) {
319
339
  case 0:
320
340
  return _context2.abrupt("return", new Promise(function (resolve, reject) {
321
- var _document5;
341
+ var _document6;
322
342
  var listener = function listener(event) {
323
343
  if (!event || !event.data) return;
324
344
  if (event.data.type === 'finalize-document') {
@@ -336,7 +356,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
336
356
 
337
357
  // Optionally nudge the iframe if it supports being prompted to finalize
338
358
  // @ts-ignore
339
- var iframeWin = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow;
359
+ var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow;
340
360
  iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
341
361
  type: 'finalize-document'
342
362
  }, window.location.origin);
@@ -352,29 +372,29 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
352
372
  };
353
373
  }();
354
374
  var toggleSignatureModal = function toggleSignatureModal(enable) {
355
- var _document6;
375
+ var _document7;
356
376
  // @ts-ignore
357
- var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow;
377
+ var iframeWin = (_document7 = document) === null || _document7 === void 0 || (_document7 = _document7.getElementById('webviewer-1')) === null || _document7 === void 0 ? void 0 : _document7.contentWindow;
358
378
  iframeWin.postMessage({
359
379
  type: 'toggle-signature-modal',
360
380
  enable: enable
361
381
  }, window.location.origin);
362
382
  };
363
383
  var setThumbnailZoom = function setThumbnailZoom(value) {
364
- var _document7;
384
+ var _document8;
365
385
  // @ts-ignore
366
- var iframeWin = (_document7 = document) === null || _document7 === void 0 || (_document7 = _document7.getElementById('webviewer-1')) === null || _document7 === void 0 ? void 0 : _document7.contentWindow;
386
+ var iframeWin = (_document8 = document) === null || _document8 === void 0 || (_document8 = _document8.getElementById('webviewer-1')) === null || _document8 === void 0 ? void 0 : _document8.contentWindow;
367
387
  iframeWin.postMessage({
368
388
  type: 'set-thumbnail-zoom',
369
389
  value: value
370
390
  }, window.location.origin);
371
391
  };
372
392
  var setAuthInfo = function setAuthInfo(_ref4) {
373
- var _document8;
393
+ var _document9;
374
394
  var token = _ref4.token,
375
395
  refreshToken = _ref4.refreshToken;
376
396
  // @ts-ignore
377
- var iframeWin = (_document8 = document) === null || _document8 === void 0 || (_document8 = _document8.getElementById('webviewer-1')) === null || _document8 === void 0 ? void 0 : _document8.contentWindow;
397
+ var iframeWin = (_document9 = document) === null || _document9 === void 0 || (_document9 = _document9.getElementById('webviewer-1')) === null || _document9 === void 0 ? void 0 : _document9.contentWindow;
378
398
  iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
379
399
  type: 'set-auth-info',
380
400
  authInfo: {
@@ -389,7 +409,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
389
409
  while (1) switch (_context3.prev = _context3.next) {
390
410
  case 0:
391
411
  return _context3.abrupt("return", new Promise(function (resolve, reject) {
392
- var _document9;
412
+ var _document10;
393
413
  var listener = function listener(event) {
394
414
  if (event.data.type === 'split-pages-completed' && event.data.success) {
395
415
  resolve(event.data.message); // Resolve the promise with the result
@@ -404,7 +424,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
404
424
  window.addEventListener('message', listener);
405
425
 
406
426
  // @ts-ignore
407
- var iframeWin = (_document9 = document) === null || _document9 === void 0 || (_document9 = _document9.getElementById('webviewer-1')) === null || _document9 === void 0 ? void 0 : _document9.contentWindow;
427
+ var iframeWin = (_document10 = document) === null || _document10 === void 0 || (_document10 = _document10.getElementById('webviewer-1')) === null || _document10 === void 0 ? void 0 : _document10.contentWindow;
408
428
 
409
429
  // Sending the extract-pages message to the iframe
410
430
  iframeWin.postMessage({
@@ -427,7 +447,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
427
447
  while (1) switch (_context4.prev = _context4.next) {
428
448
  case 0:
429
449
  return _context4.abrupt("return", new Promise(function (resolve, reject) {
430
- var _document10;
450
+ var _document11;
431
451
  var listener = function listener(event) {
432
452
  if (event.data.type === 'merge-files-completed' && event.data.success) {
433
453
  resolve(event.data.message); // Resolve the promise with the result
@@ -442,7 +462,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
442
462
  window.addEventListener('message', listener);
443
463
 
444
464
  // @ts-ignore
445
- var iframeWin = (_document10 = document) === null || _document10 === void 0 || (_document10 = _document10.getElementById('webviewer-1')) === null || _document10 === void 0 ? void 0 : _document10.contentWindow;
465
+ var iframeWin = (_document11 = document) === null || _document11 === void 0 || (_document11 = _document11.getElementById('webviewer-1')) === null || _document11 === void 0 ? void 0 : _document11.contentWindow;
446
466
 
447
467
  // Sending the extract-pages message to the iframe
448
468
  iframeWin.postMessage({
@@ -466,7 +486,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
466
486
  while (1) switch (_context5.prev = _context5.next) {
467
487
  case 0:
468
488
  return _context5.abrupt("return", new Promise(function (resolve, reject) {
469
- var _document11;
489
+ var _document12;
470
490
  var listener = function listener(event) {
471
491
  if (event.data.type === 'remove-chat-history-completed' && event.data.success) {
472
492
  resolve(event.data.message); // Resolve the promise with the result
@@ -481,7 +501,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
481
501
  window.addEventListener('message', listener);
482
502
 
483
503
  // @ts-ignore
484
- var iframeWin = (_document11 = document) === null || _document11 === void 0 || (_document11 = _document11.getElementById('webviewer-1')) === null || _document11 === void 0 ? void 0 : _document11.contentWindow;
504
+ var iframeWin = (_document12 = document) === null || _document12 === void 0 || (_document12 = _document12.getElementById('webviewer-1')) === null || _document12 === void 0 ? void 0 : _document12.contentWindow;
485
505
 
486
506
  // Sending the extract-pages message to the iframe
487
507
  iframeWin.postMessage({
@@ -504,7 +524,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
504
524
  while (1) switch (_context6.prev = _context6.next) {
505
525
  case 0:
506
526
  return _context6.abrupt("return", new Promise(function (resolve, reject) {
507
- var _document12;
527
+ var _document13;
508
528
  var listener = function listener(event) {
509
529
  if (event.data.type === 'combine-files-completed' && event.data.success) {
510
530
  resolve(event.data.message); // Resolve the promise with the result
@@ -519,7 +539,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
519
539
  window.addEventListener('message', listener);
520
540
 
521
541
  // @ts-ignore
522
- var iframeWin = (_document12 = document) === null || _document12 === void 0 || (_document12 = _document12.getElementById('webviewer-1')) === null || _document12 === void 0 ? void 0 : _document12.contentWindow;
542
+ var iframeWin = (_document13 = document) === null || _document13 === void 0 || (_document13 = _document13.getElementById('webviewer-1')) === null || _document13 === void 0 ? void 0 : _document13.contentWindow;
523
543
 
524
544
  // Sending the extract-pages message to the iframe
525
545
  iframeWin.postMessage({
@@ -543,7 +563,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
543
563
  while (1) switch (_context7.prev = _context7.next) {
544
564
  case 0:
545
565
  return _context7.abrupt("return", new Promise(function (resolve, reject) {
546
- var _document13;
566
+ var _document14;
547
567
  var listener = function listener(event) {
548
568
  if (event.data.type === 'extract-pages-completed' && event.data.success) {
549
569
  resolve(event.data.result); // Resolve the promise with the result
@@ -558,7 +578,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
558
578
  window.addEventListener('message', listener);
559
579
 
560
580
  // @ts-ignore
561
- var iframeWin = (_document13 = document) === null || _document13 === void 0 || (_document13 = _document13.getElementById('webviewer-1')) === null || _document13 === void 0 ? void 0 : _document13.contentWindow;
581
+ var iframeWin = (_document14 = document) === null || _document14 === void 0 || (_document14 = _document14.getElementById('webviewer-1')) === null || _document14 === void 0 ? void 0 : _document14.contentWindow;
562
582
 
563
583
  // Sending the extract-pages message to the iframe
564
584
  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.46",
4
4
  "description": "## Core",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -186,9 +186,13 @@ export const useCreateIframeAndLoadViewer = ({
186
186
 
187
187
  useEffect(() => {
188
188
  document.addEventListener('click', function() {
189
+ const iframe = document.getElementById('webviewer-1');
190
+ if (!iframe) {
191
+ return;
192
+ }
189
193
  // @ts-ignore
190
- var iframeWin = document.getElementById('webviewer-1').contentWindow;
191
- iframeWin.postMessage('clickedOutside', window.location.origin);
194
+ const iframeWin = iframe.contentWindow;
195
+ iframeWin?.postMessage('clickedOutside', window.location.origin);
192
196
  });
193
197
  document.addEventListener('visibilitychange', handleVisibilityChange);
194
198
  return () => {