Skip to content

Commit ebe2107

Browse files
committed
Only use named exports
1 parent 39bb40d commit ebe2107

11 files changed

+19
-34
lines changed

src/components/AreaHighlight.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,3 @@ export function AreaHighlight({
5858
</div>
5959
);
6060
}
61-
62-
export default AreaHighlight;

src/components/MouseMonitor.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Props {
77
children: JSX.Element;
88
}
99

10-
class MouseMonitor extends Component<Props> {
10+
export class MouseMonitor extends Component<Props> {
1111
container: HTMLDivElement | null = null;
1212
unsubscribe = () => {};
1313

@@ -58,5 +58,3 @@ class MouseMonitor extends Component<Props> {
5858
);
5959
}
6060
}
61-
62-
export default MouseMonitor;

src/components/MouseSelection.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface Props {
2626
onChange: (isVisible: boolean) => void;
2727
}
2828

29-
class MouseSelection extends Component<Props, State> {
29+
export class MouseSelection extends Component<Props, State> {
3030
state: State = {
3131
locked: false,
3232
start: null,
@@ -206,5 +206,3 @@ class MouseSelection extends Component<Props, State> {
206206
);
207207
}
208208
}
209-
210-
export default MouseSelection;

src/components/PdfHighlighter.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import styles from "../style/PdfHighlighter.module.css";
2-
31
import debounce from "debounce";
42
import type { PDFDocumentProxy } from "pdfjs-dist";
53
import type { EventBus, PDFViewer } from "pdfjs-dist/legacy/web/pdf_viewer.mjs";
@@ -10,16 +8,17 @@ import React, {
108
} from "react";
119
import { type Root, createRoot } from "react-dom/client";
1210
import { scaledToViewport, viewportToScaled } from "../lib/coordinates";
13-
import getAreaAsPng from "../lib/get-area-as-png";
14-
import getBoundingRect from "../lib/get-bounding-rect";
15-
import getClientRects from "../lib/get-client-rects";
11+
import { getAreaAsPNG } from "../lib/get-area-as-png";
12+
import { getBoundingRect } from "../lib/get-bounding-rect";
13+
import { getClientRects } from "../lib/get-client-rects";
1614
import {
1715
findOrCreateContainerLayer,
1816
getPageFromElement,
1917
getPagesFromRange,
2018
getWindow,
2119
isHTMLElement,
2220
} from "../lib/pdfjs-dom";
21+
import styles from "../style/PdfHighlighter.module.css";
2322
import type {
2423
IHighlight,
2524
LTWH,
@@ -29,7 +28,7 @@ import type {
2928
ScaledPosition,
3029
} from "../types";
3130
import { HighlightLayer } from "./HighlightLayer";
32-
import MouseSelection from "./MouseSelection";
31+
import { MouseSelection } from "./MouseSelection";
3332
import { TipContainer } from "./TipContainer";
3433

3534
export type T_ViewportHighlight<T_HT> = { position: Position } & T_HT;
@@ -307,7 +306,7 @@ export class PdfHighlighter<T_HT extends IHighlight> extends PureComponent<
307306
screenshot(position: LTWH, pageNumber: number) {
308307
const canvas = this.viewer.getPageView(pageNumber - 1).canvas;
309308

310-
return getAreaAsPng(canvas, position);
309+
return getAreaAsPNG(canvas, position);
311310
}
312311

313312
hideTipAndSelection = () => {

src/components/PdfLoader.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,3 @@ export class PdfLoader extends Component<Props, State> {
114114
return null;
115115
}
116116
}
117-
118-
export default PdfLoader;

src/components/Popup.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
import MouseMonitor from "./MouseMonitor";
2+
import { MouseMonitor } from "./MouseMonitor";
33

44
interface Props {
55
onMouseOver: (content: JSX.Element) => void;

src/components/Tip.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,3 @@ export class Tip extends Component<Props, State> {
9494
);
9595
}
9696
}
97-
98-
export default Tip;

src/lib/get-area-as-png.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import type { LTWHP } from "../types.js";
22
import { isHTMLCanvasElement } from "./pdfjs-dom";
33

4-
const getAreaAsPNG = (canvas: HTMLCanvasElement, position: LTWHP): string => {
4+
export const getAreaAsPNG = (
5+
canvas: HTMLCanvasElement,
6+
position: LTWHP,
7+
): string => {
58
const { left, top, width, height } = position;
69

710
const doc = canvas ? canvas.ownerDocument : null;
@@ -37,5 +40,3 @@ const getAreaAsPNG = (canvas: HTMLCanvasElement, position: LTWHP): string => {
3740

3841
return newCanvas.toDataURL("image/png");
3942
};
40-
41-
export default getAreaAsPNG;

src/lib/get-bounding-rect.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { LTWHP } from "../types.js";
22

3-
const getBoundingRect = (clientRects: Array<LTWHP>): LTWHP => {
3+
export const getBoundingRect = (clientRects: Array<LTWHP>): LTWHP => {
44
const rects = Array.from(clientRects).map((rect) => {
55
const { left, top, width, height, pageNumber } = rect;
66

@@ -50,5 +50,3 @@ const getBoundingRect = (clientRects: Array<LTWHP>): LTWHP => {
5050
pageNumber,
5151
};
5252
};
53-
54-
export default getBoundingRect;

src/lib/get-client-rects.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { LTWHP, Page } from "../types.js";
2-
3-
import optimizeClientRects from "./optimize-client-rects";
2+
import { optimizeClientRects } from "./optimize-client-rects";
43

54
const isClientRectInsidePageRect = (clientRect: DOMRect, pageRect: DOMRect) => {
65
if (clientRect.top < pageRect.top) {
@@ -19,7 +18,7 @@ const isClientRectInsidePageRect = (clientRect: DOMRect, pageRect: DOMRect) => {
1918
return true;
2019
};
2120

22-
const getClientRects = (
21+
export const getClientRects = (
2322
range: Range,
2423
pages: Page[],
2524
shouldOptimize = true,
@@ -54,5 +53,3 @@ const getClientRects = (
5453

5554
return shouldOptimize ? optimizeClientRects(rects) : rects;
5655
};
57-
58-
export default getClientRects;

src/lib/optimize-client-rects.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ const extendWidth = (A: LTWHP, B: LTWHP) => {
4545
A.width = Math.max(B.width - A.left + B.left, A.width);
4646
};
4747

48-
const optimizeClientRects = (clientRects: Array<LTWHP>): Array<LTWHP> => {
48+
export const optimizeClientRects = (
49+
clientRects: Array<LTWHP>,
50+
): Array<LTWHP> => {
4951
const rects = sort(clientRects);
5052

5153
const toRemove = new Set();
@@ -88,5 +90,3 @@ const optimizeClientRects = (clientRects: Array<LTWHP>): Array<LTWHP> => {
8890

8991
return firstPass.filter((rect) => !toRemove.has(rect));
9092
};
91-
92-
export default optimizeClientRects;

0 commit comments

Comments
 (0)