aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PDFBox.tsx
diff options
context:
space:
mode:
authorMichael Foiani <sotech117@Michaels-MacBook-Pro-5.local>2022-06-23 13:13:46 -0400
committerMichael Foiani <sotech117@Michaels-MacBook-Pro-5.local>2022-06-23 13:13:46 -0400
commit7cacf9781395bc12c479acb51fa63cd0925a9430 (patch)
treed34cb900e73909006e1ca822f22c94a12634e01b /src/client/views/nodes/PDFBox.tsx
parent0370192be9c6c723f198fbf28d2a63ceef0e70d4 (diff)
parent8eb794e233f905daaa5b9a25c6720e567512653e (diff)
merge with mehek video
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
-rw-r--r--src/client/views/nodes/PDFBox.tsx44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index f2ca6c96e..4eb07fd8d 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -26,6 +26,7 @@ import { ImageBox } from './ImageBox';
import "./PDFBox.scss";
import { VideoBox } from './VideoBox';
import React = require("react");
+import { CollectionFreeFormView } from '../collections/collectionFreeForm';
@observer
export class PDFBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps & FieldViewProps>() {
@@ -147,34 +148,23 @@ export class PDFBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
}
updateIcon = () => {
- return; // currently we render pdf icons as text labels
+ // currently we render pdf icons as text labels
const docViewContent = this.props.docViewPath().lastElement().ContentDiv!;
- const newDiv = docViewContent.cloneNode(true) as HTMLDivElement;
- newDiv.style.width = (this.layoutDoc[WidthSym]()).toString();
- newDiv.style.height = (this.layoutDoc[HeightSym]()).toString();
- this.replaceCanvases(docViewContent, newDiv);
- const htmlString = this._pdfViewer?._mainCont.current && new XMLSerializer().serializeToString(newDiv);
- const nativeWidth = this.layoutDoc[WidthSym]();
- const nativeHeight = this.layoutDoc[HeightSym]();
-
- CreateImage(
- "",
- document.styleSheets,
- htmlString,
- nativeWidth,
- nativeWidth * this.props.PanelHeight() / this.props.PanelWidth(),
- NumCast(this.layoutDoc._scrollTop) * this.props.PanelHeight() / NumCast(this.rootDoc[this.fieldKey + "-nativeHeight"])
- ).then
- ((data_url: any) => {
- VideoBox.convertDataUri(data_url, this.layoutDoc[Id] + "-icon" + (new Date()).getTime(), true, this.layoutDoc[Id] + "-icon").then(
- returnedfilename => setTimeout(action(() => {
- this.dataDoc.icon = new ImageField(returnedfilename);
- this.dataDoc["icon-nativeWidth"] = nativeWidth;
- this.dataDoc["icon-nativeHeight"] = nativeHeight;
- }), 500));
- })
- .catch(function (error: any) {
- console.error('oops, something went wrong!', error);
+ const filename = this.layoutDoc[Id] + "-icon" + (new Date()).getTime();
+ this._pdfViewer?._mainCont.current && CollectionFreeFormView.UpdateIcon(
+ filename, docViewContent,
+ this.layoutDoc[WidthSym](), this.layoutDoc[HeightSym](),
+ this.props.PanelWidth(), this.props.PanelHeight(),
+ NumCast(this.layoutDoc._scrollTop),
+ NumCast(this.rootDoc[this.fieldKey + "-nativeHeight"], 1),
+ true,
+ this.layoutDoc[Id] + "-icon",
+ (iconFile:string, nativeWidth:number, nativeHeight:number) => {
+ setTimeout(() => {
+ this.dataDoc.icon = new ImageField(iconFile);
+ this.dataDoc["icon-nativeWidth"] = nativeWidth;
+ this.dataDoc["icon-nativeHeight"] = nativeHeight;
+ }, 500);
});
}