@inkbar/react 0.4.0 → 0.6.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 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 thread and suggestion popovers, all styled by `@inkbar/theme`.
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
 
@@ -50,7 +50,6 @@ import {
50
50
  InkNextPage,
51
51
  InkZoomSelect,
52
52
  InkThreadPopover,
53
- InkSuggestionCard,
54
53
  } from '@inkbar/react'
55
54
  import type { Annotation } from '@inkbar/core'
56
55
  import { assets } from 'virtual:inkbar-assets'
@@ -90,7 +89,6 @@ export function Review({
90
89
  <InkZoomSelect />
91
90
  </InkToolbar>
92
91
  <InkThreadPopover />
93
- <InkSuggestionCard />
94
92
  </InkRoot>
95
93
  )
96
94
  }
@@ -153,11 +151,29 @@ The highlight tool leaves `contents` free for the comment. `doc.text(page)` retu
153
151
 
154
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.
155
153
 
154
+ ## Plugins
155
+
156
+ A plugin from `definePlugin` (in `@inkbar/core/dom`) adds commands, tools, decorations, page layers and its own record stores. Pass plugins to `InkRoot` once: the prop is read when the root mounts. Nothing a plugin registers shows until you place it:
157
+
158
+ ```tsx
159
+ <InkRoot src={src} assets={assets} plugins={[suggestions]}>
160
+ <InkToolbar>
161
+ <InkCommand id="sandbox.suggest" />
162
+ <InkToolButton tool="sandbox.stamp" />
163
+ </InkToolbar>
164
+ <InkViewport />
165
+ </InkRoot>
166
+ ```
167
+
168
+ `InkCommand` is a button named by the command's label, disabled while the command is, and its status in a live region beside it. While the command runs, the button keeps focus and has `aria-busy` and `aria-disabled`, and pressing it does nothing. It shows the command's icon, or its label as text when the command has no icon. To build your own, `useCommand(id)` returns `run`, `enabled`, `busy`, `status`, `label` and `icon`. Plugins are set up once `InkRoot` has mounted in the browser, never on the server. Until then the command is disabled and has no label, and `InkCommand` keeps its button out of the accessibility tree (`aria-hidden`). An id no plugin registered stays that way: `InkCommand` and `useCommand` log an `InkError('UnknownCommand')` to the console once, naming the id and the registered ones, and nothing throws. `InkToolButton` takes a plugin tool's own label and icon.
169
+
170
+ Plugin stores undo with annotations. In controlled mode with `history`, each undo step also snapshots the plugin stores, so accepting something and undoing it restores both.
171
+
156
172
  ## Custom rendering
157
173
 
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.
174
+ 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 }`; `InkCommand` a node or a function of `{ label, busy }`. The props each receives are typed as `AnnotationSlotProps` and `ThreadPopoverSlotProps`, the same types the Vue package exports.
159
175
 
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.
176
+ `InkRoot`, `InkToolbar`, `InkToolButton`, `InkCommand`, `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.
161
177
 
162
178
  ## Keyboard
163
179
 
@@ -169,7 +185,7 @@ The scroll area takes focus. From there:
169
185
 
170
186
  On a focused annotation:
171
187
 
172
- - `Enter` or `Space` selects and activates it. A note opens its thread and a suggested redaction its card; other types are only selected.
188
+ - `Enter` or `Space` selects and activates it. A note or text markup opens its thread; other types are only selected.
173
189
  - `ArrowUp` and `ArrowDown` move to the previous or next annotation on the page.
174
190
  - `Shift` + arrow moves it by 1 pt, or by 10 pt with `Alt` as well.
175
191
  - `Ctrl` or `Cmd` + `Shift` + arrow resizes an area redaction, text box or shape.
@@ -183,7 +199,7 @@ Components carry state on data attributes, for example `[data-annotation][data-s
183
199
 
184
200
  ## Hooks
185
201
 
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.
202
+ `useDocument`, `useAnnotations`, `useTool`, `useSelection`, `useZoom`, `usePage`, `useHistory`, `useEmbedded` and `useCommand` 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.
187
203
 
188
204
  ## Licence
189
205