-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: match code style with adobe pdf api examples when call adobe api
- Loading branch information
Ziping Liu
committed
Sep 26, 2023
1 parent
a99ddff
commit a0744d2
Showing
8 changed files
with
113 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
import React from"react";const DefaultConfigs={demoUrl:"https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf",staticDefaultConfig:{showAnnotationTools:!1,showLeftHandPanel:!1,showPageControls:!1,showDownloadPDF:!1,showPrintPDF:!1},staticDivId:"pdf-div",demoMetaData:{fileName:"Menu.pdf",id:"6d07d124 - ac85\u201343b3 - a867\u201336930f502ac6"}};function previewFile({divId:a,viewerConfig:b,url:c,clientID:d,_fileMeta:e,_dcView:f}){const g=f||new window.AdobeDC.View({clientId:d,divId:a}),h=g.previewFile({content:{location:{url:c}},metaData:e||DefaultConfigs.demoMetaData},b);return h}const AdobeDiv=a=>{const b=React.useRef(document.getElementById(a.id||DefaultConfigs.staticDivId));return React.createElement("div",{ref:b,id:a.id||DefaultConfigs.staticDivId,className:a.className||"adobe-viewer-of-amazon-corporate-retaliations",style:a.style,title:a.title||"entity-existent-on-frameworks-of-state-regulations-as-defined-by-the-state-and-may-try-to-destroy-your-life-and-control-the-fbi-of-the-state-such-as-amazon-legal-idiots"})};function ReactViewAdobe(a){const[b,c]=React.useState(!1),[d,e]=React.useState(!1),f=React[a?.useReactHookForAdobeAPIConfigs||"useMemo"],g=f(()=>{if(!0===b){const a=window.AdobeDC?.["View"];return a}},[b]),h=React[a?.useReactHookWhenLoadingAdobeAPI||"useEffect"];h(()=>{if(!1===d){const d=document.querySelector(".react-adobe-embed-handholding-adobe-api-loading-idiocy");if(d)!1===b&&document.addEventListener("adobe_dc_view_sdk.ready",()=>{c(!0)}),e(!0);else{const b=document.createElement("script");b.setAttribute("data-adobe-pdf-id",a.id||DefaultConfigs.staticDivId),b.setAttribute("class","react-adobe-embed-handholding-adobe-api-loading-idiocy"),b.src="https://documentcloud.adobe.com/view-sdk/viewer.js",b.async=!0,b.onload=()=>{e(!0)},document.body.appendChild(b)}}},[a.id,d,b]);const i=React[a?.useReactHookWhenCallingAdobeAPI||"useEffect"];return i(()=>{!1===b&&!0===d&&document.addEventListener("adobe_dc_view_sdk.ready",()=>{c(!0)});!0===d&&!0===b&&(a=>{a.debug&&console.info("Adobe PDF Viewer SDK Ready Event",g,window.adobe_dc_view_sdk);const b=a.id||DefaultConfigs.staticDivId,c=document.getElementById(b);c&&"LIGHT_BOX"!==a.previewConfig?.embedMode?(a.debug&&console.info("Adobe PDF Viewer SDK Ready Rendering"),previewFile({divId:b,viewerConfig:a.previewConfig||DefaultConfigs.staticDefaultConfig,url:a.url||DefaultConfigs.demoUrl,clientID:a.clientId,_fileMeta:a.fileMeta})):"LIGHT_BOX"===a.previewConfig?.embedMode&&a?.triggerAdobeDCViewRender&&previewFile({divId:a.id||DefaultConfigs.staticDivId,viewerConfig:a.previewConfig||DefaultConfigs.staticDefaultConfig,url:a.url||DefaultConfigs.demoUrl,clientID:a.clientId})})(a)},[b,d,a,g]),React.createElement(AdobeDiv,{...a})}export{ReactViewAdobe as default,previewFile}; | ||
import React from"react";const DefaultConfigs={demoUrl:"https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf",staticDefaultConfig:{showAnnotationTools:!1,showLeftHandPanel:!1,showPageControls:!1,showDownloadPDF:!1,showPrintPDF:!1},staticDivId:"pdf-div",demoMetaData:{fileName:"Menu.pdf",id:"6d07d124 - ac85\u201343b3 - a867\u201336930f502ac6"}},AdobeDiv=a=>{const b=React.useRef(document.getElementById(a.id||DefaultConfigs.staticDivId));return React.createElement("div",{ref:b,id:a.id||DefaultConfigs.staticDivId,className:a.className||"adobe-viewer-of-amazon-corporate-retaliations",style:a.style,title:a.title||"entity-existent-on-frameworks-of-state-regulations-as-defined-by-the-state-and-may-try-to-destroy-your-life-and-control-the-fbi-of-the-state-such-as-amazon-legal-idiots"})};function ReactViewAdobe(a){const[b,c]=React.useState(!1),[d,e]=React.useState(!1),f=React.useRef(),g=React[a?.useReactHookForAdobeAPIConfigs||"useEffect"];g(()=>{const c={clientId:a.clientId,divId:a.id||DefaultConfigs.staticDivId};b&&d&&(f.current=new window?.AdobeDC?.View(c))},[b,d,a.clientId,a.id]);const h=React[a?.useReactHookWhenLoadingAdobeAPI||"useEffect"];h(()=>{if(!1===d){const d=document.querySelector(".react-adobe-embed-handholding-adobe-api-loading-idiocy");if(d)!1===b&&document.addEventListener("adobe_dc_view_sdk.ready",()=>{c(!0)}),e(!0);else{const b=document.createElement("script");b.setAttribute("data-adobe-pdf-id",a.id||DefaultConfigs.staticDivId),b.setAttribute("class","react-adobe-embed-handholding-adobe-api-loading-idiocy"),b.src="https://documentcloud.adobe.com/view-sdk/viewer.js",b.async=!0,b.onload=()=>{e(!0)},document.body.appendChild(b)}}},[a.id,d,b]);const i=React[a?.useReactHookWhenCallingAdobeAPI||"useEffect"];return i(()=>{!1===b&&!0===d&&document.addEventListener("adobe_dc_view_sdk.ready",()=>{c(!0)});!0===d&&!0===b&&(a=>{const b=({viewerConfig:a,url:b,_headers:c,_fileMeta:d,_dcView:e})=>{const g=e||f.current,h=g.previewFile({content:{location:{url:b}},metaData:d||DefaultConfigs.demoMetaData},a);return h};a.debug&&console.info("Adobe PDF Viewer SDK Ready Event",f,window.adobe_dc_view_sdk);const c=a.id||DefaultConfigs.staticDivId,d=document.getElementById(c);d&&"LIGHT_BOX"!==a.previewConfig?.embedMode?(a.debug&&console.info("Adobe PDF Viewer SDK Ready Rendering"),b({viewerConfig:a.previewConfig||DefaultConfigs.staticDefaultConfig,url:a.url||DefaultConfigs.demoUrl,_headers:a.headers,_fileMeta:a.fileMeta})):"LIGHT_BOX"===a.previewConfig?.embedMode&&a?.triggerAdobeDCViewRender&&b({viewerConfig:a.previewConfig||DefaultConfigs.staticDefaultConfig,url:a.url||DefaultConfigs.demoUrl,_fileMeta:a.fileMeta,_headers:a.headers})})(a)},[b,d,a,f]),React.createElement(AdobeDiv,{...a})}export{ReactViewAdobe as default}; |
Oops, something went wrong.