@inkbar/react 0.3.0 → 0.4.0
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 +16 -9
- package/dist/index.d.mts +1439 -84
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1197 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
Drop a PDF viewer into your React app and let people highlight text, leave notes with replies and review redactions. `@inkbar/react` gives you components and hooks to build your own toolbars, plus
|
|
23
|
+
Drop a PDF viewer into your React app and let people highlight text, leave notes with replies and review redactions. `@inkbar/react` gives you components and hooks to build your own toolbars, plus thread and suggestion popovers, all styled by `@inkbar/theme`.
|
|
24
24
|
|
|
25
25
|
Annotations are plain typed objects. Control them from your own state, or let Inkbar hold them with undo and redo.
|
|
26
26
|
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
InkPageCount,
|
|
50
50
|
InkNextPage,
|
|
51
51
|
InkZoomSelect,
|
|
52
|
-
|
|
52
|
+
InkThreadPopover,
|
|
53
53
|
InkSuggestionCard,
|
|
54
54
|
} from '@inkbar/react'
|
|
55
55
|
import type { Annotation } from '@inkbar/core'
|
|
@@ -72,7 +72,7 @@ export function Review({
|
|
|
72
72
|
onAnnotationsChange={setAnnotations}
|
|
73
73
|
>
|
|
74
74
|
<InkToolbar>
|
|
75
|
-
<InkToolButton tool="
|
|
75
|
+
<InkToolButton tool="select-text" />
|
|
76
76
|
<InkToolButton tool="select" />
|
|
77
77
|
<InkToolButton tool="highlight" />
|
|
78
78
|
<InkToolButton tool="redact-area" />
|
|
@@ -89,7 +89,7 @@ export function Review({
|
|
|
89
89
|
<InkNextPage />
|
|
90
90
|
<InkZoomSelect />
|
|
91
91
|
</InkToolbar>
|
|
92
|
-
<
|
|
92
|
+
<InkThreadPopover />
|
|
93
93
|
<InkSuggestionCard />
|
|
94
94
|
</InkRoot>
|
|
95
95
|
)
|
|
@@ -141,15 +141,21 @@ Inside `InkRoot`, `useHistory()` returns the same object. Its `batch(fn)` runs `
|
|
|
141
141
|
|
|
142
142
|
`key` identifies the document. Reuse the same key when only the signed URL changes and the document is not reloaded.
|
|
143
143
|
|
|
144
|
-
##
|
|
144
|
+
## Thread popover
|
|
145
145
|
|
|
146
|
-
`
|
|
146
|
+
`InkThreadPopover` opens the comment thread of the activated note or text markup (a highlight, underline, strikeout or squiggly). A new note or highlight has no text yet, so the form first writes its own `contents` (labelled "Comment"); after that it adds replies. A highlight with a comment shows a small marker at its end. Replies show in the thread only; the page draws just the note or highlight they answer.
|
|
147
147
|
|
|
148
|
-
A root note with no text and no replies is removed when its popover closes, or when activation moves to another annotation, so abandoned notes do not stay on the page. Locked
|
|
148
|
+
A root note with no text and no replies is removed when its popover closes, or when activation moves to another annotation, so abandoned notes do not stay on the page. A highlight stays: the mark is the point. Locked annotations are never removed. If you add notes yourself (`add({ type: 'text', ... })`), give them `contents`, or they will be removed the first time someone opens and closes them.
|
|
149
|
+
|
|
150
|
+
The highlight tool leaves `contents` free for the comment. `doc.text(page)` returns the page's text items; match the markup's `quads` against them to get the marked text. `InkHighlightMenu` is a split button for the tool: it picks the markup kind and its colour.
|
|
151
|
+
|
|
152
|
+
## Signatures
|
|
153
|
+
|
|
154
|
+
`InkSignatureMenu` lists saved signatures, picks one for the `signature` tool, removes them, and opens `InkSignatureDialog` to draw, type or upload a new one. These are marks on the page, not cryptographic signatures. Pass `signatures` to `InkRoot` to keep them somewhere: `createLocalSignatureStore(key)` from `@inkbar/core` uses `localStorage`, and without it they last until reload. `signatureFonts` lists the handwriting fonts the Type tab offers; load them with `@font-face`. A placed signature keeps its aspect ratio when resized.
|
|
149
155
|
|
|
150
156
|
## Custom rendering
|
|
151
157
|
|
|
152
|
-
Slots are render props. `InkViewport` takes `loading`, `empty`, `error`, `renderAnnotation` and `renderPageError`; `
|
|
158
|
+
Slots are render props. `InkViewport` takes `loading`, `empty`, `error`, `renderAnnotation` and `renderPageError`; `InkThreadPopover` and `InkSuggestionCard` take a function as `children`; `InkToolButton` takes a node or a function of `{ active, label }`. The props each receives are typed as `AnnotationSlotProps`, `ThreadPopoverSlotProps` and `SuggestionCardSlotProps`, the same types the Vue package exports.
|
|
153
159
|
|
|
154
160
|
`InkRoot`, `InkToolbar`, `InkToolButton`, `InkUndo`, `InkRedo`, `InkPrevPage`, `InkNextPage`, `InkZoomIn` and `InkZoomOut` take `asChild` to render your own element in place of theirs, such as a button from your design system. Pass that element as the only child. The control keeps its behaviour and accessible name.
|
|
155
161
|
|
|
@@ -159,6 +165,7 @@ The scroll area takes focus. From there:
|
|
|
159
165
|
|
|
160
166
|
- With the `highlight` or `redact-area` tool active, `Enter` turns the text selection into a mark.
|
|
161
167
|
- With the `note` tool active, `Enter` places a note at the centre of the current page and opens it.
|
|
168
|
+
- With the `signature` tool active, `Enter` places the chosen signature at the centre of the current page.
|
|
162
169
|
|
|
163
170
|
On a focused annotation:
|
|
164
171
|
|
|
@@ -176,7 +183,7 @@ Components carry state on data attributes, for example `[data-annotation][data-s
|
|
|
176
183
|
|
|
177
184
|
## Hooks
|
|
178
185
|
|
|
179
|
-
`useDocument`, `useAnnotations`, `useTool`, `useSelection`, `useZoom`, `usePage`, `useHistory` and `useEmbedded` read the state of the nearest `InkRoot`. Build your own toolbar or side panel from them.
|
|
186
|
+
`useDocument`, `useAnnotations`, `useTool`, `useSelection`, `useZoom`, `usePage`, `useHistory` and `useEmbedded` read the state of the nearest `InkRoot`. Build your own toolbar or side panel from them. Tool options, such as the shape kind, last as long as `InkRoot`. The tool style that `useToolStyle` reads and sets (colours, line style, text style) belongs to the document: opening another one starts again from the theme's defaults.
|
|
180
187
|
|
|
181
188
|
## Licence
|
|
182
189
|
|