@inkbar/core 0.2.0 → 0.3.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 +10 -6
- package/dist/{document-Cywnv8Sz.d.mts → document-BftlPZKU.d.mts} +343 -71
- package/dist/document-BftlPZKU.d.mts.map +1 -0
- package/dist/dom.d.mts +1 -1
- package/dist/dom.mjs +22 -22
- package/dist/dom.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/{threads-BtvtrAhL.mjs → threads-2USvyGpX.mjs} +70 -47
- package/dist/threads-2USvyGpX.mjs.map +1 -0
- package/package.json +2 -2
- package/schema.json +122 -91
- package/dist/document-Cywnv8Sz.d.mts.map +0 -1
- package/dist/threads-BtvtrAhL.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -47,9 +47,9 @@ doc.annotations.add({ type: 'highlight', page: 0, quads })
|
|
|
47
47
|
const json = doc.exportAnnotations('json')
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
`file` can be a `File`, `Blob`, `Uint8Array`, a URL string,
|
|
50
|
+
`file` can be a `File`, `Blob`, `Uint8Array`, a URL string, `{ url, key }` when the URL is signed and changes between loads, or `{ data, key }` for bytes you want to identify. `quads` is a list of quads in PDF user space.
|
|
51
51
|
|
|
52
|
-
Writing annotations back into the PDF needs `@inkbar/engine`, which is not released yet. Until then `save()` rejects with `EngineUnavailable`. Persist `exportAnnotations('json')` instead and re-import it on the next open.
|
|
52
|
+
Writing annotations back into the PDF needs `@inkbar/engine`, which is not released yet. Until then `save()` rejects with `EngineUnavailable`. Persist `exportAnnotations('json')` instead and re-import it on the next open. `doc.key` stays the same between opens only when you open with a key: a URL string, `{ url, key }` or `{ data, key }`. A `File`, `Blob` or raw bytes get a new random key each time.
|
|
53
53
|
|
|
54
54
|
The DOM layer (`@inkbar/core/dom`) provides the viewport, canvas renderer, text layer, overlay and tools for hosts without a framework package. Vue hosts should use [`@inkbar/vue`](https://github.com/inkbar/inkbar/tree/main/packages/vue), React hosts [`@inkbar/react`](https://github.com/inkbar/inkbar/tree/main/packages/react), Svelte hosts [`@inkbar/svelte`](https://github.com/inkbar/inkbar/tree/main/packages/svelte).
|
|
55
55
|
|
|
@@ -73,7 +73,11 @@ import '@inkbar/theme/theme.css'
|
|
|
73
73
|
const viewer = createViewer(el, { source: file, assets, zoom: 'fit-width' })
|
|
74
74
|
|
|
75
75
|
const tools = createToolbar()
|
|
76
|
-
tools.append(
|
|
76
|
+
tools.append(
|
|
77
|
+
createToolButton(viewer, 'view'),
|
|
78
|
+
createToolButton(viewer, 'select'),
|
|
79
|
+
createToolButton(viewer, 'highlight')
|
|
80
|
+
)
|
|
77
81
|
|
|
78
82
|
const undo = document.createElement('button')
|
|
79
83
|
undo.textContent = 'Undo'
|
|
@@ -97,7 +101,7 @@ viewer.open(lockedFile, { password }) // this password applies to this load only
|
|
|
97
101
|
viewer.destroy()
|
|
98
102
|
```
|
|
99
103
|
|
|
100
|
-
It takes the [`mountViewer` options](#mounting-a-viewer) except `container` and `document`, plus `password`, `defaults`, `history`, `onReady` and `onError`. Set `notes` or `suggestions` to `false` to leave that part out. `viewer.status`, `viewer.document`, `viewer.engine`, `viewer.viewport` and `viewer.tools` are readables; the last two change when the engine rebuilds. A password you pass to `open` replaces the `createViewer` one for that load. The controls are `createToolButton`, `createUndo`, `createRedo`, `createZoomIn`, `createZoomOut`, `createZoomSelect`, `createPageInput`, `createPageCount`, `createPrevPage` and `createNextPage`. Each one disables itself while no document is ready and lives as long as its viewer. Buttons show an icon from [`@inkbar/icons`](https://github.com/inkbar/inkbar/tree/main/packages/icons). Replace their children with your own icon and the accessible name stays; `createIcon` draws any `@inkbar/icons` icon for your own buttons. `createToolbar` gives one Tab stop to all its buttons, with arrow keys between them, and `createToolbarSeparator` divides groups of controls in it. An input, select or textarea you add keeps its arrow keys and its own `tabindex`: it is a Tab stop unless you give it `tabindex="-1"`.
|
|
104
|
+
It takes the [`mountViewer` options](#mounting-a-viewer) except `container` and `document`, plus `source` and `assets` (both required), `password`, `defaults`, `history`, `onReady` and `onError`. Set `notes` or `suggestions` to `false` to leave that part out. `viewer.status`, `viewer.document`, `viewer.engine`, `viewer.viewport` and `viewer.tools` are readables; the last two change when the engine rebuilds. A password you pass to `open` replaces the `createViewer` one for that load. The controls are `createToolButton`, `createUndo`, `createRedo`, `createZoomIn`, `createZoomOut`, `createZoomSelect`, `createPageInput`, `createPageCount`, `createPrevPage` and `createNextPage`. Each one disables itself while no document is ready and lives as long as its viewer. Buttons show an icon from [`@inkbar/icons`](https://github.com/inkbar/inkbar/tree/main/packages/icons). Replace their children with your own icon and the accessible name stays; `createIcon` draws any `@inkbar/icons` icon for your own buttons. `createToolbar` gives one Tab stop to all its buttons, with arrow keys between them, and `createToolbarSeparator` divides groups of controls in it. An input, select or textarea you add keeps its arrow keys and its own `tabindex`: it is a Tab stop unless you give it `tabindex="-1"`.
|
|
101
105
|
|
|
102
106
|
`createViewer` reads the theme's colours from the element you pass, so that element needs to be in the page when you call it.
|
|
103
107
|
|
|
@@ -142,11 +146,11 @@ The viewport mounts pages synchronously, so a build's page callbacks fire before
|
|
|
142
146
|
|
|
143
147
|
`add` throws if `input.id` is already in the list. Locked annotations refuse changes to their geometry, `page` and `contents`.
|
|
144
148
|
|
|
145
|
-
`doc.history.batch(fn)` records everything `fn` changes as one undo step, so a host that adds many annotations at once can undo them together. Change events still fire once per annotation. `fn` must be synchronous, and nested calls join the outer batch.
|
|
149
|
+
`doc.history.batch(fn)` records everything `fn` changes as one undo step, so a host that adds many annotations at once can undo them together. Change events still fire once per annotation. `fn` must be synchronous, and nested calls join the outer batch. In controlled mode `doc.history` records nothing; the framework packages' `useHistory().batch` works in both modes.
|
|
146
150
|
|
|
147
151
|
## Tools and keyboard
|
|
148
152
|
|
|
149
|
-
`createToolController` from `@inkbar/core/dom` routes pointer and key events on the viewport to the active tool: `view`, `select`, `highlight`, `redact-area` or `note`.
|
|
153
|
+
`createToolController` from `@inkbar/core/dom` routes pointer and key events on the viewport to the active tool: `view`, `select`, `highlight`, `redact-area` or `note`. Highlights, text redactions and notes can be made from the keyboard. Drawing an area redaction needs a pointer.
|
|
150
154
|
|
|
151
155
|
| Where focus is | Key | Effect |
|
|
152
156
|
| ---------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------- |
|