kokopu-react 1.9.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.
- package/dist/lib/ArrowMarkerIcon.js +1 -29
- package/dist/lib/Chessboard.js +99 -242
- package/dist/lib/ErrorBox.js +7 -24
- package/dist/lib/Movetext.js +74 -178
- package/dist/lib/SquareMarkerIcon.js +2 -10
- package/dist/lib/TextMarkerIcon.js +0 -11
- package/dist/lib/css/movetext.css +4 -0
- package/dist/lib/formatmove.js +2 -14
- package/dist/lib/i18n.js +1 -1
- package/dist/lib/impl/ArrowTip.js +0 -6
- package/dist/lib/impl/HtmlSanitizer.js +13 -46
- package/dist/lib/impl/Motion.js +7 -33
- package/dist/lib/impl/TextSymbol.js +2 -11
- package/dist/lib/impl/colorsets.js +0 -2
- package/dist/lib/impl/piecesets.js +0 -87
- package/dist/lib/impl/util.js +1 -11
- package/dist/lib/index.js +0 -10
- package/dist/lib/markers.js +18 -38
- package/package.json +18 -18
- package/scripts/docker-compose.yml +1 -1
- package/src/css/movetext.css +4 -0
package/dist/lib/ErrorBox.js
CHANGED
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = ErrorBox;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _i18n = _interopRequireDefault(require("./i18n"));
|
|
13
|
-
|
|
14
10
|
var _util = require("./impl/util");
|
|
15
|
-
|
|
16
11
|
require("./css/error_box.css");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
13
|
/******************************************************************************
|
|
21
14
|
* *
|
|
22
15
|
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
@@ -37,12 +30,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
37
30
|
* <http://www.gnu.org/licenses/>. *
|
|
38
31
|
* *
|
|
39
32
|
******************************************************************************/
|
|
33
|
+
|
|
40
34
|
var BACKWARD_CHARACTERS = 5;
|
|
41
35
|
var FORWARD_CHARACTERS = 36;
|
|
36
|
+
|
|
42
37
|
/**
|
|
43
38
|
* Display an error message.
|
|
44
39
|
*/
|
|
45
|
-
|
|
46
40
|
function ErrorBox(props) {
|
|
47
41
|
var excerpt = typeof props.text === 'string' && props.errorIndex >= 0 && props.errorIndex < props.text.length ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
48
42
|
className: "kokopu-errorExcerpt"
|
|
@@ -55,33 +49,29 @@ function ErrorBox(props) {
|
|
|
55
49
|
className: "kokopu-errorMessage"
|
|
56
50
|
}, props.message), excerpt);
|
|
57
51
|
}
|
|
58
|
-
|
|
59
52
|
ErrorBox.propTypes = {
|
|
60
53
|
/**
|
|
61
54
|
* Title of the error box.
|
|
62
55
|
*/
|
|
63
56
|
title: _propTypes["default"].string.isRequired,
|
|
64
|
-
|
|
65
57
|
/**
|
|
66
58
|
* Additional message providing details about the error.
|
|
67
59
|
*/
|
|
68
60
|
message: _propTypes["default"].string.isRequired,
|
|
69
|
-
|
|
70
61
|
/**
|
|
71
62
|
* Raw text whose processing results in the error.
|
|
72
63
|
*/
|
|
73
64
|
text: _propTypes["default"].string,
|
|
74
|
-
|
|
75
65
|
/**
|
|
76
66
|
* Index of the character within `text` that results in the error.
|
|
77
67
|
*/
|
|
78
68
|
errorIndex: _propTypes["default"].number,
|
|
79
|
-
|
|
80
69
|
/**
|
|
81
70
|
* Index (1-based) of the line in which is the character that results in the error.
|
|
82
71
|
*/
|
|
83
72
|
lineNumber: _propTypes["default"].number
|
|
84
73
|
};
|
|
74
|
+
|
|
85
75
|
/**
|
|
86
76
|
* Ellipsis function.
|
|
87
77
|
*
|
|
@@ -99,44 +89,37 @@ ErrorBox.propTypes = {
|
|
|
99
89
|
* @param {number} forwardCharacters Number of characters to keep after `pos`.
|
|
100
90
|
* @returns {string}
|
|
101
91
|
*/
|
|
102
|
-
|
|
103
92
|
function ellipsisAt(text, pos, backwardCharacters, forwardCharacters, lineNumber) {
|
|
104
93
|
// p1 => begin of the extracted sub-string
|
|
105
94
|
var p1 = pos;
|
|
106
95
|
var e1 = '... ';
|
|
107
|
-
|
|
108
96
|
while (p1 > pos - backwardCharacters) {
|
|
109
97
|
--p1;
|
|
110
|
-
|
|
111
98
|
if (p1 < 0 || text.charAt(p1) === '\n' || text.charAt(p1) === '\r') {
|
|
112
99
|
++p1;
|
|
113
100
|
e1 = '';
|
|
114
101
|
break;
|
|
115
102
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
103
|
+
}
|
|
118
104
|
|
|
105
|
+
// p2 => one character after the end of the extracted sub-string
|
|
119
106
|
var p2 = pos;
|
|
120
107
|
var e2 = ' ...';
|
|
121
|
-
|
|
122
108
|
while (p2 < pos + forwardCharacters) {
|
|
123
109
|
++p2;
|
|
124
|
-
|
|
125
110
|
if (p2 >= text.length || text.charAt(p2) === '\n' || text.charAt(p2) === '\r') {
|
|
126
111
|
--p2;
|
|
127
112
|
e2 = '';
|
|
128
113
|
break;
|
|
129
114
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
115
|
+
}
|
|
132
116
|
|
|
117
|
+
// Extract the sub-string around the requested position.
|
|
133
118
|
var excerpt = e1 + text.substring(p1, p2 + 1) + e2;
|
|
134
119
|
excerpt = excerpt.replace(/\n|\r|\t/g, ' ');
|
|
135
120
|
var secondLine = Array(1 + e1.length + pos - p1).join(' ') + '^';
|
|
136
|
-
|
|
137
121
|
if (lineNumber) {
|
|
138
122
|
secondLine += " (".concat((0, _util.fillPlaceholder)(_i18n["default"].LINE, lineNumber), ")");
|
|
139
123
|
}
|
|
140
|
-
|
|
141
124
|
return excerpt + '\n' + secondLine;
|
|
142
125
|
}
|