cm-chessboard 4.5.8 → 5.0.2

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.
Files changed (2) hide show
  1. package/README.md +37 -29
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -10,15 +10,17 @@ aspects of chess games.
10
10
 
11
11
  ## Features
12
12
 
13
- - [Mobile friendly and responsive](https://shaack.com/projekte/cm-chessboard/examples/responsive-board.html)
13
+ - **No dependencies**, just clean ES6
14
14
  - [Can handle moves input via click or drag](https://shaack.com/projekte/cm-chessboard/examples/validate-moves.html)
15
- - [Styleable via css](https://shaack.com/projekte/cm-chessboard/examples/different-styles.html)
16
- - [Supports multiple piece sets](https://shaack.com/projekte/cm-chessboard/examples/different-styles.html)
17
- - [Supports an optimized usage for visually impaired people](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-accessibility-extension.html)
18
- 🆕
15
+ - [Styleable via css and supports multiple piece sets](https://shaack.com/projekte/cm-chessboard/examples/different-styles.html)
19
16
  - Uses SVG for rendering
20
- - Vanilla JavaScript modules in ECMAScript 6 syntax
21
- - **No dependencies**
17
+ - [Allows adding **
18
+ extensions** to extend the functionality](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html)
19
+
20
+ ## Extensions 🆕
21
+
22
+ - [Accessibility Extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-accessibility-extension.html)
23
+ - [Arrows Extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html)
22
24
 
23
25
  ## Demo and repository
24
26
 
@@ -43,18 +45,6 @@ with `{sprite.url: "./url/of/chessboard-sprite.svg"}`
43
45
  To run the unit tests in `/test` you first have to `npm install` the dev dependencies. Without tests there are no
44
46
  dependencies.
45
47
 
46
- ## Version 4.x has many changes
47
-
48
- > With the new version 4 of cm-chessboard I completely redesigned the animation of positions with
49
- > the use of promises.
50
-
51
- The pieces animations are now smoother and less error-prone for race conditions.
52
-
53
- As of version 4.x, the API functions `setPosition()`, `setPiece()` and `movePiece()` are **not animated** as default.
54
- If you want some pieces animations you have to give the parameter `animated = true`.
55
-
56
- And with 4.x the chessboard has become more accessible for visually impaired people.
57
-
58
48
  ## Usage
59
49
 
60
50
  Preconditions for using cm-chessboard in a web page:
@@ -333,6 +323,8 @@ chessboard.removeMarkers(undefined, myMarkerType)
333
323
  cm-chessboard provides the ability to extend its functionality with extensions. Extensions extend the class `Extension`
334
324
  and have access to the chessboard and can register extension points.
335
325
 
326
+ ### registerExtensionPoint(name, callback)
327
+
336
328
  ```js
337
329
  class MyCoolChessboardExtension extends Extension {
338
330
  constructor(chessboard, props) {
@@ -349,11 +341,11 @@ Currently possible extension points are defined in `Extension.js`.
349
341
 
350
342
  ```js
351
343
  export const EXTENSION_POINT = {
352
- positionChanged: "positionChanged", // the positions of the pieces was changed
353
- boardChanged: "boardChanged", // the board (orientation) was changed
354
- moveInputToggled: "moveInputToggled", // move input was enabled or disabled
355
- moveInput: "moveInput", // move started, cancelled or done
356
- destroy: "destroy" // called, before the board is destroyed
344
+ positionChanged: "positionChanged", // the positions of the pieces was changed
345
+ boardChanged: "boardChanged", // the board (orientation) was changed
346
+ moveInputToggled: "moveInputToggled", // move input was enabled or disabled
347
+ moveInput: "moveInput", // move started, cancelled or done
348
+ destroy: "destroy" // called, before the board is destroyed
357
349
  }
358
350
  ```
359
351
 
@@ -372,15 +364,30 @@ const chessboard = new Chessboard(document.getElementById("board"), {
372
364
  })
373
365
  ```
374
366
 
375
- ### `Accessibility` extension
367
+ ### registerMethod(name, callback)
368
+
369
+ Add methods to the main chessboard from your extension with `this.registerMethod("name", callback)`
370
+ like `addArrow(from, to, type)` in the
371
+ [Arrows extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html).
372
+
373
+ ```js
374
+ this.registerMethod("addArrow", this.addArrow)
375
+ ```
376
+
377
+ ### Existing extensions
378
+
379
+ cm-chessboard is shipped with these extensions.
380
+
381
+ #### Accessibility Extension
376
382
 
377
383
  This extension ensures that visual impaired people can better use the chessboard. It displays the braille notation
378
384
  of the current position in the alt tag of the board image and enables a form to move the pieces via text input. It
379
385
  can also display the board as HTML table and the pieces as list.
380
386
 
381
- See example [Accessibility extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-accessibility-extension.html)
387
+ See
388
+ example [Accessibility extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-accessibility-extension.html)
382
389
 
383
- #### Usage
390
+ ##### Usage
384
391
 
385
392
  ```js
386
393
  const chessboard = new Chessboard(document.getElementById("board"), {
@@ -405,11 +412,12 @@ const chessboard = new Chessboard(document.getElementById("board"), {
405
412
  })
406
413
  ```
407
414
 
408
- ### `Arrows` extension
415
+ #### Arrows extension
409
416
 
410
417
  To draw arrows on the board.
411
418
 
412
- See example [Arrows extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html)
419
+ See
420
+ example [Arrows extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/chessboard-arrows-extension.html)
413
421
 
414
422
  ## Usage with React
415
423
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "4.5.8",
3
+ "version": "5.0.2",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -12,6 +12,7 @@
12
12
  "module",
13
13
  "widget"
14
14
  ],
15
+ "type": "module",
15
16
  "browser": "./src/cm-chessboard/Chessboard.js",
16
17
  "scripts": {
17
18
  "test": "tput setaf 4;echo 'Run test/index.html in your browser for unit testing.'; echo ''; exit 0"