pdf_editor_aleon35_react_plugin
Advanced tools
Comparing version 1.0.62 to 1.0.64
@@ -19,3 +19,3 @@ "use strict"; | ||
var useCreateIframeAndLoadViewer = function useCreateIframeAndLoadViewer(_ref) { | ||
var file = _ref.file, | ||
var files = _ref.files, | ||
fileName = _ref.fileName, | ||
@@ -63,3 +63,3 @@ licenseKey = _ref.licenseKey, | ||
var message = { | ||
file: file, | ||
files: files, | ||
fileName: fileName, | ||
@@ -133,3 +133,3 @@ tools: tools, | ||
createIframe(); | ||
}, [container, file]); | ||
}, [container, files]); | ||
(0, _react.useEffect)(function () { | ||
@@ -172,11 +172,2 @@ document.addEventListener('click', function () { | ||
}; | ||
var mergeFiles2 = function mergeFiles2(value) { | ||
var _document4; | ||
// @ts-ignore | ||
var iframeWin = (_document4 = document) === null || _document4 === void 0 || (_document4 = _document4.getElementById('webviewer-1')) === null || _document4 === void 0 ? void 0 : _document4.contentWindow; | ||
iframeWin.postMessage({ | ||
type: 'merge-files', | ||
value: value | ||
}, window.location.origin); | ||
}; | ||
var mergeFiles = /*#__PURE__*/function () { | ||
@@ -188,3 +179,3 @@ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) { | ||
return _context.abrupt("return", new Promise(function (resolve, reject) { | ||
var _document5; | ||
var _document4; | ||
var listener = function listener(event) { | ||
@@ -204,3 +195,3 @@ if (event.data.type === 'merge-files-completed' && event.data.success) { | ||
// @ts-ignore | ||
var iframeWin = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow; | ||
var iframeWin = (_document4 = document) === null || _document4 === void 0 || (_document4 = _document4.getElementById('webviewer-1')) === null || _document4 === void 0 ? void 0 : _document4.contentWindow; | ||
@@ -223,3 +214,3 @@ // Sending the extract-pages message to the iframe | ||
}(); | ||
var extractPages = /*#__PURE__*/function () { | ||
var combineFiles = /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value) { | ||
@@ -230,2 +221,41 @@ return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
return _context2.abrupt("return", new Promise(function (resolve, reject) { | ||
var _document5; | ||
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 = (_document5 = document) === null || _document5 === void 0 || (_document5 = _document5.getElementById('webviewer-1')) === null || _document5 === void 0 ? void 0 : _document5.contentWindow; | ||
// Sending the extract-pages message to the iframe | ||
iframeWin.postMessage({ | ||
type: 'combine-files', | ||
value: value | ||
}, window.location.origin); | ||
})); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
return function combineFiles(_x3) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
var extractPages = /*#__PURE__*/function () { | ||
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(value) { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
return _context3.abrupt("return", new Promise(function (resolve, reject) { | ||
var _document6; | ||
@@ -256,11 +286,12 @@ var listener = function listener(event) { | ||
case "end": | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
}, _callee2); | ||
}, _callee3); | ||
})); | ||
return function extractPages(_x3) { | ||
return _ref3.apply(this, arguments); | ||
return function extractPages(_x4) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
}(); | ||
return { | ||
combineFiles: combineFiles, | ||
mergeFiles: mergeFiles, | ||
@@ -267,0 +298,0 @@ pagesLoaded: pagesLoaded, |
{ | ||
"name": "pdf_editor_aleon35_react_plugin", | ||
"version": "1.0.62", | ||
"version": "1.0.64", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,3 +6,3 @@ import * as React from 'react'; | ||
props: { | ||
file: string; | ||
files: string[]; | ||
licenseKey: string; | ||
@@ -9,0 +9,0 @@ tools: { |
import { useEffect, useRef, useState } from 'react'; | ||
export const useCreateIframeAndLoadViewer = ({ | ||
file, | ||
files, | ||
fileName, | ||
@@ -42,3 +42,3 @@ licenseKey, | ||
const targetOrigin = window.location.origin; | ||
const message = { file, fileName, tools, locale, licenseKey }; | ||
const message = { files, fileName, tools, locale, licenseKey }; | ||
@@ -110,3 +110,3 @@ // Set up a function to send the message | ||
createIframe(); | ||
}, [container, file]); | ||
}, [container, files]); | ||
@@ -143,8 +143,2 @@ useEffect(() => { | ||
const mergeFiles2 = (value) => { | ||
// @ts-ignore | ||
var iframeWin = document?.getElementById('webviewer-1')?.contentWindow; | ||
iframeWin.postMessage({ type: 'merge-files', value }, window.location.origin); | ||
} | ||
const mergeFiles = async (value) => { | ||
@@ -174,2 +168,26 @@ return new Promise((resolve, reject) => { | ||
const combineFiles = async (value) => { | ||
return new Promise((resolve, reject) => { | ||
const 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 = document?.getElementById('webviewer-1')?.contentWindow; | ||
// Sending the extract-pages message to the iframe | ||
iframeWin.postMessage({ type: 'combine-files', value }, window.location.origin); | ||
}); | ||
}; | ||
const extractPages = async (value) => { | ||
@@ -199,3 +217,7 @@ return new Promise((resolve, reject) => { | ||
return { mergeFiles, pagesLoaded, extractPages, download, toggleFullScreenThumbnails, isReady: internalIsReady, setThumbnailZoom, selectedPages }; | ||
return { | ||
combineFiles, | ||
mergeFiles, | ||
pagesLoaded, | ||
extractPages, download, toggleFullScreenThumbnails, isReady: internalIsReady, setThumbnailZoom, selectedPages }; | ||
}; |
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
20010423
149658