cm-chessboard 8.12.7 → 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.
package/README.md
CHANGED
|
@@ -318,7 +318,6 @@ Currently possible extension points are defined in `Extension.js`.
|
|
|
318
318
|
export const EXTENSION_POINT = {
|
|
319
319
|
positionChanged: "positionChanged", // the positions of the pieces was changed
|
|
320
320
|
boardChanged: "boardChanged", // the board (orientation) was changed
|
|
321
|
-
boardResized: "boardResized", // the board was resized
|
|
322
321
|
moveInputToggled: "moveInputToggled", // move input was enabled or disabled
|
|
323
322
|
moveInput: "moveInput", // move started, moving over a square, validating or canceled
|
|
324
323
|
beforeRedrawBoard: "beforeRedrawBoard", // called before redrawing the board
|
package/package.json
CHANGED
|
@@ -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.
|
|
81
|
-
this.
|
|
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.
|
|
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.
|
|
156
|
+
this.removeOwnMarkers(start.square)
|
|
144
157
|
this.chessboard.addMarker(circleType, start.square)
|
|
145
158
|
}
|
|
146
159
|
}
|