cm-chessboard 5.1.6 → 5.1.8
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
CHANGED
|
@@ -14,7 +14,8 @@ aspects of chess games.
|
|
|
14
14
|
- [Can handle moves input via click or drag](https://shaack.com/projekte/cm-chessboard/examples/validate-moves.html)
|
|
15
15
|
- [Styleable via css and supports multiple piece sets](https://shaack.com/projekte/cm-chessboard/examples/different-styles.html)
|
|
16
16
|
- Uses SVG for rendering
|
|
17
|
-
- [Allows adding **
|
|
17
|
+
- [Allows adding **
|
|
18
|
+
extensions** to extend the functionality](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html)
|
|
18
19
|
|
|
19
20
|
## Extensions 🆕
|
|
20
21
|
|
|
@@ -54,6 +55,7 @@ Preconditions for using cm-chessboard in a web page:
|
|
|
54
55
|
Example, showing a FEN:
|
|
55
56
|
|
|
56
57
|
```html
|
|
58
|
+
|
|
57
59
|
<script type="module">
|
|
58
60
|
import {Chessboard} from "./src/cm-chessboard/Chessboard.js"
|
|
59
61
|
|
|
@@ -130,7 +132,7 @@ Sets the position as `fen`. Special values are "start", sets the chess start pos
|
|
|
130
132
|
|
|
131
133
|
Returns the board position as `fen`.
|
|
132
134
|
|
|
133
|
-
### addMarker(type, square)
|
|
135
|
+
### addMarker(type, square)
|
|
134
136
|
|
|
135
137
|
> signature changed with V5.1 from (square, type) to (type, square)
|
|
136
138
|
|
|
@@ -155,7 +157,8 @@ below.
|
|
|
155
157
|
|
|
156
158
|
Returns the board's markers as an array.
|
|
157
159
|
|
|
158
|
-
Only set type, to get all markers of a type on the board. Set type to `undefined`, to get markers of all types on a
|
|
160
|
+
Only set type, to get all markers of a type on the board. Set type to `undefined`, to get markers of all types on a
|
|
161
|
+
square.
|
|
159
162
|
Set `both` to `undefined` to get all markers on the board.
|
|
160
163
|
|
|
161
164
|
### removeMarkers(type = undefined, square = undefined)
|
|
@@ -418,10 +421,26 @@ const chessboard = new Chessboard(document.getElementById("board"), {
|
|
|
418
421
|
|
|
419
422
|
#### Arrows extension
|
|
420
423
|
|
|
421
|
-
|
|
424
|
+
Draw arrows on the board.
|
|
422
425
|
|
|
423
|
-
|
|
424
|
-
|
|
426
|
+
Example: [Arrows extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html)
|
|
427
|
+
|
|
428
|
+
##### Methods
|
|
429
|
+
|
|
430
|
+
###### addArrow(type, fromSquare, toSquare)
|
|
431
|
+
|
|
432
|
+
Add an arrow.
|
|
433
|
+
|
|
434
|
+
###### removeArrows(type, from, to)
|
|
435
|
+
|
|
436
|
+
To remove all arrows, call `chessboard.removeArrows()` without parameters. To remove all arrows of a specific
|
|
437
|
+
type (type "danger"), call `chessboard.removeArrows(ARROW_TYPE.danger)`. To remove all arrows starting at "
|
|
438
|
+
e2"
|
|
439
|
+
you can call `chessboard.removeArrows(undefined, "e2")` and so on...
|
|
440
|
+
|
|
441
|
+
###### getArrows(type, from, to)
|
|
442
|
+
|
|
443
|
+
To get all arrows, call `chessboard.getArrows()` without parameters, as with `removeArrows(type, from, to)`.
|
|
425
444
|
|
|
426
445
|
## Usage with React
|
|
427
446
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<h2>Example: Arrows extension</h2>
|
|
14
14
|
<div class="board" id="board"></div>
|
|
15
15
|
<br style="clear: both"/>
|
|
16
|
+
<h2>Example code</h2>
|
|
16
17
|
<pre>
|
|
17
18
|
import {ARROW_TYPE, Arrows} from "../../src/cm-chessboard/extensions/arrows/Arrows.js"
|
|
18
19
|
import {Chessboard} from "../../src/cm-chessboard/Chessboard.js"
|
|
@@ -36,6 +37,18 @@ chessboard.addArrow(ARROW_TYPE.default, "b8", "c6");
|
|
|
36
37
|
chessboard.addArrow(ARROW_TYPE.pointy, "d2", "d3");
|
|
37
38
|
chessboard.addArrow(ARROW_TYPE.danger, "g5", "e6");
|
|
38
39
|
</pre>
|
|
40
|
+
<h2>Methods</h2>
|
|
41
|
+
<h3><code>addArrow(type, fromSquare, toSquare)</code></h3>
|
|
42
|
+
<h3><code>removeArrows(type, fromSquare, toSquare)</code></h3>
|
|
43
|
+
<p>
|
|
44
|
+
To remove all arrows, call <code>chessboard.removeArrows()</code> without parameters. To remove all arrows of a specific
|
|
45
|
+
type (type "danger"), call <code>chessboard.removeArrows(ARROW_TYPE.danger)</code>. To remove all arrows starting at "e2"
|
|
46
|
+
you can call <code>chessboard.removeArrows(undefined, "e2")</code> and so on...
|
|
47
|
+
</p>
|
|
48
|
+
<h3><code>getArrows(type, from, to)</code></h3>
|
|
49
|
+
<p>
|
|
50
|
+
To get all arrows, call <code>chessboard.getArrows()</code> without parameters, as with <code>removeArrows(type, from, to)</code>.
|
|
51
|
+
</p>
|
|
39
52
|
|
|
40
53
|
<script type="module">
|
|
41
54
|
import {ARROW_TYPE, Arrows} from "../../src/cm-chessboard/extensions/arrows/Arrows.js"
|
|
@@ -55,10 +68,10 @@ chessboard.addArrow(ARROW_TYPE.danger, "g5", "e6");
|
|
|
55
68
|
|
|
56
69
|
}]
|
|
57
70
|
})
|
|
58
|
-
chessboard.addArrow(ARROW_TYPE.default, "f3", "d5")
|
|
59
|
-
chessboard.addArrow(ARROW_TYPE.default, "b8", "c6")
|
|
60
|
-
chessboard.addArrow(ARROW_TYPE.pointy, "d2", "d3")
|
|
61
|
-
chessboard.addArrow(ARROW_TYPE.danger, "g5", "e6")
|
|
71
|
+
chessboard.addArrow(ARROW_TYPE.default, "f3", "d5")
|
|
72
|
+
chessboard.addArrow(ARROW_TYPE.default, "b8", "c6")
|
|
73
|
+
chessboard.addArrow(ARROW_TYPE.pointy, "d2", "d3")
|
|
74
|
+
chessboard.addArrow(ARROW_TYPE.danger, "g5", "e6")
|
|
62
75
|
</script>
|
|
63
76
|
</body>
|
|
64
|
-
</html>
|
|
77
|
+
</html>
|