kokopu-react 1.2.0 → 1.4.1

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 (81) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/lib/ArrowMarkerIcon.js +5 -7
  3. package/dist/lib/Chessboard.js +27 -33
  4. package/dist/lib/{impl/ErrorBox.js → ErrorBox.js} +2 -2
  5. package/dist/lib/SquareMarkerIcon.js +1 -1
  6. package/dist/lib/TextMarkerIcon.js +12 -11
  7. package/dist/lib/css/arrow.css +1 -1
  8. package/dist/lib/css/chessboard.css +1 -1
  9. package/dist/lib/css/error_box.css +1 -1
  10. package/dist/lib/css/label.css +1 -1
  11. package/dist/lib/css/symbol.css +25 -0
  12. package/dist/lib/i18n.js +35 -0
  13. package/dist/lib/impl/ArrowTip.js +3 -8
  14. package/dist/lib/impl/TextSymbol.js +100 -0
  15. package/dist/lib/impl/colorsets.js +1 -1
  16. package/dist/lib/impl/piecesets.js +1 -1
  17. package/dist/lib/impl/util.js +6 -6
  18. package/dist/lib/index.js +34 -18
  19. package/dist/lib/markers.js +10 -10
  20. package/doc_src/{demo/.eslintrc.yml → .eslintrc.yml} +0 -0
  21. package/doc_src/demo/PageChessboardBase.js +36 -41
  22. package/doc_src/demo/PageChessboardEdition.js +59 -71
  23. package/doc_src/demo/PageChessboardMove.js +21 -28
  24. package/doc_src/demo/PageChessboardSmallScreens.js +16 -17
  25. package/doc_src/demo/demo.css +1 -1
  26. package/doc_src/demo/util.js +1 -1
  27. package/doc_src/examples/ErrorBox.md +3 -0
  28. package/doc_src/theming/LogoRenderer.js +50 -0
  29. package/doc_src/theming/kokopu-react-favicon.png +0 -0
  30. package/doc_src/theming/kokopu-react-logo.png +0 -0
  31. package/doc_src/theming/theming.css +29 -0
  32. package/graphic_test_app/01_marker_icons.js +6 -4
  33. package/graphic_test_app/02_chessboard_simple.js +1 -1
  34. package/graphic_test_app/03_chessboard_flipped.js +1 -1
  35. package/graphic_test_app/04_chessboard_annotations.js +2 -2
  36. package/graphic_test_app/05_chessboard_move.js +1 -1
  37. package/graphic_test_app/06_chessboard_theme.js +1 -1
  38. package/graphic_test_app/07_chessboard_click_squares.js +1 -1
  39. package/graphic_test_app/08_chessboard_move_pieces.js +1 -1
  40. package/graphic_test_app/09_chessboard_edit_arrows.js +1 -1
  41. package/graphic_test_app/10_chessboard_play_moves.js +1 -1
  42. package/graphic_test_app/11_chessboard_play_promotions.js +1 -1
  43. package/graphic_test_app/common/test_app.css +1 -1
  44. package/graphic_test_app/common/test_app.js +1 -1
  45. package/package.json +23 -22
  46. package/scripts/test_graphic/clean-graphic-output.js +1 -1
  47. package/scripts/test_graphic/docker-compose.yml +1 -1
  48. package/scripts/test_graphic/webpack-config.js +2 -1
  49. package/scripts/test_headless.webpack-config.js +2 -1
  50. package/src/ArrowMarkerIcon.js +2 -2
  51. package/src/Chessboard.js +16 -14
  52. package/src/{impl/ErrorBox.js → ErrorBox.js} +2 -2
  53. package/src/SquareMarkerIcon.js +1 -1
  54. package/src/TextMarkerIcon.js +7 -7
  55. package/src/css/arrow.css +1 -1
  56. package/src/css/chessboard.css +1 -1
  57. package/src/css/error_box.css +1 -1
  58. package/src/css/label.css +1 -1
  59. package/src/css/symbol.css +25 -0
  60. package/src/i18n.js +30 -0
  61. package/src/impl/ArrowTip.js +3 -7
  62. package/src/impl/TextSymbol.js +77 -0
  63. package/src/impl/colorsets.js +1 -1
  64. package/src/impl/piecesets.js +1 -1
  65. package/src/impl/util.js +2 -2
  66. package/src/index.js +3 -1
  67. package/src/markers.js +8 -7
  68. package/test/1_markers.js +20 -1
  69. package/test/2_chessboard_util.js +1 -1
  70. package/test/3_marker_icons_graphic.js +2 -2
  71. package/test/4_chessboard_graphic.js +1 -1
  72. package/test/5_chessboard_interaction.js +1 -1
  73. package/test/6_chessboard_play_moves.js +1 -1
  74. package/test/common/graphic.js +1 -1
  75. package/test/references/01_marker_icons/10.png +0 -0
  76. package/test/references/01_marker_icons/9.png +0 -0
  77. package/test/references/02_chessboard_simple/2.png +0 -0
  78. package/test/references/02_chessboard_simple/5.png +0 -0
  79. package/test/references/03_chessboard_flipped/2.png +0 -0
  80. package/test/references/04_chessboard_annotations/4.png +0 -0
  81. package/test/references/04_chessboard_annotations/5.png +0 -0
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -23,9 +23,8 @@
23
23
  import PropTypes from 'prop-types';
24
24
  import React from 'react';
25
25
 
26
- import './css/label.css';
27
-
28
26
  import { MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, sanitizeInteger, isValidSymbol } from './impl/util';
27
+ import TextSymbol from './impl/TextSymbol';
29
28
 
30
29
 
31
30
  /**
@@ -39,9 +38,7 @@ export default function TextMarkerIcon(props) {
39
38
  let viewBox = `0 0 ${size} ${size}`;
40
39
  return (
41
40
  <svg className="kokopu-textMarkerIcon" viewBox={viewBox} width={size} height={size}>
42
- <text className="kokopu-label" x={size / 2} y={size / 2} fill={props.color} style={{ 'fontSize': size }}>
43
- {props.symbol}
44
- </text>
41
+ <TextSymbol x={size / 2} y={size / 2} size={size} symbol={props.symbol} color={props.color} />
45
42
  </svg>
46
43
  );
47
44
  }
@@ -54,7 +51,10 @@ TextMarkerIcon.propTypes = {
54
51
  size: PropTypes.number.isRequired,
55
52
 
56
53
  /**
57
- * Symbol to represent on the icon. Must be either a letter (upper-case or lower-case) or a digit.
54
+ * Symbol to represent on the icon. Must be one of:
55
+ * - any letter from A to Z (either upper-case or lower-case),
56
+ * - any digit from 0 to 9,
57
+ * - any symbol code among `'plus'`, `'times'`, `'dot'`, or `'circle'`.
58
58
  */
59
59
  symbol: PropTypes.string.isRequired,
60
60
 
package/src/css/arrow.css CHANGED
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
package/src/css/label.css CHANGED
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -0,0 +1,25 @@
1
+ /******************************************************************************
2
+ * *
3
+ * This file is part of Kokopu-React, a JavaScript chess library. *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
+ * *
6
+ * This program is free software: you can redistribute it and/or *
7
+ * modify it under the terms of the GNU Lesser General Public License *
8
+ * as published by the Free Software Foundation, either version 3 of *
9
+ * the License, or (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General *
17
+ * Public License along with this program. If not, see *
18
+ * <http://www.gnu.org/licenses/>. *
19
+ * *
20
+ ******************************************************************************/
21
+
22
+
23
+ .kokopu-symbolCircle {
24
+ fill: transparent;
25
+ }
package/src/i18n.js ADDED
@@ -0,0 +1,30 @@
1
+ /******************************************************************************
2
+ * *
3
+ * This file is part of Kokopu-React, a JavaScript chess library. *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
+ * *
6
+ * This program is free software: you can redistribute it and/or *
7
+ * modify it under the terms of the GNU Lesser General Public License *
8
+ * as published by the Free Software Foundation, either version 3 of *
9
+ * the License, or (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General *
17
+ * Public License along with this program. If not, see *
18
+ * <http://www.gnu.org/licenses/>. *
19
+ * *
20
+ ******************************************************************************/
21
+
22
+
23
+ const i18n = {
24
+ INVALID_FEN_ERROR_TITLE: 'Invalid FEN string.',
25
+ INVALID_NOTATION_ERROR_TITLE: 'Invalid move notation.',
26
+ INVALID_POSITION_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "position" attribute.',
27
+ INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "move" attribute.',
28
+ };
29
+
30
+ export default i18n;
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -29,7 +29,7 @@ import React from 'react';
29
29
  */
30
30
  export default function ArrowTip(props) {
31
31
  return (
32
- <marker id={props.id} markerWidth={4} markerHeight={4} refX={2.5} refY={2} orient="auto" style={{ fill: props.color }}>
32
+ <marker id={props.id} markerWidth={4} markerHeight={4} refX={2.5} refY={2} orient="auto" fill={props.color}>
33
33
  <path d="M 4,2 L 0,4 L 1,2 L 0,0 Z" />
34
34
  </marker>
35
35
  );
@@ -45,9 +45,5 @@ ArrowTip.propTypes = {
45
45
  /**
46
46
  * Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
47
47
  */
48
- color: PropTypes.string,
49
- };
50
-
51
- ArrowTip.defaultProps = {
52
- color: 'currentcolor',
48
+ color: PropTypes.string.isRequired,
53
49
  };
@@ -0,0 +1,77 @@
1
+ /******************************************************************************
2
+ * *
3
+ * This file is part of Kokopu-React, a JavaScript chess library. *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
+ * *
6
+ * This program is free software: you can redistribute it and/or *
7
+ * modify it under the terms of the GNU Lesser General Public License *
8
+ * as published by the Free Software Foundation, either version 3 of *
9
+ * the License, or (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General *
17
+ * Public License along with this program. If not, see *
18
+ * <http://www.gnu.org/licenses/>. *
19
+ * *
20
+ ******************************************************************************/
21
+
22
+
23
+ import PropTypes from 'prop-types';
24
+ import React from 'react';
25
+
26
+ import '../css/label.css';
27
+ import '../css/symbol.css';
28
+
29
+ const SHAPE_THICKNESS_FACTOR = 0.1;
30
+ const DOT_RADIUS_FACTOR = 0.15;
31
+ const CIRCLE_RADIUS_FACTOR = 0.425;
32
+
33
+
34
+ /**
35
+ * Symbol of a text marker.
36
+ */
37
+ export default function TextSymbol(props) {
38
+ if (props.symbol === 'dot') {
39
+ return <circle cx={props.x} cy={props.y} r={props.size * DOT_RADIUS_FACTOR} fill={props.color} />;
40
+ }
41
+ else if (props.symbol === 'circle') {
42
+ let thickness = props.size * SHAPE_THICKNESS_FACTOR;
43
+ return <circle className="kokopu-symbolCircle" cx={props.x} cy={props.y} r={props.size * CIRCLE_RADIUS_FACTOR} stroke={props.color} strokeWidth={thickness} />;
44
+ }
45
+ else {
46
+ let symbol = props.symbol === 'plus' ? '+' : props.symbol === 'times' ? '\u00d7' : props.symbol;
47
+ return <text className="kokopu-label" x={props.x} y={props.y} fill={props.color} fontSize={props.size}>{symbol}</text>;
48
+ }
49
+ }
50
+
51
+ TextSymbol.propTypes = {
52
+
53
+ /**
54
+ * X-coordinate of the center of the symbol.
55
+ */
56
+ x: PropTypes.number.isRequired,
57
+
58
+ /**
59
+ * Y-coordinate of the center of the symbol.
60
+ */
61
+ y: PropTypes.number.isRequired,
62
+
63
+ /**
64
+ * Size of the symbol (i.e. size of square in which the symbol is rendered).
65
+ */
66
+ size: PropTypes.number.isRequired,
67
+
68
+ /**
69
+ * Symbol code.
70
+ */
71
+ symbol: PropTypes.string.isRequired,
72
+
73
+ /**
74
+ * Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
75
+ */
76
+ color: PropTypes.string.isRequired,
77
+ };
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
package/src/impl/util.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -56,5 +56,5 @@ export function isValidColor(color) {
56
56
 
57
57
 
58
58
  export function isValidSymbol(symbol) {
59
- return /^[A-Za-z0-9]$/.test(symbol);
59
+ return /^(?:[A-Za-z0-9]|plus|times|dot|circle)$/.test(symbol);
60
60
  }
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -21,7 +21,9 @@
21
21
 
22
22
 
23
23
  export { flattenSquareMarkers, parseSquareMarkers, flattenTextMarkers, parseTextMarkers, flattenArrowMarkers, parseArrowMarkers } from './markers';
24
+ export { default as i18n } from './i18n';
24
25
  export { default as Chessboard } from './Chessboard';
26
+ export { default as ErrorBox } from './ErrorBox';
25
27
  export { default as SquareMarkerIcon } from './SquareMarkerIcon';
26
28
  export { default as TextMarkerIcon } from './TextMarkerIcon';
27
29
  export { default as ArrowMarkerIcon } from './ArrowMarkerIcon';
package/src/markers.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -41,14 +41,14 @@ export function flattenSquareMarkers(markers) {
41
41
  /**
42
42
  * Transform a set of text markers defined as a "square -> (symbol, color)" struct into a comma-separated string.
43
43
  *
44
- * @param {object} markers For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }}`
45
- * @returns {string} For example: `'Rzd5,GAe4'`
44
+ * @param {object} markers For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }, h3: { symbol: 'plus', color: 'y' } }`
45
+ * @returns {string} For example: `'Rzd5,GAe4,Y(plus)h3'`
46
46
  */
47
47
  export function flattenTextMarkers(markers) {
48
48
  return Object.entries(markers)
49
49
  .filter(([ sq, desc ]) => isValidSquare(sq) && desc && isValidColor(desc.color) && isValidSymbol(desc.symbol))
50
50
  .sort((a, b) => a[0].localeCompare(b[0]))
51
- .map(([ sq, desc ]) => desc.color.toUpperCase() + desc.symbol + sq)
51
+ .map(([ sq, desc ]) => desc.color.toUpperCase() + (desc.symbol.length === 1 ? desc.symbol : '(' + desc.symbol + ')') + sq)
52
52
  .join(',');
53
53
  }
54
54
 
@@ -91,12 +91,13 @@ export function parseSquareMarkers(markers) {
91
91
  /**
92
92
  * Parse a set of text markers defined as a comma-separated string into a "square -> (symbol, color)" struct.
93
93
  *
94
- * @param {string} markers For example: `'Rzd5,GAe4'`
95
- * @returns {object} For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }}`
94
+ * @param {string} markers For example: `'Rzd5,GAe4,Y(plus)h3'`
95
+ * @returns {object} For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }, h3: { symbol: 'plus', color: 'y' } }`
96
96
  */
97
97
  export function parseTextMarkers(markers) {
98
98
  return parseMarkers(markers, token => {
99
- return /^([GRY])([A-Za-z0-9])([a-h][1-8])$/.test(token) ? { key: RegExp.$3, value: { symbol: RegExp.$2, color: RegExp.$1.toLowerCase() } } : undefined;
99
+ return /^([GRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ?
100
+ { key: RegExp.$4, value: { symbol: RegExp.$2 || RegExp.$3, color: RegExp.$1.toLowerCase() } } : undefined;
100
101
  });
101
102
  }
102
103
 
package/test/1_markers.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -65,6 +65,13 @@ describe('Flatten text markers', () => {
65
65
  h7: { symbol: 'x', color: 'r' },
66
66
  d2: { symbol: 'L', color: 'r' },
67
67
  })).is('G2a1,YMc5,RLd2,Rxh7,Ywh8'); });
68
+ it('Multi-character symbols', () => { test.value(flattenTextMarkers({
69
+ a1: { symbol: 'A', color: 'y' },
70
+ a7: { symbol: 'plus', color: 'g' },
71
+ b3: { symbol: 'times', color: 'r' },
72
+ g5: { symbol: 'dot', color: 'y' },
73
+ h3: { symbol: 'circle', color: 'g' },
74
+ })).is('YAa1,G(plus)a7,R(times)b3,Y(dot)g5,G(circle)h3'); });
68
75
  it('<empty>', () => { test.value(flattenTextMarkers({})).is(''); });
69
76
 
70
77
  it('Wrong square', () => { test.value(flattenTextMarkers({
@@ -83,6 +90,10 @@ describe('Flatten text markers', () => {
83
90
  d8: { symbol: '-', color: 'r' },
84
91
  c1: { symbol: 'abcd', color: 'r' },
85
92
  })).is('G0a2'); });
93
+ it('Wrong multi-character symbol', () => { test.value(flattenTextMarkers({
94
+ a2: { symbol: '0', color: 'g' },
95
+ b5: { symbol: 'whatever', color: 'r' },
96
+ })).is('G0a2'); });
86
97
  });
87
98
 
88
99
 
@@ -100,6 +111,13 @@ describe('Parse text markers', () => {
100
111
  h7: { symbol: 'x', color: 'r' },
101
112
  d2: { symbol: 'L', color: 'r' },
102
113
  }); });
114
+ it('Multi-character symbols', () => { test.value(parseTextMarkers('YAa1,G(plus)a7, R(times)b3 ,Y(dot)g5,G(circle)h3')).is({
115
+ a1: { symbol: 'A', color: 'y' },
116
+ a7: { symbol: 'plus', color: 'g' },
117
+ b3: { symbol: 'times', color: 'r' },
118
+ g5: { symbol: 'dot', color: 'y' },
119
+ h3: { symbol: 'circle', color: 'g' },
120
+ }); });
103
121
  it('<empty>', () => { test.value(parseTextMarkers('')).is({}); });
104
122
  it('<blank>', () => { test.value(parseTextMarkers(' ')).is({}); });
105
123
 
@@ -107,6 +125,7 @@ describe('Parse text markers', () => {
107
125
  it('Duplicated square', () => { test.value(parseTextMarkers('Rka3,Gba3')).is({ a3: { symbol: 'b', color: 'g' } }); });
108
126
  it('Wrong color', () => { test.value(parseTextMarkers('G3a6,BAg5')).is({ a6: { symbol: '3', color: 'g' } }); });
109
127
  it('Wrong symbol', () => { test.value(parseTextMarkers('Rb2,RAg5,G.d3,Yabcde7')).is({ g5: { symbol: 'A', color: 'r' } }); });
128
+ it('Wrong multi-character symbol', () => { test.value(parseTextMarkers('RZb2,Y(whatever)e4')).is({ b2: { symbol: 'Z', color: 'r' } }); });
110
129
  it('Wrong format', () => { test.value(parseTextMarkers('Something RHa2 invalid, Yqe4, G g3')).is({ e4: { symbol: 'q', color: 'y' } }); });
111
130
  });
112
131
 
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -36,5 +36,5 @@ describe('Marker icons graphic', function() {
36
36
  });
37
37
 
38
38
  itChecksScreenshots(browserContext, '01_marker_icons', [ 'default square', 'colorized square', 'wrapped square', 'default text', 'colorized text', 'wrapped text',
39
- 'default arrow', 'colorized arrow', 'wrapped arrow' ]);
39
+ 'default arrow', 'colorized arrow', 'wrapped arrow', 'colorized symbol', 'wrapped symbol' ]);
40
40
  });
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *