@embedpdf/plugin-annotation 3.0.0-next.3 → 3.0.0-next.4
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/{capability-hb2AU0f6.cjs → capability-CYbikyob.cjs} +36 -26
- package/dist/capability-CYbikyob.cjs.map +1 -0
- package/dist/{capability-fghl0JmE.js → capability-DjUdnoYn.js} +36 -26
- package/dist/capability-DjUdnoYn.js.map +1 -0
- package/dist/index.cjs +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/{types-Da6JRmhw.d.ts → types-CfewRmXH.d.cts} +12 -11
- package/dist/{types-BhWgqgbX.d.cts → types-DZ29RSW9.d.ts} +12 -11
- package/package.json +7 -7
- package/dist/capability-fghl0JmE.js.map +0 -1
- package/dist/capability-hb2AU0f6.cjs.map +0 -1
|
@@ -2,6 +2,7 @@ import { CONTINUOUS_RENDER_POLICY, createCapabilityToken, snapAppearanceScale }
|
|
|
2
2
|
import { InteractionToken } from "@embedpdf/plugin-interaction";
|
|
3
3
|
import { resolveBinarySource, sniffBinaryMetadata } from "@embedpdf/engine-core/runtime";
|
|
4
4
|
import { FLAG_KEYS, calloutLinePoints, chrome, clickCreateGeom, cloudyBorderExtent, contentToPdfPoint, contentToPdfRect, contentToPdfRect as contentToPdfRect$1, creationDraftAnchor, cursorAt, defaultsFor, expandGroups, fitStampBox, geomPdfBounds, geomRotation, geomVisualBounds, groupKeyOf, hitTest, initialTextStyle, normalizeDeg, pageItems, pdfToContentPoint, pdfToContentPoint as pdfToContentPoint$1, pdfToContentRect, pdfToContentRect as pdfToContentRect$1, propsFor, readProp, resolveClickPlacement, rotatedAabb, selectionAnchor, selectionQuad, sharedProps, styleFromProps, textBoxes, unionRect, update, uprightRotation, viewable } from "@embedpdf/core-annotation";
|
|
5
|
+
import { normalizeQuad, textQuadBounds } from "@embedpdf/core-geometry";
|
|
5
6
|
//#region src/types.ts
|
|
6
7
|
/**
|
|
7
8
|
* The annotation capability token. Typed to the full {@link AnnotationHostCapability}
|
|
@@ -522,20 +523,29 @@ const freeText = {
|
|
|
522
523
|
};
|
|
523
524
|
//#endregion
|
|
524
525
|
//#region src/repository/kinds/quads.ts
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
526
|
+
/**
|
|
527
|
+
* Imported `/QuadPoints` → semantic TextQuads. `normalizeQuad` is a
|
|
528
|
+
* NORMALIZER, not a cast: the de-facto zigzag order passes through, ring-order
|
|
529
|
+
* producers are repaired, and garbage gets a deterministic labeling — so
|
|
530
|
+
* drawing code can never put an underline on the wrong edge of a well-formed
|
|
531
|
+
* quad, rotated ones included.
|
|
532
|
+
*/
|
|
533
|
+
const quadsFromDTO = (quadPoints, crop) => quadPoints.map((q) => normalizeQuad({
|
|
534
|
+
p1: pdfToContentPoint$1(q.p1, crop),
|
|
535
|
+
p2: pdfToContentPoint$1(q.p2, crop),
|
|
536
|
+
p3: pdfToContentPoint$1(q.p3, crop),
|
|
537
|
+
p4: pdfToContentPoint$1(q.p4, crop)
|
|
538
|
+
}));
|
|
539
|
+
/** Content quads → engine `/QuadPoints` (PDF user space, zigzag slot order:
|
|
540
|
+
* p1..p4 = upper-start, upper-end, lower-start, lower-end — under the y-flip
|
|
541
|
+
* exactly PDFium's documented TL, TR, BL, BR); null off quads geom. */
|
|
532
542
|
function quadPointsFor(a, crop) {
|
|
533
543
|
if (a.geom.t !== "quads") return null;
|
|
534
544
|
return a.geom.quads.map((q) => ({
|
|
535
|
-
p1: contentToPdfPoint(q
|
|
536
|
-
p2: contentToPdfPoint(q
|
|
537
|
-
p3: contentToPdfPoint(q
|
|
538
|
-
p4: contentToPdfPoint(q
|
|
545
|
+
p1: contentToPdfPoint(q.upperStart, crop),
|
|
546
|
+
p2: contentToPdfPoint(q.upperEnd, crop),
|
|
547
|
+
p3: contentToPdfPoint(q.lowerStart, crop),
|
|
548
|
+
p4: contentToPdfPoint(q.lowerEnd, crop)
|
|
539
549
|
}));
|
|
540
550
|
}
|
|
541
551
|
/** PDF-space bounding box of a set of `/QuadPoints` quads — the `/Rect` a
|
|
@@ -593,15 +603,17 @@ const strikeout = markupProjection("strikeout");
|
|
|
593
603
|
const caret = {
|
|
594
604
|
ingest: (dto, crop) => {
|
|
595
605
|
const d = dto;
|
|
606
|
+
const rot = d.rotation ? fromPdfRotation(d.rotation) : 0;
|
|
596
607
|
return {
|
|
597
608
|
geom: {
|
|
598
609
|
t: "caret",
|
|
599
|
-
rect: pdfToContentRect$1(d.rect, crop)
|
|
610
|
+
rect: pdfToContentRect$1(rot && d.unrotatedRect ? d.unrotatedRect : d.rect, crop),
|
|
611
|
+
...rot ? { rot } : {}
|
|
600
612
|
},
|
|
601
613
|
...d.intent ? { intent: d.intent } : {}
|
|
602
614
|
};
|
|
603
615
|
},
|
|
604
|
-
geometry: (a, crop) => a.geom.t === "caret" ?
|
|
616
|
+
geometry: (a, crop) => a.geom.t === "caret" ? boxGeomFields(a.geom.rect, a.geom.rot ?? 0, crop) : null,
|
|
605
617
|
draftExtras: (a) => ({
|
|
606
618
|
rectDifferences: {
|
|
607
619
|
left: .5,
|
|
@@ -780,8 +792,6 @@ function foldAttachedLinks(annots) {
|
|
|
780
792
|
if (!folded.size) return annots;
|
|
781
793
|
return annots.filter((a) => !folded.has(a.id)).map((a) => patched.get(a.id) ?? a);
|
|
782
794
|
}
|
|
783
|
-
/** Bounds of one quad (content space). */
|
|
784
|
-
const quadBounds = (q) => unionRect(q);
|
|
785
795
|
/**
|
|
786
796
|
* The DESIRED hit rects (content space) of a parent's attached link
|
|
787
797
|
* children — derived fresh from the parent's committed geometry, never
|
|
@@ -797,7 +807,7 @@ const quadBounds = (q) => unionRect(q);
|
|
|
797
807
|
* `/QuadPoints` (tier 2).
|
|
798
808
|
*/
|
|
799
809
|
function linkChildRects(a) {
|
|
800
|
-
if (a.geom.t === "quads") return a.geom.quads.map(
|
|
810
|
+
if (a.geom.t === "quads") return a.geom.quads.map(textQuadBounds);
|
|
801
811
|
return [unionRect(selectionQuad(a.geom, a.style.strokeWidth, a.style.border))];
|
|
802
812
|
}
|
|
803
813
|
//#endregion
|
|
@@ -2477,30 +2487,30 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2477
2487
|
finishCreationDraft: () => apply({ t: "finishCreationDraft" }),
|
|
2478
2488
|
finishInkDraft: () => apply({ t: "finishInkDraft" }),
|
|
2479
2489
|
cancelCreationDraft: () => apply({ t: "cancel" }),
|
|
2480
|
-
createMarkup: (subtype, pon,
|
|
2490
|
+
createMarkup: (subtype, pon, quads, preset) => apply({
|
|
2481
2491
|
t: "createMarkup",
|
|
2482
2492
|
subtype,
|
|
2483
2493
|
pon,
|
|
2484
|
-
|
|
2494
|
+
quads,
|
|
2485
2495
|
preset,
|
|
2486
2496
|
flags: preset ? registry.get(preset)?.flags : void 0
|
|
2487
2497
|
}),
|
|
2488
|
-
createCaret: (pon,
|
|
2498
|
+
createCaret: (pon, anchor) => apply({
|
|
2489
2499
|
t: "createCaret",
|
|
2490
2500
|
pon,
|
|
2491
|
-
|
|
2501
|
+
anchor
|
|
2492
2502
|
}),
|
|
2493
|
-
createReplaceText: (pon,
|
|
2503
|
+
createReplaceText: (pon, quads, anchor, preset) => apply({
|
|
2494
2504
|
t: "createReplaceText",
|
|
2495
2505
|
pon,
|
|
2496
|
-
|
|
2497
|
-
|
|
2506
|
+
quads,
|
|
2507
|
+
anchor,
|
|
2498
2508
|
preset
|
|
2499
2509
|
}),
|
|
2500
|
-
previewMarkup: (subtype,
|
|
2510
|
+
previewMarkup: (subtype, quadsByPage, preset) => apply({
|
|
2501
2511
|
t: "setMarkupPreview",
|
|
2502
2512
|
subtype,
|
|
2503
|
-
|
|
2513
|
+
quadsByPage,
|
|
2504
2514
|
preset
|
|
2505
2515
|
}),
|
|
2506
2516
|
clearMarkupPreview: () => apply({ t: "clearMarkupPreview" }),
|
|
@@ -2677,4 +2687,4 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2677
2687
|
//#endregion
|
|
2678
2688
|
export { toCreateDraft as a, styleFromDTO as c, fromDTO as i, widgetAppearanceFromProps as l, DEFAULT_TOOLS as n, toPatch as o, buildToolRegistry as r, refKey as s, createAnnotationCapability as t, AnnotationToken as u };
|
|
2679
2689
|
|
|
2680
|
-
//# sourceMappingURL=capability-
|
|
2690
|
+
//# sourceMappingURL=capability-DjUdnoYn.js.map
|