@fieldnotes/react 0.1.2 → 0.2.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 +20 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ function App() {
|
|
|
56
56
|
}
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Embedded
|
|
59
|
+
Embedded components use a **two-mode interaction model**: by default they can be selected, dragged, and resized. **Double-click** to enter interact mode (clicks, inputs, forms work). **Escape** or click outside to exit.
|
|
60
60
|
|
|
61
61
|
## Hooks
|
|
62
62
|
|
|
@@ -116,6 +116,25 @@ function CameraInfo() {
|
|
|
116
116
|
}
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
### Changing Tool Options
|
|
120
|
+
|
|
121
|
+
Use `useViewport()` to access tool instances and change options at runtime:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { useViewport } from '@fieldnotes/react';
|
|
125
|
+
import type { PencilTool } from '@fieldnotes/core';
|
|
126
|
+
|
|
127
|
+
function ColorPicker() {
|
|
128
|
+
const viewport = useViewport();
|
|
129
|
+
|
|
130
|
+
const setColor = (color: string) => {
|
|
131
|
+
viewport.toolManager.getTool<PencilTool>('pencil')?.setOptions({ color });
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return <input type="color" onChange={(e) => setColor(e.target.value)} />;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
119
138
|
## Component API
|
|
120
139
|
|
|
121
140
|
### `<FieldNotesCanvas>`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fieldnotes/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React wrapper for Field Notes canvas SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -16,14 +16,9 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsup",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"test:watch": "vitest"
|
|
23
|
-
},
|
|
24
19
|
"license": "MIT",
|
|
25
20
|
"dependencies": {
|
|
26
|
-
"@fieldnotes/core": "
|
|
21
|
+
"@fieldnotes/core": "0.2.1"
|
|
27
22
|
},
|
|
28
23
|
"peerDependencies": {
|
|
29
24
|
"react": ">=18",
|
|
@@ -39,5 +34,10 @@
|
|
|
39
34
|
"react-dom": "^19.2.4",
|
|
40
35
|
"tsup": "^8.5.1",
|
|
41
36
|
"vitest": "^4.1.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|