@inkbar/react 0.3.0 → 0.5.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 +17 -12
- package/dist/index.d.mts +1628 -718
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1254 -135
- 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
|
|
23
|
+
Drop a PDF viewer into your React app and let people highlight text, leave notes with replies and redact. `@inkbar/react` gives you components and hooks to build your own toolbars, plus a popover for comment threads, 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,8 +49,7 @@ import {
|
|
|
49
49
|
InkPageCount,
|
|
50
50
|
InkNextPage,
|
|
51
51
|
InkZoomSelect,
|
|
52
|
-
|
|
53
|
-
InkSuggestionCard,
|
|
52
|
+
InkThreadPopover,
|
|
54
53
|
} from '@inkbar/react'
|
|
55
54
|
import type { Annotation } from '@inkbar/core'
|
|
56
55
|
import { assets } from 'virtual:inkbar-assets'
|
|
@@ -72,7 +71,7 @@ export function Review({
|
|
|
72
71
|
onAnnotationsChange={setAnnotations}
|
|
73
72
|
>
|
|
74
73
|
<InkToolbar>
|
|
75
|
-
<InkToolButton tool="
|
|
74
|
+
<InkToolButton tool="select-text" />
|
|
76
75
|
<InkToolButton tool="select" />
|
|
77
76
|
<InkToolButton tool="highlight" />
|
|
78
77
|
<InkToolButton tool="redact-area" />
|
|
@@ -89,8 +88,7 @@ export function Review({
|
|
|
89
88
|
<InkNextPage />
|
|
90
89
|
<InkZoomSelect />
|
|
91
90
|
</InkToolbar>
|
|
92
|
-
<
|
|
93
|
-
<InkSuggestionCard />
|
|
91
|
+
<InkThreadPopover />
|
|
94
92
|
</InkRoot>
|
|
95
93
|
)
|
|
96
94
|
}
|
|
@@ -141,15 +139,21 @@ Inside `InkRoot`, `useHistory()` returns the same object. Its `batch(fn)` runs `
|
|
|
141
139
|
|
|
142
140
|
`key` identifies the document. Reuse the same key when only the signed URL changes and the document is not reloaded.
|
|
143
141
|
|
|
144
|
-
##
|
|
142
|
+
## Thread popover
|
|
145
143
|
|
|
146
|
-
`
|
|
144
|
+
`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
145
|
|
|
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
|
|
146
|
+
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.
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
## Signatures
|
|
151
|
+
|
|
152
|
+
`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
153
|
|
|
150
154
|
## Custom rendering
|
|
151
155
|
|
|
152
|
-
Slots are render props. `InkViewport` takes `loading`, `empty`, `error`, `renderAnnotation` and `renderPageError`; `
|
|
156
|
+
Slots are render props. `InkViewport` takes `loading`, `empty`, `error`, `renderAnnotation` and `renderPageError`; `InkThreadPopover` takes a function as `children`; `InkToolButton` takes a node or a function of `{ active, label }`. The props each receives are typed as `AnnotationSlotProps` and `ThreadPopoverSlotProps`, the same types the Vue package exports.
|
|
153
157
|
|
|
154
158
|
`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
159
|
|
|
@@ -159,10 +163,11 @@ The scroll area takes focus. From there:
|
|
|
159
163
|
|
|
160
164
|
- With the `highlight` or `redact-area` tool active, `Enter` turns the text selection into a mark.
|
|
161
165
|
- With the `note` tool active, `Enter` places a note at the centre of the current page and opens it.
|
|
166
|
+
- With the `signature` tool active, `Enter` places the chosen signature at the centre of the current page.
|
|
162
167
|
|
|
163
168
|
On a focused annotation:
|
|
164
169
|
|
|
165
|
-
- `Enter` or `Space` selects and activates it. A note
|
|
170
|
+
- `Enter` or `Space` selects and activates it. A note or text markup opens its thread; other types are only selected.
|
|
166
171
|
- `ArrowUp` and `ArrowDown` move to the previous or next annotation on the page.
|
|
167
172
|
- `Shift` + arrow moves it by 1 pt, or by 10 pt with `Alt` as well.
|
|
168
173
|
- `Ctrl` or `Cmd` + `Shift` + arrow resizes an area redaction, text box or shape.
|
|
@@ -176,7 +181,7 @@ Components carry state on data attributes, for example `[data-annotation][data-s
|
|
|
176
181
|
|
|
177
182
|
## Hooks
|
|
178
183
|
|
|
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.
|
|
184
|
+
`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
185
|
|
|
181
186
|
## Licence
|
|
182
187
|
|