cm-chessboard 5.4.7 → 5.5.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 +1 -1
- package/examples/extensions/chessboard-promotion-dialog-extension.html +4 -1
- package/package.json +1 -1
- package/src/cm-chessboard/Chessboard.js +1 -16
- package/src/cm-chessboard/model/Extension.js +0 -1
- package/src/cm-chessboard/model/Position.js +2 -4
- package/src/cm-chessboard/view/VisualMoveInput.js +1 -1
package/README.md
CHANGED
|
@@ -350,7 +350,7 @@ export const EXTENSION_POINT = {
|
|
|
350
350
|
positionChanged: "positionChanged", // the positions of the pieces was changed
|
|
351
351
|
boardChanged: "boardChanged", // the board (orientation) was changed
|
|
352
352
|
moveInputToggled: "moveInputToggled", // move input was enabled or disabled
|
|
353
|
-
moveInput: "moveInput", //
|
|
353
|
+
moveInput: "moveInput", // to validate and/or cancel the move on start or end
|
|
354
354
|
redrawBoard: "redrawBoard", // called after redrawing the board
|
|
355
355
|
destroy: "destroy" // called, before the board is destroyed
|
|
356
356
|
}
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
import {Chessboard, COLOR, INPUT_EVENT_TYPE} from "../../src/cm-chessboard/Chessboard.js"
|
|
23
23
|
import {PromotionDialog} from "../../src/cm-chessboard/extensions/promotion-dialog/PromotionDialog.js"
|
|
24
24
|
|
|
25
|
+
const position = "4k3/1P6/8/8/6r1/8/8/2R1K3 w - - 0 1"
|
|
25
26
|
const chessboard = new Chessboard(document.getElementById("chessboard"), {
|
|
26
|
-
position:
|
|
27
|
+
position: position,
|
|
27
28
|
sprite: {
|
|
28
29
|
url: "../../assets/images/chessboard-sprite.svg", // pieces and markers are stored in a sprite file
|
|
29
30
|
},
|
|
@@ -39,6 +40,8 @@
|
|
|
39
40
|
console.log("48a99d Piece selected", event.piece)
|
|
40
41
|
if(event.piece) {
|
|
41
42
|
chessboard.setPiece(event.square, event.piece, true)
|
|
43
|
+
} else {
|
|
44
|
+
chessboard.setPosition(position)
|
|
42
45
|
}
|
|
43
46
|
})
|
|
44
47
|
}
|
package/package.json
CHANGED
|
@@ -15,12 +15,9 @@ export const COLOR = {
|
|
|
15
15
|
black: "b"
|
|
16
16
|
}
|
|
17
17
|
export const INPUT_EVENT_TYPE = {
|
|
18
|
-
moveStart: "moveInputStarted", // TODO deprecated 2022-08-24, use `moveInputStarted`
|
|
19
18
|
moveInputStarted: "moveInputStarted",
|
|
20
|
-
moveDone: "validateMoveInput", // TODO deprecated 2022-08-24, use `validateMoveInput` https://github.com/shaack/cm-chessboard/issues/83
|
|
21
19
|
validateMoveInput: "validateMoveInput",
|
|
22
|
-
|
|
23
|
-
moveInputCanceled: "moveInputCanceled",
|
|
20
|
+
moveInputCanceled: "moveInputCanceled"
|
|
24
21
|
}
|
|
25
22
|
export const SQUARE_SELECT_TYPE = {
|
|
26
23
|
primary: "primary",
|
|
@@ -156,19 +153,11 @@ export class Chessboard {
|
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
addMarker(type, square) {
|
|
159
|
-
if (typeof type === "string" || typeof square === "object") { // todo remove 2022-12-01
|
|
160
|
-
console.error("changed the signature of `addMarker` to `(type, square)` with v5.1.x")
|
|
161
|
-
return
|
|
162
|
-
}
|
|
163
156
|
this.state.addMarker(square, type)
|
|
164
157
|
this.view.drawMarkers()
|
|
165
158
|
}
|
|
166
159
|
|
|
167
160
|
getMarkers(type = undefined, square = undefined) {
|
|
168
|
-
if (typeof type === "string" || typeof square === "object") { // todo remove 2022-12-01
|
|
169
|
-
console.error("changed the signature of `getMarkers` to `(type, square)` with v5.1.x")
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
161
|
const markersFound = []
|
|
173
162
|
this.state.markers.forEach((marker) => {
|
|
174
163
|
const markerSquare = marker.square
|
|
@@ -182,10 +171,6 @@ export class Chessboard {
|
|
|
182
171
|
}
|
|
183
172
|
|
|
184
173
|
removeMarkers(type = undefined, square = undefined) {
|
|
185
|
-
if (typeof type === "string" || typeof square === "object") { // todo remove 2022-12-01
|
|
186
|
-
console.error("changed the signature of `removeMarkers` to `(type, square)` with v5.1.x")
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
174
|
this.state.removeMarkers(square, type)
|
|
190
175
|
this.view.drawMarkers()
|
|
191
176
|
}
|
|
@@ -9,7 +9,6 @@ export const EXTENSION_POINT = {
|
|
|
9
9
|
boardChanged: "boardChanged", // the board (orientation) was changed
|
|
10
10
|
moveInputToggled: "moveInputToggled", // move input was enabled or disabled
|
|
11
11
|
moveInput: "moveInput", // move started, to validate or canceled
|
|
12
|
-
// moveInputStateChanged: "moveInput", // TODO deprecated, use `moveInput`
|
|
13
12
|
redrawBoard: "redrawBoard", // called after redrawing the board
|
|
14
13
|
destroy: "destroy" // called, before the board is destroyed
|
|
15
14
|
}
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* Repository: https://github.com/shaack/cm-chessboard
|
|
4
4
|
* License: MIT, see file 'LICENSE'
|
|
5
5
|
*/
|
|
6
|
-
export const FEN_START_POSITION = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" // TODO deprecated, use FEN
|
|
7
|
-
export const FEN_EMPTY_POSITION = "8/8/8/8/8/8/8/8" // TODO deprecated, use FEN
|
|
8
6
|
export const FEN = {
|
|
9
|
-
start:
|
|
10
|
-
empty:
|
|
7
|
+
start: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
|
|
8
|
+
empty: "8/8/8/8/8/8/8/8"
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
export class Position {
|
|
@@ -197,7 +197,7 @@ export class VisualMoveInput {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
createDraggablePiece(pieceName) {
|
|
200
|
-
//
|
|
200
|
+
// maybe I should use the existing piece from the board and don't create a new one
|
|
201
201
|
if (this.draggablePiece) {
|
|
202
202
|
throw Error("draggablePiece exists")
|
|
203
203
|
}
|