pdf_editor_aleon35_react_plugin
Advanced tools
Comparing version 1.0.68 to 1.0.70
@@ -169,4 +169,4 @@ "use strict"; | ||
}; | ||
var mergeFiles = /*#__PURE__*/function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) { | ||
var splitPages = /*#__PURE__*/function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
@@ -178,6 +178,6 @@ while (1) switch (_context.prev = _context.next) { | ||
var listener = function listener(event) { | ||
if (event.data.type === 'merge-files-completed' && event.data.success) { | ||
if (event.data.type === 'split-pages-completed' && event.data.success) { | ||
resolve(event.data.message); // Resolve the promise with the result | ||
window.removeEventListener('message', listener); // Remove the listener to clean up | ||
} else if (event.data.type === 'merge-files-failed') { | ||
} else if (event.data.type === 'split-pages-failed') { | ||
reject(new Error(event.data.message)); // Reject the promise with the error message | ||
@@ -196,4 +196,3 @@ window.removeEventListener('message', listener); // Remove the listener to clean up | ||
iframeWin.postMessage({ | ||
type: 'merge-files', | ||
value: value | ||
type: 'split-pages' | ||
}, window.location.origin); | ||
@@ -207,7 +206,7 @@ })); | ||
})); | ||
return function mergeFiles(_x2) { | ||
return function splitPages() { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}(); | ||
var combineFiles = /*#__PURE__*/function () { | ||
var mergeFiles = /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value) { | ||
@@ -220,6 +219,6 @@ return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
var listener = function listener(event) { | ||
if (event.data.type === 'combine-files-completed' && event.data.success) { | ||
if (event.data.type === 'merge-files-completed' && event.data.success) { | ||
resolve(event.data.message); // Resolve the promise with the result | ||
window.removeEventListener('message', listener); // Remove the listener to clean up | ||
} else if (event.data.type === 'combine-files-failed') { | ||
} else if (event.data.type === 'merge-files-failed') { | ||
reject(new Error(event.data.message)); // Reject the promise with the error message | ||
@@ -238,3 +237,3 @@ window.removeEventListener('message', listener); // Remove the listener to clean up | ||
iframeWin.postMessage({ | ||
type: 'combine-files', | ||
type: 'merge-files', | ||
value: value | ||
@@ -249,7 +248,7 @@ }, window.location.origin); | ||
})); | ||
return function combineFiles(_x3) { | ||
return function mergeFiles(_x2) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
var extractPages = /*#__PURE__*/function () { | ||
var combineFiles = /*#__PURE__*/function () { | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(value) { | ||
@@ -262,2 +261,41 @@ return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
var listener = function listener(event) { | ||
if (event.data.type === 'combine-files-completed' && event.data.success) { | ||
resolve(event.data.message); // Resolve the promise with the result | ||
window.removeEventListener('message', listener); // Remove the listener to clean up | ||
} else if (event.data.type === 'combine-files-failed') { | ||
reject(new Error(event.data.message)); // Reject the promise with the error message | ||
window.removeEventListener('message', listener); // Remove the listener to clean up | ||
} | ||
}; | ||
// Adding the event listener before sending the postMessage | ||
window.addEventListener('message', listener); | ||
// @ts-ignore | ||
var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow; | ||
// Sending the extract-pages message to the iframe | ||
iframeWin.postMessage({ | ||
type: 'combine-files', | ||
value: value | ||
}, window.location.origin); | ||
})); | ||
case 1: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3); | ||
})); | ||
return function combineFiles(_x3) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
}(); | ||
var extractPages = /*#__PURE__*/function () { | ||
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value) { | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
return _context4.abrupt("return", new Promise(function (resolve, reject) { | ||
var _document7; | ||
var listener = function listener(event) { | ||
if (event.data.type === 'extract-pages-completed' && event.data.success) { | ||
@@ -276,3 +314,3 @@ resolve(event.data.result); // Resolve the promise with the result | ||
// @ts-ignore | ||
var iframeWin = (_document6 = document) === null || _document6 === void 0 || (_document6 = _document6.getElementById('webviewer-1')) === null || _document6 === void 0 ? void 0 : _document6.contentWindow; | ||
var iframeWin = (_document7 = document) === null || _document7 === void 0 || (_document7 = _document7.getElementById('webviewer-1')) === null || _document7 === void 0 ? void 0 : _document7.contentWindow; | ||
@@ -287,11 +325,12 @@ // Sending the extract-pages message to the iframe | ||
case "end": | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
}, _callee3); | ||
}, _callee4); | ||
})); | ||
return function extractPages(_x4) { | ||
return _ref4.apply(this, arguments); | ||
return _ref5.apply(this, arguments); | ||
}; | ||
}(); | ||
return { | ||
splitPages: splitPages, | ||
combineFiles: combineFiles, | ||
@@ -298,0 +337,0 @@ mergeFiles: mergeFiles, |
{ | ||
"name": "pdf_editor_aleon35_react_plugin", | ||
"version": "1.0.68", | ||
"version": "1.0.70", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -141,2 +141,26 @@ import { useEffect, useRef, useState } from 'react'; | ||
const splitPages = async () => { | ||
return new Promise((resolve, reject) => { | ||
const listener = (event) => { | ||
if (event.data.type === 'split-pages-completed' && event.data.success) { | ||
resolve(event.data.message); // Resolve the promise with the result | ||
window.removeEventListener('message', listener); // Remove the listener to clean up | ||
} | ||
else if (event.data.type === 'split-pages-failed') { | ||
reject(new Error(event.data.message)); // Reject the promise with the error message | ||
window.removeEventListener('message', listener); // Remove the listener to clean up | ||
} | ||
}; | ||
// Adding the event listener before sending the postMessage | ||
window.addEventListener('message', listener); | ||
// @ts-ignore | ||
var iframeWin = document?.getElementById('webviewer-1')?.contentWindow; | ||
// Sending the extract-pages message to the iframe | ||
iframeWin.postMessage({ type: 'split-pages' }, window.location.origin); | ||
}); | ||
} | ||
const mergeFiles = async (value) => { | ||
@@ -215,2 +239,3 @@ return new Promise((resolve, reject) => { | ||
return { | ||
splitPages, | ||
combineFiles, | ||
@@ -217,0 +242,0 @@ mergeFiles, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24888558
195
149879