kokopu-react 1.5.4 → 1.7.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.
Files changed (114) hide show
  1. package/.nycrc.yml +1 -1
  2. package/CHANGELOG.md +18 -0
  3. package/README.md +2 -2
  4. package/dist/lib/ArrowMarkerIcon.js +2 -2
  5. package/dist/lib/Chessboard.js +23 -15
  6. package/dist/lib/Movetext.js +41 -82
  7. package/dist/lib/formatmove.js +119 -0
  8. package/dist/lib/impl/HtmlSanitizer.js +8 -3
  9. package/dist/lib/impl/colorsets.js +44 -44
  10. package/dist/lib/impl/util.js +1 -1
  11. package/dist/lib/index.js +14 -0
  12. package/dist/lib/markers.js +7 -7
  13. package/doc_src/demo/PageChessboardInteraction.js +4 -3
  14. package/doc_src/demo/PageChessboardMove.js +36 -5
  15. package/doc_src/demo/demo.css +4 -0
  16. package/{graphic_test_app → graphic_test_src}/01_marker_icons.js +0 -0
  17. package/{graphic_test_app → graphic_test_src}/02_chessboard_simple.js +0 -0
  18. package/{graphic_test_app → graphic_test_src}/03_chessboard_flipped.js +0 -0
  19. package/{graphic_test_app → graphic_test_src}/04_chessboard_annotations.js +8 -8
  20. package/{graphic_test_app → graphic_test_src}/05_chessboard_move.js +4 -4
  21. package/{graphic_test_app → graphic_test_src}/06_chessboard_theme.js +2 -2
  22. package/{graphic_test_app → graphic_test_src}/07_chessboard_click_squares.js +0 -0
  23. package/{graphic_test_app → graphic_test_src}/08_chessboard_move_pieces.js +1 -1
  24. package/{graphic_test_app → graphic_test_src}/09_chessboard_edit_arrows.js +0 -0
  25. package/{graphic_test_app → graphic_test_src}/10_chessboard_play_moves.js +1 -1
  26. package/{graphic_test_app → graphic_test_src}/11_chessboard_play_promotions.js +0 -0
  27. package/{graphic_test_app → graphic_test_src}/12_movetext_simple.js +0 -0
  28. package/{graphic_test_app → graphic_test_src}/13_movetext_error.js +0 -0
  29. package/{graphic_test_app → graphic_test_src}/14_movetext_html.js +0 -0
  30. package/{graphic_test_app → graphic_test_src}/15_movetext_options.js +0 -4
  31. package/{graphic_test_app → graphic_test_src}/16_movetext_interaction.js +0 -0
  32. package/{graphic_test_app → graphic_test_src}/common/dummy.pgn +0 -0
  33. package/{graphic_test_app → graphic_test_src}/common/games.pgn +11 -5
  34. package/{graphic_test_app → graphic_test_src}/common/heartbeat.txt +0 -0
  35. package/graphic_test_src/common/smiley.png +0 -0
  36. package/{graphic_test_app → graphic_test_src}/common/test_app.css +0 -0
  37. package/{graphic_test_app → graphic_test_src}/common/test_app.js +3 -2
  38. package/graphics/chess_sprites/cburnett/bb.svg +45 -0
  39. package/graphics/chess_sprites/cburnett/bk.svg +47 -0
  40. package/graphics/chess_sprites/cburnett/bn.svg +37 -0
  41. package/graphics/chess_sprites/cburnett/bp.svg +19 -0
  42. package/graphics/chess_sprites/cburnett/bq.svg +58 -0
  43. package/graphics/chess_sprites/cburnett/br.svg +60 -0
  44. package/graphics/chess_sprites/cburnett/bx.svg +56 -0
  45. package/graphics/chess_sprites/cburnett/wb.svg +48 -0
  46. package/graphics/chess_sprites/cburnett/wk.svg +26 -0
  47. package/graphics/chess_sprites/cburnett/wn.svg +37 -0
  48. package/graphics/chess_sprites/cburnett/wp.svg +19 -0
  49. package/graphics/chess_sprites/cburnett/wq.svg +60 -0
  50. package/graphics/chess_sprites/cburnett/wr.svg +44 -0
  51. package/graphics/chess_sprites/cburnett/wx.svg +56 -0
  52. package/graphics/chess_sprites/generate_sprites.sh +135 -0
  53. package/graphics/chess_sprites/mmonge/celtic-bx.svg +112 -0
  54. package/graphics/chess_sprites/mmonge/celtic-wx.svg +111 -0
  55. package/graphics/chess_sprites/mmonge/celtic.svg +1576 -0
  56. package/graphics/chess_sprites/mmonge/eyes-spatial-bx.svg +101 -0
  57. package/graphics/chess_sprites/mmonge/eyes-spatial-wx.svg +100 -0
  58. package/graphics/chess_sprites/mmonge/eyes.svg +2538 -0
  59. package/graphics/chess_sprites/mmonge/fantasy-bx.svg +112 -0
  60. package/graphics/chess_sprites/mmonge/fantasy-wx.svg +111 -0
  61. package/graphics/chess_sprites/mmonge/fantasy.svg +5497 -0
  62. package/graphics/chess_sprites/mmonge/fantasy_alt.svg +3742 -0
  63. package/graphics/chess_sprites/mmonge/freak.svg +3479 -0
  64. package/graphics/chess_sprites/mmonge/prmi.svg +6776 -0
  65. package/graphics/chess_sprites/mmonge/skulls-bx.svg +124 -0
  66. package/graphics/chess_sprites/mmonge/skulls-wx.svg +111 -0
  67. package/graphics/chess_sprites/mmonge/skulls.svg +12978 -0
  68. package/graphics/chess_sprites/mmonge/spatial.svg +1223 -0
  69. package/package.json +28 -27
  70. package/scripts/{test_graphic/clean-graphic-output.js → clean-graphic-output.js} +1 -1
  71. package/scripts/{test_graphic/docker-compose.yml → docker-compose.yml} +3 -3
  72. package/scripts/{test_graphic/webpack-config.js → test-graphic.webpack.config.js} +9 -5
  73. package/scripts/{test_headless.webpack-config.js → test-headless.webpack.config.js} +2 -1
  74. package/src/Chessboard.js +21 -13
  75. package/src/Movetext.js +37 -59
  76. package/src/formatmove.js +91 -0
  77. package/src/impl/HtmlSanitizer.js +8 -2
  78. package/src/impl/colorsets.js +44 -44
  79. package/src/impl/util.js +1 -1
  80. package/src/index.js +1 -0
  81. package/src/markers.js +7 -7
  82. package/test/1_markers.js +14 -14
  83. package/test/common/graphic.js +2 -2
  84. package/test/references/04_chessboard_annotations/0.png +0 -0
  85. package/test/references/04_chessboard_annotations/1.png +0 -0
  86. package/test/references/04_chessboard_annotations/2.png +0 -0
  87. package/test/references/04_chessboard_annotations/3.png +0 -0
  88. package/test/references/04_chessboard_annotations/4.png +0 -0
  89. package/test/references/04_chessboard_annotations/5.png +0 -0
  90. package/test/references/05_chessboard_move/4.png +0 -0
  91. package/test/references/05_chessboard_move/5.png +0 -0
  92. package/test/references/05_chessboard_move/6.png +0 -0
  93. package/test/references/06_chessboard_theme/0.png +0 -0
  94. package/test/references/06_chessboard_theme/1.png +0 -0
  95. package/test/references/06_chessboard_theme/2.png +0 -0
  96. package/test/references/06_chessboard_theme/3.png +0 -0
  97. package/test/references/06_chessboard_theme/4.png +0 -0
  98. package/test/references/06_chessboard_theme/5.png +0 -0
  99. package/test/references/06_chessboard_theme/6.png +0 -0
  100. package/test/references/06_chessboard_theme/7.png +0 -0
  101. package/test/references/06_chessboard_theme/8.png +0 -0
  102. package/test/references/08_chessboard_move_pieces/over_arrow_marker.png +0 -0
  103. package/test/references/08_chessboard_move_pieces/over_square_marker.png +0 -0
  104. package/test/references/08_chessboard_move_pieces/over_text_marker.png +0 -0
  105. package/test/references/09_chessboard_edit_arrows/base_1.png +0 -0
  106. package/test/references/09_chessboard_edit_arrows/base_2.png +0 -0
  107. package/test/references/09_chessboard_edit_arrows/null_vector.png +0 -0
  108. package/test/references/09_chessboard_edit_arrows/over_arrow_marker.png +0 -0
  109. package/test/references/09_chessboard_edit_arrows/over_square_marker.png +0 -0
  110. package/test/references/10_chessboard_play_moves/castling_move.png +0 -0
  111. package/test/references/10_chessboard_play_moves/regular_move_2.png +0 -0
  112. package/test/references/14_movetext_html/0.png +0 -0
  113. package/test/references/14_movetext_html/1.png +0 -0
  114. package/test/references/14_movetext_html/2.png +0 -0
@@ -29,42 +29,42 @@ var _default = {
29
29
  original: {
30
30
  b: '#b5876b',
31
31
  w: '#f0dec7',
32
- g: '#0e0',
33
- r: '#d00',
34
- y: '#db0',
35
- highlight: '#04f'
32
+ cb: '#04f',
33
+ cg: '#0e0',
34
+ cr: '#d00',
35
+ cy: '#db0'
36
36
  },
37
37
  gray: {
38
38
  b: '#bbbbbb',
39
39
  w: '#f8f8f8',
40
- g: '#0a0',
41
- r: '#d00',
42
- y: '#a90',
43
- highlight: '#04f'
40
+ cb: '#04f',
41
+ cg: '#0a0',
42
+ cr: '#d00',
43
+ cy: '#a90'
44
44
  },
45
45
  scid: {
46
46
  b: '#7389b6',
47
47
  w: '#f3f3f3',
48
- g: '#0e0',
49
- r: '#d00',
50
- y: '#db0',
51
- highlight: '#04f'
48
+ cb: '#04f',
49
+ cg: '#0e0',
50
+ cr: '#d00',
51
+ cy: '#db0'
52
52
  },
53
53
  wikipedia: {
54
54
  b: '#d18b47',
55
55
  w: '#ffce9e',
56
- g: '#0e0',
57
- r: '#d00',
58
- y: '#db0',
59
- highlight: '#04f'
56
+ cb: '#04f',
57
+ cg: '#0e0',
58
+ cr: '#d00',
59
+ cy: '#db0'
60
60
  },
61
61
  xboard: {
62
62
  b: '#77a26d',
63
63
  w: '#c8c365',
64
- g: '#0f0',
65
- r: '#d00',
66
- y: '#ff0',
67
- highlight: '#04f'
64
+ cb: '#04f',
65
+ cg: '#0f0',
66
+ cr: '#d00',
67
+ cy: '#ff0'
68
68
  },
69
69
 
70
70
  /*
@@ -74,50 +74,50 @@ var _default = {
74
74
  coral: {
75
75
  b: 'rgb(112,162,163)',
76
76
  w: 'rgb(177,228,185)',
77
- g: '#080',
78
- r: '#d00',
79
- y: '#ff0',
80
- highlight: '#04f'
77
+ cb: '#04f',
78
+ cg: '#080',
79
+ cr: '#d00',
80
+ cy: '#ff0'
81
81
  },
82
82
  dusk: {
83
83
  b: 'rgb(112,102,119)',
84
84
  w: 'rgb(204,183,174)',
85
- g: '#3f3',
86
- r: '#f20',
87
- y: '#ff0',
88
- highlight: '#04f'
85
+ cb: '#04f',
86
+ cg: '#3f3',
87
+ cr: '#f20',
88
+ cy: '#ff0'
89
89
  },
90
90
  emerald: {
91
91
  b: 'rgb(111,143,114)',
92
92
  w: 'rgb(173,189,143)',
93
- g: '#6f6',
94
- r: '#d00',
95
- y: '#ff0',
96
- highlight: '#04f'
93
+ cb: '#04f',
94
+ cg: '#6f6',
95
+ cr: '#d00',
96
+ cy: '#ff0'
97
97
  },
98
98
  marine: {
99
99
  b: 'rgb(111,115,210)',
100
100
  w: 'rgb(157,172,255)',
101
- g: '#6f6',
102
- r: '#f50',
103
- y: '#ff0',
104
- highlight: '#04f'
101
+ cb: '#04f',
102
+ cg: '#6f6',
103
+ cr: '#f50',
104
+ cy: '#ff0'
105
105
  },
106
106
  sandcastle: {
107
107
  b: 'rgb(184,139,74)',
108
108
  w: 'rgb(227,193,111)',
109
- g: '#0c3',
110
- r: '#d02',
111
- y: '#ff0',
112
- highlight: '#04f'
109
+ cb: '#04f',
110
+ cg: '#0c3',
111
+ cr: '#d02',
112
+ cy: '#ff0'
113
113
  },
114
114
  wheat: {
115
115
  b: 'rgb(187,190,100)',
116
116
  w: 'rgb(234,240,206)',
117
- g: '#0c3',
118
- r: '#d00',
119
- y: '#ff3',
120
- highlight: '#04f'
117
+ cb: '#04f',
118
+ cg: '#0c3',
119
+ cr: '#d00',
120
+ cy: '#ff3'
121
121
  }
122
122
  };
123
123
  exports["default"] = _default;
@@ -61,7 +61,7 @@ function isValidVector(vect) {
61
61
  }
62
62
 
63
63
  function isValidColor(color) {
64
- return color === 'g' || color === 'r' || color === 'y';
64
+ return color === 'b' || color === 'g' || color === 'r' || color === 'y';
65
65
  }
66
66
 
67
67
  function isValidSymbol(symbol) {
package/dist/lib/index.js CHANGED
@@ -57,12 +57,24 @@ Object.defineProperty(exports, "flattenTextMarkers", {
57
57
  return _markers.flattenTextMarkers;
58
58
  }
59
59
  });
60
+ Object.defineProperty(exports, "formatMove", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _formatmove.formatMove;
64
+ }
65
+ });
60
66
  Object.defineProperty(exports, "i18n", {
61
67
  enumerable: true,
62
68
  get: function get() {
63
69
  return _i18n["default"];
64
70
  }
65
71
  });
72
+ Object.defineProperty(exports, "moveFormatter", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _formatmove.moveFormatter;
76
+ }
77
+ });
66
78
  Object.defineProperty(exports, "parseArrowMarkers", {
67
79
  enumerable: true,
68
80
  get: function get() {
@@ -84,6 +96,8 @@ Object.defineProperty(exports, "parseTextMarkers", {
84
96
 
85
97
  var _markers = require("./markers");
86
98
 
99
+ var _formatmove = require("./formatmove");
100
+
87
101
  var _i18n = _interopRequireDefault(require("./i18n"));
88
102
 
89
103
  var _Chessboard = _interopRequireDefault(require("./Chessboard"));
@@ -75,8 +75,8 @@ function flattenTextMarkers(markers) {
75
75
  /**
76
76
  * Transform a set of arrow markers defined as a "squareFromSquareTo -> color" struct into a comma-separated string.
77
77
  *
78
- * @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'y' }`
79
- * @returns {string} For example: `'Ge2e4,Rg8f6,Yg8h6'`
78
+ * @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
79
+ * @returns {string} For example: `'Ge2e4,Rg8f6,Bg8h6'`
80
80
  */
81
81
 
82
82
 
@@ -121,7 +121,7 @@ function parseMarkers(markers, tokenParser) {
121
121
 
122
122
  function parseSquareMarkers(markers) {
123
123
  return parseMarkers(markers, function (token) {
124
- return /^([GRY])([a-h][1-8])$/.test(token) ? {
124
+ return /^([BGRY])([a-h][1-8])$/.test(token) ? {
125
125
  key: RegExp.$2,
126
126
  value: RegExp.$1.toLowerCase()
127
127
  } : undefined;
@@ -137,7 +137,7 @@ function parseSquareMarkers(markers) {
137
137
 
138
138
  function parseTextMarkers(markers) {
139
139
  return parseMarkers(markers, function (token) {
140
- return /^([GRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ? {
140
+ return /^([BGRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ? {
141
141
  key: RegExp.$4,
142
142
  value: {
143
143
  symbol: RegExp.$2 || RegExp.$3,
@@ -149,14 +149,14 @@ function parseTextMarkers(markers) {
149
149
  /**
150
150
  * Parse a set of arrow markers defined as a comma-separated string into a "squareFromSquareTo -> color" struct.
151
151
  *
152
- * @param {string} markers For example: `'Ge2e4,Rg8f6,Yg8h6'`
153
- * @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'y' }`
152
+ * @param {string} markers For example: `'Ge2e4,Rg8f6,Bg8h6'`
153
+ * @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
154
154
  */
155
155
 
156
156
 
157
157
  function parseArrowMarkers(markers) {
158
158
  return parseMarkers(markers, function (token) {
159
- return /^([GRY])([a-h][1-8][a-h][1-8])$/.test(token) ? {
159
+ return /^([BGRY])([a-h][1-8][a-h][1-8])$/.test(token) ? {
160
160
  key: RegExp.$2,
161
161
  value: RegExp.$1.toLowerCase()
162
162
  } : undefined;
@@ -165,9 +165,10 @@ export default class Page extends React.Component {
165
165
  let colorset = Chessboard.colorsets()['original'];
166
166
  return (
167
167
  <ToggleButtonGroup value={this.state[attributeName]} exclusive size="small" onChange={(_, newColor) => this.setIfNonNull(attributeName, newColor)}>
168
- <ToggleButton className="kokopu-fixTextTransform" value="g">{this.renderColorButtonLabel(colorset.g)}</ToggleButton>
169
- <ToggleButton className="kokopu-fixTextTransform" value="r">{this.renderColorButtonLabel(colorset.r)}</ToggleButton>
170
- <ToggleButton className="kokopu-fixTextTransform" value="y">{this.renderColorButtonLabel(colorset.y)}</ToggleButton>
168
+ <ToggleButton className="kokopu-fixTextTransform" value="b">{this.renderColorButtonLabel(colorset.cb)}</ToggleButton>
169
+ <ToggleButton className="kokopu-fixTextTransform" value="g">{this.renderColorButtonLabel(colorset.cg)}</ToggleButton>
170
+ <ToggleButton className="kokopu-fixTextTransform" value="r">{this.renderColorButtonLabel(colorset.cr)}</ToggleButton>
171
+ <ToggleButton className="kokopu-fixTextTransform" value="y">{this.renderColorButtonLabel(colorset.cy)}</ToggleButton>
171
172
  </ToggleButtonGroup>
172
173
  );
173
174
  }
@@ -23,7 +23,7 @@
23
23
  import React from 'react';
24
24
  import kokopu from 'kokopu';
25
25
 
26
- import { Chessboard } from '../../src/index';
26
+ import { Chessboard, ArrowMarkerIcon } from '../../src/index';
27
27
  import { buildComponentDemoCode } from './util';
28
28
 
29
29
  import Box from '@mui/material/Box';
@@ -33,9 +33,13 @@ import FormControlLabel from '@mui/material/FormControlLabel';
33
33
  import Stack from '@mui/material/Stack';
34
34
  import Switch from '@mui/material/Switch';
35
35
  import TextField from '@mui/material/TextField';
36
+ import ToggleButton from '@mui/material/ToggleButton';
37
+ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
36
38
 
37
39
  import './demo.css';
38
40
 
41
+ const COLOR_ICON_SIZE = 16;
42
+
39
43
 
40
44
  export default class Page extends React.Component {
41
45
 
@@ -49,6 +53,7 @@ export default class Page extends React.Component {
49
53
  positionAfter: positionAfter, // non-null only if a valid move has been played
50
54
  flipped: false,
51
55
  moveArrowVisible: true,
56
+ moveArrowColor: 'b',
52
57
  animated: true,
53
58
  editedMove: 'Nf6',
54
59
  playedMove: 'e4',
@@ -71,12 +76,13 @@ export default class Page extends React.Component {
71
76
  <FormControlLabel label="Flip"
72
77
  control={<Switch checked={this.state.flipped} onChange={() => this.set('flipped', !this.state.flipped)} color="primary" />}
73
78
  />
74
- <FormControlLabel label="Show move arrow" disabled={!this.state.positionAfter}
75
- control={<Switch checked={this.state.moveArrowVisible} onChange={() => this.set('moveArrowVisible', !this.state.moveArrowVisible)} color="primary" />}
76
- />
77
79
  <FormControlLabel label="Animation" disabled={!this.state.positionAfter}
78
80
  control={<Switch checked={this.state.animated} onChange={() => this.set('animated', !this.state.animated)} color="primary" />}
79
81
  />
82
+ <FormControlLabel label="Show move arrow" disabled={!this.state.positionAfter}
83
+ control={<Switch checked={this.state.moveArrowVisible} onChange={() => this.set('moveArrowVisible', !this.state.moveArrowVisible)} color="primary" />}
84
+ />
85
+ {this.renderColorSelector()}
80
86
  </Stack>
81
87
  <Stack direction="row" spacing={2} alignItems="center">
82
88
  <TextField label="Move" variant="standard" value={this.state.editedMove} onChange={evt => this.set('editedMove', evt.target.value)} />
@@ -89,6 +95,21 @@ export default class Page extends React.Component {
89
95
  </>);
90
96
  }
91
97
 
98
+ renderColorSelector() {
99
+ if (!this.state.moveArrowVisible) {
100
+ return undefined;
101
+ }
102
+ let colorset = Chessboard.colorsets()['original'];
103
+ return (
104
+ <ToggleButtonGroup value={this.state.moveArrowColor} exclusive size="small" disabled={!this.state.positionAfter} onChange={(_, newColor) => this.setMoveColor(newColor)}>
105
+ <ToggleButton className="kokopu-fixOpacity" value="b"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cb} /></ToggleButton>
106
+ <ToggleButton className="kokopu-fixOpacity" value="g"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cg} /></ToggleButton>
107
+ <ToggleButton className="kokopu-fixOpacity" value="r"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cr} /></ToggleButton>
108
+ <ToggleButton className="kokopu-fixOpacity" value="y"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cy} /></ToggleButton>
109
+ </ToggleButtonGroup>
110
+ );
111
+ }
112
+
92
113
  renderChessboard() {
93
114
  return (
94
115
  <Box>
@@ -97,6 +118,7 @@ export default class Page extends React.Component {
97
118
  move={this.state.playedMove}
98
119
  flipped={this.state.flipped}
99
120
  moveArrowVisible={this.state.moveArrowVisible}
121
+ moveArrowColor={this.state.moveArrowColor}
100
122
  animated={this.state.animated}
101
123
  />
102
124
  </Box>
@@ -112,8 +134,11 @@ export default class Page extends React.Component {
112
134
  if (this.state.flipped) {
113
135
  attributes.push('flipped');
114
136
  }
115
- attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
116
137
  attributes.push(`animated={${this.state.animated}}`);
138
+ attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
139
+ if (this.state.moveArrowVisible) {
140
+ attributes.push(`moveArrowColor={${this.state.moveArrowColor}}`);
141
+ }
117
142
  return <pre className="kokopu-demoCode">{buildComponentDemoCode('Chessboard', attributes)}</pre>;
118
143
  }
119
144
 
@@ -123,6 +148,12 @@ export default class Page extends React.Component {
123
148
  this.setState(newState);
124
149
  }
125
150
 
151
+ setMoveColor(newValue) {
152
+ if (newValue !== null) {
153
+ this.set('moveArrowColor', newValue);
154
+ }
155
+ }
156
+
126
157
  setPosition(newPosition) {
127
158
  let newState = {};
128
159
  newState.position = newPosition;
@@ -33,6 +33,10 @@
33
33
  text-transform: none;
34
34
  }
35
35
 
36
+ .MuiToggleButton-root.Mui-disabled.kokopu-fixOpacity .kokopu-arrowMarkerIcon {
37
+ opacity: 0.3;
38
+ }
39
+
36
40
  .kokopu-fixedPopup {
37
41
  position: fixed;
38
42
  bottom: 20px;
@@ -24,17 +24,17 @@ import React from 'react';
24
24
  import testApp from './common/test_app';
25
25
  import { Chessboard } from '../src/index';
26
26
 
27
- let squareMarkers1 = 'Ga1,Ga2,Rb1,Rb2,Yc1,Yc2';
28
- let arrowMarkers1 = 'Gb8c6,Re8f6,Yf8g6';
29
- let textMarkers1 = 'GAf1,Gaf2,RZg1,Rzg2,Y2h1,Y8h2';
27
+ let squareMarkers1 = 'Ba1,Ba2,Gb1,Gb2,Rc1,Rc2,Yd1,Yd2';
28
+ let arrowMarkers1 = 'Ba8b6,Gb8c6,Re8f6,Yf8g6';
29
+ let textMarkers1 = 'B(circle)e1,B(plus)e2,GAf1,Gaf2,RZg1,Rzg2,Y2h1,Y8h2';
30
30
 
31
- let squareMarkers2 = { e4: 'g', g5: 'r', g1: 'y' };
32
- let arrowMarkers2 = { c3a2: 'y', c4a4: 'g', c5a6: 'r', c6a8: 'y', d6c8: 'g', e6e8: 'r', f6g8: 'y' };
33
- let textMarkers2 = { g3: { symbol: 'H', color: 'r' }, g5: { symbol: 'M', color: 'g' } };
31
+ let squareMarkers2 = { e4: 'g', g5: 'r', g1: 'y', h4: 'b' };
32
+ let arrowMarkers2 = { c3a2: 'b', c4a4: 'g', c5a6: 'r', c6a8: 'y', d6c8: 'b', e6e8: 'g', f6g8: 'r' };
33
+ let textMarkers2 = { g3: { symbol: 'H', color: 'r' }, g5: { symbol: 'M', color: 'g' }, h4: { symbol: 'times', color: 'y' } };
34
34
 
35
- let squareMarkers3 = { b5: 'r', e4: 'g', h5: 'y' };
35
+ let squareMarkers3 = { b5: 'r', e4: 'g', h5: 'y', e2: 'b' };
36
36
  let arrowMarkers3 = { d1h5: 'g', a5f4: 'r', c7c3: 'y', g7g7: 'g' };
37
- let textMarkers3 = 'G5c6,R(plus)a1,G(times)b1,R(dot)a2,Y(circle)b2';
37
+ let textMarkers3 = 'G5c6,R(plus)a1,G(times)b1,B(dot)a2,Y(circle)b2';
38
38
 
39
39
  testApp([ /* eslint-disable react/jsx-key */
40
40
  <Chessboard squareMarkers={squareMarkers1} arrowMarkers={arrowMarkers1} textMarkers={textMarkers1} flipped={false} coordinateVisible={true} />,
@@ -33,9 +33,9 @@ testApp([ /* eslint-disable react/jsx-key */
33
33
  <Chessboard move="Nf3" moveArrowVisible={false} animated={false} />,
34
34
  <Chessboard move="Nf4" animated={false} />,
35
35
  <Chessboard position="rnbqkbnr/pppp1ppp/4p3/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq - 0 2" move="Bb4+" moveArrowVisible={true} flipped={true} animated={false} />,
36
- <Chessboard position={pos} move={move} animated={false} />,
37
- <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={false} />,
38
- <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={false} />,
39
- <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={false} />,
36
+ <Chessboard position={pos} move={move} animated={false} moveArrowColor="g" />,
37
+ <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={false} moveArrowColor="r" />,
38
+ <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={false} moveArrowColor="y" />,
39
+ <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={false} moveArrowColor="b" />,
40
40
  <Chessboard move={42} animated={false} />,
41
41
  ]); /* eslint-enable react/jsx-key */
@@ -30,8 +30,8 @@ let mv1 = 'Ba5';
30
30
  let pos2 = 'start';
31
31
  let mv2 = 'e4';
32
32
 
33
- let sm = 'Ga8,Ga7,Rb8,Rb7,Yc8,Yc7';
34
- let am = 'Gb1b3,Rc1c3,Yd1d3';
33
+ let sm = 'Ba8,Ba7,Gb8,Gb7,Rc8,Rc7,Yd8,Yd7';
34
+ let am = 'Ba1a3,Gb1b3,Rc1c3,Yd1d3';
35
35
 
36
36
  testApp([ /* eslint-disable react/jsx-key */
37
37
  <Chessboard position={pos1} move={mv1} squareMarkers={sm} arrowMarkers={am} animated={false} />,
@@ -31,6 +31,6 @@ function onPieceMoved(from, to) {
31
31
  testApp([ /* eslint-disable react/jsx-key */
32
32
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="movePieces" onPieceMoved={onPieceMoved} />,
33
33
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="movePieces" onPieceMoved={onPieceMoved} flipped
34
- squareMarkers="Gc4" textMarkers="RAh3" arrowMarkers="Gc8a4" />,
34
+ squareMarkers="Gc4" textMarkers="BAh3" arrowMarkers="Gc8a4" moveArrowColor="r" />,
35
35
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="movePieces" onPieceMoved={onPieceMoved} move="e4" animated={false} />,
36
36
  ]); /* eslint-enable react/jsx-key */
@@ -31,7 +31,7 @@ function onMovePlayed(move) {
31
31
  testApp([ /* eslint-disable react/jsx-key */
32
32
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="playMoves" onMovePlayed={onMovePlayed} />,
33
33
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="playMoves" onMovePlayed={onMovePlayed}
34
- flipped position="rnbqk2r/ppp2ppp/3p1n2/2b1p3/4P3/2NP1N2/PPP2PPP/R1BQKB1R w KQkq - 0 1" move="Bg5" animated={false} />,
34
+ flipped position="rnbqk2r/ppp2ppp/3p1n2/2b1p3/4P3/2NP1N2/PPP2PPP/R1BQKB1R w KQkq - 0 1" move="Bg5" animated={false} moveArrowColor="g" />,
35
35
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="playMoves" onMovePlayed={onMovePlayed}
36
36
  position="rnbq1bnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1" />,
37
37
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="playMoves" onMovePlayed={onMovePlayed}
@@ -26,8 +26,6 @@ import { Movetext, i18n } from '../src/index';
26
26
 
27
27
  import pgn from './common/games.pgn';
28
28
 
29
- let legacyPieceSymbols = i18n.PIECE_SYMBOLS;
30
-
31
29
  // Localization for French
32
30
  i18n.PIECE_SYMBOLS = { K: 'R', Q: 'D', R: 'T', B: 'F', N: 'C', P: 'P' };
33
31
 
@@ -38,5 +36,3 @@ testApp([ /* eslint-disable react/jsx-key */
38
36
  diagramOptions={{ flipped: true, coordinateVisible: false, squareSize: 32, colorset: 'scid', pieceset: 'eyes' }} />,
39
37
  <Movetext game={pgn} gameIndex={9} diagramVisible={false} />,
40
38
  ], 'width-600'); /* eslint-enable react/jsx-key */
41
-
42
- i18n.PIECE_SYMBOLS = legacyPieceSymbols;
@@ -85,7 +85,7 @@ probably to assure himself that the combination was sound and that he had a forc
85
85
  [Date "????.??.??"]
86
86
  [Round "<strong>3</strong>.2"]
87
87
  [White "1<sup>st</sup> <em>player</em>"]
88
- [Black "2<sub>nd</sub> <em>player</em>"]
88
+ [Black "2<sub>nd</sub> <i>player</i>"]
89
89
  [Result "*"]
90
90
  [WhiteElo "<ins>2800</ins>"]
91
91
  [BlackElo "<del>1010</del>"]
@@ -104,7 +104,13 @@ probably to assure himself that the combination was sound and that he had a forc
104
104
  [Black "?"]
105
105
  [Result "*"]
106
106
 
107
- {I'm a <strong><ins>comment</ins></strong> with some <em class="myClass">HTML content</em> in it.}
107
+ {I'm a <strong><ins>comment</ins></strong> with some <em class="myClass">HTML content</em> in it.<br/>
108
+ Lists are supported:
109
+ <ul>
110
+ <li>1<sup>st</sup> point</li>
111
+ <li>2<sup>nd</sup> point</li>
112
+ </ul>
113
+ ... and so are images: <img src="../smiley.png" alt="smiley" />}
108
114
 
109
115
  *
110
116
 
@@ -119,9 +125,9 @@ probably to assure himself that the combination was sound and that he had a forc
119
125
  [Result "*"]
120
126
 
121
127
  {
122
- Using <div class="myClass">div tags</div> is not allowed.
123
- ... but <div class="myClass"><em>legit HTML elements</em> within forbidden HTML tags</div> are rendered.
124
- Using <span style="color: cyan;">style attributes</span> is not allowed.
128
+ Using <form class="myClass">form-related tags</form> is not allowed.<br/>
129
+ ... but <button class="myClass"><em>legit HTML elements</em> within forbidden HTML tags</button> are rendered.<br/>
130
+ Using <span style="color: cyan;">style attributes</span> is not allowed.<br/>
125
131
  Using scripts is not allowed. <script>alert('You should not see this either.');</script>
126
132
  }
127
133
 
@@ -21,7 +21,7 @@
21
21
 
22
22
 
23
23
  import React from 'react';
24
- import ReactDOM from 'react-dom';
24
+ import { createRoot } from 'react-dom/client';
25
25
  import './test_app.css';
26
26
 
27
27
 
@@ -45,8 +45,9 @@ export default function(elements, containerClassName) {
45
45
  document.body.appendChild(anchor);
46
46
 
47
47
  // Render the content.
48
+ let root = createRoot(anchor);
48
49
  let content = flattenMultiElements(elements, containerClassName);
49
- ReactDOM.render(content, anchor);
50
+ root.render(content);
50
51
 
51
52
  // Append a text area
52
53
  let sandbox = document.createElement('pre');
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg
4
+ xmlns:svg="http://www.w3.org/2000/svg"
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ version="1.1"
7
+ width="45"
8
+ height="45"
9
+ id="svg3128">
10
+ <defs
11
+ id="defs3130" />
12
+ <g
13
+ style="display:inline"
14
+ id="layer1">
15
+ <path
16
+ d="M 9,36 C 12.385,35.028 19.115,36.431 22.5,34 C 25.885,36.431 32.615,35.028 36,36 C 36,36 37.646,36.542 39,38 C 38.323,38.972 37.354,38.986 36,38.5 C 32.615,37.528 25.885,38.958 22.5,37.5 C 19.115,38.958 12.385,37.528 9,38.5 C 7.6459,38.986 6.6771,38.972 6,38 C 7.3541,36.055 9,36 9,36 z "
17
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
18
+ id="path4582" />
19
+ <path
20
+ d="M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z "
21
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
22
+ id="path4584" />
23
+ <path
24
+ d="M 25 10 A 2.5 2.5 0 1 1 20,10 A 2.5 2.5 0 1 1 25 10 z"
25
+ transform="translate(0,-2)"
26
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
27
+ id="path4586" />
28
+ <path
29
+ d="M 17.5,26 L 27.5,26"
30
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
31
+ id="path4588" />
32
+ <path
33
+ d="M 15,30 L 30,30"
34
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
35
+ id="path4590" />
36
+ <path
37
+ d="M 22.5,15.5 L 22.5,20.5"
38
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
39
+ id="path4592" />
40
+ <path
41
+ d="M 20,18 L 25,18"
42
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
43
+ id="path4594" />
44
+ </g>
45
+ </svg>
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg
4
+ xmlns:svg="http://www.w3.org/2000/svg"
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ version="1.1"
7
+ width="45"
8
+ height="45"
9
+ id="svg3128">
10
+ <defs
11
+ id="defs3130" />
12
+ <g
13
+ id="layer1">
14
+ <path
15
+ d="M 22.5,11.625 L 22.5,6"
16
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
17
+ id="path6570" />
18
+ <path
19
+ d="M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25"
20
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
21
+ id="path5683" />
22
+ <path
23
+ d="M 11.5,37 C 17,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 19,16 9.5,13 6.5,19.5 C 3.5,25.5 11.5,29.5 11.5,29.5 L 11.5,37 z "
24
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
25
+ id="path5681" />
26
+ <path
27
+ d="M 20,8 L 25,8"
28
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
29
+ id="path6572" />
30
+ <path
31
+ d="M 11.5,29.5 C 17,27 27,27 32.5,30"
32
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
33
+ id="path6574" />
34
+ <path
35
+ d="M 11.5,37 C 17,34.5 27,34.5 32.5,37"
36
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
37
+ id="path6576" />
38
+ <path
39
+ d="M 11.5,33.5 C 17,31.5 27,31.5 32.5,33.5"
40
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
41
+ id="path6578" />
42
+ <path
43
+ d="M 32,29.5 C 32,29.5 40.5,25.5 38.026,19.847 C 34.147,13.997 25,18 22.5,24.5 L 22.512,26.597 L 22.5,24.5 C 20,18 9.9064,13.997 6.9975,19.847 C 4.5,25.5 11.846,28.847 11.846,28.847"
44
+ style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
45
+ id="path5638" />
46
+ </g>
47
+ </svg>