kokopu-react 1.8.0 → 1.9.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 (158) hide show
  1. package/dist/lib/ArrowMarkerIcon.js +1 -29
  2. package/dist/lib/Chessboard.js +152 -298
  3. package/dist/lib/ErrorBox.js +7 -24
  4. package/dist/lib/Movetext.js +74 -178
  5. package/dist/lib/SquareMarkerIcon.js +2 -10
  6. package/dist/lib/TextMarkerIcon.js +0 -11
  7. package/dist/lib/css/movetext.css +4 -0
  8. package/dist/lib/formatmove.js +2 -14
  9. package/dist/lib/i18n.js +1 -1
  10. package/dist/lib/impl/ArrowTip.js +2 -8
  11. package/dist/lib/impl/HtmlSanitizer.js +13 -46
  12. package/dist/lib/impl/Motion.js +107 -0
  13. package/dist/lib/impl/TextSymbol.js +2 -11
  14. package/dist/lib/impl/colorsets.js +0 -2
  15. package/dist/lib/impl/piecesets.js +0 -87
  16. package/dist/lib/impl/util.js +1 -11
  17. package/dist/lib/index.js +0 -10
  18. package/dist/lib/markers.js +18 -38
  19. package/graphic_test_src/05_chessboard_move.js +2 -2
  20. package/graphic_test_src/06a_chessboard_animated_move.js +36 -0
  21. package/graphic_test_src/06b_chessboard_animated_move.js +36 -0
  22. package/graphic_test_src/06c_chessboard_animated_move.js +36 -0
  23. package/graphic_test_src/{06_chessboard_theme.js → 07_chessboard_theme.js} +0 -0
  24. package/graphic_test_src/{07_chessboard_click_squares.js → 08_chessboard_click_squares.js} +0 -0
  25. package/graphic_test_src/{08_chessboard_move_pieces.js → 09_chessboard_move_pieces.js} +0 -0
  26. package/graphic_test_src/{09_chessboard_edit_arrows.js → 10_chessboard_edit_arrows.js} +0 -0
  27. package/graphic_test_src/{10_chessboard_play_moves.js → 11_chessboard_play_moves.js} +0 -0
  28. package/graphic_test_src/{11_chessboard_play_promotions.js → 12_chessboard_play_promotions.js} +0 -0
  29. package/graphic_test_src/{12_movetext_simple.js → 13_movetext_simple.js} +0 -0
  30. package/graphic_test_src/{13_movetext_error.js → 14_movetext_error.js} +0 -0
  31. package/graphic_test_src/{14_movetext_html.js → 15_movetext_html.js} +0 -0
  32. package/graphic_test_src/{15_movetext_options.js → 16_movetext_options.js} +0 -0
  33. package/graphic_test_src/{16_movetext_interaction.js → 17_movetext_interaction.js} +0 -0
  34. package/package.json +19 -21
  35. package/scripts/docker-compose.yml +1 -1
  36. package/src/Chessboard.js +24 -20
  37. package/src/css/movetext.css +4 -0
  38. package/src/impl/ArrowTip.js +2 -2
  39. package/src/impl/Motion.js +99 -0
  40. package/test/4_chessboard_graphic.js +4 -1
  41. package/test/5_chessboard_interaction.js +5 -5
  42. package/test/6_chessboard_play_moves.js +4 -4
  43. package/test/7_movetext_graphic.js +4 -4
  44. package/test/8_movetext_interaction.js +2 -2
  45. package/test/common/graphic.js +6 -0
  46. package/test/references/06a_chessboard_animated_move/0.png +0 -0
  47. package/test/references/06a_chessboard_animated_move/1.png +0 -0
  48. package/test/references/06a_chessboard_animated_move/2.png +0 -0
  49. package/test/references/06a_chessboard_animated_move/3.png +0 -0
  50. package/test/references/06a_chessboard_animated_move/4.png +0 -0
  51. package/test/references/06a_chessboard_animated_move/5.png +0 -0
  52. package/test/references/06b_chessboard_animated_move/0.png +0 -0
  53. package/test/references/06b_chessboard_animated_move/1.png +0 -0
  54. package/test/references/06b_chessboard_animated_move/2.png +0 -0
  55. package/test/references/06b_chessboard_animated_move/3.png +0 -0
  56. package/test/references/06b_chessboard_animated_move/4.png +0 -0
  57. package/test/references/06b_chessboard_animated_move/5.png +0 -0
  58. package/test/references/06c_chessboard_animated_move/0.png +0 -0
  59. package/test/references/06c_chessboard_animated_move/1.png +0 -0
  60. package/test/references/06c_chessboard_animated_move/2.png +0 -0
  61. package/test/references/06c_chessboard_animated_move/3.png +0 -0
  62. package/test/references/06c_chessboard_animated_move/4.png +0 -0
  63. package/test/references/06c_chessboard_animated_move/5.png +0 -0
  64. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/0.png +0 -0
  65. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/1.png +0 -0
  66. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/2.png +0 -0
  67. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/3.png +0 -0
  68. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/4.png +0 -0
  69. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/5.png +0 -0
  70. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/6.png +0 -0
  71. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/7.png +0 -0
  72. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/8.png +0 -0
  73. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/after_move.png +0 -0
  74. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/empty_square.png +0 -0
  75. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/null_vector.png +0 -0
  76. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/out_of_board.png +0 -0
  77. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_arrow_marker.png +0 -0
  78. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_empty.png +0 -0
  79. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_non_empty_1.png +0 -0
  80. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_non_empty_2.png +0 -0
  81. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_square_marker.png +0 -0
  82. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_text_marker.png +0 -0
  83. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/base_1.png +0 -0
  84. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/base_2.png +0 -0
  85. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/edit_color_not_set.png +0 -0
  86. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/null_vector.png +0 -0
  87. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/out_of_board.png +0 -0
  88. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/over_arrow_marker.png +0 -0
  89. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/over_square_marker.png +0 -0
  90. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/castling_move.png +0 -0
  91. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_ambiguous_king_move.png +0 -0
  92. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_castling_move_1.png +0 -0
  93. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_castling_move_2.png +0 -0
  94. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_non_kxr_castling.png +0 -0
  95. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/illegal_move.png +0 -0
  96. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/illegal_position.png +0 -0
  97. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/null_vector.png +0 -0
  98. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/out_of_board.png +0 -0
  99. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/regular_move_1.png +0 -0
  100. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/regular_move_2.png +0 -0
  101. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/wrong_color.png +0 -0
  102. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/antichess_promotion.png +0 -0
  103. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/cancel_promotion.png +0 -0
  104. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/regular_promotion_1.png +0 -0
  105. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/regular_promotion_2.png +0 -0
  106. package/test/references/{12_movetext_simple → 13_movetext_simple}/0.png +0 -0
  107. package/test/references/{12_movetext_simple → 13_movetext_simple}/1.png +0 -0
  108. package/test/references/{12_movetext_simple → 13_movetext_simple}/2.png +0 -0
  109. package/test/references/{12_movetext_simple → 13_movetext_simple}/3.png +0 -0
  110. package/test/references/{13_movetext_error → 14_movetext_error}/0.png +0 -0
  111. package/test/references/{13_movetext_error → 14_movetext_error}/1.png +0 -0
  112. package/test/references/{13_movetext_error → 14_movetext_error}/2.png +0 -0
  113. package/test/references/{13_movetext_error → 14_movetext_error}/3.png +0 -0
  114. package/test/references/{13_movetext_error → 14_movetext_error}/4.png +0 -0
  115. package/test/references/{14_movetext_html → 15_movetext_html}/0.png +0 -0
  116. package/test/references/{14_movetext_html → 15_movetext_html}/1.png +0 -0
  117. package/test/references/{14_movetext_html → 15_movetext_html}/2.png +0 -0
  118. package/test/references/{15_movetext_options → 16_movetext_options}/0.png +0 -0
  119. package/test/references/{15_movetext_options → 16_movetext_options}/1.png +0 -0
  120. package/test/references/{15_movetext_options → 16_movetext_options}/2.png +0 -0
  121. package/test/references/{15_movetext_options → 16_movetext_options}/3.png +0 -0
  122. package/test/references/{16_movetext_interaction → 17_movetext_interaction}/0.png +0 -0
  123. package/test/references/{16_movetext_interaction → 17_movetext_interaction}/1.png +0 -0
  124. package/test/references/{16_movetext_interaction → 17_movetext_interaction}/2.png +0 -0
  125. package/CHANGELOG.md +0 -141
  126. package/graphics/chess_sprites/cburnett/bb.svg +0 -45
  127. package/graphics/chess_sprites/cburnett/bk.svg +0 -47
  128. package/graphics/chess_sprites/cburnett/bn.svg +0 -37
  129. package/graphics/chess_sprites/cburnett/bp.svg +0 -19
  130. package/graphics/chess_sprites/cburnett/bq.svg +0 -58
  131. package/graphics/chess_sprites/cburnett/br.svg +0 -60
  132. package/graphics/chess_sprites/cburnett/bx.svg +0 -56
  133. package/graphics/chess_sprites/cburnett/wb.svg +0 -48
  134. package/graphics/chess_sprites/cburnett/wk.svg +0 -26
  135. package/graphics/chess_sprites/cburnett/wn.svg +0 -37
  136. package/graphics/chess_sprites/cburnett/wp.svg +0 -19
  137. package/graphics/chess_sprites/cburnett/wq.svg +0 -60
  138. package/graphics/chess_sprites/cburnett/wr.svg +0 -44
  139. package/graphics/chess_sprites/cburnett/wx.svg +0 -56
  140. package/graphics/chess_sprites/generate_sprites.sh +0 -135
  141. package/graphics/chess_sprites/mmonge/celtic-bx.svg +0 -112
  142. package/graphics/chess_sprites/mmonge/celtic-wx.svg +0 -111
  143. package/graphics/chess_sprites/mmonge/celtic.svg +0 -1576
  144. package/graphics/chess_sprites/mmonge/eyes-spatial-bx.svg +0 -101
  145. package/graphics/chess_sprites/mmonge/eyes-spatial-wx.svg +0 -100
  146. package/graphics/chess_sprites/mmonge/eyes.svg +0 -2538
  147. package/graphics/chess_sprites/mmonge/fantasy-bx.svg +0 -112
  148. package/graphics/chess_sprites/mmonge/fantasy-wx.svg +0 -111
  149. package/graphics/chess_sprites/mmonge/fantasy.svg +0 -5497
  150. package/graphics/chess_sprites/mmonge/fantasy_alt.svg +0 -3742
  151. package/graphics/chess_sprites/mmonge/freak.svg +0 -3479
  152. package/graphics/chess_sprites/mmonge/prmi.svg +0 -6776
  153. package/graphics/chess_sprites/mmonge/skulls-bx.svg +0 -124
  154. package/graphics/chess_sprites/mmonge/skulls-wx.svg +0 -111
  155. package/graphics/chess_sprites/mmonge/skulls.svg +0 -12978
  156. package/graphics/chess_sprites/mmonge/spatial.svg +0 -1223
  157. package/graphics/logo-small.svg +0 -14
  158. package/graphics/logo.svg +0 -26
@@ -1,91 +1,55 @@
1
1
  "use strict";
2
2
 
3
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
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
9
  var _react = _interopRequireDefault(require("react"));
13
-
14
10
  var _kokopu = require("kokopu");
15
-
16
11
  var _HtmlSanitizer = _interopRequireDefault(require("./impl/HtmlSanitizer"));
17
-
18
12
  var _util = require("./impl/util");
19
-
20
13
  var _Chessboard = _interopRequireDefault(require("./Chessboard"));
21
-
22
14
  var _ErrorBox = _interopRequireDefault(require("./ErrorBox"));
23
-
24
15
  var _formatmove = require("./formatmove");
25
-
26
16
  var _i18n = _interopRequireDefault(require("./i18n"));
27
-
28
17
  require("./css/movetext.css");
29
-
30
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
-
32
19
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
-
34
20
  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."); }
35
-
36
21
  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; }
37
-
38
22
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
-
40
23
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
41
-
42
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); }
43
-
44
25
  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; }
45
-
46
26
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
47
-
48
27
  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); } }
49
-
50
28
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
51
-
52
29
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
53
-
54
30
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
55
-
56
31
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
57
-
58
32
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
59
-
60
33
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
61
-
62
34
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
63
-
64
35
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
65
-
66
36
  /**
67
37
  * Display a chess game, i.e. the headers (name of the players, event, etc.), the moves, and all the related annotations if any (comments, variations, NAGs...).
68
38
  */
69
39
  var Movetext = /*#__PURE__*/function (_React$Component) {
70
40
  _inherits(Movetext, _React$Component);
71
-
72
41
  var _super = _createSuper(Movetext);
73
-
74
42
  function Movetext(props) {
75
43
  var _this;
76
-
77
44
  _classCallCheck(this, Movetext);
78
-
79
45
  _this = _super.call(this, props);
80
46
  _this.focusFieldRef = /*#__PURE__*/_react["default"].createRef();
81
47
  return _this;
82
48
  }
83
-
84
49
  _createClass(Movetext, [{
85
50
  key: "render",
86
51
  value: function render() {
87
52
  var info = parseGame(this.props.game, this.props.gameIndex);
88
-
89
53
  if (info.error) {
90
54
  return /*#__PURE__*/_react["default"].createElement(_ErrorBox["default"], {
91
55
  title: _i18n["default"].INVALID_PGN_ERROR_TITLE,
@@ -95,7 +59,6 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
95
59
  lineNumber: info.lineNumber
96
60
  });
97
61
  }
98
-
99
62
  return /*#__PURE__*/_react["default"].createElement("div", {
100
63
  className: "kokopu-movetext"
101
64
  }, this.renderHeaders(info.game), this.renderBody(info.game), this.renderFocusField(info.game));
@@ -106,7 +69,6 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
106
69
  if (!this.props.headerVisible) {
107
70
  return undefined;
108
71
  }
109
-
110
72
  var headers = [];
111
73
  headers.push(this.renderPlayerHeaders(game, 'w'));
112
74
  headers.push(this.renderPlayerHeaders(game, 'b'));
@@ -119,31 +81,26 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
119
81
  className: "kokopu-headers"
120
82
  }, headers) : undefined;
121
83
  }
84
+
122
85
  /**
123
86
  * Header containing the player-related information (name, rating, title) corresponding to the given color.
124
87
  */
125
-
126
88
  }, {
127
89
  key: "renderPlayerHeaders",
128
90
  value: function renderPlayerHeaders(game, color) {
129
91
  var playerName = game.playerName(color);
130
-
131
92
  if (playerName === undefined) {
132
93
  return undefined;
133
94
  }
134
-
135
95
  var title = game.playerTitle(color);
136
96
  var rating = game.playerElo(color);
137
97
  var classNames = ['kokopu-headerGroup-player', color === 'w' ? 'kokopu-headerGroup-whitePlayer' : 'kokopu-headerGroup-blackPlayer'];
138
-
139
98
  var colorTag = /*#__PURE__*/_react["default"].createElement("span", {
140
99
  className: "kokopu-colorTag"
141
100
  });
142
-
143
101
  var playerNameElement = /*#__PURE__*/_react["default"].createElement("span", {
144
102
  className: "kokopu-header-playerName"
145
103
  }, sanitizeHtml(playerName));
146
-
147
104
  var titleElement = title === undefined ? undefined : /*#__PURE__*/_react["default"].createElement("span", {
148
105
  className: "kokopu-header-playerTitle"
149
106
  }, sanitizeHtml(title));
@@ -151,7 +108,6 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
151
108
  className: "kokopu-header-playerRating"
152
109
  }, rating);
153
110
  var separator = title === undefined || rating === undefined ? undefined : "\xA0"; // \u00a0 == &nbsp;
154
-
155
111
  var titleRatingGroup = title === undefined && rating === undefined ? undefined : /*#__PURE__*/_react["default"].createElement("span", {
156
112
  className: "kokopu-headerGroup-titleRating"
157
113
  }, titleElement, separator, ratingElement);
@@ -160,47 +116,41 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
160
116
  key: 'player-' + color
161
117
  }, colorTag, playerNameElement, titleRatingGroup);
162
118
  }
119
+
163
120
  /**
164
121
  * Header containing the event-related information: event + round.
165
122
  */
166
-
167
123
  }, {
168
124
  key: "renderEventRoundHeaders",
169
125
  value: function renderEventRoundHeaders(game) {
170
126
  var evt = game.event();
171
-
172
127
  if (evt === undefined) {
173
128
  return undefined;
174
129
  }
175
-
176
130
  var round = game.round();
177
131
  var roundElement = round === undefined ? undefined : /*#__PURE__*/_react["default"].createElement("span", {
178
132
  className: "kokopu-header-round"
179
133
  }, sanitizeHtml(round));
180
-
181
134
  var evtElement = /*#__PURE__*/_react["default"].createElement("span", {
182
135
  className: "kokopu-header-event"
183
136
  }, sanitizeHtml(evt));
184
-
185
137
  return /*#__PURE__*/_react["default"].createElement("div", {
186
138
  className: "kokopu-headerGroup-eventRound",
187
139
  key: "event-round"
188
140
  }, evtElement, roundElement);
189
141
  }
142
+
190
143
  /**
191
144
  * Header containing the date/place information.
192
145
  */
193
-
194
146
  }, {
195
147
  key: "renderDateSiteHeaders",
196
148
  value: function renderDateSiteHeaders(game) {
197
149
  var date = game.date();
198
150
  var site = game.site();
199
-
200
151
  if (date === undefined && site === undefined) {
201
152
  return undefined;
202
153
  }
203
-
204
154
  var dateElement = date === undefined ? undefined : /*#__PURE__*/_react["default"].createElement("span", {
205
155
  className: "kokopu-header-date"
206
156
  }, capitalizeFirstWord(game.dateAsString()));
@@ -208,25 +158,22 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
208
158
  className: "kokopu-header-site"
209
159
  }, sanitizeHtml(site));
210
160
  var separator = date === undefined || site === undefined ? undefined : "\xA0\u2013\xA0"; // \u00a0 == &nbsp; \u2013 == &ndash;
211
-
212
161
  return /*#__PURE__*/_react["default"].createElement("div", {
213
162
  className: "kokopu-headerGroup-dateSite",
214
163
  key: "date-site"
215
164
  }, dateElement, separator, siteElement);
216
165
  }
166
+
217
167
  /**
218
168
  * Header containing the annotator information.
219
169
  */
220
-
221
170
  }, {
222
171
  key: "renderAnnotatorHeader",
223
172
  value: function renderAnnotatorHeader(game) {
224
173
  var annotator = game.annotator();
225
-
226
174
  if (annotator === undefined) {
227
175
  return undefined;
228
176
  }
229
-
230
177
  annotator = (0, _util.fillPlaceholder)(_i18n["default"].ANNOTATED_BY, annotator);
231
178
  return /*#__PURE__*/_react["default"].createElement("div", {
232
179
  className: "kokopu-header-annotator",
@@ -237,11 +184,9 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
237
184
  key: "renderFocusField",
238
185
  value: function renderFocusField(game) {
239
186
  var _this2 = this;
240
-
241
187
  if (this.props.interactionMode !== 'selectMove') {
242
188
  return undefined;
243
189
  }
244
-
245
190
  return /*#__PURE__*/_react["default"].createElement("div", {
246
191
  className: "kokopu-focusFieldContainer"
247
192
  }, /*#__PURE__*/_react["default"].createElement("a", {
@@ -259,50 +204,47 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
259
204
  var notationTextBuilder = (0, _formatmove.moveFormatter)(this.props.pieceSymbols);
260
205
  return this.renderVariation(notationTextBuilder, game.mainVariation(), 'main-variation', true, game.result());
261
206
  }
207
+
262
208
  /**
263
209
  * Render the given variation and its sub-variations, recursively.
264
210
  */
265
-
266
211
  }, {
267
212
  key: "renderVariation",
268
213
  value: function renderVariation(notationTextBuilder, variation, variationKey, isMainVariation, gameResult) {
269
214
  var moveGroups = []; // ... and also long comments and long sub-variations
215
+ var currentMoveGroupElements = [];
270
216
 
271
- var currentMoveGroupElements = []; // Close the current move group, if any.
272
-
217
+ // Close the current move group, if any.
273
218
  function closeMoveGroup() {
274
219
  if (!variation.isLongVariation() || currentMoveGroupElements.length === 0) {
275
220
  return;
276
221
  }
277
-
278
222
  moveGroups.push( /*#__PURE__*/_react["default"].createElement("div", {
279
223
  className: "kokopu-moveGroup",
280
224
  key: 'group-' + moveGroups.length
281
225
  }, currentMoveGroupElements));
282
226
  currentMoveGroupElements = [];
283
- } // Write the initial comment, if any.
284
-
227
+ }
285
228
 
229
+ // Write the initial comment, if any.
286
230
  var variationComment = this.extractComment(variation);
287
-
288
231
  if (variationComment !== undefined) {
289
232
  if (variation.isLongComment()) {
290
233
  moveGroups.push(this.renderComment(variation, variationComment, true));
291
234
  } else {
292
235
  currentMoveGroupElements.push(this.renderComment(variation, variationComment, true));
293
236
  }
294
- } // Visit all the PGN nodes (one node per move) within the variation.
295
-
237
+ }
296
238
 
239
+ // Visit all the PGN nodes (one node per move) within the variation.
297
240
  var forcePrintMoveNumber = true;
298
241
  var node = variation.first();
299
-
300
242
  while (node !== undefined) {
301
243
  // Write the move, including directly related information (i.e. move number + NAGs).
302
- currentMoveGroupElements.push(this.renderMove(notationTextBuilder, node, forcePrintMoveNumber)); // Write the comment (if any).
244
+ currentMoveGroupElements.push(this.renderMove(notationTextBuilder, node, forcePrintMoveNumber));
303
245
 
246
+ // Write the comment (if any).
304
247
  var nodeComment = this.extractComment(node);
305
-
306
248
  if (nodeComment !== undefined) {
307
249
  if (node.isLongComment()) {
308
250
  closeMoveGroup();
@@ -310,22 +252,18 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
310
252
  } else {
311
253
  currentMoveGroupElements.push(this.renderComment(node, nodeComment, false));
312
254
  }
313
- } // Write the sub-variations.
314
-
255
+ }
315
256
 
257
+ // Write the sub-variations.
316
258
  var hasNonEmptySubVariations = false;
317
-
318
259
  var _iterator = _createForOfIteratorHelper(node.variations().entries()),
319
- _step;
320
-
260
+ _step;
321
261
  try {
322
262
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
323
263
  var _step$value = _slicedToArray(_step.value, 2),
324
- index = _step$value[0],
325
- subVariation = _step$value[1];
326
-
264
+ index = _step$value[0],
265
+ subVariation = _step$value[1];
327
266
  var subVariationElement = this.renderVariation(notationTextBuilder, subVariation, node.fullMoveNumber() + node.moveColor() + '-variation-' + index, false);
328
-
329
267
  if (subVariationElement) {
330
268
  if (subVariation.isLongVariation()) {
331
269
  closeMoveGroup();
@@ -333,37 +271,34 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
333
271
  } else {
334
272
  currentMoveGroupElements.push(subVariationElement);
335
273
  }
336
-
337
274
  hasNonEmptySubVariations = true;
338
275
  }
339
- } // Back to the current variation, go to the next move.
276
+ }
340
277
 
278
+ // Back to the current variation, go to the next move.
341
279
  } catch (err) {
342
280
  _iterator.e(err);
343
281
  } finally {
344
282
  _iterator.f();
345
283
  }
346
-
347
284
  forcePrintMoveNumber = nodeComment !== undefined || hasNonEmptySubVariations;
348
285
  node = node.next();
349
- } // Append the game result at the end of the main variation.
350
-
286
+ }
351
287
 
288
+ // Append the game result at the end of the main variation.
352
289
  if (isMainVariation && gameResult !== '*') {
353
290
  currentMoveGroupElements.push( /*#__PURE__*/_react["default"].createElement("span", {
354
291
  className: "kokopu-gameResult",
355
292
  key: "gameResult"
356
293
  }, formatResult(gameResult)));
357
- } // Close the last move group, and return the result.
358
-
294
+ }
359
295
 
296
+ // Close the last move group, and return the result.
360
297
  closeMoveGroup();
361
298
  var elements = variation.isLongVariation() ? moveGroups : currentMoveGroupElements;
362
-
363
299
  if (elements.length === 0) {
364
300
  return undefined;
365
301
  }
366
-
367
302
  if (isMainVariation) {
368
303
  return /*#__PURE__*/_react["default"].createElement("div", {
369
304
  className: "kokopu-variation kokopu-mainVariation",
@@ -381,51 +316,47 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
381
316
  }, elements);
382
317
  }
383
318
  }
319
+
384
320
  /**
385
321
  * Render the given move, move number, and NAG (if any).
386
322
  */
387
-
388
323
  }, {
389
324
  key: "renderMove",
390
325
  value: function renderMove(notationTextBuilder, node, forcePrintMoveNumber) {
391
326
  var _this3 = this;
392
-
393
327
  // Move number
394
328
  var moveNumber = undefined;
395
-
396
329
  if (forcePrintMoveNumber || node.moveColor() === 'w') {
397
330
  var moveNumberText = node.fullMoveNumber() + (node.moveColor() === 'w' ? '.' : "\u2026");
398
331
  moveNumber = /*#__PURE__*/_react["default"].createElement("span", {
399
332
  className: "kokopu-moveNumber"
400
333
  }, moveNumberText);
401
- } // SAN notation.
402
-
334
+ }
403
335
 
404
- var notationText = notationTextBuilder(node.notation()); // NAGs
336
+ // SAN notation.
337
+ var notationText = notationTextBuilder(node.notation());
405
338
 
339
+ // NAGs
406
340
  var nagElements = node.nags().map(function (nag) {
407
341
  return /*#__PURE__*/_react["default"].createElement("span", {
408
342
  className: "kokopu-nag",
409
343
  key: nag
410
344
  }, (0, _kokopu.nagSymbol)(nag));
411
- }); // Class
345
+ });
412
346
 
347
+ // Class
413
348
  var nodeId = node.id();
414
349
  var moveClassNames = ['kokopu-move'];
415
350
  var onClick = undefined;
416
-
417
351
  if (this.props.selection && this.props.selection === nodeId) {
418
352
  moveClassNames.push('kokopu-selectedMove');
419
353
  }
420
-
421
354
  if (this.props.interactionMode === 'selectMove') {
422
355
  moveClassNames.push('kokopu-clickableMove');
423
-
424
356
  onClick = function onClick() {
425
357
  return _this3.handleNodeClicked(nodeId);
426
358
  };
427
359
  }
428
-
429
360
  return /*#__PURE__*/_react["default"].createElement("span", {
430
361
  className: moveClassNames.join(' '),
431
362
  key: node.fullMoveNumber() + node.moveColor()
@@ -436,32 +367,27 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
436
367
  className: "kokopu-moveNotation"
437
368
  }, notationText), nagElements.length === 0 ? undefined : nagElements));
438
369
  }
370
+
439
371
  /**
440
372
  * Render the given text comment with its diagrams, if any.
441
373
  */
442
-
443
374
  }, {
444
375
  key: "renderComment",
445
376
  value: function renderComment(node, comment, isVariation) {
446
377
  var content;
447
378
  var sanitizer = createSanitizer(true);
448
-
449
379
  if (this.props.diagramVisible && comment.includes('[#]')) {
450
380
  content = [];
451
381
  var isFirstPart = true;
452
-
453
382
  var _iterator2 = _createForOfIteratorHelper(comment.split('[#]').entries()),
454
- _step2;
455
-
383
+ _step2;
456
384
  try {
457
385
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
458
386
  var _step2$value = _slicedToArray(_step2.value, 2),
459
- index = _step2$value[0],
460
- part = _step2$value[1];
461
-
387
+ index = _step2$value[0],
388
+ part = _step2$value[1];
462
389
  if (!isFirstPart) {
463
390
  var position = isVariation ? node.initialPosition() : node.position();
464
-
465
391
  var diagram = /*#__PURE__*/_react["default"].createElement(_Chessboard["default"], {
466
392
  position: position,
467
393
  squareMarkers: node.tag('csl'),
@@ -474,16 +400,13 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
474
400
  colorset: this.props.diagramOptions.colorset,
475
401
  pieceset: this.props.diagramOptions.pieceset
476
402
  });
477
-
478
403
  content.push( /*#__PURE__*/_react["default"].createElement("div", {
479
404
  className: "kokopu-diagram",
480
405
  key: 'diagram-' + index
481
406
  }, diagram));
482
407
  }
483
-
484
408
  isFirstPart = false;
485
409
  part = part.trim();
486
-
487
410
  if (part.length !== 0) {
488
411
  content.push(sanitizeHtml(part, sanitizer));
489
412
  }
@@ -496,7 +419,6 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
496
419
  } else {
497
420
  content = sanitizeHtml(comment, sanitizer);
498
421
  }
499
-
500
422
  var key = isVariation ? 'initial-comment' : node.fullMoveNumber() + node.moveColor() + '-comment';
501
423
  return node.isLongComment() ? /*#__PURE__*/_react["default"].createElement("div", {
502
424
  className: "kokopu-comment",
@@ -510,17 +432,15 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
510
432
  key: "extractComment",
511
433
  value: function extractComment(node) {
512
434
  var comment = node.comment();
513
-
514
435
  if (comment) {
515
436
  // Remove the diagrams if necessary.
516
437
  if (!this.props.diagramVisible) {
517
438
  comment = comment.replace(/\[#\]/g, ' ');
518
- } // Trim and sanitize the space characters.
519
-
439
+ }
520
440
 
441
+ // Trim and sanitize the space characters.
521
442
  comment = comment.replace(/\s+/g, ' ').trim();
522
443
  }
523
-
524
444
  return comment ? comment : undefined;
525
445
  }
526
446
  }, {
@@ -529,16 +449,12 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
529
449
  if (evt.key !== 'Home' && evt.key !== 'ArrowLeft' && evt.key !== 'ArrowRight' && evt.key !== 'End') {
530
450
  return;
531
451
  }
532
-
533
452
  evt.preventDefault();
534
-
535
453
  if (!this.props.selection) {
536
454
  return;
537
455
  }
538
-
539
456
  var nodeId = undefined;
540
457
  var evtOrigin = '';
541
-
542
458
  if (evt.key === 'Home') {
543
459
  nodeId = Movetext.firstNodeId(game, this.props.selection);
544
460
  evtOrigin = 'key-first';
@@ -553,7 +469,6 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
553
469
  nodeId = Movetext.lastNodeId(game, this.props.selection);
554
470
  evtOrigin = 'key-last';
555
471
  }
556
-
557
472
  if (nodeId && this.props.onMoveSelected) {
558
473
  this.props.onMoveSelected(nodeId, evtOrigin);
559
474
  }
@@ -562,22 +477,22 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
562
477
  key: "handleNodeClicked",
563
478
  value: function handleNodeClicked(nodeId) {
564
479
  this.focus();
565
-
566
480
  if (this.props.onMoveSelected) {
567
481
  this.props.onMoveSelected(nodeId === this.props.selection ? undefined : nodeId, 'click');
568
482
  }
569
483
  }
484
+
570
485
  /**
571
486
  * Set the focus to the current component.
572
487
  *
573
488
  * @public
574
489
  */
575
-
576
490
  }, {
577
491
  key: "focus",
578
492
  value: function focus() {
579
493
  this.focusFieldRef.current.focus();
580
494
  }
495
+
581
496
  /**
582
497
  * Return the ID of the main variation in the given chess game.
583
498
  * If the given selection corresponds already at the main variation, `undefined` is returned.
@@ -589,16 +504,15 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
589
504
  * @returns {string?}
590
505
  * @public
591
506
  */
592
-
593
507
  }], [{
594
508
  key: "firstNodeId",
595
509
  value: function firstNodeId(game, selection) {
596
510
  if (!game.findById(selection)) {
597
511
  return undefined;
598
512
  }
599
-
600
513
  return selection === 'start' ? undefined : 'start';
601
514
  }
515
+
602
516
  /**
603
517
  * Return the ID of the node immediately preceding the given selection in the given chess game.
604
518
  * If no such node exists, `undefined` is returned.
@@ -610,16 +524,13 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
610
524
  * @returns {string?}
611
525
  * @public
612
526
  */
613
-
614
527
  }, {
615
528
  key: "previousNodeId",
616
529
  value: function previousNodeId(game, selection) {
617
530
  var currentNode = game.findById(selection);
618
-
619
531
  if (!currentNode) {
620
532
  return undefined;
621
533
  }
622
-
623
534
  if (selection === 'start') {
624
535
  return undefined;
625
536
  } else if (selection.endsWith('start')) {
@@ -628,16 +539,14 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
628
539
 
629
540
  while (currentNode) {
630
541
  var previousNode = currentNode.previous();
631
-
632
542
  if (previousNode) {
633
543
  return previousNode.id();
634
544
  }
635
-
636
545
  currentNode = currentNode.parentVariation().parentNode();
637
546
  }
638
-
639
547
  return 'start';
640
548
  }
549
+
641
550
  /**
642
551
  * Return the ID of the node immediately following the given selection in the given chess game.
643
552
  * If no such node exists, `undefined` is returned.
@@ -649,19 +558,17 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
649
558
  * @returns {string?}
650
559
  * @public
651
560
  */
652
-
653
561
  }, {
654
562
  key: "nextNodeId",
655
563
  value: function nextNodeId(game, selection) {
656
564
  var currentNode = game.findById(selection);
657
-
658
565
  if (!currentNode) {
659
566
  return undefined;
660
567
  }
661
-
662
568
  var nextNode = selection.endsWith('start') ? currentNode.first() : currentNode.next();
663
569
  return nextNode ? nextNode.id() : undefined;
664
570
  }
571
+
665
572
  /**
666
573
  * Return the ID of the node at then end of the variation in which lies the given selection in the given chess game.
667
574
  * If the selection is already at the end its variation, `undefined` is returned.
@@ -673,38 +580,29 @@ var Movetext = /*#__PURE__*/function (_React$Component) {
673
580
  * @returns {string?}
674
581
  * @public
675
582
  */
676
-
677
583
  }, {
678
584
  key: "lastNodeId",
679
585
  value: function lastNodeId(game, selection) {
680
586
  var currentNode = game.findById(selection);
681
-
682
587
  if (!currentNode) {
683
588
  return undefined;
684
589
  }
685
-
686
590
  currentNode = selection.endsWith('start') ? currentNode.first() : currentNode.next();
687
-
688
591
  if (!currentNode) {
689
592
  // Ensure that the input node is not already the last one.
690
593
  return undefined;
691
594
  }
692
-
693
595
  while (true) {
694
596
  var nextNode = currentNode.next();
695
-
696
597
  if (!nextNode) {
697
598
  return currentNode.id();
698
599
  }
699
-
700
600
  currentNode = nextNode;
701
601
  }
702
602
  }
703
603
  }]);
704
-
705
604
  return Movetext;
706
605
  }(_react["default"].Component);
707
-
708
606
  exports["default"] = Movetext;
709
607
  Movetext.propTypes = {
710
608
  /**
@@ -713,14 +611,12 @@ Movetext.propTypes = {
713
611
  * or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation).
714
612
  */
715
613
  game: _propTypes["default"].oneOfType([_propTypes["default"].instanceOf(_kokopu.Game), _propTypes["default"].instanceOf(_kokopu.Database), _propTypes["default"].string]),
716
-
717
614
  /**
718
615
  * Index of the game to display (only if attribute `game` is a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html)
719
616
  * or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation)): `0` for the first game of the database/PGN, `1` for the second one, etc.
720
617
  * If omitted, the first game of the database/PGN is displayed.
721
618
  */
722
619
  gameIndex: _propTypes["default"].number,
723
-
724
620
  /**
725
621
  * Options applicable to the diagrams in the comments. See [Chessboard](#/Components/Chessboard) for more details about each option.
726
622
  */
@@ -732,7 +628,6 @@ Movetext.propTypes = {
732
628
  colorset: _Chessboard["default"].propTypes.colorset,
733
629
  pieceset: _Chessboard["default"].propTypes.pieceset
734
630
  }),
735
-
736
631
  /**
737
632
  * Symbols to use for the chess pieces. Can be:
738
633
  * - `'native'`: use the first letter of the piece names (in English),
@@ -748,30 +643,25 @@ Movetext.propTypes = {
748
643
  N: _propTypes["default"].string.isRequired,
749
644
  P: _propTypes["default"].string.isRequired
750
645
  })]),
751
-
752
646
  /**
753
647
  * Whether the diagrams within the comments (if any) are displayed or not.
754
648
  */
755
649
  diagramVisible: _propTypes["default"].bool,
756
-
757
650
  /**
758
651
  * Whether the game headers (if any) are displayed or not.
759
652
  */
760
653
  headerVisible: _propTypes["default"].bool,
761
-
762
654
  /**
763
655
  * ID of the selected move (or `'start'` for the beginning of the main variation).
764
656
  * Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id) to get the ID of a game move.
765
657
  */
766
658
  selection: _propTypes["default"].string,
767
-
768
659
  /**
769
660
  * Type of action allowed with the mouse/keys on the component. If undefined, then the user cannot interact with the component.
770
661
  *
771
662
  * - `'selectMove'` allows the user to select a move.
772
663
  */
773
664
  interactionMode: _propTypes["default"].oneOf(['selectMove']),
774
-
775
665
  /**
776
666
  * Callback invoked when the user selects a move (only if `interactionMode` is set to `'selectMove'`).
777
667
  *
@@ -794,76 +684,83 @@ Movetext.defaultProps = {
794
684
  diagramVisible: true,
795
685
  headerVisible: true
796
686
  };
687
+
797
688
  /**
798
689
  * Example: `'hello world'` is turned into `'Hello world'`.
799
690
  */
800
-
801
691
  function capitalizeFirstWord(text) {
802
692
  return text.length === 0 ? '' : text.charAt(0).toUpperCase() + text.slice(1);
803
693
  }
804
-
805
694
  function formatResult(result) {
806
695
  switch (result) {
807
696
  case '1/2-1/2':
808
697
  return "\xBD\u2013\xBD";
809
-
810
698
  case '1-0':
811
699
  return "1\u20130";
812
-
813
700
  case '0-1':
814
701
  return "0\u20131";
815
702
  }
816
703
  }
817
-
818
704
  function createSanitizer(withBlockTags) {
819
- var allowedTags = ['span', // general purpose
820
- 'a', // links
821
- 'b', 'strong', 'i', 'em', // bold, italic
822
- 'del', 'ins', 's', 'u', // underline, strikethrough
823
- 'sub', 'sup', // subscript, superscript
824
- 'abbr', // acronym (typically associated to a title=".." tooltip)
825
- 'q', 'cite', // quotation and title of a work
826
- 'mark', // highlighted text
705
+ var allowedTags = ['span',
706
+ // general purpose
707
+ 'a',
708
+ // links
709
+ 'b', 'strong', 'i', 'em',
710
+ // bold, italic
711
+ 'del', 'ins', 's', 'u',
712
+ // underline, strikethrough
713
+ 'sub', 'sup',
714
+ // subscript, superscript
715
+ 'abbr',
716
+ // acronym (typically associated to a title=".." tooltip)
717
+ 'q', 'cite',
718
+ // quotation and title of a work
719
+ 'mark',
720
+ // highlighted text
827
721
  'small' // smaller text
828
722
  ];
723
+
829
724
  var allowedAttributes = {
830
725
  '*': ['class', 'id', 'title'],
831
726
  'a': ['href', 'target']
832
727
  };
833
-
834
728
  if (withBlockTags) {
835
- allowedTags = allowedTags.concat(['div', // general purpose
836
- 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', // headings
837
- 'p', 'br', // paragraph and line break
838
- 'blockquote', // long quotation
839
- 'img', // image
840
- 'pre', // preformatted text
729
+ allowedTags = allowedTags.concat(['div',
730
+ // general purpose
731
+ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
732
+ // headings
733
+ 'p', 'br',
734
+ // paragraph and line break
735
+ 'blockquote',
736
+ // long quotation
737
+ 'img',
738
+ // image
739
+ 'pre',
740
+ // preformatted text
841
741
  'ul', 'ol', 'li' // lists
842
742
  ]);
743
+
843
744
  Object.assign(allowedAttributes, {
844
745
  'img': ['alt', 'src', 'height', 'width']
845
746
  });
846
747
  }
847
-
848
748
  return new _HtmlSanitizer["default"]({
849
749
  allowedTags: allowedTags,
850
750
  allowedAttributes: allowedAttributes
851
751
  });
852
752
  }
853
-
854
753
  function sanitizeHtml(text, sanitizer) {
855
754
  if (!sanitizer) {
856
755
  sanitizer = createSanitizer(false);
857
756
  }
858
-
859
757
  var result = sanitizer.parse(text);
860
758
  return result !== null && result !== void 0 ? result : text;
861
759
  }
760
+
862
761
  /**
863
762
  * Try to interpret the given object as a chess game.
864
763
  */
865
-
866
-
867
764
  function parseGame(game, gameIndex) {
868
765
  if (game instanceof _kokopu.Game) {
869
766
  return {
@@ -877,7 +774,6 @@ function parseGame(game, gameIndex) {
877
774
  message: _i18n["default"].INVALID_GAME_INDEX_ATTRIBUTE_ERROR_MESSAGE
878
775
  };
879
776
  }
880
-
881
777
  try {
882
778
  var result = game instanceof _kokopu.Database ? game.game(gameIndex) : (0, _kokopu.pgnRead)(game, gameIndex);
883
779
  return {