|
1 | 1 | # React Picture Annotation |
2 | 2 |
|
3 | | -[](https://github.com/kunduin/react-picture-annotation/blob/master/LICENSE) [](https://travis-ci.com/Kunduin/react-picture-annotation) [](https://www.npmjs.com/package/react-picture-annotation) [](https://greenkeeper.io/) |
| 3 | +[](https://github.com/kunduin/react-picture-annotation/blob/master/LICENSE) [](https://travis-ci.com/Kunduin/react-picture-annotation) [](https://www.npmjs.com/package/react-picture-annotation) |
4 | 4 |
|
5 | 5 | A simple annotation component. |
6 | 6 |
|
@@ -55,119 +55,50 @@ const rootElement = document.getElementById('root'); |
55 | 55 | ReactDOM.render(<App />, rootElement); |
56 | 56 | ``` |
57 | 57 |
|
58 | | -## Props |
59 | | - |
60 | | -### annotationData `not required` |
61 | | - |
62 | | -**TYPE** |
63 | | - |
64 | | -```ts |
65 | | -Array<IAnnotation> |
66 | | -``` |
67 | | - |
68 | | -see [IAnnotation](#iannotation) |
69 | | - |
70 | | -**COMMENT** |
71 | | - |
72 | | -Control the marked areas on the page. |
73 | | - |
74 | | -### selectedId `not required` |
75 | | - |
76 | | -**TYPE** |
77 | | - |
78 | | -```ts |
79 | | -string | null; |
80 | | -``` |
81 | | - |
82 | | -**COMMENT** |
83 | | - |
84 | | -Control the selected shape. |
85 | | - |
86 | | -### onChange `required` |
87 | | - |
88 | | -**TYPE** |
89 | | - |
90 | | -```ts |
91 | | -(annotationData: IAnnotation[]) => void |
92 | | -``` |
93 | | - |
94 | | -**COMMENT** |
95 | | - |
96 | | -Called every time the shape changes. |
97 | | - |
98 | | -### onSelected `required` |
99 | | - |
100 | | -**TYPE** |
101 | | - |
102 | | -```ts |
103 | | -(id: string | null) => void |
104 | | -``` |
105 | | - |
106 | | -**COMMENT** |
107 | | - |
108 | | -Called each time the selection is changed. |
109 | | - |
110 | | -### width `required` |
111 | | - |
112 | | -**TYPE** |
113 | | - |
114 | | -```ts |
115 | | -number; |
116 | | -``` |
117 | | - |
118 | | -**COMMENT** |
119 | | - |
120 | | -Width of the canvas. |
121 | | - |
122 | | -### height `required` |
123 | | - |
124 | | -**TYPE** |
125 | | - |
126 | | -```ts |
127 | | -number; |
128 | | -``` |
129 | | - |
130 | | -**COMMENT** |
131 | | - |
132 | | -Height of the canvas. |
133 | | - |
134 | | -### image `required` |
135 | | - |
136 | | -**TYPE** |
137 | | - |
138 | | -```ts |
139 | | -string; |
140 | | -``` |
141 | | - |
142 | | -**COMMENT** |
143 | | - |
144 | | -Image to be annotated. |
145 | | - |
146 | | -### inputElement `not required` |
147 | | - |
148 | | -**TYPE** |
149 | | - |
150 | | -```ts |
151 | | -(value: string, onChange: (value: string) => void, onDelete: () => void) => |
152 | | - React.ReactElement; |
153 | | -``` |
154 | | - |
155 | | -**COMMENT** |
156 | | - |
157 | | -Customizable input control. |
158 | | - |
159 | | -**EXAMPLE** |
160 | | - |
161 | | -```jsx |
162 | | -<ReactPictureAnnotation |
163 | | - {...props} |
164 | | - inputElement={inputProps => <MyInput {...inputProps} />} |
165 | | -/> |
| 58 | +## ReactPictureAnnotation Props |
| 59 | + |
| 60 | +| Name | Type | Comment | required | |
| 61 | +| --------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------ | -------- | |
| 62 | +| onChange | `(annotationData: IAnnotation[]) => void` | Called every time the shape changes. | √ | |
| 63 | +| onSelected | `(id: string or null) => void` | Called each time the selection is changed. | √ | |
| 64 | +| width | `number` | Width of the canvas. | √ | |
| 65 | +| height | `number` | Height of the canvas. | √ | |
| 66 | +| image | `string` | Image to be annotated. | √ | |
| 67 | +| inputElement | `(value: string,onChange: (value: string) => void,onDelete: () => void) => React.ReactElement;` | Customizable input control. | X | |
| 68 | +| annotationData | `Array<IAnnotation>` | Control the marked areas on the page. | X | |
| 69 | +| annotationStyle | `IShapeStyle` | Control the mark style | X | |
| 70 | +| selectedId | `string or null` | Selected markId | X | |
| 71 | +| scrollSpeed | `number` | Speed of wheel zoom, default 0.0005 | X | |
| 72 | +| marginWithInput | `number` | Margin between input and mark, default 1 | X | |
| 73 | + |
| 74 | +## IShapeStyle |
| 75 | + |
| 76 | +ReactPictureAnnotation can be easily modified the style through a prop named `annotationStyle` |
| 77 | + |
| 78 | +```typescript |
| 79 | +export const defaultShapeStyle: IShapeStyle = { |
| 80 | + /** text area **/ |
| 81 | + padding: 5, // text padding |
| 82 | + fontSize: 12, // text font size |
| 83 | + fontColor: "#212529", // text font color |
| 84 | + fontBackground: "#f8f9fa", // text background color |
| 85 | + fontFamily: |
| 86 | + "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif", |
| 87 | + |
| 88 | + /** stroke style **/ |
| 89 | + lineWidth: 2, // stroke width |
| 90 | + shapeBackground: "hsla(210, 16%, 93%, 0.2)", // background color in the middle of the marker |
| 91 | + shapeStrokeStyle: "#f8f9fa", // shape stroke color |
| 92 | + shadowBlur: 10, // stroke shadow blur |
| 93 | + shapeShadowStyle: "hsla(210, 9%, 31%, 0.35)", // shape shadow color |
| 94 | + |
| 95 | + /** transformer style **/ |
| 96 | + transformerBackground: "#5c7cfa", |
| 97 | + transformerSize: 10 |
| 98 | +}; |
166 | 99 | ``` |
167 | 100 |
|
168 | | -## Types |
169 | | - |
170 | | -### IAnnotation |
| 101 | +## IAnnotation |
171 | 102 |
|
172 | 103 | ```js |
173 | 104 | { |
|
0 commit comments