@embedpdf/plugin-annotation 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +2 -57
- package/dist/preact/index.js.map +1 -1
- package/dist/preact/utils.d.ts +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +3 -58
- package/dist/react/index.js.map +1 -1
- package/dist/react/utils.d.ts +1 -0
- package/dist/shared-preact/index.d.ts +1 -0
- package/dist/shared-preact/types.d.ts +1 -1
- package/dist/shared-react/index.d.ts +1 -0
- package/dist/shared-react/types.d.ts +1 -1
- package/package.json +11 -10
- package/dist/shared-preact/components/counter-rotate-container.d.ts +0 -33
- package/dist/shared-react/components/counter-rotate-container.d.ts +0 -33
package/dist/preact/index.js
CHANGED
|
@@ -1,72 +1,17 @@
|
|
|
1
1
|
import { usePlugin, useCapability } from "@embedpdf/core/preact";
|
|
2
2
|
import { AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationByPageIndex, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp } from "@embedpdf/plugin-annotation";
|
|
3
|
+
export * from "@embedpdf/plugin-annotation";
|
|
3
4
|
import { jsx, jsxs, Fragment as Fragment$1 } from "preact/jsx-runtime";
|
|
4
5
|
import { restoreOffset, rectEquals, PdfAnnotationBorderStyle, PdfAnnotationSubtype, expandRect, rectFromPoints, textAlignmentToCss, standardFontCss, PdfVerticalAlignment, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, uuidV4 } from "@embedpdf/models";
|
|
5
6
|
import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
|
|
6
7
|
import { useSelectionCapability } from "@embedpdf/plugin-selection/preact";
|
|
7
8
|
import { Fragment } from "preact";
|
|
8
9
|
import { useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from "preact/hooks";
|
|
10
|
+
import { CounterRotate } from "@embedpdf/utils/preact";
|
|
9
11
|
import { clamp } from "@embedpdf/core";
|
|
10
12
|
const useAnnotationPlugin = () => usePlugin(AnnotationPlugin.id);
|
|
11
13
|
const useAnnotationCapability = () => useCapability(AnnotationPlugin.id);
|
|
12
14
|
const mapDoubleClick = (handler) => handler ? { onDblClick: handler } : {};
|
|
13
|
-
function getCounterRotation(rect, rotation) {
|
|
14
|
-
const { width: w, height: h } = rect.size;
|
|
15
|
-
switch (rotation % 4) {
|
|
16
|
-
case 1:
|
|
17
|
-
return {
|
|
18
|
-
matrix: `matrix(0, -1, 1, 0, 0, ${h})`,
|
|
19
|
-
width: h,
|
|
20
|
-
height: w
|
|
21
|
-
};
|
|
22
|
-
case 2:
|
|
23
|
-
return {
|
|
24
|
-
matrix: `matrix(-1, 0, 0, -1, ${w}, ${h})`,
|
|
25
|
-
width: w,
|
|
26
|
-
height: h
|
|
27
|
-
};
|
|
28
|
-
case 3:
|
|
29
|
-
return {
|
|
30
|
-
matrix: `matrix(0, 1, -1, 0, ${w}, 0)`,
|
|
31
|
-
width: h,
|
|
32
|
-
height: w
|
|
33
|
-
};
|
|
34
|
-
default:
|
|
35
|
-
return {
|
|
36
|
-
matrix: `matrix(1, 0, 0, 1, 0, 0)`,
|
|
37
|
-
width: w,
|
|
38
|
-
height: h
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function CounterRotate({ children, ...props }) {
|
|
43
|
-
const { rect, rotation } = props;
|
|
44
|
-
const { matrix, width, height } = getCounterRotation(rect, rotation);
|
|
45
|
-
const menuWrapperStyle = {
|
|
46
|
-
position: "absolute",
|
|
47
|
-
left: rect.origin.x,
|
|
48
|
-
top: rect.origin.y,
|
|
49
|
-
transform: matrix,
|
|
50
|
-
transformOrigin: "0 0",
|
|
51
|
-
width,
|
|
52
|
-
height,
|
|
53
|
-
pointerEvents: "none",
|
|
54
|
-
zIndex: 3
|
|
55
|
-
};
|
|
56
|
-
const menuWrapperProps = {
|
|
57
|
-
style: menuWrapperStyle,
|
|
58
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
59
|
-
onTouchStart: (e) => e.stopPropagation()
|
|
60
|
-
};
|
|
61
|
-
return /* @__PURE__ */ jsx(Fragment, { children: children({
|
|
62
|
-
menuWrapperProps,
|
|
63
|
-
matrix,
|
|
64
|
-
rect: {
|
|
65
|
-
origin: { x: rect.origin.x, y: rect.origin.y },
|
|
66
|
-
size: { width, height }
|
|
67
|
-
}
|
|
68
|
-
}) });
|
|
69
|
-
}
|
|
70
15
|
function VertexEditor({
|
|
71
16
|
rect,
|
|
72
17
|
rotation,
|