@embedpdf/plugin-annotation 3.0.0-next.6 → 3.0.0-next.8
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-BMBwSdaY.cjs → capability-2FkTVblD.cjs} +50 -14
- package/dist/capability-2FkTVblD.cjs.map +1 -0
- package/dist/{capability-CYYDz4dW.js → capability-BNMRdnKf.js} +46 -16
- package/dist/capability-BNMRdnKf.js.map +1 -0
- package/dist/index.cjs +36 -9
- 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 +36 -9
- 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-N25K86pT.d.cts → types-CvtDbnF5.d.cts} +24 -5
- package/dist/{types-BCB5YKIk.d.ts → types-Dy1RganE.d.ts} +24 -5
- package/package.json +7 -7
- package/dist/capability-BMBwSdaY.cjs.map +0 -1
- package/dist/capability-CYYDz4dW.js.map +0 -1
|
@@ -2,7 +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 { SelectionToken } from "@embedpdf/plugin-selection";
|
|
5
|
-
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 { FLAG_KEYS, calloutLinePoints, canMove, 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";
|
|
6
6
|
import { normalizeQuad, textQuadBounds } from "@embedpdf/core-geometry";
|
|
7
7
|
//#region src/types.ts
|
|
8
8
|
/**
|
|
@@ -10,7 +10,7 @@ import { normalizeQuad, textQuadBounds } from "@embedpdf/core-geometry";
|
|
|
10
10
|
* here (the package internals + the `/internal` entry use this view). The package
|
|
11
11
|
* root re-exports the SAME token narrowed to {@link AnnotationCapability}.
|
|
12
12
|
*/
|
|
13
|
-
const AnnotationToken = createCapabilityToken("annotation");
|
|
13
|
+
const AnnotationToken = createCapabilityToken("annotation", { hint: `add annotationPlugin() from '@embedpdf/plugin-annotation' to your plugins list` });
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/repository/seam.ts
|
|
16
16
|
function refKey(ref) {
|
|
@@ -1126,6 +1126,17 @@ const TOOL_DEFAULT_KEYS = {
|
|
|
1126
1126
|
const DRAW_TAGS = ["annotation-draw", "annotation-edit"];
|
|
1127
1127
|
const MARKUP_TAGS = ["text-select", "annotation-edit"];
|
|
1128
1128
|
/**
|
|
1129
|
+
* Whether arming this ANNOTATION tool is touch consent (`Tool.touchDirect`):
|
|
1130
|
+
* drag-CREATE tools — shape/ink draw and text-markup select — take
|
|
1131
|
+
* single-finger touch wholesale (finger draws/marks, two fingers navigate:
|
|
1132
|
+
* the drawing-app convention). Click-to-PLACE tools (stamp, note) do not: a
|
|
1133
|
+
* tap places without any claim, and drags keep scrolling. Derived from the
|
|
1134
|
+
* gesture tags, so custom registered tools inherit the right behavior. Only
|
|
1135
|
+
* annotation-owned tools run through this — the built-in `pointer` tool also
|
|
1136
|
+
* enables `text-select`, but it is registered by the hub, not here.
|
|
1137
|
+
*/
|
|
1138
|
+
const isTouchDirect = (enables) => enables.has("annotation-draw") || enables.has("text-select");
|
|
1139
|
+
/**
|
|
1129
1140
|
* The built-in tools — a data mirror of v2's registrations (shapes + lines + ink
|
|
1130
1141
|
* + free text in the draw channel, text markup + caret behind text selection, and
|
|
1131
1142
|
* the click-to-place stamp). Order is display-neutral; the toolbar owns layout.
|
|
@@ -1560,16 +1571,23 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
1560
1571
|
};
|
|
1561
1572
|
/** The CSS-px chrome settings converted to CONTENT units by the page's view
|
|
1562
1573
|
* scale (px per content unit) — screen-constant grab zones + stalk at every
|
|
1563
|
-
* zoom. No scale → the values are read as content units (headless callers).
|
|
1564
|
-
|
|
1574
|
+
* zoom. No scale → the values are read as content units (headless callers).
|
|
1575
|
+
* `boost` widens the GRAB tolerances only (never the drawn chrome or the
|
|
1576
|
+
* knob's position) — the touch path passes {@link TOUCH_GRAB_BOOST} so
|
|
1577
|
+
* handles present finger-sized targets. */
|
|
1578
|
+
const chromeGeomAt = (scale, boost = 1) => {
|
|
1565
1579
|
const cs = chromeSettings();
|
|
1566
1580
|
const s = scale || 1;
|
|
1567
1581
|
return {
|
|
1568
|
-
handleTol: cs.handles.hitSize / 2 / s,
|
|
1569
|
-
knobTol: cs.knob.hitSize / 2 / s,
|
|
1582
|
+
handleTol: cs.handles.hitSize / 2 / s * boost,
|
|
1583
|
+
knobTol: cs.knob.hitSize / 2 / s * boost,
|
|
1570
1584
|
knobOffset: cs.knob.offset / s
|
|
1571
1585
|
};
|
|
1572
1586
|
};
|
|
1587
|
+
/** Finger-sized grab zones: 2× the mouse tolerances lands a ~24px handle hit
|
|
1588
|
+
* box in Apple's ~44pt-target territory without moving any visuals. */
|
|
1589
|
+
const TOUCH_GRAB_BOOST = 2;
|
|
1590
|
+
const grabBoost = (touch) => touch ? TOUCH_GRAB_BOOST : 1;
|
|
1573
1591
|
const itemsCache = /* @__PURE__ */ new Map();
|
|
1574
1592
|
const chromeCache = /* @__PURE__ */ new Map();
|
|
1575
1593
|
const memoItems = (pon, view) => {
|
|
@@ -2340,7 +2358,8 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2340
2358
|
const un = ctx.tryGet(InteractionToken)?.registerTool({
|
|
2341
2359
|
id: resolved.id,
|
|
2342
2360
|
cursor: resolved.cursor,
|
|
2343
|
-
enables: resolved.enables
|
|
2361
|
+
enables: resolved.enables,
|
|
2362
|
+
touchDirect: isTouchDirect(resolved.enables)
|
|
2344
2363
|
});
|
|
2345
2364
|
if (resolved.defaults) apply({
|
|
2346
2365
|
t: "setDefaults",
|
|
@@ -2396,7 +2415,14 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2396
2415
|
selectionAnchor: (scale, rotation, zoom) => memoAnchor(scale, rotation, zoom),
|
|
2397
2416
|
creationDraftAnchor: () => memoDraftAnchor(),
|
|
2398
2417
|
selection: () => model().selected,
|
|
2399
|
-
hitKind: (pon, point, scale, rotation, zoom) => hitTest(model(), pon, point, chromeGeomAt(scale), model().hitMargin, pageBoxOf(pon), inertIdsAt(pon), viewEnv(zoom, rotation)).t,
|
|
2418
|
+
hitKind: (pon, point, scale, rotation, zoom, touch) => hitTest(model(), pon, point, chromeGeomAt(scale, grabBoost(touch)), model().hitMargin, pageBoxOf(pon), inertIdsAt(pon), viewEnv(zoom, rotation)).t,
|
|
2419
|
+
claimsTouchAt: (pon, point, scale, rotation, zoom) => {
|
|
2420
|
+
const m = model();
|
|
2421
|
+
const t = hitTest(m, pon, point, chromeGeomAt(scale, TOUCH_GRAB_BOOST), m.hitMargin, pageBoxOf(pon), inertIdsAt(pon), viewEnv(zoom, rotation));
|
|
2422
|
+
if (t.t === "handle" || t.t === "rotate" || t.t === "group-handle") return true;
|
|
2423
|
+
if (t.t === "annot") return m.selected.includes(t.id) && m.selected.every((id) => canMove(m, id));
|
|
2424
|
+
return false;
|
|
2425
|
+
},
|
|
2400
2426
|
cursorAt: (pon, point, scale, rotation, zoom) => cursorAt(model(), pon, point, chromeGeomAt(scale), model().hitMargin, pageBoxOf(pon), inertIdsAt(pon), viewEnv(zoom, rotation)),
|
|
2401
2427
|
hoverAt: (at) => {
|
|
2402
2428
|
const m = model();
|
|
@@ -2435,7 +2461,7 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2435
2461
|
const crop = cropOf(pon);
|
|
2436
2462
|
return crop ? pdfToContentRect(rect, crop) : null;
|
|
2437
2463
|
},
|
|
2438
|
-
editPointer: (phase, pon, point, shift, scale, rotation, zoom) => apply({
|
|
2464
|
+
editPointer: (phase, pon, point, shift, scale, rotation, zoom, touch) => apply({
|
|
2439
2465
|
t: "editPointer",
|
|
2440
2466
|
phase,
|
|
2441
2467
|
in: {
|
|
@@ -2443,7 +2469,7 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2443
2469
|
point,
|
|
2444
2470
|
shift,
|
|
2445
2471
|
pageBox: pageBoxOf(pon),
|
|
2446
|
-
chrome: chromeGeomAt(scale),
|
|
2472
|
+
chrome: chromeGeomAt(scale, grabBoost(touch)),
|
|
2447
2473
|
inert: inertIdsAt(pon),
|
|
2448
2474
|
...zoom != null ? { zoom } : {},
|
|
2449
2475
|
...rotation != null ? { displayRotation: rotation } : {}
|
|
@@ -2659,10 +2685,14 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2659
2685
|
const m = model();
|
|
2660
2686
|
const h = hitTest(m, pon, point, chromeGeomAt(scale), m.hitMargin, pageBoxOf(pon), void 0, viewEnv(zoom, rotation));
|
|
2661
2687
|
const id = h.t === "annot" || h.t === "handle" ? h.id : null;
|
|
2662
|
-
if (id != null && m.byId[id]?.geom.t === "text")
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2688
|
+
if (id != null && m.byId[id]?.geom.t === "text") {
|
|
2689
|
+
apply({
|
|
2690
|
+
t: "beginTextEdit",
|
|
2691
|
+
id
|
|
2692
|
+
});
|
|
2693
|
+
return true;
|
|
2694
|
+
}
|
|
2695
|
+
return false;
|
|
2666
2696
|
},
|
|
2667
2697
|
setContents: (ref, text) => {
|
|
2668
2698
|
apply({
|
|
@@ -2706,6 +2736,6 @@ function createAnnotationCapability(ctx, config = {}) {
|
|
|
2706
2736
|
};
|
|
2707
2737
|
}
|
|
2708
2738
|
//#endregion
|
|
2709
|
-
export {
|
|
2739
|
+
export { fromDTO as a, refKey as c, AnnotationToken as d, isTouchDirect as i, styleFromDTO as l, DEFAULT_TOOLS as n, toCreateDraft as o, buildToolRegistry as r, toPatch as s, createAnnotationCapability as t, widgetAppearanceFromProps as u };
|
|
2710
2740
|
|
|
2711
|
-
//# sourceMappingURL=capability-
|
|
2741
|
+
//# sourceMappingURL=capability-BNMRdnKf.js.map
|