Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-adobe-embed

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-adobe-embed - npm Package Compare versions

Comparing version 0.7.69 to 0.8.69

88

lib/index.js

@@ -29,10 +29,6 @@ "use strict";

const react_1 = __importStar(require("react"));
const lodash_1 = require("lodash");
class AdobeReactView extends react_1.default.Component {
constructor(props) {
super(props);
this.onLoaded = () => {
var _a, _b, _c;
this.previewFile(((_a = this.state.config) === null || _a === void 0 ? void 0 : _a.divId) || "pdf-div", ((_b = this.state.config) === null || _b === void 0 ? void 0 : _b.clientId) || "CLIENT_ID", this.state.previewConfig || AdobeReactView.staticDefaultCOnfig, ((_c = this.state.config) === null || _c === void 0 ? void 0 : _c.url) ||
AdobeReactView.demoUrl);
};
this.state = {

@@ -47,8 +43,9 @@ isReady: props.isReady || false,

}
previewFile(divId, clientId, viewerConfig, url) {
previewFile(divId, viewerConfig, url) {
var _a;
this.adobeDCView = new window.AdobeDC.View({
clientId: clientId || ((_a = this.state.config) === null || _a === void 0 ? void 0 : _a.clientId) || "CLIENT_ID",
divId: divId || AdobeReactView.staticDefaultDivId,
});
const config = {
clientId: (_a = this.state.config) === null || _a === void 0 ? void 0 : _a.clientId,
divId,
};
this.adobeDCView = new window.AdobeDC.View(config);
const previewFilePromise = this.adobeDCView.previewFile({

@@ -64,2 +61,9 @@ content: {

}
onLoaded() {
var _a, _b;
this.previewFile(((_a = this.state.config) === null || _a === void 0 ? void 0 : _a.divId) || "pdf-div", this.state.previewConfig || AdobeReactView.staticDefaultCOnfig, ((_b = this.state.config) === null || _b === void 0 ? void 0 : _b.url) ||
AdobeReactView.demoUrl);
this.setState({ isReady: false });
}
;
onLoad() {

@@ -81,9 +85,51 @@ var _a;

}
previewFileUsingFilePromise(divId, filePromise, fileName) {
var _a;
this.adobeDCView = new window.AdobeDC.View({
clientId: (_a = this.state.config) === null || _a === void 0 ? void 0 : _a.clientId,
divId,
});
this.adobeDCView.previewFile({
content: {
promise: filePromise,
},
metaData: {
fileName: fileName,
},
}, {});
}
registerSaveApiHandler() {
const apiHandler = {
saveApiHandler: (metaData, content, options) => {
console.log(metaData, content, options);
return new Promise((resolve) => {
setTimeout(() => {
const response = {
code: window.AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
data: {
metaData: Object.assign(metaData, {
updatedAt: new Date().getTime(),
}),
},
};
resolve(response);
}, 2000);
});
},
};
this.adobeDCView.registerCallback(window.AdobeDC.View.Enum.CallbackType.SAVE_API, apiHandler, {});
}
registerEventsHandler() {
this.adobeDCView.registerCallback(window.AdobeDC.View.Enum.CallbackType.EVENT_LISTENER, (event) => {
console.log(event);
}, {
enablePDFAnalytics: true,
});
}
render() {
var _a, _b;
if (document.getElementById(((_a = this.state.config) === null || _a === void 0 ? void 0 : _a.divId) || AdobeReactView.staticDefaultDivId) ||
(this.state.isReady && this.state.adobeMainReady)) {
var _a;
if ((this.state.isReady && this.state.adobeMainReady)) {
this.onLoaded();
}
return ((0, jsx_runtime_1.jsx)("div", { id: ((_b = this.state.config) === null || _b === void 0 ? void 0 : _b.divId) || AdobeReactView.staticDefaultDivId, className: "AdobeReactView" }));
return ((0, jsx_runtime_1.jsx)("div", { id: ((_a = this.state.config) === null || _a === void 0 ? void 0 : _a.divId) || AdobeReactView.staticDefaultDivId, className: "AdobeReactView" }));
}

@@ -108,2 +154,4 @@ }

const [adobeMainReady, setAdobeMainReady] = (0, react_1.useState)(props.adobeMainReady || false);
const [previewConfig, setPreviewConfig] = (0, react_1.useState)(props.previewConfig ? (0, lodash_1.cloneDeep)(props.previewConfig) : AdobeReactView.staticDefaultCOnfig);
const [config, setConfig] = (0, react_1.useState)(props.config ? (0, lodash_1.cloneDeep)(props.config) : {});
const [isReady, setIsReady] = (0, react_1.useState)(props.isReady || false);

@@ -113,3 +161,5 @@ const divID = ((_a = props.config) === null || _a === void 0 ? void 0 : _a.divId) || AdobeReactView.staticDefaultDivId;

if (document.getElementById(divID)) {
setIsReady(true);
if (isReady === false) {
setIsReady(true);
}
}

@@ -125,8 +175,8 @@ if (global.adobeDCView) {

}, props: {
previewConfig: props.previewConfig,
config: props.config,
isReady: isReady,
adobeMainReady: adobeMainReady,
previewConfig,
config,
isReady,
adobeMainReady,
} }));
};
exports.default = ReactViewAdobe;
{
"name": "react-adobe-embed",
"version": "0.7.69",
"version": "0.8.69",
"description": "React Wrapper for Embed Adobe API",

@@ -25,3 +25,7 @@ "main": "lib/index.js",

"typescript": "^4.8.4"
},
"dependencies": {
"@types/lodash": "^4.14.186",
"lodash": "^4.17.21"
}
}

@@ -34,5 +34,8 @@ import React from "react";

} & Partial<EmbedState>);
previewFile(divId?: string, clientId?: string, viewerConfig?: Partial<PreviewFileConfig>, url?: string): any;
onLoaded: () => void;
previewFile(divId: string, viewerConfig: Partial<PreviewFileConfig>, url: string): any;
onLoaded(): void;
onLoad(): void;
previewFileUsingFilePromise(divId: string, filePromise: any, fileName: string): void;
registerSaveApiHandler(): void;
registerEventsHandler(): void;
render(): JSX.Element;

@@ -39,0 +42,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc