@cogic/annotorious 2.7.18 → 2.7.20
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/dist/annotorious.min.js +1 -1
- package/dist/annotorious.umd.js.map +1 -1
- package/dist/index.html +3 -0
- package/package.json +1 -1
- package/public/index.html +3 -0
- package/src/ImageAnnotator.jsx +10 -6
- package/src/tools/Tool.js +8 -6
package/dist/index.html
CHANGED
package/package.json
CHANGED
package/public/index.html
CHANGED
package/src/ImageAnnotator.jsx
CHANGED
|
@@ -72,12 +72,16 @@ export default class ImageAnnotator extends Component {
|
|
|
72
72
|
|
|
73
73
|
onKeyUp = evt => {
|
|
74
74
|
if (evt.which === 27) { // Escape
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.
|
|
75
|
+
const { disableEscapeKey } = this.props.config;
|
|
76
|
+
|
|
77
|
+
if (!disableEscapeKey) {
|
|
78
|
+
this.annotationLayer.stopDrawing();
|
|
79
|
+
|
|
80
|
+
const { selectedAnnotation } = this.state;
|
|
81
|
+
if (selectedAnnotation) {
|
|
82
|
+
this.cancelSelected();
|
|
83
|
+
this.props.onCancelSelected(selectedAnnotation);
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
} else if (evt.which === 46) { // Delete
|
|
83
87
|
const { disableDeleteKey } = this.props.config;
|
package/src/tools/Tool.js
CHANGED
|
@@ -153,6 +153,7 @@ export class ToolLike extends EventEmitter {
|
|
|
153
153
|
* Base class that adds some convenience stuff for tool plugins.
|
|
154
154
|
*/
|
|
155
155
|
export default class Tool extends ToolLike {
|
|
156
|
+
_eventTarget
|
|
156
157
|
|
|
157
158
|
constructor(g, config, env) {
|
|
158
159
|
super(g, config, env);
|
|
@@ -161,6 +162,7 @@ export default class Tool extends ToolLike {
|
|
|
161
162
|
// the user has started moving, so we can
|
|
162
163
|
// fire the startSelection event
|
|
163
164
|
this.started = false;
|
|
165
|
+
this._eventTarget = this.config.bindEventListenersInternally === true ? this.svg : document;
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
attachListeners = ({ mouseMove, mouseUp, mouseDown, dblClick }) => {
|
|
@@ -189,7 +191,7 @@ export default class Tool extends ToolLike {
|
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
// Mouse up goes on doc, so we capture events outside, too
|
|
192
|
-
|
|
194
|
+
this._eventTarget.addEventListener('mouseup', this.mouseUp);
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
if (mouseDown) {
|
|
@@ -200,7 +202,7 @@ export default class Tool extends ToolLike {
|
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
// Mouse down goes on doc, so we capture events outside, too
|
|
203
|
-
|
|
205
|
+
this._eventTarget.addEventListener('mousedown', this.mouseDown);
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
if (dblClick) {
|
|
@@ -209,7 +211,7 @@ export default class Tool extends ToolLike {
|
|
|
209
211
|
dblClick(x, y, evt);
|
|
210
212
|
}
|
|
211
213
|
|
|
212
|
-
|
|
214
|
+
this._eventTarget.addEventListener('dblclick', this.dblClick);
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
}
|
|
@@ -219,13 +221,13 @@ export default class Tool extends ToolLike {
|
|
|
219
221
|
this.svg.removeEventListener('mousemove', this.mouseMove);
|
|
220
222
|
|
|
221
223
|
if (this.mouseUp)
|
|
222
|
-
|
|
224
|
+
this._eventTarget.removeEventListener('mouseup', this.mouseUp);
|
|
223
225
|
|
|
224
226
|
if (this.mouseDown)
|
|
225
|
-
|
|
227
|
+
this._eventTarget.removeEventListener('mousedown', this.mouseDown);
|
|
226
228
|
|
|
227
229
|
if (this.dblClick)
|
|
228
|
-
|
|
230
|
+
this._eventTarget.removeEventListener('dblclick', this.dblClick);
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
/**
|