kokopu-react 3.0.2 → 3.2.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/.eslintrc.yml +1 -1
- package/CHANGELOG.md +13 -1
- package/dist/lib/chessboard/BoardProperties.d.ts +91 -0
- package/dist/lib/chessboard/BoardProperties.js +43 -0
- package/dist/lib/chessboard/BoardProperties.js.map +1 -0
- package/dist/lib/chessboard/Chessboard.css +13 -13
- package/dist/lib/chessboard/Chessboard.d.ts +14 -58
- package/dist/lib/chessboard/Chessboard.js +26 -92
- package/dist/lib/chessboard/Chessboard.js.map +1 -1
- package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
- package/dist/lib/chessboard/Draggable.js.map +1 -1
- package/dist/lib/chessboard/Motion.js.map +1 -1
- package/dist/lib/chessboard/colorsets.js.map +1 -1
- package/dist/lib/chessboard/piecesets.js.map +1 -1
- package/dist/lib/errorbox/ErrorBox.css +18 -18
- package/dist/lib/errorbox/ErrorBox.js.map +1 -1
- package/dist/lib/errorbox/parsing.d.ts +57 -0
- package/dist/lib/errorbox/parsing.js +140 -0
- package/dist/lib/errorbox/parsing.js.map +1 -0
- package/dist/lib/exception.js.map +1 -1
- package/dist/lib/i18n.d.ts +6 -0
- package/dist/lib/i18n.js +7 -0
- package/dist/lib/i18n.js.map +1 -1
- package/dist/lib/icons/AnnotationSymbolShape.css +6 -6
- package/dist/lib/icons/AnnotationSymbolShape.js.map +1 -1
- package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
- package/dist/lib/icons/ArrowTip.js.map +1 -1
- package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
- package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
- package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
- package/dist/lib/icons/arrow.css +1 -1
- package/dist/lib/index.d.ts +5 -1
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/movetext/Movetext.css +27 -40
- package/dist/lib/movetext/Movetext.d.ts +9 -43
- package/dist/lib/movetext/Movetext.js +15 -67
- package/dist/lib/movetext/Movetext.js.map +1 -1
- package/dist/lib/movetext/MovetextImpl.d.ts +7 -28
- package/dist/lib/movetext/MovetextImpl.js +15 -94
- package/dist/lib/movetext/MovetextImpl.js.map +1 -1
- package/dist/lib/movetext/fonts.css +7 -7
- package/dist/lib/movetext/htmlFilter.js.map +1 -1
- package/dist/lib/movetext/moveFormatter.js.map +1 -1
- package/dist/lib/navigationboard/NavigationBoard.d.ts +156 -0
- package/dist/lib/navigationboard/NavigationBoard.js +195 -0
- package/dist/lib/navigationboard/NavigationBoard.js.map +1 -0
- package/dist/lib/navigationboard/NavigationButton.d.ts +54 -0
- package/dist/lib/navigationboard/NavigationButton.js +35 -0
- package/dist/lib/navigationboard/NavigationButton.js.map +1 -0
- package/dist/lib/navigationboard/NavigationField.css +36 -0
- package/dist/lib/navigationboard/NavigationField.d.ts +81 -0
- package/dist/lib/navigationboard/NavigationField.js +154 -0
- package/dist/lib/navigationboard/NavigationField.js.map +1 -0
- package/dist/lib/navigationboard/NavigationToolbar.css +54 -0
- package/dist/lib/navigationboard/NavigationToolbar.d.ts +34 -0
- package/dist/lib/navigationboard/NavigationToolbar.js +73 -0
- package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -0
- package/dist/lib/navigationboard/iconPaths.d.ts +29 -0
- package/dist/lib/navigationboard/iconPaths.js +91 -0
- package/dist/lib/navigationboard/iconPaths.js.map +1 -0
- package/dist/lib/sanitization.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/util.js.map +1 -1
- package/doc_src/demo/PageChessboardBase.tsx +115 -115
- package/doc_src/demo/PageChessboardInteraction.tsx +303 -303
- package/doc_src/demo/PageChessboardMove.tsx +173 -156
- package/doc_src/demo/PageChessboardSmallScreens.tsx +94 -94
- package/doc_src/demo/PageMovetextBase.tsx +180 -180
- package/doc_src/demo/PageMovetextInteraction.tsx +123 -123
- package/doc_src/demo/PageNavigationBoardBase.tsx +201 -0
- package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +114 -0
- package/doc_src/demo/decs.d.ts +4 -4
- package/doc_src/demo/demo.css +12 -12
- package/doc_src/demo/game-3.pgn +10 -0
- package/doc_src/demo/util.ts +1 -1
- package/doc_src/examples/Movetext.md +1 -1
- package/doc_src/examples/NavigationBoard.md +15 -0
- package/doc_src/theming/LogoRenderer.js +13 -13
- package/doc_src/theming/theming.css +5 -5
- package/package.json +95 -95
- package/scripts/doc.styleguide.config.js +133 -123
- package/scripts/doc.tsconfig.json +5 -5
- package/scripts/docker-compose.yml +1 -1
- package/scripts/test-graphic.tsconfig.json +5 -5
- package/scripts/test-graphic.webpack.config.js +57 -57
- package/scripts/test-headless.webpack.config.js +29 -29
- package/src/chessboard/BoardProperties.ts +131 -0
- package/src/chessboard/Chessboard.css +13 -13
- package/src/chessboard/Chessboard.tsx +389 -518
- package/src/chessboard/ChessboardImpl.tsx +557 -557
- package/src/chessboard/Draggable.tsx +185 -185
- package/src/chessboard/Motion.tsx +67 -67
- package/src/chessboard/colorsets.ts +66 -66
- package/src/chessboard/piecesets.ts +84 -84
- package/src/decs.d.ts +2 -2
- package/src/errorbox/ErrorBox.css +18 -18
- package/src/errorbox/ErrorBox.tsx +75 -75
- package/src/errorbox/parsing.tsx +158 -0
- package/src/exception.ts +17 -17
- package/src/i18n.ts +8 -0
- package/src/icons/AnnotationSymbolShape.css +6 -6
- package/src/icons/AnnotationSymbolShape.tsx +31 -31
- package/src/icons/ArrowMarkerIcon.tsx +34 -34
- package/src/icons/ArrowTip.tsx +14 -14
- package/src/icons/ChessPieceIcon.tsx +45 -45
- package/src/icons/SquareMarkerIcon.tsx +20 -20
- package/src/icons/TextMarkerIcon.tsx +29 -29
- package/src/icons/arrow.css +1 -1
- package/src/index.ts +8 -3
- package/src/movetext/Movetext.css +27 -40
- package/src/movetext/Movetext.tsx +163 -228
- package/src/movetext/MovetextImpl.tsx +351 -438
- package/src/movetext/fonts.css +7 -7
- package/src/movetext/htmlFilter.tsx +129 -129
- package/src/movetext/moveFormatter.tsx +37 -37
- package/src/navigationboard/NavigationBoard.tsx +350 -0
- package/src/navigationboard/NavigationButton.ts +72 -0
- package/src/navigationboard/NavigationField.css +36 -0
- package/src/navigationboard/NavigationField.tsx +185 -0
- package/src/navigationboard/NavigationToolbar.css +54 -0
- package/src/navigationboard/NavigationToolbar.tsx +117 -0
- package/src/navigationboard/iconPaths.ts +98 -0
- package/src/sanitization.ts +17 -17
- package/src/types.ts +116 -116
- package/src/util.ts +11 -11
- package/test/01_types.js +167 -167
- package/test/02_chessboard_util.js +114 -114
- package/test/03_error_box_graphic.js +16 -16
- package/test/04_icons_graphic.js +32 -32
- package/test/05_chessboard_graphic.js +60 -58
- package/test/06_chessboard_animation.js +36 -36
- package/test/07_chessboard_interaction.js +101 -101
- package/test/08_chessboard_play_moves.js +62 -62
- package/test/09_chessboard_small_screens.js +42 -21
- package/test/10_movetext_graphic.js +36 -31
- package/test/11_movetext_interaction.js +100 -96
- package/test/12_navigation_board_base.js +151 -0
- package/test/13_navigation_board_graphic.js +68 -0
- package/test/14_navigation_board_autoplay.js +100 -0
- package/test/common/graphic.js +106 -97
- package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_bottom_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_top_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_bottom_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_top_component.png +0 -0
- package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_piece_symbol_value.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/invalid_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/overriding_initial_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_end.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default_with_game_index.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_on_null-move.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_4.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_4.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_5.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/single_button.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/error/pgn_parsing_error.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/error/wrong_game_type.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/custom_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/custom_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/large.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_reaching_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/already_at_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_at_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_test_app/03_error_box_graphic/base.tsx +14 -14
- package/test/graphic_test_app/03_error_box_graphic/localization.tsx +1 -1
- package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +7 -7
- package/test/graphic_test_app/04_icons_graphic/marker.tsx +15 -15
- package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -7
- package/test/graphic_test_app/05_chessboard_graphic/base.tsx +6 -6
- package/test/graphic_test_app/05_chessboard_graphic/chess_variants.tsx +7 -7
- package/test/graphic_test_app/05_chessboard_graphic/flipped.tsx +5 -5
- package/test/graphic_test_app/05_chessboard_graphic/move.tsx +12 -10
- package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +12 -12
- package/test/graphic_test_app/06_chessboard_animation/base_1.tsx +6 -6
- package/test/graphic_test_app/06_chessboard_animation/base_2.tsx +6 -6
- package/test/graphic_test_app/06_chessboard_animation/base_3.tsx +6 -6
- package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +16 -16
- package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +5 -5
- package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -4
- package/test/graphic_test_app/07_chessboard_interaction/error.tsx +2 -2
- package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +5 -5
- package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +8 -8
- package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +4 -4
- package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +9 -9
- package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +48 -0
- package/test/graphic_test_app/10_movetext_graphic/base.tsx +4 -4
- package/test/graphic_test_app/10_movetext_graphic/error.tsx +6 -6
- package/test/graphic_test_app/10_movetext_graphic/format_move.tsx +31 -0
- package/test/graphic_test_app/10_movetext_graphic/html.tsx +5 -5
- package/test/graphic_test_app/10_movetext_graphic/options.tsx +10 -9
- package/test/graphic_test_app/11_movetext_interaction/error.tsx +1 -1
- package/test/graphic_test_app/11_movetext_interaction/select_moves.tsx +11 -10
- package/test/graphic_test_app/12_navigation_board_base/controlled.tsx +43 -0
- package/test/graphic_test_app/12_navigation_board_base/uncontrolled.tsx +56 -0
- package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +49 -0
- package/test/graphic_test_app/13_navigation_board_graphic/error.tsx +34 -0
- package/test/graphic_test_app/13_navigation_board_graphic/theme.tsx +38 -0
- package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +73 -0
- package/test/graphic_test_app/14_navigation_board_autoplay/uncontrolled.tsx +34 -0
- package/test/graphic_test_app/common/decs.d.ts +2 -2
- package/test/graphic_test_app/common/test_app.css +15 -15
- package/test/graphic_test_app/common/test_app.tsx +48 -48
- package/tsconfig.json +13 -13
package/dist/lib/index.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ export { SquareMarkerIcon, SquareMarkerIconProps } from './icons/SquareMarkerIco
|
|
|
28
28
|
export { TextMarkerIcon, TextMarkerIconProps } from './icons/TextMarkerIcon';
|
|
29
29
|
export { ArrowMarkerIcon, ArrowMarkerIconProps } from './icons/ArrowMarkerIcon';
|
|
30
30
|
export { ChessPieceIcon, ChessPieceIconProps } from './icons/ChessPieceIcon';
|
|
31
|
-
export {
|
|
31
|
+
export { SmallScreenLimit } from './chessboard/BoardProperties';
|
|
32
|
+
export { Chessboard, ChessboardProps } from './chessboard/Chessboard';
|
|
32
33
|
export { formatMove, moveFormatter } from './movetext/moveFormatter';
|
|
33
34
|
export { Movetext, MovetextProps, MoveSelectEventOrigin } from './movetext/Movetext';
|
|
35
|
+
export { NavigationButton, NavigationButtonList, isNavigationButton } from './navigationboard/NavigationButton';
|
|
36
|
+
export { firstNodeId, previousNodeId, nextNodeId, lastNodeId } from './navigationboard/NavigationField';
|
|
37
|
+
export { NavigationBoard, NavigationBoardProps } from './navigationboard/NavigationBoard';
|
package/dist/lib/index.js
CHANGED
|
@@ -31,4 +31,7 @@ export { ChessPieceIcon } from './icons/ChessPieceIcon';
|
|
|
31
31
|
export { Chessboard } from './chessboard/Chessboard';
|
|
32
32
|
export { formatMove, moveFormatter } from './movetext/moveFormatter';
|
|
33
33
|
export { Movetext } from './movetext/Movetext';
|
|
34
|
+
export { isNavigationButton } from './navigationboard/NavigationButton';
|
|
35
|
+
export { firstNodeId, previousNodeId, nextNodeId, lastNodeId } from './navigationboard/NavigationField';
|
|
36
|
+
export { NavigationBoard } from './navigationboard/NavigationBoard';
|
|
34
37
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,EACH,oBAAoB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,mBAAmB,EAChJ,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAyB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,cAAc,EAAuB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAwB,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAuB,MAAM,wBAAwB,CAAC;AAG7E,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAwC,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAA0C,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAChH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACxG,OAAO,EAAE,eAAe,EAAwB,MAAM,mCAAmC,CAAC"}
|
|
@@ -23,101 +23,88 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
.kokopu-colorTag {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
width : 1.2em;
|
|
27
|
+
height: 1.2em;
|
|
28
|
+
vertical-align: middle;
|
|
29
|
+
display: inline-block;
|
|
30
|
+
border: 1px solid black;
|
|
31
|
+
margin-right: 0.25em;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.kokopu-headerGroup-whitePlayer .kokopu-colorTag {
|
|
35
|
-
|
|
35
|
+
background-color: white;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
.kokopu-headerGroup-blackPlayer .kokopu-colorTag {
|
|
39
|
-
|
|
39
|
+
background-color: black;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.kokopu-headerGroup-titleRating:before,
|
|
43
43
|
.kokopu-header-round:before {
|
|
44
|
-
|
|
44
|
+
content: "\a0("; /* \a0 == */
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
.kokopu-headerGroup-titleRating:after,
|
|
48
48
|
.kokopu-header-round:after {
|
|
49
|
-
|
|
49
|
+
content: ")";
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
.kokopu-header-round,
|
|
53
53
|
.kokopu-header-annotator {
|
|
54
|
-
|
|
54
|
+
font-style: italic;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
* + .kokopu-move:before,
|
|
58
58
|
* + .kokopu-gameResult:before,
|
|
59
59
|
* + span.kokopu-comment:before {
|
|
60
|
-
|
|
60
|
+
content: " ";
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
span.kokopu-variation:before {
|
|
64
|
-
|
|
64
|
+
content: " (";
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
span.kokopu-variation:after {
|
|
68
|
-
|
|
68
|
+
content: ")";
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
* + .kokopu-nag:before {
|
|
72
|
-
|
|
72
|
+
content: "\a0"; /* \a0 == */
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
div.kokopu-subVariation {
|
|
76
|
-
|
|
76
|
+
margin-left: 1.5em;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
.kokopu-move,
|
|
80
80
|
.kokopu-gameResult {
|
|
81
|
-
|
|
81
|
+
font-weight: bold;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
.kokopu-subVariation .kokopu-move {
|
|
85
|
-
|
|
85
|
+
font-weight: inherit;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
.kokopu-diagram {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
text-align: center;
|
|
90
|
+
line-height: 0px;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
.kokopu-moveContent {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
display: inline-block;
|
|
95
|
+
padding-left: 1px;
|
|
96
|
+
padding-right: 1px;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
.kokopu-selectedMove .kokopu-moveContent {
|
|
100
|
-
|
|
100
|
+
background-color: currentcolor;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
.kokopu-selectedMove .kokopu-moveContent > * {
|
|
104
|
-
|
|
104
|
+
filter: invert(1);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.kokopu-clickableMove .kokopu-moveContent:hover {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.kokopu-focusFieldContainer {
|
|
113
|
-
position: fixed;
|
|
114
|
-
bottom: 0px;
|
|
115
|
-
right: 0px;
|
|
116
|
-
width: 0px;
|
|
117
|
-
height: 0px;
|
|
118
|
-
overflow: hidden;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.kokopu-focusField {
|
|
122
|
-
position: absolute; /* see #1 */
|
|
108
|
+
text-decoration: underline;
|
|
109
|
+
cursor: pointer;
|
|
123
110
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import * as React from 'react';
|
|
24
24
|
import { Database, Game } from 'kokopu';
|
|
25
25
|
import { PieceSymbolMapping } from '../types';
|
|
26
|
-
import {
|
|
26
|
+
import { StaticBoardGraphicProps } from '../chessboard/BoardProperties';
|
|
27
27
|
import './Movetext.css';
|
|
28
28
|
/**
|
|
29
29
|
* Origin of a "move-selected" event in {@link Movetext}. See {@link MovetextProps.onMoveSelected} for more details.
|
|
@@ -31,7 +31,7 @@ import './Movetext.css';
|
|
|
31
31
|
export type MoveSelectEventOrigin = 'key-first' | 'key-previous' | 'key-next' | 'key-last' | 'key-exit' | 'click';
|
|
32
32
|
export interface MovetextProps {
|
|
33
33
|
/**
|
|
34
|
-
* Displayed
|
|
34
|
+
* Displayed game. Can be a [kokopu.Game](https://kokopu.yo35.org/docs/current/classes/Game.html) object,
|
|
35
35
|
* a [kokopu.Database](https://kokopu.yo35.org/docs/current/classes/Database.html) object,
|
|
36
36
|
* or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation).
|
|
37
37
|
*/
|
|
@@ -45,14 +45,8 @@ export interface MovetextProps {
|
|
|
45
45
|
/**
|
|
46
46
|
* Options applicable to the diagrams in the comments. See [Chessboard](#/Components/Chessboard) for more details about each option.
|
|
47
47
|
*/
|
|
48
|
-
diagramOptions: {
|
|
49
|
-
flipped?:
|
|
50
|
-
squareSize?: ChessboardProps['squareSize'];
|
|
51
|
-
coordinateVisible?: ChessboardProps['coordinateVisible'];
|
|
52
|
-
turnVisible?: ChessboardProps['turnVisible'];
|
|
53
|
-
colorset?: ChessboardProps['colorset'];
|
|
54
|
-
pieceset?: ChessboardProps['pieceset'];
|
|
55
|
-
smallScreenLimits?: ChessboardProps['smallScreenLimits'];
|
|
48
|
+
diagramOptions: Partial<StaticBoardGraphicProps> & {
|
|
49
|
+
flipped?: boolean;
|
|
56
50
|
};
|
|
57
51
|
/**
|
|
58
52
|
* Symbols to use for the chess pieces. See {@link moveFormatter}.
|
|
@@ -67,7 +61,7 @@ export interface MovetextProps {
|
|
|
67
61
|
*/
|
|
68
62
|
headerVisible: boolean;
|
|
69
63
|
/**
|
|
70
|
-
* ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
64
|
+
* ID of the selected move (or `'start'`/`'end'` for the beginning/end of the main variation).
|
|
71
65
|
* Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/classes/Node.html#id) to get the ID of a game move.
|
|
72
66
|
*/
|
|
73
67
|
selection?: string;
|
|
@@ -114,47 +108,19 @@ export declare class Movetext extends React.Component<MovetextProps> {
|
|
|
114
108
|
*/
|
|
115
109
|
focus(): void;
|
|
116
110
|
/**
|
|
117
|
-
*
|
|
118
|
-
* If the given selection corresponds already at the main variation, `undefined` is returned.
|
|
119
|
-
*
|
|
120
|
-
* This corresponds to the operation performed when the user presses key "home" on a `Movetext` component.
|
|
121
|
-
*
|
|
122
|
-
* @param game - Considered chess game.
|
|
123
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
124
|
-
* @public
|
|
111
|
+
* @deprecated
|
|
125
112
|
*/
|
|
126
113
|
static firstNodeId(game: Game, selection: string): string | undefined;
|
|
127
114
|
/**
|
|
128
|
-
*
|
|
129
|
-
* If no such node exists, `undefined` is returned.
|
|
130
|
-
*
|
|
131
|
-
* This corresponds to the operation performed when the user presses key "arrow left" on a `Movetext` component.
|
|
132
|
-
*
|
|
133
|
-
* @param game - Considered chess game.
|
|
134
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
135
|
-
* @public
|
|
115
|
+
* @deprecated
|
|
136
116
|
*/
|
|
137
117
|
static previousNodeId(game: Game, selection: string): string | undefined;
|
|
138
118
|
/**
|
|
139
|
-
*
|
|
140
|
-
* If no such node exists, `undefined` is returned.
|
|
141
|
-
*
|
|
142
|
-
* This corresponds to the operation performed when the user presses key "arrow right" on a `Movetext` component.
|
|
143
|
-
*
|
|
144
|
-
* @param game - Considered chess game.
|
|
145
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
146
|
-
* @public
|
|
119
|
+
* @deprecated
|
|
147
120
|
*/
|
|
148
121
|
static nextNodeId(game: Game, selection: string): string | undefined;
|
|
149
122
|
/**
|
|
150
|
-
*
|
|
151
|
-
* If the selection is already at the end its variation, `undefined` is returned.
|
|
152
|
-
*
|
|
153
|
-
* This corresponds to the operation performed when the user presses key "end" on a `Movetext` component.
|
|
154
|
-
*
|
|
155
|
-
* @param game - Considered chess game.
|
|
156
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
157
|
-
* @public
|
|
123
|
+
* @deprecated
|
|
158
124
|
*/
|
|
159
125
|
static lastNodeId(game: Game, selection: string): string | undefined;
|
|
160
126
|
}
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
* *
|
|
22
22
|
* -------------------------------------------------------------------------- */
|
|
23
23
|
import * as React from 'react';
|
|
24
|
-
import {
|
|
24
|
+
import { Game } from 'kokopu';
|
|
25
25
|
import { IllegalArgument } from '../exception';
|
|
26
|
-
import { i18n } from '../i18n';
|
|
27
26
|
import { sanitizeString, sanitizeBoolean, sanitizeOptional } from '../sanitization';
|
|
28
|
-
import {
|
|
27
|
+
import { parseGame } from '../errorbox/parsing';
|
|
28
|
+
import { firstNodeId as firstNodeIdImpl, previousNodeId as previousNodeIdImpl, nextNodeId as nextNodeIdImpl, lastNodeId as lastNodeIdImpl } from '../navigationboard/NavigationField';
|
|
29
29
|
import { moveFormatter } from './moveFormatter';
|
|
30
|
-
import { MovetextImpl
|
|
30
|
+
import { MovetextImpl } from './MovetextImpl';
|
|
31
31
|
import './Movetext.css';
|
|
32
32
|
/**
|
|
33
33
|
* 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...).
|
|
@@ -39,9 +39,9 @@ export class Movetext extends React.Component {
|
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
41
|
// Validate the game and game-index attributes.
|
|
42
|
-
const info = parseGame(this.props.game, this.props.gameIndex);
|
|
42
|
+
const info = parseGame(this.props.game, this.props.gameIndex, 'Movetext');
|
|
43
43
|
if (info.error) {
|
|
44
|
-
return
|
|
44
|
+
return info.errorBox;
|
|
45
45
|
}
|
|
46
46
|
// Validate the appearance attributes.
|
|
47
47
|
if (typeof this.props.diagramOptions !== 'object' || this.props.diagramOptions === null) {
|
|
@@ -72,59 +72,36 @@ export class Movetext extends React.Component {
|
|
|
72
72
|
*/
|
|
73
73
|
focus() {
|
|
74
74
|
const movetextImpl = this.implRef.current;
|
|
75
|
+
// istanbul ignore else
|
|
75
76
|
if (movetextImpl) {
|
|
76
77
|
movetextImpl.focus();
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
|
-
*
|
|
81
|
-
* If the given selection corresponds already at the main variation, `undefined` is returned.
|
|
82
|
-
*
|
|
83
|
-
* This corresponds to the operation performed when the user presses key "home" on a `Movetext` component.
|
|
84
|
-
*
|
|
85
|
-
* @param game - Considered chess game.
|
|
86
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
87
|
-
* @public
|
|
81
|
+
* @deprecated
|
|
88
82
|
*/
|
|
83
|
+
// istanbul ignore next
|
|
89
84
|
static firstNodeId(game, selection) {
|
|
90
85
|
return firstNodeIdImpl(game, selection);
|
|
91
86
|
}
|
|
92
87
|
/**
|
|
93
|
-
*
|
|
94
|
-
* If no such node exists, `undefined` is returned.
|
|
95
|
-
*
|
|
96
|
-
* This corresponds to the operation performed when the user presses key "arrow left" on a `Movetext` component.
|
|
97
|
-
*
|
|
98
|
-
* @param game - Considered chess game.
|
|
99
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
100
|
-
* @public
|
|
88
|
+
* @deprecated
|
|
101
89
|
*/
|
|
90
|
+
// istanbul ignore next
|
|
102
91
|
static previousNodeId(game, selection) {
|
|
103
92
|
return previousNodeIdImpl(game, selection);
|
|
104
93
|
}
|
|
105
94
|
/**
|
|
106
|
-
*
|
|
107
|
-
* If no such node exists, `undefined` is returned.
|
|
108
|
-
*
|
|
109
|
-
* This corresponds to the operation performed when the user presses key "arrow right" on a `Movetext` component.
|
|
110
|
-
*
|
|
111
|
-
* @param game - Considered chess game.
|
|
112
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
113
|
-
* @public
|
|
95
|
+
* @deprecated
|
|
114
96
|
*/
|
|
97
|
+
// istanbul ignore next
|
|
115
98
|
static nextNodeId(game, selection) {
|
|
116
99
|
return nextNodeIdImpl(game, selection);
|
|
117
100
|
}
|
|
118
101
|
/**
|
|
119
|
-
*
|
|
120
|
-
* If the selection is already at the end its variation, `undefined` is returned.
|
|
121
|
-
*
|
|
122
|
-
* This corresponds to the operation performed when the user presses key "end" on a `Movetext` component.
|
|
123
|
-
*
|
|
124
|
-
* @param game - Considered chess game.
|
|
125
|
-
* @param selection - ID of the selected move (or `'start'` for the beginning of the main variation).
|
|
126
|
-
* @public
|
|
102
|
+
* @deprecated
|
|
127
103
|
*/
|
|
104
|
+
// istanbul ignore next
|
|
128
105
|
static lastNodeId(game, selection) {
|
|
129
106
|
return lastNodeIdImpl(game, selection);
|
|
130
107
|
}
|
|
@@ -137,33 +114,4 @@ Movetext.defaultProps = {
|
|
|
137
114
|
diagramVisible: true,
|
|
138
115
|
headerVisible: true,
|
|
139
116
|
};
|
|
140
|
-
/**
|
|
141
|
-
* Try to interpret the given object as a chess game.
|
|
142
|
-
*/
|
|
143
|
-
function parseGame(game, gameIndex) {
|
|
144
|
-
if (game instanceof Game) {
|
|
145
|
-
return { error: false, game: game };
|
|
146
|
-
}
|
|
147
|
-
else if (game instanceof Database || typeof game === 'string') {
|
|
148
|
-
if (!Number.isInteger(gameIndex) || gameIndex < 0) {
|
|
149
|
-
throw new IllegalArgument('Movetext', 'gameIndex');
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const result = game instanceof Database ? game.game(gameIndex) : pgnRead(game, gameIndex);
|
|
153
|
-
return { error: false, game: result };
|
|
154
|
-
}
|
|
155
|
-
catch (e) {
|
|
156
|
-
// istanbul ignore else
|
|
157
|
-
if (e instanceof kokopuException.InvalidPGN) {
|
|
158
|
-
return { error: true, pgnException: e };
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
throw e;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
throw new IllegalArgument('Movetext', 'game');
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
117
|
//# sourceMappingURL=Movetext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Movetext.js","sourceRoot":"","sources":["../../../src/movetext/Movetext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;gFAqBgF;AAGhF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"Movetext.js","sourceRoot":"","sources":["../../../src/movetext/Movetext.tsx"],"names":[],"mappings":"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"}
|
|
@@ -22,18 +22,12 @@
|
|
|
22
22
|
* -------------------------------------------------------------------------- */
|
|
23
23
|
import * as React from 'react';
|
|
24
24
|
import { Game } from 'kokopu';
|
|
25
|
-
import {
|
|
25
|
+
import { StaticBoardGraphicProps } from '../chessboard/BoardProperties';
|
|
26
26
|
import './Movetext.css';
|
|
27
27
|
interface MovetextImplProps {
|
|
28
28
|
game: Game;
|
|
29
|
-
diagramOptions: {
|
|
30
|
-
flipped?:
|
|
31
|
-
squareSize?: ChessboardProps['squareSize'];
|
|
32
|
-
coordinateVisible?: ChessboardProps['coordinateVisible'];
|
|
33
|
-
turnVisible?: ChessboardProps['turnVisible'];
|
|
34
|
-
colorset?: ChessboardProps['colorset'];
|
|
35
|
-
pieceset?: ChessboardProps['pieceset'];
|
|
36
|
-
smallScreenLimits?: ChessboardProps['smallScreenLimits'];
|
|
29
|
+
diagramOptions: Partial<StaticBoardGraphicProps> & {
|
|
30
|
+
flipped?: boolean;
|
|
37
31
|
};
|
|
38
32
|
moveFormatter: (notation: string) => React.ReactNode;
|
|
39
33
|
diagramVisible: boolean;
|
|
@@ -48,7 +42,7 @@ interface MovetextImplProps {
|
|
|
48
42
|
* This implementation assumes that all the parameter sanitization has been performed beforehand.
|
|
49
43
|
*/
|
|
50
44
|
export declare class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
51
|
-
private
|
|
45
|
+
private navigationFieldRef;
|
|
52
46
|
render(): React.JSX.Element;
|
|
53
47
|
private renderHeaders;
|
|
54
48
|
/**
|
|
@@ -67,7 +61,7 @@ export declare class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
67
61
|
* Header containing the annotator information.
|
|
68
62
|
*/
|
|
69
63
|
private renderAnnotatorHeader;
|
|
70
|
-
private
|
|
64
|
+
private renderNavigationField;
|
|
71
65
|
private renderBody;
|
|
72
66
|
/**
|
|
73
67
|
* Render the given variation and its sub-variations, recursively.
|
|
@@ -82,7 +76,8 @@ export declare class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
82
76
|
*/
|
|
83
77
|
private renderComment;
|
|
84
78
|
private extractComment;
|
|
85
|
-
private
|
|
79
|
+
private handleNavigationPressed;
|
|
80
|
+
private handleExitPressed;
|
|
86
81
|
private fireMoveSelected;
|
|
87
82
|
private handleNodeClicked;
|
|
88
83
|
/**
|
|
@@ -90,20 +85,4 @@ export declare class MovetextImpl extends React.Component<MovetextImplProps> {
|
|
|
90
85
|
*/
|
|
91
86
|
focus(): void;
|
|
92
87
|
}
|
|
93
|
-
/**
|
|
94
|
-
* See {@link Movetext.firstNodeId}.
|
|
95
|
-
*/
|
|
96
|
-
export declare function firstNodeIdImpl(game: Game, selection: string): string | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* See {@link Movetext.previousNodeId}.
|
|
99
|
-
*/
|
|
100
|
-
export declare function previousNodeIdImpl(game: Game, selection: string): string | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* See {@link Movetext.nextNodeId}.
|
|
103
|
-
*/
|
|
104
|
-
export declare function nextNodeIdImpl(game: Game, selection: string): string | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* See {@link Movetext.lastNodeId}.
|
|
107
|
-
*/
|
|
108
|
-
export declare function lastNodeIdImpl(game: Game, selection: string): string | undefined;
|
|
109
88
|
export {};
|
|
@@ -25,6 +25,7 @@ import { Variation, nagSymbol } from 'kokopu';
|
|
|
25
25
|
import { i18n } from '../i18n';
|
|
26
26
|
import { fillPlaceholder } from '../util';
|
|
27
27
|
import { Chessboard } from '../chessboard/Chessboard';
|
|
28
|
+
import { NavigationField, firstNodeId, previousNodeId, nextNodeId, lastNodeId } from '../navigationboard/NavigationField';
|
|
28
29
|
import { htmlFilter } from './htmlFilter';
|
|
29
30
|
import './Movetext.css';
|
|
30
31
|
/**
|
|
@@ -35,13 +36,13 @@ import './Movetext.css';
|
|
|
35
36
|
export class MovetextImpl extends React.Component {
|
|
36
37
|
constructor() {
|
|
37
38
|
super(...arguments);
|
|
38
|
-
this.
|
|
39
|
+
this.navigationFieldRef = React.createRef();
|
|
39
40
|
}
|
|
40
41
|
render() {
|
|
41
42
|
return (React.createElement("div", { className: "kokopu-movetext" },
|
|
42
43
|
this.renderHeaders(),
|
|
43
44
|
this.renderBody(),
|
|
44
|
-
this.
|
|
45
|
+
this.renderNavigationField()));
|
|
45
46
|
}
|
|
46
47
|
renderHeaders() {
|
|
47
48
|
if (!this.props.headerVisible) {
|
|
@@ -124,12 +125,11 @@ export class MovetextImpl extends React.Component {
|
|
|
124
125
|
}
|
|
125
126
|
return React.createElement("div", { className: "kokopu-header-annotator", key: "annotator" }, filter(fillPlaceholder(i18n.ANNOTATED_BY, annotator)));
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
+
renderNavigationField() {
|
|
128
129
|
if (this.props.interactionMode !== 'selectMove') {
|
|
129
130
|
return undefined;
|
|
130
131
|
}
|
|
131
|
-
return
|
|
132
|
-
React.createElement("a", { className: "kokopu-focusField", href: "#", ref: this.focusFieldRef, onKeyDown: evt => this.handleKeyDownInFocusField(evt) })));
|
|
132
|
+
return React.createElement(NavigationField, { ref: this.navigationFieldRef, onFirstPressed: () => this.handleNavigationPressed(firstNodeId, 'key-first'), onPreviousPressed: () => this.handleNavigationPressed(previousNodeId, 'key-previous'), onNextPressed: () => this.handleNavigationPressed(nextNodeId, 'key-next'), onLastPressed: () => this.handleNavigationPressed(lastNodeId, 'key-last'), onExitPressed: () => this.handleExitPressed() });
|
|
133
133
|
}
|
|
134
134
|
renderBody() {
|
|
135
135
|
const filter = htmlFilter('comment');
|
|
@@ -258,7 +258,7 @@ export class MovetextImpl extends React.Component {
|
|
|
258
258
|
for (let textSegment of comment.split('[#]')) {
|
|
259
259
|
if (!isFirstTextSegment) {
|
|
260
260
|
const position = node instanceof Variation ? node.initialPosition() : node.position();
|
|
261
|
-
const diagram = React.createElement(Chessboard, { position: position, squareMarkers: node.tag('csl'), arrowMarkers: node.tag('cal'), textMarkers: node.tag('ctl'), flipped: this.props.diagramOptions.flipped, squareSize: this.props.diagramOptions.squareSize, coordinateVisible: this.props.diagramOptions.coordinateVisible, turnVisible: this.props.diagramOptions.turnVisible,
|
|
261
|
+
const diagram = React.createElement(Chessboard, { position: position, squareMarkers: node.tag('csl'), arrowMarkers: node.tag('cal'), textMarkers: node.tag('ctl'), flipped: this.props.diagramOptions.flipped, squareSize: this.props.diagramOptions.squareSize, coordinateVisible: this.props.diagramOptions.coordinateVisible, turnVisible: this.props.diagramOptions.turnVisible, colorset: this.props.diagramOptions.colorset, pieceset: this.props.diagramOptions.pieceset, smallScreenLimits: this.props.diagramOptions.smallScreenLimits });
|
|
262
262
|
segmentElements.push(React.createElement("div", { className: "kokopu-diagram", key: 'diagram-' + (diagramIndex++) }, diagram));
|
|
263
263
|
}
|
|
264
264
|
isFirstTextSegment = false;
|
|
@@ -287,30 +287,14 @@ export class MovetextImpl extends React.Component {
|
|
|
287
287
|
}
|
|
288
288
|
return comment ? comment : undefined;
|
|
289
289
|
}
|
|
290
|
-
|
|
291
|
-
if (
|
|
292
|
-
|
|
290
|
+
handleNavigationPressed(transition, evtOrigin) {
|
|
291
|
+
if (this.props.selection) {
|
|
292
|
+
this.fireMoveSelected(transition(this.props.game, this.props.selection), evtOrigin);
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (evt.key === 'Home') {
|
|
299
|
-
this.fireMoveSelected(firstNodeIdImpl(this.props.game, this.props.selection), 'key-first');
|
|
300
|
-
}
|
|
301
|
-
else if (evt.key === 'ArrowLeft') {
|
|
302
|
-
this.fireMoveSelected(previousNodeIdImpl(this.props.game, this.props.selection), 'key-previous');
|
|
303
|
-
}
|
|
304
|
-
else if (evt.key === 'ArrowRight') {
|
|
305
|
-
this.fireMoveSelected(nextNodeIdImpl(this.props.game, this.props.selection), 'key-next');
|
|
306
|
-
}
|
|
307
|
-
else if (evt.key === 'End') {
|
|
308
|
-
this.fireMoveSelected(lastNodeIdImpl(this.props.game, this.props.selection), 'key-last');
|
|
309
|
-
}
|
|
310
|
-
else { // evt.key === 'Escape'
|
|
311
|
-
if (this.props.game.findById(this.props.selection)) {
|
|
312
|
-
this.fireMoveSelected(undefined, 'key-exit');
|
|
313
|
-
}
|
|
294
|
+
}
|
|
295
|
+
handleExitPressed() {
|
|
296
|
+
if (this.props.selection && this.props.game.findById(this.props.selection)) {
|
|
297
|
+
this.fireMoveSelected(undefined, 'key-exit');
|
|
314
298
|
}
|
|
315
299
|
}
|
|
316
300
|
fireMoveSelected(nodeId, evtOrigin) {
|
|
@@ -328,76 +312,13 @@ export class MovetextImpl extends React.Component {
|
|
|
328
312
|
* Set the focus to the current component.
|
|
329
313
|
*/
|
|
330
314
|
focus() {
|
|
331
|
-
const target = this.
|
|
315
|
+
const target = this.navigationFieldRef.current;
|
|
316
|
+
// istanbul ignore else
|
|
332
317
|
if (target) {
|
|
333
318
|
target.focus();
|
|
334
319
|
}
|
|
335
320
|
}
|
|
336
321
|
}
|
|
337
|
-
/**
|
|
338
|
-
* See {@link Movetext.firstNodeId}.
|
|
339
|
-
*/
|
|
340
|
-
export function firstNodeIdImpl(game, selection) {
|
|
341
|
-
if (!game.findById(selection)) {
|
|
342
|
-
return undefined;
|
|
343
|
-
}
|
|
344
|
-
return selection === 'start' ? undefined : 'start';
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* See {@link Movetext.previousNodeId}.
|
|
348
|
-
*/
|
|
349
|
-
export function previousNodeIdImpl(game, selection) {
|
|
350
|
-
let currentNode = game.findById(selection);
|
|
351
|
-
if (!currentNode) {
|
|
352
|
-
return undefined;
|
|
353
|
-
}
|
|
354
|
-
if (currentNode instanceof Variation) {
|
|
355
|
-
currentNode = currentNode.parentNode();
|
|
356
|
-
if (!currentNode) {
|
|
357
|
-
return undefined; // This case corresponds to the first variation being selected initially.
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
while (currentNode) {
|
|
361
|
-
const previousNode = currentNode.previous();
|
|
362
|
-
if (previousNode) {
|
|
363
|
-
return previousNode.id();
|
|
364
|
-
}
|
|
365
|
-
currentNode = currentNode.parentVariation().parentNode();
|
|
366
|
-
}
|
|
367
|
-
return 'start';
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* See {@link Movetext.nextNodeId}.
|
|
371
|
-
*/
|
|
372
|
-
export function nextNodeIdImpl(game, selection) {
|
|
373
|
-
const currentNode = game.findById(selection);
|
|
374
|
-
if (!currentNode) {
|
|
375
|
-
return undefined;
|
|
376
|
-
}
|
|
377
|
-
const nextNode = currentNode instanceof Variation ? currentNode.first() : currentNode.next();
|
|
378
|
-
return nextNode ? nextNode.id() : undefined;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* See {@link Movetext.lastNodeId}.
|
|
382
|
-
*/
|
|
383
|
-
export function lastNodeIdImpl(game, selection) {
|
|
384
|
-
let currentNode = game.findById(selection);
|
|
385
|
-
if (!currentNode) {
|
|
386
|
-
return undefined;
|
|
387
|
-
}
|
|
388
|
-
currentNode = currentNode instanceof Variation ? currentNode.first() : currentNode.next();
|
|
389
|
-
if (!currentNode) { // Ensure that the input node is not already the last one.
|
|
390
|
-
return undefined;
|
|
391
|
-
}
|
|
392
|
-
let currentNodeNotNull = currentNode;
|
|
393
|
-
while (true) {
|
|
394
|
-
const nextNode = currentNodeNotNull.next();
|
|
395
|
-
if (!nextNode) {
|
|
396
|
-
return currentNodeNotNull.id();
|
|
397
|
-
}
|
|
398
|
-
currentNodeNotNull = nextNode;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
322
|
/**
|
|
402
323
|
* Example: `'hello world'` is turned into `'Hello world'`.
|
|
403
324
|
*/
|