kokopu-react 1.3.1 → 1.5.0
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/lib/ArrowMarkerIcon.js +5 -7
- package/dist/lib/Chessboard.js +23 -33
- package/dist/lib/ErrorBox.js +85 -5
- package/dist/lib/Movetext.js +839 -0
- package/dist/lib/SquareMarkerIcon.js +1 -1
- package/dist/lib/TextMarkerIcon.js +12 -11
- package/dist/lib/css/arrow.css +1 -1
- package/dist/lib/css/chessboard.css +6 -1
- package/dist/lib/css/error_box.css +13 -2
- package/dist/lib/css/fonts.css +34 -0
- package/dist/lib/css/movetext.css +117 -0
- package/dist/lib/css/{label.css → symbol.css} +6 -2
- package/dist/lib/fonts/chessalpha.woff +0 -0
- package/dist/lib/fonts/chessalpha.woff2 +0 -0
- package/dist/lib/i18n.js +17 -2
- package/dist/lib/impl/ArrowTip.js +3 -8
- package/dist/lib/impl/HtmlSanitizer.js +171 -0
- package/dist/lib/impl/TextSymbol.js +98 -0
- package/dist/lib/impl/colorsets.js +1 -1
- package/dist/lib/impl/piecesets.js +1 -1
- package/dist/lib/impl/util.js +6 -6
- package/dist/lib/index.js +32 -24
- package/dist/lib/markers.js +10 -10
- package/doc_src/demo/PageChessboardBase.js +1 -1
- package/doc_src/demo/{PageChessboardEdition.js → PageChessboardInteraction.js} +4 -5
- package/doc_src/demo/PageChessboardMove.js +1 -1
- package/doc_src/demo/PageChessboardSmallScreens.js +1 -1
- package/doc_src/demo/PageMovetextBase.js +214 -0
- package/doc_src/demo/PageMovetextInteraction.js +155 -0
- package/doc_src/demo/demo.css +8 -1
- package/doc_src/demo/game-1.pgn +23 -0
- package/doc_src/demo/game-2.pgn +22 -0
- package/doc_src/demo/game-invalid.pgn +10 -0
- package/doc_src/demo/util.js +1 -1
- package/doc_src/examples/Movetext.md +15 -0
- package/doc_src/home.md +2 -0
- package/doc_src/theming/LogoRenderer.js +1 -1
- package/doc_src/theming/kokopu-react-favicon.png +0 -0
- package/doc_src/theming/theming.css +1 -1
- package/graphic_test_app/01_marker_icons.js +6 -4
- package/graphic_test_app/02_chessboard_simple.js +1 -1
- package/graphic_test_app/03_chessboard_flipped.js +1 -1
- package/graphic_test_app/04_chessboard_annotations.js +2 -2
- package/graphic_test_app/05_chessboard_move.js +1 -1
- package/graphic_test_app/06_chessboard_theme.js +1 -1
- package/graphic_test_app/07_chessboard_click_squares.js +1 -1
- package/graphic_test_app/08_chessboard_move_pieces.js +1 -1
- package/graphic_test_app/09_chessboard_edit_arrows.js +1 -1
- package/graphic_test_app/10_chessboard_play_moves.js +1 -1
- package/graphic_test_app/11_chessboard_play_promotions.js +1 -1
- package/graphic_test_app/12_movetext_simple.js +41 -0
- package/graphic_test_app/13_movetext_error.js +38 -0
- package/graphic_test_app/14_movetext_html.js +40 -0
- package/graphic_test_app/15_movetext_options.js +42 -0
- package/graphic_test_app/16_movetext_interaction.js +42 -0
- package/graphic_test_app/common/dummy.pgn +8 -0
- package/graphic_test_app/common/games.pgn +167 -0
- package/graphic_test_app/common/heartbeat.txt +1 -0
- package/graphic_test_app/common/test_app.css +20 -4
- package/graphic_test_app/common/test_app.js +6 -6
- package/package.json +26 -25
- package/scripts/test_graphic/clean-graphic-output.js +1 -1
- package/scripts/test_graphic/docker-compose.yml +1 -1
- package/scripts/test_graphic/webpack-config.js +8 -3
- package/scripts/test_headless.webpack-config.js +3 -2
- package/src/ArrowMarkerIcon.js +2 -2
- package/src/Chessboard.js +11 -11
- package/src/ErrorBox.js +80 -1
- package/src/Movetext.js +616 -0
- package/src/SquareMarkerIcon.js +1 -1
- package/src/TextMarkerIcon.js +7 -7
- package/src/css/arrow.css +1 -1
- package/src/css/chessboard.css +6 -1
- package/src/css/error_box.css +13 -2
- package/src/css/fonts.css +34 -0
- package/src/css/movetext.css +117 -0
- package/src/css/{label.css → symbol.css} +6 -2
- package/src/fonts/chessalpha.woff +0 -0
- package/src/fonts/chessalpha.woff2 +0 -0
- package/src/i18n.js +12 -1
- package/src/impl/ArrowTip.js +3 -7
- package/src/impl/HtmlSanitizer.js +120 -0
- package/src/impl/TextSymbol.js +76 -0
- package/src/impl/colorsets.js +1 -1
- package/src/impl/piecesets.js +1 -1
- package/src/impl/util.js +2 -2
- package/src/index.js +2 -1
- package/src/markers.js +8 -7
- package/test/1_markers.js +20 -1
- package/test/2_chessboard_util.js +1 -1
- package/test/3_marker_icons_graphic.js +2 -2
- package/test/4_chessboard_graphic.js +1 -1
- package/test/5_chessboard_interaction.js +1 -1
- package/test/6_chessboard_play_moves.js +1 -1
- package/test/7_movetext_graphic.js +43 -0
- package/test/8_movetext_interaction.js +99 -0
- package/test/common/graphic.js +2 -2
- package/test/references/01_marker_icons/10.png +0 -0
- package/test/references/01_marker_icons/9.png +0 -0
- package/test/references/04_chessboard_annotations/4.png +0 -0
- package/test/references/04_chessboard_annotations/5.png +0 -0
- package/test/references/05_chessboard_move/3.png +0 -0
- package/test/references/12_movetext_simple/0.png +0 -0
- package/test/references/12_movetext_simple/1.png +0 -0
- package/test/references/12_movetext_simple/2.png +0 -0
- package/test/references/12_movetext_simple/3.png +0 -0
- package/test/references/13_movetext_error/0.png +0 -0
- package/test/references/13_movetext_error/1.png +0 -0
- package/test/references/13_movetext_error/2.png +0 -0
- package/test/references/13_movetext_error/3.png +0 -0
- package/test/references/14_movetext_html/0.png +0 -0
- package/test/references/14_movetext_html/1.png +0 -0
- package/test/references/14_movetext_html/2.png +0 -0
- package/test/references/15_movetext_options/0.png +0 -0
- package/test/references/15_movetext_options/1.png +0 -0
- package/test/references/15_movetext_options/2.png +0 -0
- package/test/references/15_movetext_options/3.png +0 -0
- package/test/references/16_movetext_interaction/0.png +0 -0
- package/test/references/16_movetext_interaction/1.png +0 -0
- package/test/references/16_movetext_interaction/2.png +0 -0
- package/graphic_test_app/common/healthcheck.txt +0 -1
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
16
16
|
/******************************************************************************
|
|
17
17
|
* *
|
|
18
18
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
19
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
19
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
20
20
|
* *
|
|
21
21
|
* This program is free software: you can redistribute it and/or *
|
|
22
22
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -9,16 +9,16 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
require("./css/label.css");
|
|
13
|
-
|
|
14
12
|
var _util = require("./impl/util");
|
|
15
13
|
|
|
14
|
+
var _TextSymbol = _interopRequireDefault(require("./impl/TextSymbol"));
|
|
15
|
+
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
17
|
|
|
18
18
|
/******************************************************************************
|
|
19
19
|
* *
|
|
20
20
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
21
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
21
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
22
22
|
* *
|
|
23
23
|
* This program is free software: you can redistribute it and/or *
|
|
24
24
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -52,15 +52,13 @@ function TextMarkerIcon(props) {
|
|
|
52
52
|
viewBox: viewBox,
|
|
53
53
|
width: size,
|
|
54
54
|
height: size
|
|
55
|
-
}, /*#__PURE__*/_react["default"].createElement("
|
|
56
|
-
className: "kokopu-label",
|
|
55
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextSymbol["default"], {
|
|
57
56
|
x: size / 2,
|
|
58
57
|
y: size / 2,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, props.symbol));
|
|
58
|
+
size: size,
|
|
59
|
+
symbol: props.symbol,
|
|
60
|
+
color: props.color
|
|
61
|
+
}));
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
TextMarkerIcon.propTypes = {
|
|
@@ -70,7 +68,10 @@ TextMarkerIcon.propTypes = {
|
|
|
70
68
|
size: _propTypes["default"].number.isRequired,
|
|
71
69
|
|
|
72
70
|
/**
|
|
73
|
-
* Symbol to represent on the icon. Must be
|
|
71
|
+
* Symbol to represent on the icon. Must be one of:
|
|
72
|
+
* - any letter from A to Z (either upper-case or lower-case),
|
|
73
|
+
* - any digit from 0 to 9,
|
|
74
|
+
* - any symbol code among `'plus'`, `'times'`, `'dot'`, or `'circle'`.
|
|
74
75
|
*/
|
|
75
76
|
symbol: _propTypes["default"].string.isRequired,
|
|
76
77
|
|
package/dist/lib/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 *
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
|
|
23
23
|
.kokopu-coordinate {
|
|
24
24
|
fill: currentcolor;
|
|
25
|
+
font-style: normal;
|
|
26
|
+
font-family: sans-serif;
|
|
27
|
+
text-anchor: middle;
|
|
28
|
+
dominant-baseline: central;
|
|
29
|
+
letter-spacing: 0px;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
.kokopu-annotation {
|
|
@@ -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,6 +36,17 @@
|
|
|
36
36
|
font-style: italic;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.kokopu-errorMessage
|
|
39
|
+
.kokopu-errorMessage,
|
|
40
|
+
.kokopu-errorExcerpt {
|
|
40
41
|
margin-top: 0.4em;
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
.kokopu-errorExcerpt {
|
|
45
|
+
white-space: pre-wrap;
|
|
46
|
+
font-family: monospace;
|
|
47
|
+
line-height: 1.5em;
|
|
48
|
+
color: #400;
|
|
49
|
+
background-color: #ffd;
|
|
50
|
+
border: solid 1px #aa0;
|
|
51
|
+
padding: 0.75em 1em 0.15em;
|
|
52
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
@font-face {
|
|
24
|
+
font-family: 'Chess Alpha';
|
|
25
|
+
src:
|
|
26
|
+
url('../fonts/chessalpha.woff2') format('woff2'),
|
|
27
|
+
url('../fonts/chessalpha.woff') format('woff');
|
|
28
|
+
font-weight: normal;
|
|
29
|
+
font-style: normal;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.kokopu-font-alpha {
|
|
33
|
+
font-family: 'Chess Alpha', sans-serif;
|
|
34
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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-colorTag {
|
|
24
|
+
width : 1.2em;
|
|
25
|
+
height: 1.2em;
|
|
26
|
+
vertical-align: middle;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
border: 1px solid black;
|
|
29
|
+
margin-right: 0.25em;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.kokopu-headerGroup-whitePlayer .kokopu-colorTag {
|
|
33
|
+
background-color: white;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.kokopu-headerGroup-blackPlayer .kokopu-colorTag {
|
|
37
|
+
background-color: black;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.kokopu-headerGroup-titleRating:before,
|
|
41
|
+
.kokopu-header-round:before {
|
|
42
|
+
content: "\a0("; /* \a0 == */
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.kokopu-headerGroup-titleRating:after,
|
|
46
|
+
.kokopu-header-round:after {
|
|
47
|
+
content: ")";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.kokopu-header-round,
|
|
51
|
+
.kokopu-header-annotator {
|
|
52
|
+
font-style: italic;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
* + .kokopu-move:before,
|
|
56
|
+
* + .kokopu-gameResult:before,
|
|
57
|
+
* + span.kokopu-comment:before {
|
|
58
|
+
content: " ";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
span.kokopu-variation:before {
|
|
62
|
+
content: " (";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
span.kokopu-variation:after {
|
|
66
|
+
content: ")";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
* + .kokopu-nag:before {
|
|
70
|
+
content: "\a0"; /* \a0 == */
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
div.kokopu-subVariation {
|
|
74
|
+
margin-left: 1.5em;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.kokopu-move,
|
|
78
|
+
.kokopu-gameResult {
|
|
79
|
+
font-weight: bold;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.kokopu-subVariation .kokopu-move {
|
|
83
|
+
font-weight: inherit;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.kokopu-diagram {
|
|
87
|
+
text-align: center;
|
|
88
|
+
line-height: 0px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.kokopu-moveContent {
|
|
92
|
+
display: inline-block;
|
|
93
|
+
padding-left: 1px;
|
|
94
|
+
padding-right: 1px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.kokopu-selectedMove .kokopu-moveContent {
|
|
98
|
+
background-color: currentcolor;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.kokopu-selectedMove .kokopu-moveContent > * {
|
|
102
|
+
filter: invert(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.kokopu-clickableMove .kokopu-moveContent:hover {
|
|
106
|
+
text-decoration: underline;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.kokopu-focusFieldContainer {
|
|
111
|
+
position: fixed;
|
|
112
|
+
bottom: 0px;
|
|
113
|
+
right: 0px;
|
|
114
|
+
width: 0px;
|
|
115
|
+
height: 0px;
|
|
116
|
+
overflow: hidden;
|
|
117
|
+
}
|
|
@@ -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 *
|
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
******************************************************************************/
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
.kokopu-
|
|
23
|
+
.kokopu-symbolCircle {
|
|
24
|
+
fill: transparent;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.kokopu-symbolText {
|
|
24
28
|
font-style: normal;
|
|
25
29
|
font-family: sans-serif;
|
|
26
30
|
text-anchor: middle;
|
|
Binary file
|
|
Binary file
|
package/dist/lib/i18n.js
CHANGED
|
@@ -8,7 +8,7 @@ exports["default"] = void 0;
|
|
|
8
8
|
/******************************************************************************
|
|
9
9
|
* *
|
|
10
10
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
11
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
11
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
12
12
|
* *
|
|
13
13
|
* This program is free software: you can redistribute it and/or *
|
|
14
14
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -26,10 +26,25 @@ exports["default"] = void 0;
|
|
|
26
26
|
* *
|
|
27
27
|
******************************************************************************/
|
|
28
28
|
var i18n = {
|
|
29
|
+
// Error box
|
|
30
|
+
LINE: 'line {0}',
|
|
31
|
+
// Chessboard
|
|
29
32
|
INVALID_FEN_ERROR_TITLE: 'Invalid FEN string.',
|
|
30
33
|
INVALID_NOTATION_ERROR_TITLE: 'Invalid move notation.',
|
|
31
34
|
INVALID_POSITION_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "position" attribute.',
|
|
32
|
-
INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "move" attribute.'
|
|
35
|
+
INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "move" attribute.',
|
|
36
|
+
// Movetext
|
|
37
|
+
PIECE_SYMBOLS: {
|
|
38
|
+
'K': 'K',
|
|
39
|
+
'Q': 'Q',
|
|
40
|
+
'R': 'R',
|
|
41
|
+
'B': 'B',
|
|
42
|
+
'N': 'N',
|
|
43
|
+
'P': 'P'
|
|
44
|
+
},
|
|
45
|
+
ANNOTATED_BY: 'Annotated by {0}',
|
|
46
|
+
INVALID_PGN_ERROR_TITLE: 'Invalid PGN string.',
|
|
47
|
+
INVALID_GAME_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "game" attribute.'
|
|
33
48
|
};
|
|
34
49
|
var _default = i18n;
|
|
35
50
|
exports["default"] = _default;
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
14
14
|
/******************************************************************************
|
|
15
15
|
* *
|
|
16
16
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
17
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
17
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
18
18
|
* *
|
|
19
19
|
* This program is free software: you can redistribute it and/or *
|
|
20
20
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -43,9 +43,7 @@ function ArrowTip(props) {
|
|
|
43
43
|
refX: 2.5,
|
|
44
44
|
refY: 2,
|
|
45
45
|
orient: "auto",
|
|
46
|
-
|
|
47
|
-
fill: props.color
|
|
48
|
-
}
|
|
46
|
+
fill: props.color
|
|
49
47
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
50
48
|
d: "M 4,2 L 0,4 L 1,2 L 0,0 Z"
|
|
51
49
|
}));
|
|
@@ -60,8 +58,5 @@ ArrowTip.propTypes = {
|
|
|
60
58
|
/**
|
|
61
59
|
* Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
62
60
|
*/
|
|
63
|
-
color: _propTypes["default"].string
|
|
64
|
-
};
|
|
65
|
-
ArrowTip.defaultProps = {
|
|
66
|
-
color: 'currentcolor'
|
|
61
|
+
color: _propTypes["default"].string.isRequired
|
|
67
62
|
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var htmlparser2 = _interopRequireWildcard(require("htmlparser2"));
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
|
+
|
|
22
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
+
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
|
|
26
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
27
|
+
|
|
28
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
29
|
+
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
|
|
32
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
+
|
|
34
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
35
|
+
|
|
36
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* HTML sanitizer: parse HTML string, keeping only the allowed HTML nodes, and the corresponding React object.
|
|
40
|
+
*/
|
|
41
|
+
var HtmlSanitizer = /*#__PURE__*/function () {
|
|
42
|
+
function HtmlSanitizer(_ref) {
|
|
43
|
+
var allowedTags = _ref.allowedTags,
|
|
44
|
+
allowedAttributes = _ref.allowedAttributes;
|
|
45
|
+
|
|
46
|
+
_classCallCheck(this, HtmlSanitizer);
|
|
47
|
+
|
|
48
|
+
this._allowedTags = allowedTags ? new Set(allowedTags) : new Set();
|
|
49
|
+
this._allowedAttributes = allowedAttributes ? new Map(Object.entries(allowedAttributes).map(function (_ref2) {
|
|
50
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
51
|
+
k = _ref3[0],
|
|
52
|
+
v = _ref3[1];
|
|
53
|
+
|
|
54
|
+
return [k, new Set(v)];
|
|
55
|
+
})) : new Map();
|
|
56
|
+
this._keyCounter = 0;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} text HTML string to be parsed.
|
|
60
|
+
* @returns {*} React object corresponding to the given HTML string. Can also be a fragment, or just a simple string if the given HTML string
|
|
61
|
+
* does not contain any HTML tag.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
_createClass(HtmlSanitizer, [{
|
|
66
|
+
key: "parse",
|
|
67
|
+
value: function parse(text) {
|
|
68
|
+
var _this = this;
|
|
69
|
+
|
|
70
|
+
var dom = htmlparser2.parseDocument(text); // Ensure that the returned object is a non-empty node type.
|
|
71
|
+
|
|
72
|
+
if (dom.type !== 'root') {
|
|
73
|
+
return undefined;
|
|
74
|
+
} // Process the children of the root node.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
var result = [];
|
|
78
|
+
dom.children.forEach(function (child) {
|
|
79
|
+
var childElement = _this._processNode(child);
|
|
80
|
+
|
|
81
|
+
if (childElement) {
|
|
82
|
+
result.push(childElement);
|
|
83
|
+
}
|
|
84
|
+
}); // Return the result.
|
|
85
|
+
|
|
86
|
+
if (result.length === 0) {
|
|
87
|
+
return undefined;
|
|
88
|
+
} else if (result.length === 1) {
|
|
89
|
+
return result[0];
|
|
90
|
+
} else {
|
|
91
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
92
|
+
key: this._allocateKey()
|
|
93
|
+
}, result);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "_processNode",
|
|
98
|
+
value: function _processNode(node) {
|
|
99
|
+
var _this2 = this;
|
|
100
|
+
|
|
101
|
+
if (node.type === 'text') {
|
|
102
|
+
return node.data;
|
|
103
|
+
} else if (node.type === 'tag') {
|
|
104
|
+
var children = node.children.map(function (child) {
|
|
105
|
+
return _this2._processNode(child);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (this._allowedTags.has(node.name)) {
|
|
109
|
+
var attributes = this._filterAttributes(node.name, node.attribs);
|
|
110
|
+
|
|
111
|
+
attributes['key'] = this._allocateKey();
|
|
112
|
+
return /*#__PURE__*/_react["default"].createElement(node.name, attributes, children);
|
|
113
|
+
} else {
|
|
114
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
115
|
+
key: this._allocateKey()
|
|
116
|
+
}, children);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "_filterAttributes",
|
|
124
|
+
value: function _filterAttributes(nodeName, attributes) {
|
|
125
|
+
var result = {};
|
|
126
|
+
|
|
127
|
+
for (var _i2 = 0, _Object$entries = Object.entries(attributes); _i2 < _Object$entries.length; _i2++) {
|
|
128
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
|
|
129
|
+
attribute = _Object$entries$_i[0],
|
|
130
|
+
value = _Object$entries$_i[1];
|
|
131
|
+
|
|
132
|
+
if (this._isAttributeAllowed(nodeName, attribute)) {
|
|
133
|
+
result[attribute === 'class' ? 'className' : attribute] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "_isAttributeAllowed",
|
|
141
|
+
value: function _isAttributeAllowed(nodeName, attribute) {
|
|
142
|
+
if (attribute === 'key' && attribute === 'ref' && attribute === 'className') {
|
|
143
|
+
// Those attributes are always forbidden.
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var allowedAttributesForCurrent = this._allowedAttributes.get(nodeName);
|
|
148
|
+
|
|
149
|
+
if (allowedAttributesForCurrent && allowedAttributesForCurrent.has(attribute)) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var allowedAttributesForAll = this._allowedAttributes.get('*');
|
|
154
|
+
|
|
155
|
+
if (allowedAttributesForAll && allowedAttributesForAll.has(attribute)) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "_allocateKey",
|
|
163
|
+
value: function _allocateKey() {
|
|
164
|
+
return 'auto-' + this._keyCounter++;
|
|
165
|
+
}
|
|
166
|
+
}]);
|
|
167
|
+
|
|
168
|
+
return HtmlSanitizer;
|
|
169
|
+
}();
|
|
170
|
+
|
|
171
|
+
exports["default"] = HtmlSanitizer;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = TextSymbol;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
require("../css/symbol.css");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
/******************************************************************************
|
|
17
|
+
* *
|
|
18
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
19
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
20
|
+
* *
|
|
21
|
+
* This program is free software: you can redistribute it and/or *
|
|
22
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
23
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
24
|
+
* the License, or (at your option) any later version. *
|
|
25
|
+
* *
|
|
26
|
+
* This program is distributed in the hope that it will be useful, *
|
|
27
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
28
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
29
|
+
* GNU Lesser General Public License for more details. *
|
|
30
|
+
* *
|
|
31
|
+
* You should have received a copy of the GNU Lesser General *
|
|
32
|
+
* Public License along with this program. If not, see *
|
|
33
|
+
* <http://www.gnu.org/licenses/>. *
|
|
34
|
+
* *
|
|
35
|
+
******************************************************************************/
|
|
36
|
+
var SHAPE_THICKNESS_FACTOR = 0.1;
|
|
37
|
+
var DOT_RADIUS_FACTOR = 0.15;
|
|
38
|
+
var CIRCLE_RADIUS_FACTOR = 0.425;
|
|
39
|
+
/**
|
|
40
|
+
* Symbol of a text marker.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
function TextSymbol(props) {
|
|
44
|
+
if (props.symbol === 'dot') {
|
|
45
|
+
return /*#__PURE__*/_react["default"].createElement("circle", {
|
|
46
|
+
cx: props.x,
|
|
47
|
+
cy: props.y,
|
|
48
|
+
r: props.size * DOT_RADIUS_FACTOR,
|
|
49
|
+
fill: props.color
|
|
50
|
+
});
|
|
51
|
+
} else if (props.symbol === 'circle') {
|
|
52
|
+
var thickness = props.size * SHAPE_THICKNESS_FACTOR;
|
|
53
|
+
return /*#__PURE__*/_react["default"].createElement("circle", {
|
|
54
|
+
className: "kokopu-symbolCircle",
|
|
55
|
+
cx: props.x,
|
|
56
|
+
cy: props.y,
|
|
57
|
+
r: props.size * CIRCLE_RADIUS_FACTOR,
|
|
58
|
+
stroke: props.color,
|
|
59
|
+
strokeWidth: thickness
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
var symbol = props.symbol === 'plus' ? '+' : props.symbol === 'times' ? "\xD7" : props.symbol;
|
|
63
|
+
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
64
|
+
className: "kokopu-symbolText",
|
|
65
|
+
x: props.x,
|
|
66
|
+
y: props.y,
|
|
67
|
+
fill: props.color,
|
|
68
|
+
fontSize: props.size
|
|
69
|
+
}, symbol);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
TextSymbol.propTypes = {
|
|
74
|
+
/**
|
|
75
|
+
* X-coordinate of the center of the symbol.
|
|
76
|
+
*/
|
|
77
|
+
x: _propTypes["default"].number.isRequired,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Y-coordinate of the center of the symbol.
|
|
81
|
+
*/
|
|
82
|
+
y: _propTypes["default"].number.isRequired,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Size of the symbol (i.e. size of square in which the symbol is rendered).
|
|
86
|
+
*/
|
|
87
|
+
size: _propTypes["default"].number.isRequired,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Symbol code.
|
|
91
|
+
*/
|
|
92
|
+
symbol: _propTypes["default"].string.isRequired,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
96
|
+
*/
|
|
97
|
+
color: _propTypes["default"].string.isRequired
|
|
98
|
+
};
|
|
@@ -8,7 +8,7 @@ exports["default"] = void 0;
|
|
|
8
8
|
/******************************************************************************
|
|
9
9
|
* *
|
|
10
10
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
11
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
11
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
12
12
|
* *
|
|
13
13
|
* This program is free software: you can redistribute it and/or *
|
|
14
14
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
@@ -174,7 +174,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
174
174
|
/******************************************************************************
|
|
175
175
|
* *
|
|
176
176
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
177
|
-
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net>
|
|
177
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
178
178
|
* *
|
|
179
179
|
* This program is free software: you can redistribute it and/or *
|
|
180
180
|
* modify it under the terms of the GNU Lesser General Public License *
|