@sandeepmvn/react-pdf-annotator-v2 1.1.4 → 1.2.6
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 +140 -13
- package/dist/components/AnnotationLayer.d.ts.map +1 -1
- package/dist/components/PdfPage.d.ts.map +1 -1
- package/dist/components/PdfViewer.d.ts +10 -0
- package/dist/components/PdfViewer.d.ts.map +1 -1
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/hooks/useAnnotationHistory.d.ts +7 -0
- package/dist/hooks/useAnnotationHistory.d.ts.map +1 -1
- package/dist/react-pdf-annotator.es.js +3358 -3257
- package/dist/react-pdf-annotator.es.js.map +1 -1
- package/dist/react-pdf-annotator.umd.js +16 -16
- package/dist/react-pdf-annotator.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ function App() {
|
|
|
112
112
|
|
|
113
113
|
const handleSave = async () => {
|
|
114
114
|
if (!pdfViewerRef.current) return;
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
// Get as Blob
|
|
117
117
|
const blob = await pdfViewerRef.current.getAnnotatedDocument();
|
|
118
118
|
if (blob) {
|
|
@@ -125,7 +125,7 @@ function App() {
|
|
|
125
125
|
|
|
126
126
|
const handlePreview = async () => {
|
|
127
127
|
if (!pdfViewerRef.current) return;
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
// Get as URL for preview
|
|
130
130
|
const url = await pdfViewerRef.current.getAnnotatedDocumentUrl();
|
|
131
131
|
if (url) {
|
|
@@ -134,14 +134,115 @@ function App() {
|
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
+
// Get annotation data separately (without generating PDF)
|
|
138
|
+
const handleGetAnnotationData = () => {
|
|
139
|
+
if (!pdfViewerRef.current) return;
|
|
140
|
+
|
|
141
|
+
const data = pdfViewerRef.current.getAnnotationData();
|
|
142
|
+
console.log('Current annotations:', data.annotations);
|
|
143
|
+
console.log('History state:', data.historyState);
|
|
144
|
+
|
|
145
|
+
// Save to database, send to API, etc.
|
|
146
|
+
fetch('/api/save-annotations', {
|
|
147
|
+
method: 'POST',
|
|
148
|
+
headers: { 'Content-Type': 'application/json' },
|
|
149
|
+
body: JSON.stringify(data)
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
|
|
137
153
|
return (
|
|
138
154
|
<>
|
|
139
155
|
<button onClick={handleSave}>Save to Server</button>
|
|
140
156
|
<button onClick={handlePreview}>Preview</button>
|
|
141
|
-
<
|
|
157
|
+
<button onClick={handleGetAnnotationData}>Get Annotation Data</button>
|
|
158
|
+
<PdfViewer
|
|
142
159
|
ref={pdfViewerRef}
|
|
143
|
-
fileUrl="https://example.com/sample.pdf"
|
|
144
|
-
fileName="sample.pdf"
|
|
160
|
+
fileUrl="https://example.com/sample.pdf"
|
|
161
|
+
fileName="sample.pdf"
|
|
162
|
+
/>
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Managing Annotation State
|
|
169
|
+
|
|
170
|
+
The package now supports advanced annotation state management, allowing you to save and restore annotations with full undo/redo history:
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { useState, useCallback } from 'react';
|
|
174
|
+
import { PdfViewer, AnnotationExportData } from 'react-pdf-annotator-v2';
|
|
175
|
+
import type { HistoryState } from 'react-pdf-annotator-v2';
|
|
176
|
+
|
|
177
|
+
function App() {
|
|
178
|
+
const [initialHistoryState, setInitialHistoryState] = useState<HistoryState>();
|
|
179
|
+
|
|
180
|
+
// Called when user downloads or prints the PDF
|
|
181
|
+
const handleSave = useCallback((data: AnnotationExportData) => {
|
|
182
|
+
// Save to localStorage
|
|
183
|
+
localStorage.setItem('annotations', JSON.stringify(data));
|
|
184
|
+
|
|
185
|
+
// Or save to backend
|
|
186
|
+
fetch('/api/save', {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
headers: { 'Content-Type': 'application/json' },
|
|
189
|
+
body: JSON.stringify(data)
|
|
190
|
+
});
|
|
191
|
+
}, []);
|
|
192
|
+
|
|
193
|
+
const handlePrint = useCallback((data: AnnotationExportData) => {
|
|
194
|
+
// Optionally save on print as well
|
|
195
|
+
console.log('Document printed with annotations:', data);
|
|
196
|
+
}, []);
|
|
197
|
+
|
|
198
|
+
// Load saved annotations
|
|
199
|
+
const loadSavedAnnotations = () => {
|
|
200
|
+
const saved = localStorage.getItem('annotations');
|
|
201
|
+
if (saved) {
|
|
202
|
+
const data = JSON.parse(saved) as AnnotationExportData;
|
|
203
|
+
setInitialHistoryState(data.historyState);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<>
|
|
209
|
+
<button onClick={loadSavedAnnotations}>Load Saved Annotations</button>
|
|
210
|
+
<PdfViewer
|
|
211
|
+
fileUrl="https://example.com/sample.pdf"
|
|
212
|
+
fileName="sample.pdf"
|
|
213
|
+
initialHistoryState={initialHistoryState}
|
|
214
|
+
onSave={handleSave}
|
|
215
|
+
onPrint={handlePrint}
|
|
216
|
+
/>
|
|
217
|
+
</>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Loading Annotations from PDF Metadata
|
|
223
|
+
|
|
224
|
+
Annotations are automatically embedded in the PDF when downloaded. When you open an annotated PDF, the annotations are automatically restored:
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
function App() {
|
|
228
|
+
const [pdfUrl, setPdfUrl] = useState('https://example.com/sample.pdf');
|
|
229
|
+
|
|
230
|
+
// When user uploads a previously annotated PDF
|
|
231
|
+
const handleFileUpload = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
232
|
+
const file = event.target.files?.[0];
|
|
233
|
+
if (file) {
|
|
234
|
+
const url = URL.createObjectURL(file);
|
|
235
|
+
setPdfUrl(url);
|
|
236
|
+
// Annotations will be automatically loaded from PDF metadata
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<>
|
|
242
|
+
<input type="file" accept=".pdf" onChange={handleFileUpload} />
|
|
243
|
+
<PdfViewer
|
|
244
|
+
fileUrl={pdfUrl}
|
|
245
|
+
fileName="document.pdf"
|
|
145
246
|
/>
|
|
146
247
|
</>
|
|
147
248
|
);
|
|
@@ -158,6 +259,10 @@ function App() {
|
|
|
158
259
|
| `fileName` | `string` | Yes | - | Name of the PDF file (used for downloads) |
|
|
159
260
|
| `readonly` | `boolean` | No | `false` | Hide annotation tools and prevent editing |
|
|
160
261
|
| `onAnnotationsChange` | `(annotations: Annotations) => void` | No | - | Callback fired when annotations change (add/update/delete/undo/redo) |
|
|
262
|
+
| `initialAnnotations` | `Record<number, Annotation[]>` | No | - | Initial annotations to load (basic, without undo history) |
|
|
263
|
+
| `initialHistoryState` | `HistoryState` | No | - | Initial annotation state with full undo/redo history |
|
|
264
|
+
| `onSave` | `(data: AnnotationExportData) => void` | No | - | Callback when user downloads the PDF |
|
|
265
|
+
| `onPrint` | `(data: AnnotationExportData) => void` | No | - | Callback when user prints the PDF |
|
|
161
266
|
| `ref` | `React.Ref<PdfViewerRef>` | No | - | Ref to access component methods |
|
|
162
267
|
|
|
163
268
|
### PdfViewerRef Methods
|
|
@@ -168,42 +273,64 @@ When using a ref, the following methods are available:
|
|
|
168
273
|
|--------|-------------|-------------|
|
|
169
274
|
| `getAnnotatedDocument()` | `Promise<Blob \| null>` | Returns the current PDF with annotations as a Blob |
|
|
170
275
|
| `getAnnotatedDocumentUrl()` | `Promise<string \| null>` | Returns an object URL of the annotated PDF (remember to revoke when done) |
|
|
276
|
+
| `getAnnotationData()` | `AnnotationExportData` | Returns current annotations and history state without generating PDF |
|
|
171
277
|
|
|
172
278
|
### Available Exports
|
|
173
279
|
|
|
174
280
|
```tsx
|
|
175
281
|
// Main Component and Types
|
|
176
282
|
import { PdfViewer } from 'react-pdf-annotator-v2';
|
|
177
|
-
import type {
|
|
283
|
+
import type {
|
|
284
|
+
PdfViewerRef,
|
|
285
|
+
AnnotationExportData
|
|
286
|
+
} from 'react-pdf-annotator-v2';
|
|
178
287
|
|
|
179
288
|
// Sub-components (for custom layouts)
|
|
180
|
-
import {
|
|
181
|
-
PdfPage,
|
|
182
|
-
Toolbar,
|
|
289
|
+
import {
|
|
290
|
+
PdfPage,
|
|
291
|
+
Toolbar,
|
|
183
292
|
AnnotationLayer,
|
|
184
|
-
SignatureModal
|
|
293
|
+
SignatureModal
|
|
185
294
|
} from 'react-pdf-annotator-v2';
|
|
186
295
|
|
|
187
296
|
// Hooks
|
|
188
297
|
import { useAnnotationHistory } from 'react-pdf-annotator-v2';
|
|
298
|
+
import type { HistoryState } from 'react-pdf-annotator-v2';
|
|
189
299
|
|
|
190
300
|
// Types
|
|
191
|
-
import type {
|
|
301
|
+
import type {
|
|
192
302
|
AnnotationTool,
|
|
193
303
|
Annotation,
|
|
304
|
+
Annotations,
|
|
194
305
|
PenAnnotation,
|
|
195
306
|
TextAnnotation,
|
|
196
307
|
// ... other types
|
|
197
308
|
} from 'react-pdf-annotator-v2';
|
|
198
309
|
|
|
199
310
|
// Constants
|
|
200
|
-
import {
|
|
311
|
+
import {
|
|
201
312
|
DEFAULT_COLOR,
|
|
202
313
|
DEFAULT_STROKE_WIDTH,
|
|
203
|
-
COLORS
|
|
314
|
+
COLORS
|
|
204
315
|
} from 'react-pdf-annotator-v2';
|
|
205
316
|
```
|
|
206
317
|
|
|
318
|
+
### Type Definitions
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
// Annotation data export structure
|
|
322
|
+
interface AnnotationExportData {
|
|
323
|
+
annotations: Record<number, Annotation[]>;
|
|
324
|
+
historyState: HistoryState;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// History state for undo/redo
|
|
328
|
+
interface HistoryState {
|
|
329
|
+
history: Record<number, Annotation[]>[];
|
|
330
|
+
index: number;
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
207
334
|
## 🎨 Customization
|
|
208
335
|
|
|
209
336
|
The package includes pre-built styles that use Tailwind CSS. The CSS is already bundled, so you don't need Tailwind CSS in your project.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationLayer.d.ts","sourceRoot":"","sources":["../../components/AnnotationLayer.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAS,MAAM,UAAU,CAAC;AAK7D,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IACrE,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACnD,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2MnD,CAAC;
|
|
1
|
+
{"version":3,"file":"AnnotationLayer.d.ts","sourceRoot":"","sources":["../../components/AnnotationLayer.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAS,MAAM,UAAU,CAAC;AAK7D,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IACrE,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACnD,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2MnD,CAAC;AA4JF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfPage.d.ts","sourceRoot":"","sources":["../../components/PdfPage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D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E,gBAAgB,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,aAAa,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IACrE,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACnD,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAsEnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { HistoryState } from '../hooks/useAnnotationHistory';
|
|
2
3
|
import { Annotation } from '../types';
|
|
4
|
+
export interface AnnotationExportData {
|
|
5
|
+
annotations: Record<number, Annotation[]>;
|
|
6
|
+
historyState: HistoryState;
|
|
7
|
+
}
|
|
3
8
|
export interface PdfViewerRef {
|
|
4
9
|
getAnnotatedDocument: () => Promise<Blob | null>;
|
|
5
10
|
getAnnotatedDocumentUrl: () => Promise<string | null>;
|
|
11
|
+
getAnnotationData: () => AnnotationExportData;
|
|
6
12
|
}
|
|
7
13
|
interface PdfViewerProps {
|
|
8
14
|
fileUrl: string;
|
|
9
15
|
fileName: string;
|
|
10
16
|
readonly?: boolean;
|
|
11
17
|
onAnnotationsChange?: (annotations: Record<number, Annotation[]>) => void;
|
|
18
|
+
initialAnnotations?: Record<number, Annotation[]>;
|
|
19
|
+
initialHistoryState?: HistoryState;
|
|
20
|
+
onSave?: (data: AnnotationExportData) => void;
|
|
21
|
+
onPrint?: (data: AnnotationExportData) => void;
|
|
12
22
|
}
|
|
13
23
|
declare const PdfViewer: React.ForwardRefExoticComponent<PdfViewerProps & React.RefAttributes<PdfViewerRef>>;
|
|
14
24
|
export default PdfViewer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewer.d.ts","sourceRoot":"","sources":["../../components/PdfViewer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoF,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PdfViewer.d.ts","sourceRoot":"","sources":["../../components/PdfViewer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAKzG,OAAO,EAAuB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAkB,UAAU,EAAE,MAAM,UAAU,CAAC;AAOtD,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,oBAAoB,EAAE,MAAM,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACjD,uBAAuB,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtD,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;CAC/C;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,C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EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAsBD,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+GnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { Annotations, Annotation } from '../types';
|
|
2
|
+
export interface HistoryState {
|
|
3
|
+
history: Annotations[];
|
|
4
|
+
index: number;
|
|
5
|
+
}
|
|
2
6
|
export declare const useAnnotationHistory: () => {
|
|
3
7
|
annotations: Annotations;
|
|
4
8
|
addAnnotation: (page: number, annotationData: Omit<Annotation, "id" | "page">) => void;
|
|
5
9
|
deleteAnnotation: (page: number, annotationId: string) => void;
|
|
6
10
|
updateAnnotation: (updatedAnnotation: Annotation) => void;
|
|
7
11
|
clearAnnotations: () => void;
|
|
12
|
+
setAnnotations: (newAnnotations: Annotations) => void;
|
|
8
13
|
undo: () => void;
|
|
9
14
|
redo: () => void;
|
|
10
15
|
canUndo: boolean;
|
|
11
16
|
canRedo: boolean;
|
|
17
|
+
historyState: HistoryState;
|
|
18
|
+
setHistoryState: import('react').Dispatch<import('react').SetStateAction<HistoryState>>;
|
|
12
19
|
};
|
|
13
20
|
//# sourceMappingURL=useAnnotationHistory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnnotationHistory.d.ts","sourceRoot":"","sources":["../../hooks/useAnnotationHistory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useAnnotationHistory.d.ts","sourceRoot":"","sources":["../../hooks/useAnnotationHistory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,oBAAoB;;0BAwBU,MAAM,kBAAkB,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC;6BAcpD,MAAM,gBAAgB,MAAM;0CASf,UAAU;;qCAkBf,WAAW;;;;;;;CAsChE,CAAC"}
|