react-pdf-editor-1 1.2.37 → 1.2.39
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 +95 -54
- package/package.json +1 -1
- package/src/index.js +27 -1
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
30
30
|
onFileFailed = _ref.onFileFailed,
|
|
31
31
|
defaultAnnotationEditorMode = _ref.defaultAnnotationEditorMode,
|
|
32
32
|
initialAnnotations = _ref.initialAnnotations,
|
|
33
|
+
notarySeal = _ref.notarySeal,
|
|
33
34
|
initialSigners = _ref.initialSigners,
|
|
34
35
|
modifiedUiElements = _ref.modifiedUiElements;
|
|
35
36
|
var _useState = (0, _react.useState)(false),
|
|
@@ -277,30 +278,69 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
277
278
|
return _ref2.apply(this, arguments);
|
|
278
279
|
};
|
|
279
280
|
}();
|
|
281
|
+
var finalizeDocument = /*#__PURE__*/function () {
|
|
282
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
283
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
284
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
285
|
+
case 0:
|
|
286
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
287
|
+
var _document5;
|
|
288
|
+
var listener = function listener(event) {
|
|
289
|
+
if (!event || !event.data) return;
|
|
290
|
+
if (event.data.type === 'finalize-document') {
|
|
291
|
+
// Child posts { type: 'finalize-document', annotations }
|
|
292
|
+
resolve(event.data.annotations);
|
|
293
|
+
window.removeEventListener('message', listener);
|
|
294
|
+
} else if (event.data.type === 'finalize-document-failed') {
|
|
295
|
+
reject(new Error(event.data.message || 'Finalize document failed'));
|
|
296
|
+
window.removeEventListener('message', listener);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// Add listener to capture the next finalize signal
|
|
301
|
+
window.addEventListener('message', listener);
|
|
302
|
+
|
|
303
|
+
// Optionally nudge the iframe if it supports being prompted to finalize
|
|
304
|
+
// @ts-ignore
|
|
305
|
+
var iframeWin = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow;
|
|
306
|
+
iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
|
|
307
|
+
type: 'finalize-document'
|
|
308
|
+
}, window.location.origin);
|
|
309
|
+
}));
|
|
310
|
+
case 1:
|
|
311
|
+
case "end":
|
|
312
|
+
return _context2.stop();
|
|
313
|
+
}
|
|
314
|
+
}, _callee2);
|
|
315
|
+
}));
|
|
316
|
+
return function finalizeDocument() {
|
|
317
|
+
return _ref3.apply(this, arguments);
|
|
318
|
+
};
|
|
319
|
+
}();
|
|
280
320
|
var toggleSignatureModal = function toggleSignatureModal(enable) {
|
|
281
|
-
var
|
|
321
|
+
var _document6;
|
|
282
322
|
// @ts-ignore
|
|
283
|
-
var iframeWin = (
|
|
323
|
+
var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow;
|
|
284
324
|
iframeWin.postMessage({
|
|
285
325
|
type: 'toggle-signature-modal',
|
|
286
326
|
enable: enable
|
|
287
327
|
}, window.location.origin);
|
|
288
328
|
};
|
|
289
329
|
var setThumbnailZoom = function setThumbnailZoom(value) {
|
|
290
|
-
var
|
|
330
|
+
var _document7;
|
|
291
331
|
// @ts-ignore
|
|
292
|
-
var iframeWin = (
|
|
332
|
+
var iframeWin = (_document7 = document) === null || _document7 === void 0 || (_document7 = _document7.getElementById('webviewer-1')) === null || _document7 === void 0 ? void 0 : _document7.contentWindow;
|
|
293
333
|
iframeWin.postMessage({
|
|
294
334
|
type: 'set-thumbnail-zoom',
|
|
295
335
|
value: value
|
|
296
336
|
}, window.location.origin);
|
|
297
337
|
};
|
|
298
|
-
var setAuthInfo = function setAuthInfo(
|
|
299
|
-
var
|
|
300
|
-
var token =
|
|
301
|
-
refreshToken =
|
|
338
|
+
var setAuthInfo = function setAuthInfo(_ref4) {
|
|
339
|
+
var _document8;
|
|
340
|
+
var token = _ref4.token,
|
|
341
|
+
refreshToken = _ref4.refreshToken;
|
|
302
342
|
// @ts-ignore
|
|
303
|
-
var iframeWin = (
|
|
343
|
+
var iframeWin = (_document8 = document) === null || _document8 === void 0 || (_document8 = _document8.getElementById('webviewer-1')) === null || _document8 === void 0 ? void 0 : _document8.contentWindow;
|
|
304
344
|
iframeWin === null || iframeWin === void 0 ? void 0 : iframeWin.postMessage({
|
|
305
345
|
type: 'set-auth-info',
|
|
306
346
|
authInfo: {
|
|
@@ -310,12 +350,12 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
310
350
|
}, window.location.origin);
|
|
311
351
|
};
|
|
312
352
|
var splitPages = /*#__PURE__*/function () {
|
|
313
|
-
var
|
|
314
|
-
return _regeneratorRuntime().wrap(function
|
|
315
|
-
while (1) switch (
|
|
353
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
354
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
355
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
316
356
|
case 0:
|
|
317
|
-
return
|
|
318
|
-
var
|
|
357
|
+
return _context3.abrupt("return", new Promise(function (resolve, reject) {
|
|
358
|
+
var _document9;
|
|
319
359
|
var listener = function listener(event) {
|
|
320
360
|
if (event.data.type === 'split-pages-completed' && event.data.success) {
|
|
321
361
|
resolve(event.data.message); // Resolve the promise with the result
|
|
@@ -330,7 +370,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
330
370
|
window.addEventListener('message', listener);
|
|
331
371
|
|
|
332
372
|
// @ts-ignore
|
|
333
|
-
var iframeWin = (
|
|
373
|
+
var iframeWin = (_document9 = document) === null || _document9 === void 0 || (_document9 = _document9.getElementById('webviewer-1')) === null || _document9 === void 0 ? void 0 : _document9.contentWindow;
|
|
334
374
|
|
|
335
375
|
// Sending the extract-pages message to the iframe
|
|
336
376
|
iframeWin.postMessage({
|
|
@@ -339,21 +379,21 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
339
379
|
}));
|
|
340
380
|
case 1:
|
|
341
381
|
case "end":
|
|
342
|
-
return
|
|
382
|
+
return _context3.stop();
|
|
343
383
|
}
|
|
344
|
-
},
|
|
384
|
+
}, _callee3);
|
|
345
385
|
}));
|
|
346
386
|
return function splitPages() {
|
|
347
|
-
return
|
|
387
|
+
return _ref5.apply(this, arguments);
|
|
348
388
|
};
|
|
349
389
|
}();
|
|
350
390
|
var mergeFiles = /*#__PURE__*/function () {
|
|
351
|
-
var
|
|
352
|
-
return _regeneratorRuntime().wrap(function
|
|
353
|
-
while (1) switch (
|
|
391
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value) {
|
|
392
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
393
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
354
394
|
case 0:
|
|
355
|
-
return
|
|
356
|
-
var
|
|
395
|
+
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
396
|
+
var _document10;
|
|
357
397
|
var listener = function listener(event) {
|
|
358
398
|
if (event.data.type === 'merge-files-completed' && event.data.success) {
|
|
359
399
|
resolve(event.data.message); // Resolve the promise with the result
|
|
@@ -368,7 +408,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
368
408
|
window.addEventListener('message', listener);
|
|
369
409
|
|
|
370
410
|
// @ts-ignore
|
|
371
|
-
var iframeWin = (
|
|
411
|
+
var iframeWin = (_document10 = document) === null || _document10 === void 0 || (_document10 = _document10.getElementById('webviewer-1')) === null || _document10 === void 0 ? void 0 : _document10.contentWindow;
|
|
372
412
|
|
|
373
413
|
// Sending the extract-pages message to the iframe
|
|
374
414
|
iframeWin.postMessage({
|
|
@@ -378,21 +418,21 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
378
418
|
}));
|
|
379
419
|
case 1:
|
|
380
420
|
case "end":
|
|
381
|
-
return
|
|
421
|
+
return _context4.stop();
|
|
382
422
|
}
|
|
383
|
-
},
|
|
423
|
+
}, _callee4);
|
|
384
424
|
}));
|
|
385
425
|
return function mergeFiles(_x3) {
|
|
386
|
-
return
|
|
426
|
+
return _ref6.apply(this, arguments);
|
|
387
427
|
};
|
|
388
428
|
}();
|
|
389
429
|
var removeChatHistory = /*#__PURE__*/function () {
|
|
390
|
-
var
|
|
391
|
-
return _regeneratorRuntime().wrap(function
|
|
392
|
-
while (1) switch (
|
|
430
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
431
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
432
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
393
433
|
case 0:
|
|
394
|
-
return
|
|
395
|
-
var
|
|
434
|
+
return _context5.abrupt("return", new Promise(function (resolve, reject) {
|
|
435
|
+
var _document11;
|
|
396
436
|
var listener = function listener(event) {
|
|
397
437
|
if (event.data.type === 'remove-chat-history-completed' && event.data.success) {
|
|
398
438
|
resolve(event.data.message); // Resolve the promise with the result
|
|
@@ -407,7 +447,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
407
447
|
window.addEventListener('message', listener);
|
|
408
448
|
|
|
409
449
|
// @ts-ignore
|
|
410
|
-
var iframeWin = (
|
|
450
|
+
var iframeWin = (_document11 = document) === null || _document11 === void 0 || (_document11 = _document11.getElementById('webviewer-1')) === null || _document11 === void 0 ? void 0 : _document11.contentWindow;
|
|
411
451
|
|
|
412
452
|
// Sending the extract-pages message to the iframe
|
|
413
453
|
iframeWin.postMessage({
|
|
@@ -416,21 +456,21 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
416
456
|
}));
|
|
417
457
|
case 1:
|
|
418
458
|
case "end":
|
|
419
|
-
return
|
|
459
|
+
return _context5.stop();
|
|
420
460
|
}
|
|
421
|
-
},
|
|
461
|
+
}, _callee5);
|
|
422
462
|
}));
|
|
423
463
|
return function removeChatHistory() {
|
|
424
|
-
return
|
|
464
|
+
return _ref7.apply(this, arguments);
|
|
425
465
|
};
|
|
426
466
|
}();
|
|
427
467
|
var combineFiles = /*#__PURE__*/function () {
|
|
428
|
-
var
|
|
429
|
-
return _regeneratorRuntime().wrap(function
|
|
430
|
-
while (1) switch (
|
|
468
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(value) {
|
|
469
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
470
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
431
471
|
case 0:
|
|
432
|
-
return
|
|
433
|
-
var
|
|
472
|
+
return _context6.abrupt("return", new Promise(function (resolve, reject) {
|
|
473
|
+
var _document12;
|
|
434
474
|
var listener = function listener(event) {
|
|
435
475
|
if (event.data.type === 'combine-files-completed' && event.data.success) {
|
|
436
476
|
resolve(event.data.message); // Resolve the promise with the result
|
|
@@ -445,7 +485,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
445
485
|
window.addEventListener('message', listener);
|
|
446
486
|
|
|
447
487
|
// @ts-ignore
|
|
448
|
-
var iframeWin = (
|
|
488
|
+
var iframeWin = (_document12 = document) === null || _document12 === void 0 || (_document12 = _document12.getElementById('webviewer-1')) === null || _document12 === void 0 ? void 0 : _document12.contentWindow;
|
|
449
489
|
|
|
450
490
|
// Sending the extract-pages message to the iframe
|
|
451
491
|
iframeWin.postMessage({
|
|
@@ -455,21 +495,21 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
455
495
|
}));
|
|
456
496
|
case 1:
|
|
457
497
|
case "end":
|
|
458
|
-
return
|
|
498
|
+
return _context6.stop();
|
|
459
499
|
}
|
|
460
|
-
},
|
|
500
|
+
}, _callee6);
|
|
461
501
|
}));
|
|
462
502
|
return function combineFiles(_x4) {
|
|
463
|
-
return
|
|
503
|
+
return _ref8.apply(this, arguments);
|
|
464
504
|
};
|
|
465
505
|
}();
|
|
466
506
|
var extractPages = /*#__PURE__*/function () {
|
|
467
|
-
var
|
|
468
|
-
return _regeneratorRuntime().wrap(function
|
|
469
|
-
while (1) switch (
|
|
507
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(value) {
|
|
508
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
509
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
470
510
|
case 0:
|
|
471
|
-
return
|
|
472
|
-
var
|
|
511
|
+
return _context7.abrupt("return", new Promise(function (resolve, reject) {
|
|
512
|
+
var _document13;
|
|
473
513
|
var listener = function listener(event) {
|
|
474
514
|
if (event.data.type === 'extract-pages-completed' && event.data.success) {
|
|
475
515
|
resolve(event.data.result); // Resolve the promise with the result
|
|
@@ -484,7 +524,7 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
484
524
|
window.addEventListener('message', listener);
|
|
485
525
|
|
|
486
526
|
// @ts-ignore
|
|
487
|
-
var iframeWin = (
|
|
527
|
+
var iframeWin = (_document13 = document) === null || _document13 === void 0 || (_document13 = _document13.getElementById('webviewer-1')) === null || _document13 === void 0 ? void 0 : _document13.contentWindow;
|
|
488
528
|
|
|
489
529
|
// Sending the extract-pages message to the iframe
|
|
490
530
|
iframeWin.postMessage({
|
|
@@ -494,16 +534,17 @@ var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) {
|
|
|
494
534
|
}));
|
|
495
535
|
case 1:
|
|
496
536
|
case "end":
|
|
497
|
-
return
|
|
537
|
+
return _context7.stop();
|
|
498
538
|
}
|
|
499
|
-
},
|
|
539
|
+
}, _callee7);
|
|
500
540
|
}));
|
|
501
541
|
return function extractPages(_x5) {
|
|
502
|
-
return
|
|
542
|
+
return _ref9.apply(this, arguments);
|
|
503
543
|
};
|
|
504
544
|
}();
|
|
505
545
|
return {
|
|
506
546
|
requestBuffer: requestBuffer,
|
|
547
|
+
finalizeDocument: finalizeDocument,
|
|
507
548
|
removeChatHistory: removeChatHistory,
|
|
508
549
|
setAuthInfo: setAuthInfo,
|
|
509
550
|
splitPages: splitPages,
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export const useCreateIframeAndLoadViewer = ({
|
|
|
15
15
|
onFileFailed,
|
|
16
16
|
defaultAnnotationEditorMode,
|
|
17
17
|
initialAnnotations,
|
|
18
|
+
notarySeal,
|
|
18
19
|
initialSigners,
|
|
19
20
|
modifiedUiElements
|
|
20
21
|
}) => {
|
|
@@ -210,6 +211,30 @@ export const useCreateIframeAndLoadViewer = ({
|
|
|
210
211
|
});
|
|
211
212
|
};
|
|
212
213
|
|
|
214
|
+
const finalizeDocument = async () => {
|
|
215
|
+
return new Promise((resolve, reject) => {
|
|
216
|
+
const listener = (event) => {
|
|
217
|
+
if (!event || !event.data) return;
|
|
218
|
+
if (event.data.type === 'finalize-document') {
|
|
219
|
+
// Child posts { type: 'finalize-document', annotations }
|
|
220
|
+
resolve(event.data.annotations);
|
|
221
|
+
window.removeEventListener('message', listener);
|
|
222
|
+
} else if (event.data.type === 'finalize-document-failed') {
|
|
223
|
+
reject(new Error(event.data.message || 'Finalize document failed'));
|
|
224
|
+
window.removeEventListener('message', listener);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// Add listener to capture the next finalize signal
|
|
229
|
+
window.addEventListener('message', listener);
|
|
230
|
+
|
|
231
|
+
// Optionally nudge the iframe if it supports being prompted to finalize
|
|
232
|
+
// @ts-ignore
|
|
233
|
+
var iframeWin = document?.getElementById('webviewer-1')?.contentWindow;
|
|
234
|
+
iframeWin?.postMessage({ type: 'finalize-document' }, window.location.origin);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
213
238
|
const toggleSignatureModal = (enable) => {
|
|
214
239
|
// @ts-ignore
|
|
215
240
|
var iframeWin = document?.getElementById('webviewer-1')?.contentWindow;
|
|
@@ -353,6 +378,7 @@ export const useCreateIframeAndLoadViewer = ({
|
|
|
353
378
|
|
|
354
379
|
return {
|
|
355
380
|
requestBuffer,
|
|
381
|
+
finalizeDocument,
|
|
356
382
|
removeChatHistory,
|
|
357
383
|
setAuthInfo,
|
|
358
384
|
splitPages,
|
|
@@ -371,4 +397,4 @@ export const useCreateIframeAndLoadViewer = ({
|
|
|
371
397
|
authTokens,
|
|
372
398
|
signatureModalOpen
|
|
373
399
|
};
|
|
374
|
-
};
|
|
400
|
+
};
|