cm-chessboard 7.4.1 → 7.4.3
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 +18 -2
package/package.json
CHANGED
package/src/Chessboard.js
CHANGED
|
@@ -81,7 +81,7 @@ export class Chessboard {
|
|
|
81
81
|
this.state.orientation = this.props.orientation
|
|
82
82
|
// instantiate extensions
|
|
83
83
|
for (const extensionData of this.props.extensions) {
|
|
84
|
-
this.
|
|
84
|
+
this.addExtension(extensionData.class, extensionData.props)
|
|
85
85
|
}
|
|
86
86
|
this.view.redrawBoard()
|
|
87
87
|
this.state.position = new Position(this.props.position)
|
|
@@ -187,9 +187,25 @@ export class Chessboard {
|
|
|
187
187
|
this.view.visualizeInputState()
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
addExtension(extensionClass, props) {
|
|
191
|
+
if(this.hasExtension(extensionClass)) {
|
|
192
|
+
throw Error("extension \"" + extensionClass.name + "\" already added")
|
|
193
|
+
}
|
|
194
|
+
this.extensions.push(new extensionClass(this, props))
|
|
195
|
+
}
|
|
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
|
+
|
|
190
206
|
destroy() {
|
|
191
207
|
this.state.invokeExtensionPoints(EXTENSION_POINT.destroy)
|
|
192
|
-
if(this.state.squareSelectEnabled) {
|
|
208
|
+
if (this.state.squareSelectEnabled) {
|
|
193
209
|
this.disableSquareSelect()
|
|
194
210
|
}
|
|
195
211
|
this.positionAnimationsQueue.destroy()
|