aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/PDFViewer.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/pdf/PDFViewer.tsx')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx46
1 files changed, 10 insertions, 36 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 7543b3fb1..b5c69bff0 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -51,7 +51,7 @@ interface IViewerProps extends FieldViewProps {
* Handles rendering and virtualization of the pdf
*/
@observer
-export class PDFViewer extends ObservableReactComponent {
+export class PDFViewer extends ObservableReactComponent<IViewerProps> {
static _annotationStyle = addStyleSheet();
constructor(props: IViewerProps) {
@@ -68,12 +68,12 @@ export class PDFViewer extends ObservableReactComponent {
private _pdfViewer!: PDFJSViewer.PDFViewer;
private _styleRule: number | undefined; // stylesheet rule for making hyperlinks clickable
private _retries = 0; // number of times tried to create the PDF viewer
- private _setPreviewCursor: undefined | ((x: number, y: number, drag: boolean, hide: boolean, doc: Opt) => void);
+ private _setPreviewCursor: undefined | ((x: number, y: number, drag: boolean, hide: boolean, doc: Opt<Doc>) => void);
private _marqueeref = React.createRef<MarqueeAnnotator>();
- private _annotationLayer: React.RefObject = React.createRef();
+ private _annotationLayer: React.RefObject<HTMLDivElement> = React.createRef();
private _disposers: { [name: string]: IReactionDisposer } = {};
- private _viewer: React.RefObject = React.createRef();
- _mainCont: React.RefObject = React.createRef();
+ private _viewer: React.RefObject<HTMLDivElement> = React.createRef();
+ _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
private _selectionText: string = '';
private _selectionContent: DocumentFragment | undefined;
private _downX: number = 0;
@@ -81,9 +81,9 @@ export class PDFViewer extends ObservableReactComponent {
private _lastSearch = false;
private _viewerIsSetup = false;
private _ignoreScroll = false;
- private _initialScroll: { loc: Opt; easeFunc: 'linear' | 'ease' | undefined } | undefined;
+ private _initialScroll: { loc: Opt<number>; easeFunc: 'linear' | 'ease' | undefined } | undefined;
private _forcedScroll = true;
- _getAnchor: (savedAnnotations: Opt, addAsAnnotation: boolean) => Opt = () => undefined;
+ _getAnchor: (savedAnnotations: Opt<ObservableMap<number, HTMLDivElement[]>>, addAsAnnotation: boolean) => Opt<Doc> = () => undefined;
selectionText = () => this._selectionText;
selectionContent = () => this._selectionContent;
@@ -179,7 +179,7 @@ export class PDFViewer extends ObservableReactComponent {
// otherwise it will scroll smoothly.
scrollFocus = (doc: Doc, scrollTop: number, options: FocusViewOptions) => {
const mainCont = this._mainCont.current;
- let focusSpeed: Opt;
+ let focusSpeed: Opt<number>;
if (doc !== this._props.Document && mainCont) {
const windowHeight = this._props.PanelHeight() / (this._props.NativeDimScaling?.() || 1);
const scrollTo = ClientUtils.scrollIntoView(scrollTop, doc[Height](), NumCast(this._props.layoutDoc._layout_scrollTop), windowHeight, windowHeight * 0.1, this._scrollHeight);
@@ -394,30 +394,6 @@ export class PDFViewer extends ObservableReactComponent {
}
};
- // @action
- // createMarquee = (coords: [x1: number, x2: number, y1: number, y2: number]): void => {
- // // const hit = document.elementFromPoint(e.clientX, e.clientY);
- // // bcz: Change. drag selecting requires that preventDefault is NOT called. This used to happen in DocumentView,
- // // but that's changed, so this shouldn't be needed.
- // // if (hit && hit.localName === "span" && this.annotationsActive(true)) { // drag selecting text stops propagation
- // // e.button === 0 && e.stopPropagation();
- // // }
- // // if alt+left click, drag and annotate
- // this._downX = coords[0];
- // this._downY = coords[2];
-
- // if ((this._props.Document._freeform_scale || 1) !== 1) return;
- // this._props.select(false);
- // MarqueeAnnotator.clearAnnotations(this._savedAnnotations);
- // this.isAnnotating = true;
- // this._textSelecting = false;
- // // if textLayer is hit, then we select text instead of using a marquee so clear out the marquee.
- // this._styleRule = addStyleSheetRule(PDFViewer._annotationStyle, 'htmlAnnotation', { 'pointer-events': 'none' });
-
- // this._marqueeref.current?.onInitiateSelection([coords[0], coords[2]]);
- // this._marqueeref.current?.onTerminateSelection();
- // };
-
@action
finishMarquee = (/* x?: number, y?: number */) => {
this._getAnchor = AnchorMenu.Instance?.GetAnchor;
@@ -495,7 +471,7 @@ export class PDFViewer extends ObservableReactComponent {
// e.stopPropagation(); // bcz: not sure why this was here. We need to allow the DocumentView to get clicks to process doubleClicks
};
- setPreviewCursor = (func?: (x: number, y: number, drag: boolean, hide: boolean, doc: Opt) => void) => {
+ setPreviewCursor = (func?: (x: number, y: number, drag: boolean, hide: boolean, doc: Opt<Doc>) => void) => {
this._setPreviewCursor = func;
};
@@ -520,7 +496,6 @@ export class PDFViewer extends ObservableReactComponent {
return (
<div className="pdfViewerDash-annotationLayer" style={{ height: Doc.NativeHeight(this._props.Document), transform: `scale(${NumCast(this._props.layoutDoc._freeform_scale, 1)})` }} ref={this._annotationLayer}>
{inlineAnnos.map(anno => (
- // eslint-disable-next-line react/jsx-props-no-spreading
<Annotation {...this._props} fieldKey={this._props.fieldKey + '_annotations'} pointerEvents={this.pointerEvents} containerDataDoc={this._props.dataDoc} annoDoc={anno} key={`${anno[Id]}-annotation`} />
))}
</div>
@@ -534,7 +509,7 @@ export class PDFViewer extends ObservableReactComponent {
panelHeight = () => this._props.PanelHeight() / (this._props.NativeDimScaling?.() || 1);
transparentFilter = () => [...this._props.childFilters(), ClientUtils.TransparentBackgroundFilter];
opaqueFilter = () => [...this._props.childFilters(), ClientUtils.noDragDocsFilter, ...(SnappingManager.CanEmbed && this._props.isContentActive() ? [] : [ClientUtils.OpaqueBackgroundFilter])];
- childStyleProvider = (doc: Doc | undefined, props: Opt, property: string) => {
+ childStyleProvider = (doc: Doc | undefined, props: Opt<FieldViewProps>, property: string) => {
if (doc instanceof Doc && property === StyleProp.PointerEvents) {
if (this.inlineTextAnnotations.includes(doc) || this._props.isContentActive() === false) return 'none';
const isInk = doc.layout_isSvg && !props?.LayoutTemplateString;
@@ -554,7 +529,6 @@ export class PDFViewer extends ObservableReactComponent {
pointerEvents: Doc.ActiveTool !== InkTool.None ? 'all' : undefined,
}}>
<CollectionFreeFormView
- // eslint-disable-next-line react/jsx-props-no-spreading
{...this._props}
NativeWidth={returnZero}
NativeHeight={returnZero}