cm-chessboard 8.12.6 → 8.12.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.
@@ -5,7 +5,8 @@
5
5
  "Bash(gh pr:*)",
6
6
  "Bash(gh issue:*)",
7
7
  "Bash(npm version:*)",
8
- "Bash(npm publish:*)"
8
+ "Bash(npm publish:*)",
9
+ "Bash(gh search:*)"
9
10
  ],
10
11
  "deny": [],
11
12
  "ask": []
package/README.md CHANGED
@@ -289,6 +289,10 @@ chessboard-sprite-staunty.svg) and a sprite of the
289
289
  Sprites must be 40x40px in size where the piece elements must have ids like
290
290
  "bp" (black pawn) or "wq" (white queen). Just open the sprite in a text editor, SVG is readable like HTML.
291
291
 
292
+ ### More piece sets
293
+
294
+ [piece-packager](https://github.com/deverac/piece-packager) by @deverac ships 80+ prepackaged piece sets ready to drop into `assets/pieces/`, plus a tool to bundle your own 12 individual piece files (SVG or PNG) into a cm-chessboard-compatible sprite.
295
+
292
296
  ## Extensions
293
297
 
294
298
  cm-chessboard provides the ability to extend its functionality with extensions. Extensions extend the class `Extension`
@@ -314,7 +318,6 @@ Currently possible extension points are defined in `Extension.js`.
314
318
  export const EXTENSION_POINT = {
315
319
  positionChanged: "positionChanged", // the positions of the pieces was changed
316
320
  boardChanged: "boardChanged", // the board (orientation) was changed
317
- boardResized: "boardResized", // the board was resized
318
321
  moveInputToggled: "moveInputToggled", // move input was enabled or disabled
319
322
  moveInput: "moveInput", // move started, moving over a square, validating or canceled
320
323
  beforeRedrawBoard: "beforeRedrawBoard", // called before redrawing the board
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "8.12.6",
3
+ "version": "8.12.8",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -76,9 +76,22 @@ export class RightClickAnnotator extends Extension {
76
76
  }
77
77
  }
78
78
 
79
+ // Remove only the arrows/markers created by this extension, leaving annotations from other sources untouched.
80
+ removeOwnArrows(from = undefined, to = undefined) {
81
+ for (const arrowType of Object.values(ARROW_TYPE)) {
82
+ this.chessboard.removeArrows(arrowType, from, to)
83
+ }
84
+ }
85
+
86
+ removeOwnMarkers(square = undefined) {
87
+ for (const markerType of Object.values(MARKER_TYPE)) {
88
+ this.chessboard.removeMarkers(markerType, square)
89
+ }
90
+ }
91
+
79
92
  setAnnotations(annotations) {
80
- this.chessboard.removeArrows()
81
- this.chessboard.removeMarkers()
93
+ this.removeOwnArrows()
94
+ this.removeOwnMarkers()
82
95
  if (annotations.arrows) {
83
96
  for (const arrow of annotations.arrows) {
84
97
  this.chessboard.addArrow(arrow.type, arrow.from, arrow.to)
@@ -108,7 +121,7 @@ export class RightClickAnnotator extends Extension {
108
121
  square,
109
122
  modifiers: {
110
123
  alt: event.altKey,
111
- shift: event.shiftKey
124
+ shift: event.shiftKey || event.ctrlKey
112
125
  }
113
126
  }
114
127
  }
@@ -131,7 +144,7 @@ export class RightClickAnnotator extends Extension {
131
144
  if (existing && existing.length > 0) {
132
145
  this.chessboard.removeArrows(arrowType, start.square, endSquare)
133
146
  } else {
134
- this.chessboard.removeArrows(undefined, start.square, endSquare)
147
+ this.removeOwnArrows(start.square, endSquare)
135
148
  this.chessboard.addArrow(arrowType, start.square, endSquare)
136
149
  }
137
150
  } else if (start.square) {
@@ -140,7 +153,7 @@ export class RightClickAnnotator extends Extension {
140
153
  if (existingMarkers && existingMarkers.length > 0) {
141
154
  this.chessboard.removeMarkers(circleType, start.square)
142
155
  } else {
143
- this.chessboard.removeMarkers(undefined, start.square)
156
+ this.removeOwnMarkers(start.square)
144
157
  this.chessboard.addMarker(circleType, start.square)
145
158
  }
146
159
  }