@edgepdf/viewer-react 0.0.33 → 0.0.34
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/README.md +19 -0
- package/dist/index.js +66 -8
- package/dist/lib/pdf-viewer.d.ts.map +1 -1
- package/dist/lib/use-markers.d.ts +4 -0
- package/dist/lib/use-markers.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -333,6 +333,10 @@ interface UseMarkersReturn {
|
|
|
333
333
|
zoom?: number;
|
|
334
334
|
animate?: boolean;
|
|
335
335
|
duration?: number;
|
|
336
|
+
offsetLeft?: number;
|
|
337
|
+
offsetRight?: number;
|
|
338
|
+
offsetTop?: number;
|
|
339
|
+
offsetBottom?: number;
|
|
336
340
|
}
|
|
337
341
|
) => boolean;
|
|
338
342
|
}
|
|
@@ -408,6 +412,21 @@ function MarkerControls() {
|
|
|
408
412
|
- **`clearMarkers(): void`** - Removes all markers.
|
|
409
413
|
|
|
410
414
|
- **`focusMarker(markerOrId: string | Marker, options?: FocusOptions): boolean`** - Focuses on a marker by panning and zooming. Returns `true` if successful, `false` otherwise.
|
|
415
|
+
|
|
416
|
+
**Options:**
|
|
417
|
+
- `zoom?: number` - Target zoom level (uses marker's zoom or default if not provided)
|
|
418
|
+
- `animate?: boolean` - Whether to animate the transition (default: true)
|
|
419
|
+
- `duration?: number` - Animation duration in seconds (default: 0.5)
|
|
420
|
+
- `offsetLeft?: number` - Pixel offset to move focus marker to the left (default: 0)
|
|
421
|
+
- `offsetRight?: number` - Pixel offset to move focus marker to the right (default: 0)
|
|
422
|
+
- `offsetTop?: number` - Pixel offset to move focus marker upward (default: 0)
|
|
423
|
+
- `offsetBottom?: number` - Pixel offset to move focus marker downward (default: 0)
|
|
424
|
+
|
|
425
|
+
**Example:**
|
|
426
|
+
```tsx
|
|
427
|
+
// Focus with offset to account for overlay
|
|
428
|
+
focusMarker(markerId, { offsetLeft: 100, offsetTop: 50 });
|
|
429
|
+
```
|
|
411
430
|
|
|
412
431
|
---
|
|
413
432
|
|
package/dist/index.js
CHANGED
|
@@ -11272,6 +11272,10 @@ var MarkerManager = class {
|
|
|
11272
11272
|
* @param options.zoom - Target zoom level (uses marker's zoom or default if not provided)
|
|
11273
11273
|
* @param options.animate - Whether to animate the transition (default: true)
|
|
11274
11274
|
* @param options.duration - Animation duration in seconds (default: 0.5)
|
|
11275
|
+
* @param options.offsetLeft - Pixel offset to move focus marker to the left (default: 0)
|
|
11276
|
+
* @param options.offsetRight - Pixel offset to move focus marker to the right (default: 0)
|
|
11277
|
+
* @param options.offsetTop - Pixel offset to move focus marker upward (default: 0)
|
|
11278
|
+
* @param options.offsetBottom - Pixel offset to move focus marker downward (default: 0)
|
|
11275
11279
|
* @returns True if focus was successful, false if marker not found
|
|
11276
11280
|
*
|
|
11277
11281
|
* @example
|
|
@@ -11287,6 +11291,9 @@ var MarkerManager = class {
|
|
|
11287
11291
|
*
|
|
11288
11292
|
* // Focus with custom duration
|
|
11289
11293
|
* markerManager.focusMarker('marker-123', { zoom: 2, duration: 1.0 });
|
|
11294
|
+
*
|
|
11295
|
+
* // Focus with offset to account for overlay
|
|
11296
|
+
* markerManager.focusMarker('marker-123', { offsetLeft: 100, offsetTop: 50 });
|
|
11290
11297
|
* ```
|
|
11291
11298
|
*/
|
|
11292
11299
|
focusMarker(markerOrId, options) {
|
|
@@ -11310,12 +11317,38 @@ var MarkerManager = class {
|
|
|
11310
11317
|
];
|
|
11311
11318
|
const animate = options?.animate !== false;
|
|
11312
11319
|
const duration = options?.duration ?? 0.5;
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11320
|
+
const offsetX = (options?.offsetRight ?? 0) - (options?.offsetLeft ?? 0);
|
|
11321
|
+
const offsetY = (options?.offsetBottom ?? 0) - (options?.offsetTop ?? 0);
|
|
11322
|
+
if (offsetX !== 0 || offsetY !== 0) {
|
|
11323
|
+
const currentZoom = this.map.getZoom();
|
|
11324
|
+
const needsZoomChange = currentZoom !== constrainedZoom;
|
|
11325
|
+
if (needsZoomChange) {
|
|
11326
|
+
this.map.setZoom(constrainedZoom, { animate: false });
|
|
11327
|
+
}
|
|
11328
|
+
const markerPoint = this.map.latLngToContainerPoint(position);
|
|
11329
|
+
const offsetPoint = import_leaflet3.default.point(
|
|
11330
|
+
markerPoint.x + offsetX,
|
|
11331
|
+
markerPoint.y + offsetY
|
|
11332
|
+
);
|
|
11333
|
+
const offsetLatLng = this.map.containerPointToLatLng(offsetPoint);
|
|
11334
|
+
if (needsZoomChange && animate) {
|
|
11335
|
+
this.map.setZoom(currentZoom, { animate: false });
|
|
11336
|
+
}
|
|
11337
|
+
if (animate) {
|
|
11338
|
+
this.map.flyTo(offsetLatLng, constrainedZoom, {
|
|
11339
|
+
duration
|
|
11340
|
+
});
|
|
11341
|
+
} else {
|
|
11342
|
+
this.map.setView(offsetLatLng, constrainedZoom);
|
|
11343
|
+
}
|
|
11317
11344
|
} else {
|
|
11318
|
-
|
|
11345
|
+
if (animate) {
|
|
11346
|
+
this.map.flyTo(position, constrainedZoom, {
|
|
11347
|
+
duration
|
|
11348
|
+
});
|
|
11349
|
+
} else {
|
|
11350
|
+
this.map.setView(position, constrainedZoom);
|
|
11351
|
+
}
|
|
11319
11352
|
}
|
|
11320
11353
|
return true;
|
|
11321
11354
|
}
|
|
@@ -12437,6 +12470,10 @@ var EdgePdfViewer = class {
|
|
|
12437
12470
|
* @param options.zoom - Target zoom level (uses marker's zoom or default if not provided)
|
|
12438
12471
|
* @param options.animate - Whether to animate the transition (default: true)
|
|
12439
12472
|
* @param options.duration - Animation duration in seconds (default: 0.5)
|
|
12473
|
+
* @param options.offsetLeft - Pixel offset to move focus marker to the left (default: 0)
|
|
12474
|
+
* @param options.offsetRight - Pixel offset to move focus marker to the right (default: 0)
|
|
12475
|
+
* @param options.offsetTop - Pixel offset to move focus marker upward (default: 0)
|
|
12476
|
+
* @param options.offsetBottom - Pixel offset to move focus marker downward (default: 0)
|
|
12440
12477
|
* @returns True if focus was successful, false if marker not found or viewer not initialized
|
|
12441
12478
|
*
|
|
12442
12479
|
* @example
|
|
@@ -12446,6 +12483,9 @@ var EdgePdfViewer = class {
|
|
|
12446
12483
|
*
|
|
12447
12484
|
* // Focus with specific zoom level
|
|
12448
12485
|
* viewer.focusMarker('marker-123', { zoom: 3 });
|
|
12486
|
+
*
|
|
12487
|
+
* // Focus with offset to account for overlay
|
|
12488
|
+
* viewer.focusMarker('marker-123', { offsetLeft: 100, offsetTop: 50 });
|
|
12449
12489
|
* ```
|
|
12450
12490
|
*/
|
|
12451
12491
|
focusMarker(markerOrId, options) {
|
|
@@ -12813,11 +12853,29 @@ function EdgePDFViewer({
|
|
|
12813
12853
|
if (!markerManager) {
|
|
12814
12854
|
return;
|
|
12815
12855
|
}
|
|
12856
|
+
let previousMarkers = [];
|
|
12857
|
+
const markersEqual = (a, b) => {
|
|
12858
|
+
if (a.length !== b.length)
|
|
12859
|
+
return false;
|
|
12860
|
+
const bMap = new Map(b.map((m) => [m.id, m]));
|
|
12861
|
+
for (const marker of a) {
|
|
12862
|
+
const other = bMap.get(marker.id);
|
|
12863
|
+
if (!other)
|
|
12864
|
+
return false;
|
|
12865
|
+
if (marker.x !== other.x || marker.y !== other.y || marker.position[0] !== other.position[0] || marker.position[1] !== other.position[1] || marker.iconType !== other.iconType) {
|
|
12866
|
+
return false;
|
|
12867
|
+
}
|
|
12868
|
+
}
|
|
12869
|
+
return true;
|
|
12870
|
+
};
|
|
12816
12871
|
const updateMarkers = () => {
|
|
12817
12872
|
const allMarkers = markerManager.getAllMarkers();
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
onPinsUpdateRef.current
|
|
12873
|
+
if (!markersEqual(allMarkers, previousMarkers)) {
|
|
12874
|
+
setContextValue({ markers: allMarkers });
|
|
12875
|
+
if (onPinsUpdateRef.current) {
|
|
12876
|
+
onPinsUpdateRef.current(allMarkers);
|
|
12877
|
+
}
|
|
12878
|
+
previousMarkers = allMarkers;
|
|
12821
12879
|
}
|
|
12822
12880
|
};
|
|
12823
12881
|
const unsubscribeDelete = markerManager.on("delete", updateMarkers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-viewer.d.ts","sourceRoot":"","sources":["../../src/lib/pdf-viewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,MAAM,EACN,UAAU,EACX,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qEAAqE;IACrE,oBAAoB,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACrD,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACxC,wCAAwC;IACxC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK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