@arbidocs/react 0.4.63 → 0.4.65
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/annotations/index.cjs +263 -82
- package/dist/annotations/index.cjs.map +1 -1
- package/dist/annotations/index.d.cts +72 -5
- package/dist/annotations/index.d.ts +72 -5
- package/dist/annotations/index.js +238 -63
- package/dist/annotations/index.js.map +1 -1
- package/dist/artifacts/index.cjs +79 -50
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +52 -31
- package/dist/artifacts/index.d.ts +52 -31
- package/dist/artifacts/index.js +63 -37
- package/dist/artifacts/index.js.map +1 -1
- package/dist/{chunk-QS3Q5542.js → chunk-2VW47ADK.js} +10 -3
- package/dist/chunk-2VW47ADK.js.map +1 -0
- package/dist/chunk-4PRCRCQ5.cjs +41 -0
- package/dist/chunk-4PRCRCQ5.cjs.map +1 -0
- package/dist/{chunk-X3F5ABY2.cjs → chunk-6YKVIERB.cjs} +43 -21
- package/dist/chunk-6YKVIERB.cjs.map +1 -0
- package/dist/{chunk-Z4M7JB4L.cjs → chunk-D3CSLSGD.cjs} +9 -9
- package/dist/{chunk-Z4M7JB4L.cjs.map → chunk-D3CSLSGD.cjs.map} +1 -1
- package/dist/{chunk-N5SVBDLC.js → chunk-DIZC2XVB.js} +11 -4
- package/dist/chunk-DIZC2XVB.js.map +1 -0
- package/dist/{chunk-CVN7MAGQ.js → chunk-F5WHYJRB.js} +29 -7
- package/dist/chunk-F5WHYJRB.js.map +1 -0
- package/dist/{chunk-XDCRWZF2.cjs → chunk-GXQO3IJC.cjs} +10 -3
- package/dist/chunk-GXQO3IJC.cjs.map +1 -0
- package/dist/{chunk-OBNTJEEO.cjs → chunk-LCMCZS5Y.cjs} +11 -4
- package/dist/chunk-LCMCZS5Y.cjs.map +1 -0
- package/dist/{chunk-UDOPD3GK.js → chunk-NDABXDML.js} +3 -3
- package/dist/{chunk-UDOPD3GK.js.map → chunk-NDABXDML.js.map} +1 -1
- package/dist/chunk-QICALPFQ.js +18 -0
- package/dist/chunk-QICALPFQ.js.map +1 -0
- package/dist/{chunk-DSG3E7QX.js → chunk-SX7FCSON.js} +2 -2
- package/dist/chunk-SX7FCSON.js.map +1 -0
- package/dist/{chunk-UUE2R2E2.cjs → chunk-VH5ITITV.cjs} +2 -2
- package/dist/chunk-VH5ITITV.cjs.map +1 -0
- package/dist/{index-CUxIcC5j.d.ts → index-BWv_FKi3.d.cts} +18 -3
- package/dist/{index-CUxIcC5j.d.cts → index-BWv_FKi3.d.ts} +18 -3
- package/dist/index.cjs +356 -347
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -8
- package/dist/index.d.ts +46 -8
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/shell/index.cjs +8 -7
- package/dist/shell/index.js +3 -2
- package/dist/ui/index.cjs +152 -143
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +4 -3
- package/package.json +3 -3
- package/dist/chunk-CVN7MAGQ.js.map +0 -1
- package/dist/chunk-DSG3E7QX.js.map +0 -1
- package/dist/chunk-N5SVBDLC.js.map +0 -1
- package/dist/chunk-OBNTJEEO.cjs.map +0 -1
- package/dist/chunk-QS3Q5542.js.map +0 -1
- package/dist/chunk-UUE2R2E2.cjs.map +0 -1
- package/dist/chunk-X3F5ABY2.cjs.map +0 -1
- package/dist/chunk-XDCRWZF2.cjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A as Annotation, e as RedactionStatus, d as CommentReply, b as AnnotationLayer, N as NormRect } from '../model-DIwXRuGC.cjs';
|
|
2
2
|
export { a as AnnotationKind, c as AnnotationLayerError, B as BoxAnnotation, C as CommentAnnotation, H as HighlightAnnotation, L as LAYER_SCHEMA_VERSION, R as RedactionAnnotation, S as StampAnnotation, f as annotationRects, g as clampRect, h as emptyLayer, i as isEffectiveRedaction, p as parseAnnotation, j as parseLayer } from '../model-DIwXRuGC.cjs';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Pure state for an annotation layer: actions, a reducer and undo/redo history.
|
|
@@ -68,13 +69,27 @@ declare function pendingRedactions(layer: AnnotationLayer): Annotation[];
|
|
|
68
69
|
/**
|
|
69
70
|
* Where a layer is kept. The layer is data about a document, not part of it, so the host decides
|
|
70
71
|
* (backend API, IndexedDB, a file). This package ships an in-memory store and a localStorage
|
|
71
|
-
* store; both validate on load because stored JSON is untrusted.
|
|
72
|
+
* store; both validate on load because stored JSON is untrusted. A store shared by several
|
|
73
|
+
* writers (ARBI's server-side markup) also implements the optional members: it may merge on save,
|
|
74
|
+
* pull others' changes, and say whether this user may write at all.
|
|
72
75
|
*/
|
|
73
76
|
|
|
74
77
|
interface AnnotationStore {
|
|
75
78
|
/** The saved layer, or an empty one for a document that has none yet. */
|
|
76
79
|
load(documentId: string): Promise<AnnotationLayer>;
|
|
77
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Write a layer. A store with other writers may resolve to what it actually saved — this layer
|
|
82
|
+
* merged with theirs (see `mergeLayers`); the caller then rebases its newer edits onto it.
|
|
83
|
+
*/
|
|
84
|
+
save(layer: AnnotationLayer): Promise<AnnotationLayer | void>;
|
|
85
|
+
/** Others' changes since the last load or save, or null when there are none. */
|
|
86
|
+
pull?(documentId: string): Promise<AnnotationLayer | null>;
|
|
87
|
+
/** Whether this user may change the layer; false makes it view-only. Known after `load`. */
|
|
88
|
+
canEdit?(documentId: string): boolean;
|
|
89
|
+
}
|
|
90
|
+
/** Thrown by a store whose backend cannot be reached: the layer is kept and saved when back. */
|
|
91
|
+
declare class AnnotationStoreOfflineError extends Error {
|
|
92
|
+
constructor(message?: string);
|
|
78
93
|
}
|
|
79
94
|
declare function createMemoryStore(now?: () => string): AnnotationStore;
|
|
80
95
|
/**
|
|
@@ -83,6 +98,35 @@ declare function createMemoryStore(now?: () => string): AnnotationStore;
|
|
|
83
98
|
*/
|
|
84
99
|
declare function createLocalStorageStore(storage?: Pick<Storage, 'getItem' | 'setItem'> | undefined, now?: () => string): AnnotationStore;
|
|
85
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Merging two writers' versions of one layer, by annotation id (a PDF annotation's `/NM`).
|
|
103
|
+
*
|
|
104
|
+
* Used when a save is refused because someone saved first (HTTP 409): the client re-reads the
|
|
105
|
+
* latest layer ("theirs") and merges it with its own ("mine"), relative to the layer both started
|
|
106
|
+
* from ("base"). Nobody's marks are lost:
|
|
107
|
+
*
|
|
108
|
+
* - a mark only one side has is kept, unless that side never had it and the other deleted it:
|
|
109
|
+
* a mark in `base` that `mine` no longer has was deleted here and stays deleted, and one that
|
|
110
|
+
* `theirs` no longer has was deleted there and stays deleted unless it was edited here since;
|
|
111
|
+
* - a mark both sides have: the later edit (`updatedAt`) wins as a whole; a comment additionally
|
|
112
|
+
* keeps every reply either side added;
|
|
113
|
+
* - `deleted` (the ids this session removed, its tombstones) always wins: a concurrent edit
|
|
114
|
+
* elsewhere does not resurrect a mark deleted here, even one `base` never saw.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
interface MergeInput {
|
|
118
|
+
/** The layer both sides started from (the last one this client saved or loaded). */
|
|
119
|
+
base: AnnotationLayer | null;
|
|
120
|
+
mine: AnnotationLayer;
|
|
121
|
+
theirs: AnnotationLayer;
|
|
122
|
+
/** Ids this session deleted. */
|
|
123
|
+
deleted?: ReadonlySet<string>;
|
|
124
|
+
}
|
|
125
|
+
/** Merge two versions of a layer; the result keeps `mine`'s order, then marks only `theirs` has. */
|
|
126
|
+
declare function mergeLayers({ base, mine, theirs, deleted }: MergeInput): AnnotationLayer;
|
|
127
|
+
/** True when two layers hold the same marks (by id and last edit), whatever their order. */
|
|
128
|
+
declare function sameMarks(a: AnnotationLayer, b: AnnotationLayer): boolean;
|
|
129
|
+
|
|
86
130
|
/**
|
|
87
131
|
* The redaction log of a layer: one CSV row per redaction mark (page, reason, status, who approved
|
|
88
132
|
* it and when), the record a privilege or redaction log is built from.
|
|
@@ -174,6 +218,10 @@ interface AnnotationController {
|
|
|
174
218
|
saving: boolean;
|
|
175
219
|
/** True when edits have not reached the store yet. */
|
|
176
220
|
dirty: boolean;
|
|
221
|
+
/** The device is offline (or the store unreachable): edits are kept and saved when it is back. */
|
|
222
|
+
offline: boolean;
|
|
223
|
+
/** View only (e.g. a guest on a shared document): marks show, nothing can be changed. */
|
|
224
|
+
readOnly: boolean;
|
|
177
225
|
author: string;
|
|
178
226
|
tool: AnnotationTool;
|
|
179
227
|
setTool(tool: AnnotationTool): void;
|
|
@@ -197,24 +245,41 @@ interface AnnotationController {
|
|
|
197
245
|
flush(): Promise<void>;
|
|
198
246
|
}
|
|
199
247
|
|
|
248
|
+
/** The save state in words, as the toolbar shows it. */
|
|
249
|
+
declare function layerStatusText(controller: AnnotationController): string;
|
|
250
|
+
|
|
200
251
|
/**
|
|
201
252
|
* Annotation state for one document: loads its layer from a store, applies edits through the pure
|
|
202
253
|
* reducer (so undo/redo is exact), and saves back after a short pause.
|
|
203
254
|
*
|
|
204
255
|
* Edits are applied from a ref, not inside a React state updater, so a mark that fails validation
|
|
205
256
|
* is reported through `error` instead of throwing during render.
|
|
257
|
+
*
|
|
258
|
+
* With a shared store (other people edit the same layer) a save may come back merged with their
|
|
259
|
+
* marks, and `pull` brings in their changes while this user is idle. Either way the remote layer is
|
|
260
|
+
* REBASED in: the edits made here since are replayed on top of it with `mergeLayers`, and so is
|
|
261
|
+
* every undo/redo step, so undoing never removes a colleague's mark or brings back one they deleted.
|
|
206
262
|
*/
|
|
207
263
|
|
|
264
|
+
declare const AUTOSAVE_MS = 600;
|
|
265
|
+
/** After a failed save, try again this much later (while edits are still unsaved). */
|
|
266
|
+
declare const RETRY_MS = 10000;
|
|
208
267
|
interface UseAnnotationLayerOptions {
|
|
209
268
|
documentId: string;
|
|
210
269
|
store: AnnotationStore;
|
|
211
270
|
/** Display name recorded as the author of new marks. */
|
|
212
271
|
author: string;
|
|
213
272
|
autosaveMs?: number;
|
|
273
|
+
/** View only: marks are shown and comments can be read, nothing can be changed. */
|
|
274
|
+
readOnly?: boolean;
|
|
275
|
+
/** False while the device is offline: edits are kept and saved when it comes back. */
|
|
276
|
+
online?: boolean;
|
|
277
|
+
/** Ask the store for others' changes this often while idle (0 = never). Needs `store.pull`. */
|
|
278
|
+
pullMs?: number;
|
|
214
279
|
now?: () => string;
|
|
215
280
|
makeId?: () => string;
|
|
216
281
|
}
|
|
217
|
-
declare function useAnnotationLayer({ documentId, store, author, autosaveMs, now, makeId, }: UseAnnotationLayerOptions): AnnotationController;
|
|
282
|
+
declare function useAnnotationLayer({ documentId, store, author, autosaveMs, readOnly: readOnlyProp, online, pullMs, now, makeId, }: UseAnnotationLayerOptions): AnnotationController;
|
|
218
283
|
|
|
219
284
|
/**
|
|
220
285
|
* Turns a text selection made on the page into marks while the highlight or redact-text tool is
|
|
@@ -285,9 +350,11 @@ interface AnnotationToolbarProps {
|
|
|
285
350
|
controller: AnnotationController;
|
|
286
351
|
/** Show a Freeze button; the host opens its freeze dialog. */
|
|
287
352
|
onFreeze?: () => void;
|
|
353
|
+
/** Extra host actions at the end of the bar (e.g. "Download with markup"). */
|
|
354
|
+
actions?: ReactNode;
|
|
288
355
|
className?: string;
|
|
289
356
|
}
|
|
290
|
-
declare function AnnotationToolbar({ controller, onFreeze, className }: AnnotationToolbarProps): React.JSX.Element;
|
|
357
|
+
declare function AnnotationToolbar({ controller, onFreeze, actions, className, }: AnnotationToolbarProps): React.JSX.Element;
|
|
291
358
|
|
|
292
359
|
/** Delete, Escape, undo and redo for the annotation layer. */
|
|
293
360
|
|
|
@@ -363,4 +430,4 @@ declare function qrCornerFor(corner: ProductionCorner): ProductionCorner;
|
|
|
363
430
|
declare function moveItem<T>(items: readonly T[], from: number, to: number): T[];
|
|
364
431
|
declare function ProductionDialog({ open, onOpenChange, documents, leftOut, onConfirm, busy, progress, error, }: ProductionDialogProps): React.JSX.Element;
|
|
365
432
|
|
|
366
|
-
export { Annotation, type AnnotationAction, type AnnotationController, AnnotationLayer, AnnotationPageOverlay, type AnnotationPageOverlayProps, type AnnotationPatch, type AnnotationStore, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, CommentReply, DEFAULT_SETTINGS, type DragMode, type FreezeChoices, FreezeDialog, type FreezeDialogProps, HIGHLIGHT_COLORS, type LayerHistory, type LayerStatus, MARK_COLORS, type NewMark, NormRect, type PageSelection, type PageTextMark, type PixelRect, type PixelSize, type ProductionChoices, type ProductionCorner, ProductionDialog, type ProductionDialogProps, type ProductionDocument, REDACTION_LOG_COLUMNS, REDACTION_REASONS, type RedactionLogRow, RedactionStatus, STAMP_PRESETS, type ToolSettings, type UseAnnotationLayerOptions, annotationsOnPage, applyAction, canRedo, canUndo, containsPoint, createHistory, createLocalStorageStore, createMemoryStore, dragRect, dragToNorm, intersects, isTooSmall, mergeLineRects, moveItem, patchForRect, pendingRedactions, qrCornerFor, readSelection, redactionLogCsv, redactionLogRows, redo, reduceLayer, selectionToPageMarks, singleRect, toNorm, toPixels, undo, useAnnotationLayer, useAnnotationShortcuts, useTextSelectionMarks };
|
|
433
|
+
export { AUTOSAVE_MS, Annotation, type AnnotationAction, type AnnotationController, AnnotationLayer, AnnotationPageOverlay, type AnnotationPageOverlayProps, type AnnotationPatch, type AnnotationStore, AnnotationStoreOfflineError, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, CommentReply, DEFAULT_SETTINGS, type DragMode, type FreezeChoices, FreezeDialog, type FreezeDialogProps, HIGHLIGHT_COLORS, type LayerHistory, type LayerStatus, MARK_COLORS, type MergeInput, type NewMark, NormRect, type PageSelection, type PageTextMark, type PixelRect, type PixelSize, type ProductionChoices, type ProductionCorner, ProductionDialog, type ProductionDialogProps, type ProductionDocument, REDACTION_LOG_COLUMNS, REDACTION_REASONS, RETRY_MS, type RedactionLogRow, RedactionStatus, STAMP_PRESETS, type ToolSettings, type UseAnnotationLayerOptions, annotationsOnPage, applyAction, canRedo, canUndo, containsPoint, createHistory, createLocalStorageStore, createMemoryStore, dragRect, dragToNorm, intersects, isTooSmall, layerStatusText, mergeLayers, mergeLineRects, moveItem, patchForRect, pendingRedactions, qrCornerFor, readSelection, redactionLogCsv, redactionLogRows, redo, reduceLayer, sameMarks, selectionToPageMarks, singleRect, toNorm, toPixels, undo, useAnnotationLayer, useAnnotationShortcuts, useTextSelectionMarks };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A as Annotation, e as RedactionStatus, d as CommentReply, b as AnnotationLayer, N as NormRect } from '../model-DIwXRuGC.js';
|
|
2
2
|
export { a as AnnotationKind, c as AnnotationLayerError, B as BoxAnnotation, C as CommentAnnotation, H as HighlightAnnotation, L as LAYER_SCHEMA_VERSION, R as RedactionAnnotation, S as StampAnnotation, f as annotationRects, g as clampRect, h as emptyLayer, i as isEffectiveRedaction, p as parseAnnotation, j as parseLayer } from '../model-DIwXRuGC.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Pure state for an annotation layer: actions, a reducer and undo/redo history.
|
|
@@ -68,13 +69,27 @@ declare function pendingRedactions(layer: AnnotationLayer): Annotation[];
|
|
|
68
69
|
/**
|
|
69
70
|
* Where a layer is kept. The layer is data about a document, not part of it, so the host decides
|
|
70
71
|
* (backend API, IndexedDB, a file). This package ships an in-memory store and a localStorage
|
|
71
|
-
* store; both validate on load because stored JSON is untrusted.
|
|
72
|
+
* store; both validate on load because stored JSON is untrusted. A store shared by several
|
|
73
|
+
* writers (ARBI's server-side markup) also implements the optional members: it may merge on save,
|
|
74
|
+
* pull others' changes, and say whether this user may write at all.
|
|
72
75
|
*/
|
|
73
76
|
|
|
74
77
|
interface AnnotationStore {
|
|
75
78
|
/** The saved layer, or an empty one for a document that has none yet. */
|
|
76
79
|
load(documentId: string): Promise<AnnotationLayer>;
|
|
77
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Write a layer. A store with other writers may resolve to what it actually saved — this layer
|
|
82
|
+
* merged with theirs (see `mergeLayers`); the caller then rebases its newer edits onto it.
|
|
83
|
+
*/
|
|
84
|
+
save(layer: AnnotationLayer): Promise<AnnotationLayer | void>;
|
|
85
|
+
/** Others' changes since the last load or save, or null when there are none. */
|
|
86
|
+
pull?(documentId: string): Promise<AnnotationLayer | null>;
|
|
87
|
+
/** Whether this user may change the layer; false makes it view-only. Known after `load`. */
|
|
88
|
+
canEdit?(documentId: string): boolean;
|
|
89
|
+
}
|
|
90
|
+
/** Thrown by a store whose backend cannot be reached: the layer is kept and saved when back. */
|
|
91
|
+
declare class AnnotationStoreOfflineError extends Error {
|
|
92
|
+
constructor(message?: string);
|
|
78
93
|
}
|
|
79
94
|
declare function createMemoryStore(now?: () => string): AnnotationStore;
|
|
80
95
|
/**
|
|
@@ -83,6 +98,35 @@ declare function createMemoryStore(now?: () => string): AnnotationStore;
|
|
|
83
98
|
*/
|
|
84
99
|
declare function createLocalStorageStore(storage?: Pick<Storage, 'getItem' | 'setItem'> | undefined, now?: () => string): AnnotationStore;
|
|
85
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Merging two writers' versions of one layer, by annotation id (a PDF annotation's `/NM`).
|
|
103
|
+
*
|
|
104
|
+
* Used when a save is refused because someone saved first (HTTP 409): the client re-reads the
|
|
105
|
+
* latest layer ("theirs") and merges it with its own ("mine"), relative to the layer both started
|
|
106
|
+
* from ("base"). Nobody's marks are lost:
|
|
107
|
+
*
|
|
108
|
+
* - a mark only one side has is kept, unless that side never had it and the other deleted it:
|
|
109
|
+
* a mark in `base` that `mine` no longer has was deleted here and stays deleted, and one that
|
|
110
|
+
* `theirs` no longer has was deleted there and stays deleted unless it was edited here since;
|
|
111
|
+
* - a mark both sides have: the later edit (`updatedAt`) wins as a whole; a comment additionally
|
|
112
|
+
* keeps every reply either side added;
|
|
113
|
+
* - `deleted` (the ids this session removed, its tombstones) always wins: a concurrent edit
|
|
114
|
+
* elsewhere does not resurrect a mark deleted here, even one `base` never saw.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
interface MergeInput {
|
|
118
|
+
/** The layer both sides started from (the last one this client saved or loaded). */
|
|
119
|
+
base: AnnotationLayer | null;
|
|
120
|
+
mine: AnnotationLayer;
|
|
121
|
+
theirs: AnnotationLayer;
|
|
122
|
+
/** Ids this session deleted. */
|
|
123
|
+
deleted?: ReadonlySet<string>;
|
|
124
|
+
}
|
|
125
|
+
/** Merge two versions of a layer; the result keeps `mine`'s order, then marks only `theirs` has. */
|
|
126
|
+
declare function mergeLayers({ base, mine, theirs, deleted }: MergeInput): AnnotationLayer;
|
|
127
|
+
/** True when two layers hold the same marks (by id and last edit), whatever their order. */
|
|
128
|
+
declare function sameMarks(a: AnnotationLayer, b: AnnotationLayer): boolean;
|
|
129
|
+
|
|
86
130
|
/**
|
|
87
131
|
* The redaction log of a layer: one CSV row per redaction mark (page, reason, status, who approved
|
|
88
132
|
* it and when), the record a privilege or redaction log is built from.
|
|
@@ -174,6 +218,10 @@ interface AnnotationController {
|
|
|
174
218
|
saving: boolean;
|
|
175
219
|
/** True when edits have not reached the store yet. */
|
|
176
220
|
dirty: boolean;
|
|
221
|
+
/** The device is offline (or the store unreachable): edits are kept and saved when it is back. */
|
|
222
|
+
offline: boolean;
|
|
223
|
+
/** View only (e.g. a guest on a shared document): marks show, nothing can be changed. */
|
|
224
|
+
readOnly: boolean;
|
|
177
225
|
author: string;
|
|
178
226
|
tool: AnnotationTool;
|
|
179
227
|
setTool(tool: AnnotationTool): void;
|
|
@@ -197,24 +245,41 @@ interface AnnotationController {
|
|
|
197
245
|
flush(): Promise<void>;
|
|
198
246
|
}
|
|
199
247
|
|
|
248
|
+
/** The save state in words, as the toolbar shows it. */
|
|
249
|
+
declare function layerStatusText(controller: AnnotationController): string;
|
|
250
|
+
|
|
200
251
|
/**
|
|
201
252
|
* Annotation state for one document: loads its layer from a store, applies edits through the pure
|
|
202
253
|
* reducer (so undo/redo is exact), and saves back after a short pause.
|
|
203
254
|
*
|
|
204
255
|
* Edits are applied from a ref, not inside a React state updater, so a mark that fails validation
|
|
205
256
|
* is reported through `error` instead of throwing during render.
|
|
257
|
+
*
|
|
258
|
+
* With a shared store (other people edit the same layer) a save may come back merged with their
|
|
259
|
+
* marks, and `pull` brings in their changes while this user is idle. Either way the remote layer is
|
|
260
|
+
* REBASED in: the edits made here since are replayed on top of it with `mergeLayers`, and so is
|
|
261
|
+
* every undo/redo step, so undoing never removes a colleague's mark or brings back one they deleted.
|
|
206
262
|
*/
|
|
207
263
|
|
|
264
|
+
declare const AUTOSAVE_MS = 600;
|
|
265
|
+
/** After a failed save, try again this much later (while edits are still unsaved). */
|
|
266
|
+
declare const RETRY_MS = 10000;
|
|
208
267
|
interface UseAnnotationLayerOptions {
|
|
209
268
|
documentId: string;
|
|
210
269
|
store: AnnotationStore;
|
|
211
270
|
/** Display name recorded as the author of new marks. */
|
|
212
271
|
author: string;
|
|
213
272
|
autosaveMs?: number;
|
|
273
|
+
/** View only: marks are shown and comments can be read, nothing can be changed. */
|
|
274
|
+
readOnly?: boolean;
|
|
275
|
+
/** False while the device is offline: edits are kept and saved when it comes back. */
|
|
276
|
+
online?: boolean;
|
|
277
|
+
/** Ask the store for others' changes this often while idle (0 = never). Needs `store.pull`. */
|
|
278
|
+
pullMs?: number;
|
|
214
279
|
now?: () => string;
|
|
215
280
|
makeId?: () => string;
|
|
216
281
|
}
|
|
217
|
-
declare function useAnnotationLayer({ documentId, store, author, autosaveMs, now, makeId, }: UseAnnotationLayerOptions): AnnotationController;
|
|
282
|
+
declare function useAnnotationLayer({ documentId, store, author, autosaveMs, readOnly: readOnlyProp, online, pullMs, now, makeId, }: UseAnnotationLayerOptions): AnnotationController;
|
|
218
283
|
|
|
219
284
|
/**
|
|
220
285
|
* Turns a text selection made on the page into marks while the highlight or redact-text tool is
|
|
@@ -285,9 +350,11 @@ interface AnnotationToolbarProps {
|
|
|
285
350
|
controller: AnnotationController;
|
|
286
351
|
/** Show a Freeze button; the host opens its freeze dialog. */
|
|
287
352
|
onFreeze?: () => void;
|
|
353
|
+
/** Extra host actions at the end of the bar (e.g. "Download with markup"). */
|
|
354
|
+
actions?: ReactNode;
|
|
288
355
|
className?: string;
|
|
289
356
|
}
|
|
290
|
-
declare function AnnotationToolbar({ controller, onFreeze, className }: AnnotationToolbarProps): React.JSX.Element;
|
|
357
|
+
declare function AnnotationToolbar({ controller, onFreeze, actions, className, }: AnnotationToolbarProps): React.JSX.Element;
|
|
291
358
|
|
|
292
359
|
/** Delete, Escape, undo and redo for the annotation layer. */
|
|
293
360
|
|
|
@@ -363,4 +430,4 @@ declare function qrCornerFor(corner: ProductionCorner): ProductionCorner;
|
|
|
363
430
|
declare function moveItem<T>(items: readonly T[], from: number, to: number): T[];
|
|
364
431
|
declare function ProductionDialog({ open, onOpenChange, documents, leftOut, onConfirm, busy, progress, error, }: ProductionDialogProps): React.JSX.Element;
|
|
365
432
|
|
|
366
|
-
export { Annotation, type AnnotationAction, type AnnotationController, AnnotationLayer, AnnotationPageOverlay, type AnnotationPageOverlayProps, type AnnotationPatch, type AnnotationStore, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, CommentReply, DEFAULT_SETTINGS, type DragMode, type FreezeChoices, FreezeDialog, type FreezeDialogProps, HIGHLIGHT_COLORS, type LayerHistory, type LayerStatus, MARK_COLORS, type NewMark, NormRect, type PageSelection, type PageTextMark, type PixelRect, type PixelSize, type ProductionChoices, type ProductionCorner, ProductionDialog, type ProductionDialogProps, type ProductionDocument, REDACTION_LOG_COLUMNS, REDACTION_REASONS, type RedactionLogRow, RedactionStatus, STAMP_PRESETS, type ToolSettings, type UseAnnotationLayerOptions, annotationsOnPage, applyAction, canRedo, canUndo, containsPoint, createHistory, createLocalStorageStore, createMemoryStore, dragRect, dragToNorm, intersects, isTooSmall, mergeLineRects, moveItem, patchForRect, pendingRedactions, qrCornerFor, readSelection, redactionLogCsv, redactionLogRows, redo, reduceLayer, selectionToPageMarks, singleRect, toNorm, toPixels, undo, useAnnotationLayer, useAnnotationShortcuts, useTextSelectionMarks };
|
|
433
|
+
export { AUTOSAVE_MS, Annotation, type AnnotationAction, type AnnotationController, AnnotationLayer, AnnotationPageOverlay, type AnnotationPageOverlayProps, type AnnotationPatch, type AnnotationStore, AnnotationStoreOfflineError, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, CommentReply, DEFAULT_SETTINGS, type DragMode, type FreezeChoices, FreezeDialog, type FreezeDialogProps, HIGHLIGHT_COLORS, type LayerHistory, type LayerStatus, MARK_COLORS, type MergeInput, type NewMark, NormRect, type PageSelection, type PageTextMark, type PixelRect, type PixelSize, type ProductionChoices, type ProductionCorner, ProductionDialog, type ProductionDialogProps, type ProductionDocument, REDACTION_LOG_COLUMNS, REDACTION_REASONS, RETRY_MS, type RedactionLogRow, RedactionStatus, STAMP_PRESETS, type ToolSettings, type UseAnnotationLayerOptions, annotationsOnPage, applyAction, canRedo, canUndo, containsPoint, createHistory, createLocalStorageStore, createMemoryStore, dragRect, dragToNorm, intersects, isTooSmall, layerStatusText, mergeLayers, mergeLineRects, moveItem, patchForRect, pendingRedactions, qrCornerFor, readSelection, redactionLogCsv, redactionLogRows, redo, reduceLayer, sameMarks, selectionToPageMarks, singleRect, toNorm, toPixels, undo, useAnnotationLayer, useAnnotationShortcuts, useTextSelectionMarks };
|