@tobyt/expo-pdf-markup 1.1.1 → 1.1.3
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/CHANGELOG.md +18 -0
- package/README.md +9 -6
- package/build/ExpoPdfMarkup.types.d.ts.map +1 -1
- package/build/ExpoPdfMarkup.types.js.map +1 -1
- package/build/ExpoPdfMarkupView.d.ts +1 -1
- package/build/ExpoPdfMarkupView.d.ts.map +1 -1
- package/build/ExpoPdfMarkupView.js +2 -1
- package/build/ExpoPdfMarkupView.js.map +1 -1
- package/build/ExpoPdfMarkupView.web.d.ts +2 -0
- package/build/ExpoPdfMarkupView.web.d.ts.map +1 -1
- package/build/ExpoPdfMarkupView.web.js +39 -36
- package/build/ExpoPdfMarkupView.web.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/pdfjs.d.ts +1 -0
- package/build/pdfjs.d.ts.map +1 -1
- package/build/pdfjs.js +3 -0
- package/build/pdfjs.js.map +1 -1
- package/build/pdfjs.web.d.ts +1 -1
- package/build/pdfjs.web.d.ts.map +1 -1
- package/build/pdfjs.web.js +1 -1
- package/build/pdfjs.web.js.map +1 -1
- package/build/web/annotationUtils.d.ts.map +1 -1
- package/build/web/annotationUtils.js +13 -5
- package/build/web/annotationUtils.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +113 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1648 -0
- package/docs/functions/ExpoPdfMarkupView.html +42 -0
- package/docs/functions/setPdfJsWorkerSrc.html +42 -0
- package/docs/hierarchy.html +29 -0
- package/docs/index.html +148 -0
- package/docs/modules.html +40 -0
- package/docs/types/Annotation.html +33 -0
- package/docs/types/AnnotationBounds.html +73 -0
- package/docs/types/AnnotationMode.html +33 -0
- package/docs/types/AnnotationPoint.html +61 -0
- package/docs/types/AnnotationsData.html +61 -0
- package/docs/types/ExpoPdfMarkupViewProps.html +184 -0
- package/docs/types/HighlightAnnotation.html +91 -0
- package/docs/types/InkAnnotation.html +91 -0
- package/docs/types/StampAnnotation.html +95 -0
- package/docs/types/StampDefinition.html +72 -0
- package/docs/types/TextAnnotation.html +110 -0
- package/docs/types/TextInputRequest.html +73 -0
- package/docs/types/UnderlineAnnotation.html +85 -0
- package/ios/AnnotationSerializer.swift +6 -34
- package/ios/ExpoPdfMarkupView+Ink.swift +2 -10
- package/ios/ExpoPdfMarkupView+Move.swift +4 -3
- package/ios/ExpoPdfMarkupView.swift +4 -3
- package/ios/InkPDFAnnotation.swift +45 -0
- package/ios/Tests/AnnotationSerializerTests.swift +26 -0
- package/metro.js +47 -20
- package/package.json +8 -8
- package/src/ExpoPdfMarkup.types.ts +2 -13
- package/src/ExpoPdfMarkupView.tsx +1 -1
- package/src/ExpoPdfMarkupView.web.tsx +26 -13
- package/src/index.ts +1 -1
- package/src/pdfjs.ts +4 -0
- package/src/pdfjs.web.ts +1 -1
- package/src/web/annotationUtils.ts +11 -5
|
@@ -204,17 +204,21 @@ export function hitTestAnnotation(
|
|
|
204
204
|
const onPage = annotations.filter((a) => a.page === pageIndex);
|
|
205
205
|
for (let i = onPage.length - 1; i >= 0; i--) {
|
|
206
206
|
const annotation = onPage[i];
|
|
207
|
+
if (!annotation) continue;
|
|
207
208
|
if (annotation.type === 'ink') {
|
|
208
209
|
const tolerance = Math.max(annotation.lineWidth ?? 2, 10);
|
|
209
210
|
const paths = annotation.paths ?? [];
|
|
210
211
|
for (const stroke of paths) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
212
|
+
const first = stroke[0];
|
|
213
|
+
if (stroke.length === 1 && first) {
|
|
214
|
+
const dx = pdfPoint.x - first.x;
|
|
215
|
+
const dy = pdfPoint.y - first.y;
|
|
214
216
|
if (Math.sqrt(dx * dx + dy * dy) <= tolerance) return annotation;
|
|
215
217
|
}
|
|
216
218
|
for (let j = 0; j < stroke.length - 1; j++) {
|
|
217
|
-
|
|
219
|
+
const from = stroke[j];
|
|
220
|
+
const to = stroke[j + 1];
|
|
221
|
+
if (from && to && distanceToSegment(pdfPoint, from, to) <= tolerance) {
|
|
218
222
|
return annotation;
|
|
219
223
|
}
|
|
220
224
|
}
|
|
@@ -271,7 +275,9 @@ export function drawAnnotationsOnCanvas(
|
|
|
271
275
|
if (stroke.length === 0) continue;
|
|
272
276
|
ctx.beginPath();
|
|
273
277
|
for (let i = 0; i < stroke.length; i++) {
|
|
274
|
-
const
|
|
278
|
+
const point = stroke[i];
|
|
279
|
+
if (!point) continue;
|
|
280
|
+
const { x, y } = pdfToCanvas(point.x, point.y, scale, pdfHeight);
|
|
275
281
|
if (i === 0) ctx.moveTo(x, y);
|
|
276
282
|
else ctx.lineTo(x, y);
|
|
277
283
|
}
|