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