aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/PDFBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-08-08 12:27:40 -0400
committerbobzel <zzzman@gmail.com>2024-08-08 12:27:40 -0400
commit4574b7f03ccc85c4bebdbfd9475788456086704f (patch)
treed23d30343541b9af029ef418492d629d3cc710d7 /src/client/views/nodes/PDFBox.tsx
parente1db06d59d580aa640212a0d3a6aeecb9122bdf0 (diff)
many changes to add typing in place of 'any's etc
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
-rw-r--r--src/client/views/nodes/PDFBox.tsx18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 8db68ddfe..c03694dd9 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -1,5 +1,3 @@
-/* eslint-disable jsx-a11y/no-static-element-interactions */
-/* eslint-disable jsx-a11y/control-has-associated-label */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { action, computed, IReactionDisposer, makeObservable, observable, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
@@ -76,7 +74,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
});
else if (PDFBox.pdfpromise.get(this.pdfUrl.url.href))
PDFBox.pdfpromise.get(this.pdfUrl.url.href)?.then(
- action((pdf: any) => {
+ action(pdf => {
this._pdf = pdf;
})
);
@@ -108,7 +106,8 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
};
crop = (region: Doc | undefined, addCrop?: boolean) => {
- if (!region) return undefined;
+ const docViewContent = this.DocumentView?.().ContentDiv;
+ if (!region || !docViewContent) return undefined;
const cropping = Doc.MakeCopy(region, true);
cropping.layout_unrendered = false; // text selection have this
cropping.text_inlineAnnotations = undefined; // text selections have this -- it causes them not to be rendered.
@@ -120,7 +119,6 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
regionData.followLinkToggle = true;
this.addDocument(region);
- const docViewContent = this.DocumentView?.().ContentDiv!;
const newDiv = docViewContent.cloneNode(true) as HTMLDivElement;
newDiv.style.width = NumCast(this.layoutDoc._width).toString();
newDiv.style.height = NumCast(this.layoutDoc._height).toString();
@@ -162,7 +160,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
(NumCast(region.x) * this._props.PanelWidth()) / NumCast(this.dataDoc[this.fieldKey + '_nativeWidth']),
4
)
- .then((dataUrl: any) => {
+ .then(dataUrl => {
ClientUtils.convertDataUri(dataUrl, region[Id]).then(returnedfilename =>
setTimeout(
action(() => {
@@ -172,7 +170,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
)
);
})
- .catch((error: any) => {
+ .catch(error => {
console.error('oops, something went wrong!', error);
});
@@ -181,9 +179,10 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
updateIcon = () => {
// currently we render pdf icons as text labels
- const docViewContent = this.DocumentView?.().ContentDiv!;
+ const docViewContent = this.DocumentView?.().ContentDiv;
const filename = this.layoutDoc[Id] + '-icon' + new Date().getTime();
this._pdfViewer?._mainCont.current &&
+ docViewContent &&
UpdateIcon(
filename,
docViewContent,
@@ -475,6 +474,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
const cm = ContextMenu.Instance;
const options = cm.findByDescription('Options...');
const optionItems: ContextMenuProps[] = options && 'subitems' in options ? options.subitems : [];
+
!Doc.noviceMode && optionItems.push({ description: 'Toggle Sidebar Type', event: this.toggleSidebarType, icon: 'expand-arrows-alt' });
!Doc.noviceMode && optionItems.push({ description: 'update icon', event: () => this.pdfUrl && this.updateIcon(), icon: 'expand-arrows-alt' });
// optionItems.push({ description: "Toggle Sidebar ", event: () => this.toggleSidebar(), icon: "expand-arrows-alt" });
@@ -656,7 +656,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
else {
if (!PDFBox.pdfpromise.get(href)) PDFBox.pdfpromise.set(href, Pdfjs.getDocument(href).promise);
PDFBox.pdfpromise.get(href)?.then(
- action((pdf: any) => {
+ action(pdf => {
PDFBox.pdfcache.set(href, (this._pdf = pdf));
})
);