cm-chessboard 7.4.2 → 7.4.4
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/package.json +1 -1
- package/src/Chessboard.js +12 -0
- package/src/view/ChessboardView.js +3 -0
package/package.json
CHANGED
package/src/Chessboard.js
CHANGED
|
@@ -188,9 +188,21 @@ export class Chessboard {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
addExtension(extensionClass, props) {
|
|
191
|
+
if(this.hasExtension(extensionClass)) {
|
|
192
|
+
throw Error("extension \"" + extensionClass.name + "\" already added")
|
|
193
|
+
}
|
|
191
194
|
this.extensions.push(new extensionClass(this, props))
|
|
192
195
|
}
|
|
193
196
|
|
|
197
|
+
hasExtension(extensionClass) {
|
|
198
|
+
for (const extension of this.extensions) {
|
|
199
|
+
if (extension instanceof extensionClass) {
|
|
200
|
+
return true
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return false
|
|
204
|
+
}
|
|
205
|
+
|
|
194
206
|
destroy() {
|
|
195
207
|
this.state.invokeExtensionPoints(EXTENSION_POINT.destroy)
|
|
196
208
|
if (this.state.squareSelectEnabled) {
|
|
@@ -302,6 +302,9 @@ export class ChessboardView {
|
|
|
302
302
|
// enable and disable move input //
|
|
303
303
|
|
|
304
304
|
enableMoveInput(eventHandler, color = undefined) {
|
|
305
|
+
if(this.moveInputCallback) {
|
|
306
|
+
throw Error("moveInput already enabled")
|
|
307
|
+
}
|
|
305
308
|
if (color === COLOR.white) {
|
|
306
309
|
this.chessboard.state.inputWhiteEnabled = true
|
|
307
310
|
} else if (color === COLOR.black) {
|