@edgepdf/viewer-react 0.0.3 → 0.0.5

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 CHANGED
@@ -1,6 +1,72 @@
1
- # viewer-react
1
+ # @edgepdf/viewer-react
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ EdgePDF Viewer - React components for viewing PDF documents with interactive markers and zoom controls.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @edgepdf/viewer-react @edgepdf/viewer-js
9
+ # or
10
+ pnpm add @edgepdf/viewer-react @edgepdf/viewer-js
11
+ # or
12
+ yarn add @edgepdf/viewer-react @edgepdf/viewer-js
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Next.js
18
+
19
+ In your Next.js application, you need to import the CSS file manually:
20
+
21
+ **App Router (app directory):**
22
+ ```tsx
23
+ // app/layout.tsx or app/page.tsx
24
+ import '@edgepdf/viewer-react/styles.css';
25
+ import { EdgePDFViewer } from '@edgepdf/viewer-react';
26
+ ```
27
+
28
+ **Pages Router:**
29
+ ```tsx
30
+ // pages/_app.tsx
31
+ import '@edgepdf/viewer-react/styles.css';
32
+
33
+ export default function App({ Component, pageProps }) {
34
+ return <Component {...pageProps} />;
35
+ }
36
+ ```
37
+
38
+ **Or in a specific page:**
39
+ ```tsx
40
+ // pages/your-page.tsx
41
+ import '@edgepdf/viewer-react/styles.css';
42
+ import { EdgePDFViewer } from '@edgepdf/viewer-react';
43
+ ```
44
+
45
+ ### Other React Applications
46
+
47
+ ```tsx
48
+ import '@edgepdf/viewer-react/styles.css';
49
+ import { EdgePDFViewer } from '@edgepdf/viewer-react';
50
+
51
+ function App() {
52
+ const config = {
53
+ tileUrl: 'https://example.com/tiles/{z}/{x}/{y}.png',
54
+ imageInfo: {
55
+ width: 2000,
56
+ height: 3000,
57
+ tileSize: 256,
58
+ maxZoom: 5,
59
+ minZoom: 0
60
+ }
61
+ };
62
+
63
+ return (
64
+ <EdgePDFViewer config={config}>
65
+ {/* Your components */}
66
+ </EdgePDFViewer>
67
+ );
68
+ }
69
+ ```
4
70
 
5
71
  ## Building
6
72
 
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import '@edgepdf/viewer-js/styles.css';
2
1
  // packages/viewer-react/src/lib/viewer-context.tsx
3
2
  import {
4
3
  createContext,
@@ -9583,6 +9582,26 @@ var require_leaflet_src = __commonJS({
9583
9582
  });
9584
9583
  }
9585
9584
  });
9585
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
9586
+ const existingLink = document.querySelector("link[data-edgepdf-styles]");
9587
+ if (!existingLink) {
9588
+ const link = document.createElement("link");
9589
+ link.rel = "stylesheet";
9590
+ link.type = "text/css";
9591
+ link.setAttribute("data-edgepdf-styles", "true");
9592
+ try {
9593
+ if (typeof import.meta !== "undefined" && import.meta.url) {
9594
+ const baseUrl = new URL(import.meta.url);
9595
+ link.href = new URL("./styles.css", baseUrl).href;
9596
+ } else {
9597
+ link.href = "./styles.css";
9598
+ }
9599
+ } catch (e) {
9600
+ link.href = "./styles.css";
9601
+ }
9602
+ document.head.appendChild(link);
9603
+ }
9604
+ }
9586
9605
  var import_leaflet4 = __toESM(require_leaflet_src(), 1);
9587
9606
  var import_leaflet = __toESM(require_leaflet_src(), 1);
9588
9607
  function calculateTileCount(imageSize, tileSize, zoom) {
@@ -10576,7 +10595,8 @@ var MarkerManager = class {
10576
10595
  showDeleteButton: true
10577
10596
  };
10578
10597
  defaultIconType = "pin";
10579
- iconBasePath = "/";
10598
+ iconBasePath = "./images/";
10599
+ // Default to library's images folder
10580
10600
  /**
10581
10601
  * Creates a new MarkerManager instance
10582
10602
  *
@@ -11065,11 +11085,31 @@ var MarkerManager = class {
11065
11085
  /**
11066
11086
  * Sets the base path for marker icons
11067
11087
  *
11068
- * @param basePath - Base path for icon files (default: '/')
11088
+ * @param basePath - Base path for icon files (default: './images/')
11089
+ *
11090
+ * @example
11091
+ * ```typescript
11092
+ * // Use library's built-in icons (default)
11093
+ * markerManager.setIconBasePath('./images/');
11094
+ *
11095
+ * // Use custom icons from public folder
11096
+ * markerManager.setIconBasePath('/');
11097
+ *
11098
+ * // Use icons from a CDN
11099
+ * markerManager.setIconBasePath('https://cdn.example.com/icons/');
11100
+ * ```
11069
11101
  */
11070
11102
  setIconBasePath(basePath) {
11071
11103
  this.iconBasePath = basePath.endsWith("/") ? basePath : `${basePath}/`;
11072
11104
  }
11105
+ /**
11106
+ * Gets the current base path for marker icons
11107
+ *
11108
+ * @returns The current icon base path
11109
+ */
11110
+ getIconBasePath() {
11111
+ return this.iconBasePath;
11112
+ }
11073
11113
  /**
11074
11114
  * Updates the icon type for a specific marker
11075
11115
  *
@@ -1 +1 @@
1
- {"version":3,"file":"viewer-context.d.ts","sourceRoot":"","sources":["../../src/lib/viewer-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACV,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,oCAAoC;IACpC,aAAa,EAAE,OAAO,CAAC;IACvB,sBAAsB;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,yBAAyB;IACzB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CAC7B;AAOD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,6CAA6C;IAC7C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,M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AAW,CAAC,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACpC,0BAA0B;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,UAAU,EACV,gBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAqPnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAMrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgepdf/viewer-react",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "EdgePDF Viewer - React components for viewing PDF documents with interactive markers and zoom controls",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -70,7 +70,7 @@
70
70
  "@edgepdf/testing-utils": "workspace:*"
71
71
  },
72
72
  "peerDependencies": {
73
- "@edgepdf/viewer-js": "^0.0.3",
73
+ "@edgepdf/viewer-js": "^0.0.5",
74
74
  "react": "^18.0.0",
75
75
  "react-dom": "^18.0.0"
76
76
  }