@pie-element/select-text 6.6.2 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/configure/CHANGELOG.md +33 -0
- package/configure/lib/defaultConfiguration.js +11 -1
- package/configure/lib/defaultConfiguration.js.map +1 -1
- package/configure/lib/design.js +16 -4
- package/configure/lib/design.js.map +1 -1
- package/configure/package.json +5 -5
- package/controller/CHANGELOG.md +16 -0
- package/controller/package.json +2 -2
- package/docs/config-schema.json +63 -0
- package/docs/config-schema.json.md +49 -1
- package/docs/pie-schema.json +21 -0
- package/docs/pie-schema.json.md +16 -0
- package/lib/index.js +18 -9
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
- package/module/configure.js +0 -2799
- package/module/controller.js +0 -19165
- package/module/demo.js +0 -287
- package/module/element.js +0 -2521
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -325
- package/module/print.html +0 -18
- package/module/print.js +0 -2481
package/module/print.js
DELETED
|
@@ -1,2481 +0,0 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_lodash, _dll_debug, _dll_classnames, _dll_pie_lib__render_ui, _dll_react_dom_server, _dll_pie_lib__correct_answer_toggle, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.17/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.5/module/index.js";
|
|
3
|
-
const React$7 = _dll_react;
|
|
4
|
-
const PropTypes$6 = _dll_prop_types;
|
|
5
|
-
const {Button: Button} = _dll_material_ui__core;
|
|
6
|
-
const {Switch: Switch} = _dll_material_ui__core;
|
|
7
|
-
const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
|
|
8
|
-
const {withStyles: withStyles$5} = _dll_material_ui__core_styles;
|
|
9
|
-
const _jsxFileName$6 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/tokenizer/controls.jsx";
|
|
10
|
-
class Controls extends React$7.Component {
|
|
11
|
-
static __initStatic() {
|
|
12
|
-
this.propTypes = {
|
|
13
|
-
classes: PropTypes$6.object.isRequired,
|
|
14
|
-
onClear: PropTypes$6.func.isRequired,
|
|
15
|
-
onWords: PropTypes$6.func.isRequired,
|
|
16
|
-
onSentences: PropTypes$6.func.isRequired,
|
|
17
|
-
onParagraphs: PropTypes$6.func.isRequired,
|
|
18
|
-
setCorrectMode: PropTypes$6.bool.isRequired,
|
|
19
|
-
onToggleCorrectMode: PropTypes$6.func.isRequired
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
static __initStatic2() {
|
|
23
|
-
this.defaultProps = {};
|
|
24
|
-
}
|
|
25
|
-
render() {
|
|
26
|
-
const {classes, onClear, onWords, onSentences, onParagraphs, setCorrectMode, onToggleCorrectMode} = this.props;
|
|
27
|
-
return React$7.createElement('div', {
|
|
28
|
-
className: classes.controls,
|
|
29
|
-
__self: this,
|
|
30
|
-
__source: {
|
|
31
|
-
fileName: _jsxFileName$6,
|
|
32
|
-
lineNumber: 33
|
|
33
|
-
}
|
|
34
|
-
}, React$7.createElement('div', {
|
|
35
|
-
__self: this,
|
|
36
|
-
__source: {
|
|
37
|
-
fileName: _jsxFileName$6,
|
|
38
|
-
lineNumber: 34
|
|
39
|
-
}
|
|
40
|
-
}, React$7.createElement(Button, {
|
|
41
|
-
onClick: onWords,
|
|
42
|
-
className: classes.button,
|
|
43
|
-
size: "small",
|
|
44
|
-
color: "primary",
|
|
45
|
-
disabled: setCorrectMode,
|
|
46
|
-
__self: this,
|
|
47
|
-
__source: {
|
|
48
|
-
fileName: _jsxFileName$6,
|
|
49
|
-
lineNumber: 35
|
|
50
|
-
}
|
|
51
|
-
}, "Words"), React$7.createElement(Button, {
|
|
52
|
-
onClick: onSentences,
|
|
53
|
-
className: classes.button,
|
|
54
|
-
size: "small",
|
|
55
|
-
color: "primary",
|
|
56
|
-
disabled: setCorrectMode,
|
|
57
|
-
__self: this,
|
|
58
|
-
__source: {
|
|
59
|
-
fileName: _jsxFileName$6,
|
|
60
|
-
lineNumber: 44
|
|
61
|
-
}
|
|
62
|
-
}, "Sentences"), React$7.createElement(Button, {
|
|
63
|
-
onClick: onParagraphs,
|
|
64
|
-
className: classes.button,
|
|
65
|
-
size: "small",
|
|
66
|
-
color: "primary",
|
|
67
|
-
disabled: setCorrectMode,
|
|
68
|
-
__self: this,
|
|
69
|
-
__source: {
|
|
70
|
-
fileName: _jsxFileName$6,
|
|
71
|
-
lineNumber: 53
|
|
72
|
-
}
|
|
73
|
-
}, "Paragraphs"), React$7.createElement(Button, {
|
|
74
|
-
className: classes.button,
|
|
75
|
-
size: "small",
|
|
76
|
-
color: "secondary",
|
|
77
|
-
onClick: onClear,
|
|
78
|
-
disabled: setCorrectMode,
|
|
79
|
-
__self: this,
|
|
80
|
-
__source: {
|
|
81
|
-
fileName: _jsxFileName$6,
|
|
82
|
-
lineNumber: 62
|
|
83
|
-
}
|
|
84
|
-
}, "Clear")), React$7.createElement(FormControlLabel, {
|
|
85
|
-
control: React$7.createElement(Switch, {
|
|
86
|
-
checked: setCorrectMode,
|
|
87
|
-
onChange: onToggleCorrectMode,
|
|
88
|
-
__self: this,
|
|
89
|
-
__source: {
|
|
90
|
-
fileName: _jsxFileName$6,
|
|
91
|
-
lineNumber: 73
|
|
92
|
-
}
|
|
93
|
-
}),
|
|
94
|
-
label: "Set correct answers",
|
|
95
|
-
__self: this,
|
|
96
|
-
__source: {
|
|
97
|
-
fileName: _jsxFileName$6,
|
|
98
|
-
lineNumber: 72
|
|
99
|
-
}
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
Controls.__initStatic();
|
|
104
|
-
Controls.__initStatic2();
|
|
105
|
-
var Controls$1 = withStyles$5(theme => ({
|
|
106
|
-
button: {
|
|
107
|
-
marginRight: theme.spacing.unit
|
|
108
|
-
},
|
|
109
|
-
controls: {
|
|
110
|
-
display: 'flex',
|
|
111
|
-
alignItems: 'center',
|
|
112
|
-
justifyContent: 'space-between'
|
|
113
|
-
}
|
|
114
|
-
}))(Controls);
|
|
115
|
-
var nlcstToString_1 = nlcstToString;
|
|
116
|
-
function nlcstToString(node, separator) {
|
|
117
|
-
var sep = separator || '';
|
|
118
|
-
var values;
|
|
119
|
-
var length;
|
|
120
|
-
var children;
|
|
121
|
-
if (!node || !(('length' in node)) && !node.type) {
|
|
122
|
-
throw new Error('Expected node, not `' + node + '`');
|
|
123
|
-
}
|
|
124
|
-
if (typeof node.value === 'string') {
|
|
125
|
-
return node.value;
|
|
126
|
-
}
|
|
127
|
-
children = ('length' in node) ? node : node.children;
|
|
128
|
-
length = children.length;
|
|
129
|
-
if (length === 1 && ('value' in children[0])) {
|
|
130
|
-
return children[0].value;
|
|
131
|
-
}
|
|
132
|
-
values = [];
|
|
133
|
-
while (length--) {
|
|
134
|
-
values[length] = nlcstToString(children[length], sep);
|
|
135
|
-
}
|
|
136
|
-
return values.join(sep);
|
|
137
|
-
}
|
|
138
|
-
var unistUtilVisitChildren = visitChildren$4;
|
|
139
|
-
function visitChildren$4(callback) {
|
|
140
|
-
return visitor;
|
|
141
|
-
function visitor(parent) {
|
|
142
|
-
var index = -1;
|
|
143
|
-
var children = parent && parent.children;
|
|
144
|
-
if (!children) {
|
|
145
|
-
throw new Error('Missing children in `parent` for `visitor`');
|
|
146
|
-
}
|
|
147
|
-
while ((++index in children)) {
|
|
148
|
-
callback(children[index], index, parent);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
var arrayIterate = iterate$2;
|
|
153
|
-
var own = ({}).hasOwnProperty;
|
|
154
|
-
function iterate$2(values, callback, context) {
|
|
155
|
-
var index = -1;
|
|
156
|
-
var result;
|
|
157
|
-
if (!values) {
|
|
158
|
-
throw new Error('Iterate requires that |this| not be ' + values);
|
|
159
|
-
}
|
|
160
|
-
if (!own.call(values, 'length')) {
|
|
161
|
-
throw new Error('Iterate requires that |this| has a `length`');
|
|
162
|
-
}
|
|
163
|
-
if (typeof callback !== 'function') {
|
|
164
|
-
throw new Error('`callback` must be a function');
|
|
165
|
-
}
|
|
166
|
-
while (++index < values.length) {
|
|
167
|
-
if (!((index in values))) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
result = callback.call(context, values[index], index, values);
|
|
171
|
-
if (typeof result === 'number') {
|
|
172
|
-
if (result < 0) {
|
|
173
|
-
index = 0;
|
|
174
|
-
}
|
|
175
|
-
index = result - 1;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
var iterate$1 = arrayIterate;
|
|
180
|
-
var unistUtilModifyChildren$1 = modifierFactory$1;
|
|
181
|
-
function modifierFactory$1(callback) {
|
|
182
|
-
return iteratorFactory$1(wrapperFactory$1(callback));
|
|
183
|
-
}
|
|
184
|
-
function iteratorFactory$1(callback) {
|
|
185
|
-
return iterator;
|
|
186
|
-
function iterator(parent) {
|
|
187
|
-
var children = parent && parent.children;
|
|
188
|
-
if (!children) {
|
|
189
|
-
throw new Error('Missing children in `parent` for `modifier`');
|
|
190
|
-
}
|
|
191
|
-
return iterate$1(children, callback, parent);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function wrapperFactory$1(callback) {
|
|
195
|
-
return wrapper;
|
|
196
|
-
function wrapper(value, index) {
|
|
197
|
-
return callback(value, index, this);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
var toString$d = nlcstToString_1;
|
|
201
|
-
var tokenizer$1 = tokenizerFactory;
|
|
202
|
-
function tokenizerFactory(childType, expression) {
|
|
203
|
-
return tokenizer;
|
|
204
|
-
function tokenizer(node) {
|
|
205
|
-
var children = [];
|
|
206
|
-
var tokens = node.children;
|
|
207
|
-
var type = node.type;
|
|
208
|
-
var length = tokens.length;
|
|
209
|
-
var index = -1;
|
|
210
|
-
var lastIndex = length - 1;
|
|
211
|
-
var start = 0;
|
|
212
|
-
var first;
|
|
213
|
-
var last;
|
|
214
|
-
var parent;
|
|
215
|
-
while (++index < length) {
|
|
216
|
-
if (index === lastIndex || tokens[index].type === childType && expression.test(toString$d(tokens[index]))) {
|
|
217
|
-
first = tokens[start];
|
|
218
|
-
last = tokens[index];
|
|
219
|
-
parent = {
|
|
220
|
-
type: type,
|
|
221
|
-
children: tokens.slice(start, index + 1)
|
|
222
|
-
};
|
|
223
|
-
if (first.position && last.position) {
|
|
224
|
-
parent.position = {
|
|
225
|
-
start: first.position.start,
|
|
226
|
-
end: last.position.end
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
children.push(parent);
|
|
230
|
-
start = index + 1;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return children;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
var tokenizer = tokenizer$1;
|
|
237
|
-
var parser = parserFactory;
|
|
238
|
-
function parserFactory(options) {
|
|
239
|
-
var type = options.type;
|
|
240
|
-
var tokenizerProperty = options.tokenizer;
|
|
241
|
-
var delimiter = options.delimiter;
|
|
242
|
-
var tokenize = delimiter && tokenizer(options.delimiterType, delimiter);
|
|
243
|
-
return parser;
|
|
244
|
-
function parser(value) {
|
|
245
|
-
var children = this[tokenizerProperty](value);
|
|
246
|
-
return {
|
|
247
|
-
type: type,
|
|
248
|
-
children: tokenize ? tokenize(children) : children
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
var expressions$8 = {
|
|
253
|
-
affixSymbol: /^([!"').?\u0F3B\u0F3D\u169C\u2019\u201D\u2026\u203A\u203D\u2046\u207E\u208E\u2309\u230B\u232A\u2769\u276B\u276D\u276F\u2771\u2773\u2775\u27C6\u27E7\u27E9\u27EB\u27ED\u27EF\u2984\u2986\u2988\u298A\u298C\u298E\u2990\u2992\u2994\u2996\u2998\u29D9\u29DB\u29FD\u2E03\u2E05\u2E0A\u2E0D\u2E1D\u2E21\u2E23\u2E25\u2E27\u2E29\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u301E\u301F\uFD3E\uFE18\uFE36\uFE38\uFE3A\uFE3C\uFE3E\uFE40\uFE42\uFE44\uFE48\uFE5A\uFE5C\uFE5E\uFF09\uFF3D\uFF5D\uFF60\uFF63\xBB\]}])\1*$/,
|
|
254
|
-
newLine: /^[ \t]*((\r?\n|\r)[\t ]*)+$/,
|
|
255
|
-
newLineMulti: /^[ \t]*((\r?\n|\r)[\t ]*){2,}$/,
|
|
256
|
-
terminalMarker: /^([!.?\u2026\u203D]+)$/,
|
|
257
|
-
wordSymbolInner: /^([&'\-.:=?@\xAD\xB7\u2010\u2011\u2019\u2027]|_+)$/,
|
|
258
|
-
numerical: /^(?:[\d\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])+$/,
|
|
259
|
-
digitStart: /^\d/,
|
|
260
|
-
lowerInitial: /^(?:[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0560-\u0588\u10D0-\u10FA\u10FD-\u10FF\u13F8-\u13FD\u1C80-\u1C88\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7AF\uA7B5\uA7B7\uA7B9\uA7BB\uA7BD\uA7BF\uA7C3\uA7C8\uA7CA\uA7F6\uA7FA\uAB30-\uAB5A\uAB60-\uAB68\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]|\uD801[\uDC28-\uDC4F\uDCD8-\uDCFB]|\uD803[\uDCC0-\uDCF2]|\uD806[\uDCC0-\uDCDF]|\uD81B[\uDE60-\uDE7F]|\uD835[\uDC1A-\uDC33\uDC4E-\uDC54\uDC56-\uDC67\uDC82-\uDC9B\uDCB6-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDCEA-\uDD03\uDD1E-\uDD37\uDD52-\uDD6B\uDD86-\uDD9F\uDDBA-\uDDD3\uDDEE-\uDE07\uDE22-\uDE3B\uDE56-\uDE6F\uDE8A-\uDEA5\uDEC2-\uDEDA\uDEDC-\uDEE1\uDEFC-\uDF14\uDF16-\uDF1B\uDF36-\uDF4E\uDF50-\uDF55\uDF70-\uDF88\uDF8A-\uDF8F\uDFAA-\uDFC2\uDFC4-\uDFC9\uDFCB]|\uD83A[\uDD22-\uDD43])/,
|
|
261
|
-
surrogates: /[\uD800-\uDFFF]/,
|
|
262
|
-
punctuation: /[!"'-),-/:;?[-\]_{}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u201F\u2022-\u2027\u2032-\u203A\u203C-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDFFF]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,
|
|
263
|
-
word: /[\dA-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BF2\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D63\u0D66-\u0D78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1AC0\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE6\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC52-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF]/,
|
|
264
|
-
whiteSpace: /[\t-\r \x85\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
|
|
265
|
-
};
|
|
266
|
-
var iterate = arrayIterate;
|
|
267
|
-
var unistUtilModifyChildren = modifierFactory;
|
|
268
|
-
function modifierFactory(callback) {
|
|
269
|
-
return iteratorFactory(wrapperFactory(callback));
|
|
270
|
-
}
|
|
271
|
-
function iteratorFactory(callback) {
|
|
272
|
-
return iterator;
|
|
273
|
-
function iterator(parent) {
|
|
274
|
-
var children = parent && parent.children;
|
|
275
|
-
if (!children) {
|
|
276
|
-
throw new Error('Missing children in `parent` for `modifier`');
|
|
277
|
-
}
|
|
278
|
-
iterate(children, callback, parent);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
function wrapperFactory(callback) {
|
|
282
|
-
return wrapper;
|
|
283
|
-
function wrapper(value, index) {
|
|
284
|
-
return callback(value, index, this);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
var toString$c = nlcstToString_1;
|
|
288
|
-
var modifyChildren$f = unistUtilModifyChildren;
|
|
289
|
-
var mergeInitialWordSymbol_1 = modifyChildren$f(mergeInitialWordSymbol);
|
|
290
|
-
function mergeInitialWordSymbol(child, index, parent) {
|
|
291
|
-
var children;
|
|
292
|
-
var next;
|
|
293
|
-
if (child.type !== 'SymbolNode' && child.type !== 'PunctuationNode' || toString$c(child) !== '&') {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
children = parent.children;
|
|
297
|
-
next = children[index + 1];
|
|
298
|
-
if (index !== 0 && children[index - 1].type === 'WordNode' || !(next && next.type === 'WordNode')) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
children.splice(index, 1);
|
|
302
|
-
next.children.unshift(child);
|
|
303
|
-
if (next.position && child.position) {
|
|
304
|
-
next.position.start = child.position.start;
|
|
305
|
-
}
|
|
306
|
-
return index - 1;
|
|
307
|
-
}
|
|
308
|
-
var toString$b = nlcstToString_1;
|
|
309
|
-
var modifyChildren$e = unistUtilModifyChildren;
|
|
310
|
-
var mergeFinalWordSymbol_1 = modifyChildren$e(mergeFinalWordSymbol$1);
|
|
311
|
-
function mergeFinalWordSymbol$1(child, index, parent) {
|
|
312
|
-
var children;
|
|
313
|
-
var previous;
|
|
314
|
-
var next;
|
|
315
|
-
if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && toString$b(child) === '-') {
|
|
316
|
-
children = parent.children;
|
|
317
|
-
previous = children[index - 1];
|
|
318
|
-
next = children[index + 1];
|
|
319
|
-
if ((!next || next.type !== 'WordNode') && previous && previous.type === 'WordNode') {
|
|
320
|
-
children.splice(index, 1);
|
|
321
|
-
previous.children.push(child);
|
|
322
|
-
if (previous.position && child.position) {
|
|
323
|
-
previous.position.end = child.position.end;
|
|
324
|
-
}
|
|
325
|
-
return index;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
var toString$a = nlcstToString_1;
|
|
330
|
-
var modifyChildren$d = unistUtilModifyChildren;
|
|
331
|
-
var expressions$7 = expressions$8;
|
|
332
|
-
var mergeInnerWordSymbol_1 = modifyChildren$d(mergeInnerWordSymbol);
|
|
333
|
-
var wordSymbolInner = expressions$7.wordSymbolInner;
|
|
334
|
-
function mergeInnerWordSymbol(child, index, parent) {
|
|
335
|
-
var siblings;
|
|
336
|
-
var sibling;
|
|
337
|
-
var previous;
|
|
338
|
-
var last;
|
|
339
|
-
var position;
|
|
340
|
-
var tokens;
|
|
341
|
-
var queue;
|
|
342
|
-
if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode')) {
|
|
343
|
-
siblings = parent.children;
|
|
344
|
-
previous = siblings[index - 1];
|
|
345
|
-
if (previous && previous.type === 'WordNode') {
|
|
346
|
-
position = index - 1;
|
|
347
|
-
tokens = [];
|
|
348
|
-
queue = [];
|
|
349
|
-
while (siblings[++position]) {
|
|
350
|
-
sibling = siblings[position];
|
|
351
|
-
if (sibling.type === 'WordNode') {
|
|
352
|
-
tokens = tokens.concat(queue, sibling.children);
|
|
353
|
-
queue = [];
|
|
354
|
-
} else if ((sibling.type === 'SymbolNode' || sibling.type === 'PunctuationNode') && wordSymbolInner.test(toString$a(sibling))) {
|
|
355
|
-
queue.push(sibling);
|
|
356
|
-
} else {
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (tokens.length !== 0) {
|
|
361
|
-
if (queue.length !== 0) {
|
|
362
|
-
position -= queue.length;
|
|
363
|
-
}
|
|
364
|
-
siblings.splice(index, position - index);
|
|
365
|
-
previous.children = previous.children.concat(tokens);
|
|
366
|
-
last = tokens[tokens.length - 1];
|
|
367
|
-
if (previous.position && last.position) {
|
|
368
|
-
previous.position.end = last.position.end;
|
|
369
|
-
}
|
|
370
|
-
return index;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
var toString$9 = nlcstToString_1;
|
|
376
|
-
var modifyChildren$c = unistUtilModifyChildren;
|
|
377
|
-
var mergeInnerWordSlash_1 = modifyChildren$c(mergeInnerWordSlash);
|
|
378
|
-
var slash = '/';
|
|
379
|
-
function mergeInnerWordSlash(child, index, parent) {
|
|
380
|
-
var siblings = parent.children;
|
|
381
|
-
var previous;
|
|
382
|
-
var next;
|
|
383
|
-
var previousValue;
|
|
384
|
-
var nextValue;
|
|
385
|
-
var queue;
|
|
386
|
-
var tail;
|
|
387
|
-
var count;
|
|
388
|
-
previous = siblings[index - 1];
|
|
389
|
-
next = siblings[index + 1];
|
|
390
|
-
if (previous && previous.type === 'WordNode' && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && toString$9(child) === slash) {
|
|
391
|
-
previousValue = toString$9(previous);
|
|
392
|
-
tail = child;
|
|
393
|
-
queue = [child];
|
|
394
|
-
count = 1;
|
|
395
|
-
if (next && next.type === 'WordNode') {
|
|
396
|
-
nextValue = toString$9(next);
|
|
397
|
-
tail = next;
|
|
398
|
-
queue = queue.concat(next.children);
|
|
399
|
-
count++;
|
|
400
|
-
}
|
|
401
|
-
if (previousValue.length < 3 && (!nextValue || nextValue.length < 3)) {
|
|
402
|
-
previous.children = previous.children.concat(queue);
|
|
403
|
-
siblings.splice(index, count);
|
|
404
|
-
if (previous.position && tail.position) {
|
|
405
|
-
previous.position.end = tail.position.end;
|
|
406
|
-
}
|
|
407
|
-
return index;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
var toString$8 = nlcstToString_1;
|
|
412
|
-
var modifyChildren$b = unistUtilModifyChildren;
|
|
413
|
-
var expressions$6 = expressions$8;
|
|
414
|
-
var mergeInitialisms_1 = modifyChildren$b(mergeInitialisms);
|
|
415
|
-
var numerical = expressions$6.numerical;
|
|
416
|
-
function mergeInitialisms(child, index, parent) {
|
|
417
|
-
var siblings;
|
|
418
|
-
var previous;
|
|
419
|
-
var children;
|
|
420
|
-
var length;
|
|
421
|
-
var position;
|
|
422
|
-
var otherChild;
|
|
423
|
-
var isAllDigits;
|
|
424
|
-
var value;
|
|
425
|
-
if (index !== 0 && toString$8(child) === '.') {
|
|
426
|
-
siblings = parent.children;
|
|
427
|
-
previous = siblings[index - 1];
|
|
428
|
-
children = previous.children;
|
|
429
|
-
length = children && children.length;
|
|
430
|
-
if (previous.type === 'WordNode' && length !== 1 && length % 2 !== 0) {
|
|
431
|
-
position = length;
|
|
432
|
-
isAllDigits = true;
|
|
433
|
-
while (children[--position]) {
|
|
434
|
-
otherChild = children[position];
|
|
435
|
-
value = toString$8(otherChild);
|
|
436
|
-
if (position % 2 === 0) {
|
|
437
|
-
if (value.length > 1) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (!numerical.test(value)) {
|
|
441
|
-
isAllDigits = false;
|
|
442
|
-
}
|
|
443
|
-
} else if (value !== '.') {
|
|
444
|
-
if (position < length - 2) {
|
|
445
|
-
break;
|
|
446
|
-
} else {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
if (!isAllDigits) {
|
|
452
|
-
siblings.splice(index, 1);
|
|
453
|
-
children.push(child);
|
|
454
|
-
if (previous.position && child.position) {
|
|
455
|
-
previous.position.end = child.position.end;
|
|
456
|
-
}
|
|
457
|
-
return index;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
var modifyChildren$a = unistUtilModifyChildren;
|
|
463
|
-
var mergeWords = modifyChildren$a(mergeFinalWordSymbol);
|
|
464
|
-
function mergeFinalWordSymbol(child, index, parent) {
|
|
465
|
-
var siblings = parent.children;
|
|
466
|
-
var next;
|
|
467
|
-
if (child.type === 'WordNode') {
|
|
468
|
-
next = siblings[index + 1];
|
|
469
|
-
if (next && next.type === 'WordNode') {
|
|
470
|
-
siblings.splice(index + 1, 1);
|
|
471
|
-
child.children = child.children.concat(next.children);
|
|
472
|
-
if (next.position && child.position) {
|
|
473
|
-
child.position.end = next.position.end;
|
|
474
|
-
}
|
|
475
|
-
return index;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
var visitChildren$3 = unistUtilVisitChildren;
|
|
480
|
-
var patchPosition_1 = visitChildren$3(patchPosition$1);
|
|
481
|
-
function patchPosition$1(child, index, node) {
|
|
482
|
-
var siblings = node.children;
|
|
483
|
-
if (!child.position) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
if (index === 0 && (!node.position || !node.position.start)) {
|
|
487
|
-
patch(node);
|
|
488
|
-
node.position.start = child.position.start;
|
|
489
|
-
}
|
|
490
|
-
if (index === siblings.length - 1 && (!node.position || !node.position.end)) {
|
|
491
|
-
patch(node);
|
|
492
|
-
node.position.end = child.position.end;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
function patch(node) {
|
|
496
|
-
if (!node.position) {
|
|
497
|
-
node.position = {};
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
var modifyChildren$9 = unistUtilModifyChildren;
|
|
501
|
-
var mergeNonWordSentences_1 = modifyChildren$9(mergeNonWordSentences$1);
|
|
502
|
-
function mergeNonWordSentences$1(child, index, parent) {
|
|
503
|
-
var children = child.children;
|
|
504
|
-
var position = -1;
|
|
505
|
-
var previous;
|
|
506
|
-
var next;
|
|
507
|
-
while (children[++position]) {
|
|
508
|
-
if (children[position].type === 'WordNode') {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
previous = parent.children[index - 1];
|
|
513
|
-
if (previous) {
|
|
514
|
-
previous.children = previous.children.concat(children);
|
|
515
|
-
parent.children.splice(index, 1);
|
|
516
|
-
if (previous.position && child.position) {
|
|
517
|
-
previous.position.end = child.position.end;
|
|
518
|
-
}
|
|
519
|
-
return index;
|
|
520
|
-
}
|
|
521
|
-
next = parent.children[index + 1];
|
|
522
|
-
if (next) {
|
|
523
|
-
next.children = children.concat(next.children);
|
|
524
|
-
if (next.position && child.position) {
|
|
525
|
-
next.position.start = child.position.start;
|
|
526
|
-
}
|
|
527
|
-
parent.children.splice(index, 1);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
var toString$7 = nlcstToString_1;
|
|
531
|
-
var modifyChildren$8 = unistUtilModifyChildren;
|
|
532
|
-
var expressions$5 = expressions$8;
|
|
533
|
-
var mergeAffixSymbol_1 = modifyChildren$8(mergeAffixSymbol$1);
|
|
534
|
-
var affixSymbol = expressions$5.affixSymbol;
|
|
535
|
-
function mergeAffixSymbol$1(child, index, parent) {
|
|
536
|
-
var children = child.children;
|
|
537
|
-
var first;
|
|
538
|
-
var second;
|
|
539
|
-
var previous;
|
|
540
|
-
if (children && children.length !== 0 && index !== 0) {
|
|
541
|
-
first = children[0];
|
|
542
|
-
second = children[1];
|
|
543
|
-
previous = parent.children[index - 1];
|
|
544
|
-
if ((first.type === 'SymbolNode' || first.type === 'PunctuationNode') && affixSymbol.test(toString$7(first))) {
|
|
545
|
-
previous.children.push(children.shift());
|
|
546
|
-
if (first.position && previous.position) {
|
|
547
|
-
previous.position.end = first.position.end;
|
|
548
|
-
}
|
|
549
|
-
if (second && second.position && child.position) {
|
|
550
|
-
child.position.start = second.position.start;
|
|
551
|
-
}
|
|
552
|
-
return index - 1;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
var toString$6 = nlcstToString_1;
|
|
557
|
-
var modifyChildren$7 = unistUtilModifyChildren;
|
|
558
|
-
var expressions$4 = expressions$8;
|
|
559
|
-
var mergeInitialLowerCaseLetterSentences_1 = modifyChildren$7(mergeInitialLowerCaseLetterSentences$1);
|
|
560
|
-
var lowerInitial = expressions$4.lowerInitial;
|
|
561
|
-
function mergeInitialLowerCaseLetterSentences$1(child, index, parent) {
|
|
562
|
-
var children = child.children;
|
|
563
|
-
var position;
|
|
564
|
-
var node;
|
|
565
|
-
var siblings;
|
|
566
|
-
var previous;
|
|
567
|
-
if (children && children.length !== 0 && index !== 0) {
|
|
568
|
-
position = -1;
|
|
569
|
-
while (children[++position]) {
|
|
570
|
-
node = children[position];
|
|
571
|
-
if (node.type === 'WordNode') {
|
|
572
|
-
if (!lowerInitial.test(toString$6(node))) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
siblings = parent.children;
|
|
576
|
-
previous = siblings[index - 1];
|
|
577
|
-
previous.children = previous.children.concat(children);
|
|
578
|
-
siblings.splice(index, 1);
|
|
579
|
-
if (previous.position && child.position) {
|
|
580
|
-
previous.position.end = child.position.end;
|
|
581
|
-
}
|
|
582
|
-
return index;
|
|
583
|
-
}
|
|
584
|
-
if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
var toString$5 = nlcstToString_1;
|
|
591
|
-
var modifyChildren$6 = unistUtilModifyChildren;
|
|
592
|
-
var expressions$3 = expressions$8;
|
|
593
|
-
var mergeInitialDigitSentences_1 = modifyChildren$6(mergeInitialDigitSentences$1);
|
|
594
|
-
var digit = expressions$3.digitStart;
|
|
595
|
-
function mergeInitialDigitSentences$1(child, index, parent) {
|
|
596
|
-
var children = child.children;
|
|
597
|
-
var siblings = parent.children;
|
|
598
|
-
var previous = siblings[index - 1];
|
|
599
|
-
var head = children[0];
|
|
600
|
-
if (previous && head && head.type === 'WordNode' && digit.test(toString$5(head))) {
|
|
601
|
-
previous.children = previous.children.concat(children);
|
|
602
|
-
siblings.splice(index, 1);
|
|
603
|
-
if (previous.position && child.position) {
|
|
604
|
-
previous.position.end = child.position.end;
|
|
605
|
-
}
|
|
606
|
-
return index;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
var toString$4 = nlcstToString_1;
|
|
610
|
-
var modifyChildren$5 = unistUtilModifyChildren;
|
|
611
|
-
var mergePrefixExceptions_1 = modifyChildren$5(mergePrefixExceptions);
|
|
612
|
-
var abbreviationPrefix = new RegExp('^(' + '[0-9]{1,3}|' + '[a-z]|' + 'al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|' + 'fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz' + ')$');
|
|
613
|
-
function mergePrefixExceptions(child, index, parent) {
|
|
614
|
-
var children = child.children;
|
|
615
|
-
var period;
|
|
616
|
-
var node;
|
|
617
|
-
var next;
|
|
618
|
-
if (children && children.length > 1) {
|
|
619
|
-
period = children[children.length - 1];
|
|
620
|
-
if (period && toString$4(period) === '.') {
|
|
621
|
-
node = children[children.length - 2];
|
|
622
|
-
if (node && node.type === 'WordNode' && abbreviationPrefix.test(toString$4(node).toLowerCase())) {
|
|
623
|
-
node.children.push(period);
|
|
624
|
-
children.pop();
|
|
625
|
-
if (period.position && node.position) {
|
|
626
|
-
node.position.end = period.position.end;
|
|
627
|
-
}
|
|
628
|
-
next = parent.children[index + 1];
|
|
629
|
-
if (next) {
|
|
630
|
-
child.children = children.concat(next.children);
|
|
631
|
-
parent.children.splice(index + 1, 1);
|
|
632
|
-
if (next.position && child.position) {
|
|
633
|
-
child.position.end = next.position.end;
|
|
634
|
-
}
|
|
635
|
-
return index - 1;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
var toString$3 = nlcstToString_1;
|
|
642
|
-
var modifyChildren$4 = unistUtilModifyChildren;
|
|
643
|
-
var mergeAffixExceptions_1 = modifyChildren$4(mergeAffixExceptions$1);
|
|
644
|
-
function mergeAffixExceptions$1(child, index, parent) {
|
|
645
|
-
var children = child.children;
|
|
646
|
-
var node;
|
|
647
|
-
var position;
|
|
648
|
-
var value;
|
|
649
|
-
var previousChild;
|
|
650
|
-
if (!children || children.length === 0 || index === 0) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
position = -1;
|
|
654
|
-
while (children[++position]) {
|
|
655
|
-
node = children[position];
|
|
656
|
-
if (node.type === 'WordNode') {
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
|
|
660
|
-
value = toString$3(node);
|
|
661
|
-
if (value !== ',' && value !== ';') {
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
previousChild = parent.children[index - 1];
|
|
665
|
-
previousChild.children = previousChild.children.concat(children);
|
|
666
|
-
if (previousChild.position && child.position) {
|
|
667
|
-
previousChild.position.end = child.position.end;
|
|
668
|
-
}
|
|
669
|
-
parent.children.splice(index, 1);
|
|
670
|
-
return index;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
var toString$2 = nlcstToString_1;
|
|
675
|
-
var visitChildren$2 = unistUtilVisitChildren;
|
|
676
|
-
var expressions$2 = expressions$8;
|
|
677
|
-
var mergeRemainingFullStops_1 = visitChildren$2(mergeRemainingFullStops$1);
|
|
678
|
-
var terminalMarker = expressions$2.terminalMarker;
|
|
679
|
-
function mergeRemainingFullStops$1(child) {
|
|
680
|
-
var children = child.children;
|
|
681
|
-
var position = children.length;
|
|
682
|
-
var hasFoundDelimiter = false;
|
|
683
|
-
var grandchild;
|
|
684
|
-
var previous;
|
|
685
|
-
var next;
|
|
686
|
-
var nextNext;
|
|
687
|
-
while (children[--position]) {
|
|
688
|
-
grandchild = children[position];
|
|
689
|
-
if (grandchild.type !== 'SymbolNode' && grandchild.type !== 'PunctuationNode') {
|
|
690
|
-
if (grandchild.type === 'WordNode') {
|
|
691
|
-
hasFoundDelimiter = true;
|
|
692
|
-
}
|
|
693
|
-
continue;
|
|
694
|
-
}
|
|
695
|
-
if (!terminalMarker.test(toString$2(grandchild))) {
|
|
696
|
-
continue;
|
|
697
|
-
}
|
|
698
|
-
if (!hasFoundDelimiter) {
|
|
699
|
-
hasFoundDelimiter = true;
|
|
700
|
-
continue;
|
|
701
|
-
}
|
|
702
|
-
if (toString$2(grandchild) !== '.') {
|
|
703
|
-
continue;
|
|
704
|
-
}
|
|
705
|
-
previous = children[position - 1];
|
|
706
|
-
next = children[position + 1];
|
|
707
|
-
if (previous && previous.type === 'WordNode') {
|
|
708
|
-
nextNext = children[position + 2];
|
|
709
|
-
if (next && nextNext && next.type === 'WhiteSpaceNode' && toString$2(nextNext) === '.') {
|
|
710
|
-
continue;
|
|
711
|
-
}
|
|
712
|
-
children.splice(position, 1);
|
|
713
|
-
previous.children.push(grandchild);
|
|
714
|
-
if (grandchild.position && previous.position) {
|
|
715
|
-
previous.position.end = grandchild.position.end;
|
|
716
|
-
}
|
|
717
|
-
position--;
|
|
718
|
-
} else if (next && next.type === 'WordNode') {
|
|
719
|
-
children.splice(position, 1);
|
|
720
|
-
next.children.unshift(grandchild);
|
|
721
|
-
if (grandchild.position && next.position) {
|
|
722
|
-
next.position.start = grandchild.position.start;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
var visitChildren$1 = unistUtilVisitChildren;
|
|
728
|
-
var makeInitialWhiteSpaceSiblings_1 = visitChildren$1(makeInitialWhiteSpaceSiblings$1);
|
|
729
|
-
function makeInitialWhiteSpaceSiblings$1(child, index, parent) {
|
|
730
|
-
var children = child.children;
|
|
731
|
-
var next;
|
|
732
|
-
if (children && children.length !== 0 && children[0].type === 'WhiteSpaceNode') {
|
|
733
|
-
parent.children.splice(index, 0, children.shift());
|
|
734
|
-
next = children[0];
|
|
735
|
-
if (next && next.position && child.position) {
|
|
736
|
-
child.position.start = next.position.start;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
var modifyChildren$3 = unistUtilModifyChildren;
|
|
741
|
-
var makeFinalWhiteSpaceSiblings_1 = modifyChildren$3(makeFinalWhiteSpaceSiblings$1);
|
|
742
|
-
function makeFinalWhiteSpaceSiblings$1(child, index, parent) {
|
|
743
|
-
var children = child.children;
|
|
744
|
-
var previous;
|
|
745
|
-
if (children && children.length !== 0 && children[children.length - 1].type === 'WhiteSpaceNode') {
|
|
746
|
-
parent.children.splice(index + 1, 0, child.children.pop());
|
|
747
|
-
previous = children[children.length - 1];
|
|
748
|
-
if (previous && previous.position && child.position) {
|
|
749
|
-
child.position.end = previous.position.end;
|
|
750
|
-
}
|
|
751
|
-
return index;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
var toString$1 = nlcstToString_1;
|
|
755
|
-
var modifyChildren$2 = unistUtilModifyChildren;
|
|
756
|
-
var expressions$1 = expressions$8;
|
|
757
|
-
var breakImplicitSentences_1 = modifyChildren$2(breakImplicitSentences$1);
|
|
758
|
-
var multiNewLine = expressions$1.newLineMulti;
|
|
759
|
-
function breakImplicitSentences$1(child, index, parent) {
|
|
760
|
-
var children;
|
|
761
|
-
var position;
|
|
762
|
-
var length;
|
|
763
|
-
var tail;
|
|
764
|
-
var head;
|
|
765
|
-
var end;
|
|
766
|
-
var insertion;
|
|
767
|
-
var node;
|
|
768
|
-
if (child.type !== 'SentenceNode') {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
children = child.children;
|
|
772
|
-
length = children.length - 1;
|
|
773
|
-
position = 0;
|
|
774
|
-
while (++position < length) {
|
|
775
|
-
node = children[position];
|
|
776
|
-
if (node.type !== 'WhiteSpaceNode' || !multiNewLine.test(toString$1(node))) {
|
|
777
|
-
continue;
|
|
778
|
-
}
|
|
779
|
-
child.children = children.slice(0, position);
|
|
780
|
-
insertion = {
|
|
781
|
-
type: 'SentenceNode',
|
|
782
|
-
children: children.slice(position + 1)
|
|
783
|
-
};
|
|
784
|
-
tail = children[position - 1];
|
|
785
|
-
head = children[position + 1];
|
|
786
|
-
parent.children.splice(index + 1, 0, node, insertion);
|
|
787
|
-
if (child.position && tail.position && head.position) {
|
|
788
|
-
end = child.position.end;
|
|
789
|
-
child.position.end = tail.position.end;
|
|
790
|
-
insertion.position = {
|
|
791
|
-
start: head.position.start,
|
|
792
|
-
end: end
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
return index + 1;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
var modifyChildren$1 = unistUtilModifyChildren;
|
|
799
|
-
var removeEmptyNodes_1 = modifyChildren$1(removeEmptyNodes$1);
|
|
800
|
-
function removeEmptyNodes$1(child, index, parent) {
|
|
801
|
-
if (('children' in child) && child.children.length === 0) {
|
|
802
|
-
parent.children.splice(index, 1);
|
|
803
|
-
return index;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
var createParser = parser;
|
|
807
|
-
var expressions = expressions$8;
|
|
808
|
-
var lib = ParseLatin;
|
|
809
|
-
function ParseLatin(doc, file) {
|
|
810
|
-
var value = file || doc;
|
|
811
|
-
if (!(this instanceof ParseLatin)) {
|
|
812
|
-
return new ParseLatin(doc, file);
|
|
813
|
-
}
|
|
814
|
-
this.doc = value ? String(value) : null;
|
|
815
|
-
}
|
|
816
|
-
var proto$1 = ParseLatin.prototype;
|
|
817
|
-
proto$1.position = true;
|
|
818
|
-
proto$1.tokenizeSymbol = createTextFactory('Symbol');
|
|
819
|
-
proto$1.tokenizeWhiteSpace = createTextFactory('WhiteSpace');
|
|
820
|
-
proto$1.tokenizePunctuation = createTextFactory('Punctuation');
|
|
821
|
-
proto$1.tokenizeSource = createTextFactory('Source');
|
|
822
|
-
proto$1.tokenizeText = createTextFactory('Text');
|
|
823
|
-
proto$1.run = run;
|
|
824
|
-
proto$1.use = useFactory(function (context, key, plugins) {
|
|
825
|
-
context[key] = context[key].concat(plugins);
|
|
826
|
-
});
|
|
827
|
-
proto$1.useFirst = useFactory(function (context, key, plugins) {
|
|
828
|
-
context[key] = plugins.concat(context[key]);
|
|
829
|
-
});
|
|
830
|
-
proto$1.parse = function (value) {
|
|
831
|
-
return this.tokenizeRoot(value || this.doc);
|
|
832
|
-
};
|
|
833
|
-
proto$1.tokenize = function (value) {
|
|
834
|
-
return tokenize(this, value);
|
|
835
|
-
};
|
|
836
|
-
pluggable(ParseLatin, 'tokenizeWord', function (value, eat) {
|
|
837
|
-
var add = (eat || noopEat)('');
|
|
838
|
-
var parent = {
|
|
839
|
-
type: 'WordNode',
|
|
840
|
-
children: []
|
|
841
|
-
};
|
|
842
|
-
this.tokenizeText(value, eat, parent);
|
|
843
|
-
return add(parent);
|
|
844
|
-
});
|
|
845
|
-
pluggable(ParseLatin, 'tokenizeSentence', createParser({
|
|
846
|
-
type: 'SentenceNode',
|
|
847
|
-
tokenizer: 'tokenize'
|
|
848
|
-
}));
|
|
849
|
-
pluggable(ParseLatin, 'tokenizeParagraph', createParser({
|
|
850
|
-
type: 'ParagraphNode',
|
|
851
|
-
delimiter: expressions.terminalMarker,
|
|
852
|
-
delimiterType: 'PunctuationNode',
|
|
853
|
-
tokenizer: 'tokenizeSentence'
|
|
854
|
-
}));
|
|
855
|
-
pluggable(ParseLatin, 'tokenizeRoot', createParser({
|
|
856
|
-
type: 'RootNode',
|
|
857
|
-
delimiter: expressions.newLine,
|
|
858
|
-
delimiterType: 'WhiteSpaceNode',
|
|
859
|
-
tokenizer: 'tokenizeParagraph'
|
|
860
|
-
}));
|
|
861
|
-
proto$1.use('tokenizeSentence', [mergeInitialWordSymbol_1, mergeFinalWordSymbol_1, mergeInnerWordSymbol_1, mergeInnerWordSlash_1, mergeInitialisms_1, mergeWords, patchPosition_1]);
|
|
862
|
-
proto$1.use('tokenizeParagraph', [mergeNonWordSentences_1, mergeAffixSymbol_1, mergeInitialLowerCaseLetterSentences_1, mergeInitialDigitSentences_1, mergePrefixExceptions_1, mergeAffixExceptions_1, mergeRemainingFullStops_1, makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, breakImplicitSentences_1, removeEmptyNodes_1, patchPosition_1]);
|
|
863
|
-
proto$1.use('tokenizeRoot', [makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, removeEmptyNodes_1, patchPosition_1]);
|
|
864
|
-
function createTextFactory(type) {
|
|
865
|
-
type += 'Node';
|
|
866
|
-
return createText;
|
|
867
|
-
function createText(value, eat, parent) {
|
|
868
|
-
if (value === null || value === undefined) {
|
|
869
|
-
value = '';
|
|
870
|
-
}
|
|
871
|
-
return (eat || noopEat)(value)({
|
|
872
|
-
type: type,
|
|
873
|
-
value: String(value)
|
|
874
|
-
}, parent);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
function run(key, nodes) {
|
|
878
|
-
var wareKey = key + 'Plugins';
|
|
879
|
-
var plugins = this[wareKey];
|
|
880
|
-
var index = -1;
|
|
881
|
-
if (plugins) {
|
|
882
|
-
while (plugins[++index]) {
|
|
883
|
-
plugins[index](nodes);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
return nodes;
|
|
887
|
-
}
|
|
888
|
-
function pluggable(Constructor, key, callback) {
|
|
889
|
-
Constructor.prototype[key] = function () {
|
|
890
|
-
return this.run(key, callback.apply(this, arguments));
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
function useFactory(callback) {
|
|
894
|
-
return use;
|
|
895
|
-
function use(key, plugins) {
|
|
896
|
-
var self = this;
|
|
897
|
-
var wareKey;
|
|
898
|
-
if (!((key in self))) {
|
|
899
|
-
throw new Error('Illegal Invocation: Unsupported `key` for ' + '`use(key, plugins)`. Make sure `key` is a ' + 'supported function');
|
|
900
|
-
}
|
|
901
|
-
if (!plugins) {
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
wareKey = key + 'Plugins';
|
|
905
|
-
if (typeof plugins === 'function') {
|
|
906
|
-
plugins = [plugins];
|
|
907
|
-
} else {
|
|
908
|
-
plugins = plugins.concat();
|
|
909
|
-
}
|
|
910
|
-
if (!self[wareKey]) {
|
|
911
|
-
self[wareKey] = [];
|
|
912
|
-
}
|
|
913
|
-
callback(self, wareKey, plugins);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
var wordRe = expressions.word;
|
|
917
|
-
var surrogatesRe = expressions.surrogates;
|
|
918
|
-
var punctuationRe = expressions.punctuation;
|
|
919
|
-
var whiteSpaceRe = expressions.whiteSpace;
|
|
920
|
-
function tokenize(parser, value) {
|
|
921
|
-
var tokens;
|
|
922
|
-
var offset;
|
|
923
|
-
var line;
|
|
924
|
-
var column;
|
|
925
|
-
var index;
|
|
926
|
-
var length;
|
|
927
|
-
var character;
|
|
928
|
-
var queue;
|
|
929
|
-
var previous;
|
|
930
|
-
var left;
|
|
931
|
-
var right;
|
|
932
|
-
var eater;
|
|
933
|
-
if (value === null || value === undefined) {
|
|
934
|
-
value = '';
|
|
935
|
-
} else if (value instanceof String) {
|
|
936
|
-
value = value.toString();
|
|
937
|
-
}
|
|
938
|
-
if (typeof value !== 'string') {
|
|
939
|
-
if (('length' in value) && (!value[0] || value[0].type)) {
|
|
940
|
-
return value;
|
|
941
|
-
}
|
|
942
|
-
throw new Error("Illegal invocation: '" + value + "' is not a valid argument for 'ParseLatin'");
|
|
943
|
-
}
|
|
944
|
-
tokens = [];
|
|
945
|
-
if (!value) {
|
|
946
|
-
return tokens;
|
|
947
|
-
}
|
|
948
|
-
index = 0;
|
|
949
|
-
offset = 0;
|
|
950
|
-
line = 1;
|
|
951
|
-
column = 1;
|
|
952
|
-
eater = parser.position ? eat : noPositionEat;
|
|
953
|
-
length = value.length;
|
|
954
|
-
previous = '';
|
|
955
|
-
queue = '';
|
|
956
|
-
while (index < length) {
|
|
957
|
-
character = value.charAt(index);
|
|
958
|
-
if (whiteSpaceRe.test(character)) {
|
|
959
|
-
right = 'WhiteSpace';
|
|
960
|
-
} else if (punctuationRe.test(character)) {
|
|
961
|
-
right = 'Punctuation';
|
|
962
|
-
} else if (wordRe.test(character)) {
|
|
963
|
-
right = 'Word';
|
|
964
|
-
} else {
|
|
965
|
-
right = 'Symbol';
|
|
966
|
-
}
|
|
967
|
-
tick();
|
|
968
|
-
previous = character;
|
|
969
|
-
character = '';
|
|
970
|
-
left = right;
|
|
971
|
-
right = null;
|
|
972
|
-
index++;
|
|
973
|
-
}
|
|
974
|
-
tick();
|
|
975
|
-
return tokens;
|
|
976
|
-
function tick() {
|
|
977
|
-
if (left === right && (left === 'Word' || left === 'WhiteSpace' || character === previous || surrogatesRe.test(character))) {
|
|
978
|
-
queue += character;
|
|
979
|
-
} else {
|
|
980
|
-
if (queue) {
|
|
981
|
-
parser['tokenize' + left](queue, eater);
|
|
982
|
-
}
|
|
983
|
-
queue = character;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
function eat(subvalue) {
|
|
987
|
-
var pos = position();
|
|
988
|
-
update(subvalue);
|
|
989
|
-
return apply;
|
|
990
|
-
function apply() {
|
|
991
|
-
return pos(add.apply(null, arguments));
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
function noPositionEat() {
|
|
995
|
-
return apply;
|
|
996
|
-
function apply() {
|
|
997
|
-
return add.apply(null, arguments);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
function add(node, parent) {
|
|
1001
|
-
if (parent) {
|
|
1002
|
-
parent.children.push(node);
|
|
1003
|
-
} else {
|
|
1004
|
-
tokens.push(node);
|
|
1005
|
-
}
|
|
1006
|
-
return node;
|
|
1007
|
-
}
|
|
1008
|
-
function position() {
|
|
1009
|
-
var before = now();
|
|
1010
|
-
function patch(node) {
|
|
1011
|
-
node.position = new Position(before);
|
|
1012
|
-
return node;
|
|
1013
|
-
}
|
|
1014
|
-
return patch;
|
|
1015
|
-
}
|
|
1016
|
-
function update(subvalue) {
|
|
1017
|
-
var subvalueLength = subvalue.length;
|
|
1018
|
-
var character = -1;
|
|
1019
|
-
var lastIndex = -1;
|
|
1020
|
-
offset += subvalueLength;
|
|
1021
|
-
while (++character < subvalueLength) {
|
|
1022
|
-
if (subvalue.charAt(character) === '\n') {
|
|
1023
|
-
lastIndex = character;
|
|
1024
|
-
line++;
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
if (lastIndex === -1) {
|
|
1028
|
-
column += subvalueLength;
|
|
1029
|
-
} else {
|
|
1030
|
-
column = subvalueLength - lastIndex;
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
function Position(start) {
|
|
1034
|
-
this.start = start;
|
|
1035
|
-
this.end = now();
|
|
1036
|
-
}
|
|
1037
|
-
function now() {
|
|
1038
|
-
return {
|
|
1039
|
-
line: line,
|
|
1040
|
-
column: column,
|
|
1041
|
-
offset: offset
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
function noopAdd(node, parent) {
|
|
1046
|
-
if (parent) {
|
|
1047
|
-
parent.children.push(node);
|
|
1048
|
-
}
|
|
1049
|
-
return node;
|
|
1050
|
-
}
|
|
1051
|
-
function noopEat() {
|
|
1052
|
-
return noopAdd;
|
|
1053
|
-
}
|
|
1054
|
-
var parseLatin = lib;
|
|
1055
|
-
var toString = nlcstToString_1;
|
|
1056
|
-
var visitChildren = unistUtilVisitChildren;
|
|
1057
|
-
var modifyChildren = unistUtilModifyChildren$1;
|
|
1058
|
-
var Parser = parseLatin;
|
|
1059
|
-
var mergeNonWordSentences = mergeNonWordSentences_1;
|
|
1060
|
-
var mergeAffixSymbol = mergeAffixSymbol_1;
|
|
1061
|
-
var mergeInitialLowerCaseLetterSentences = mergeInitialLowerCaseLetterSentences_1;
|
|
1062
|
-
var mergeInitialDigitSentences = mergeInitialDigitSentences_1;
|
|
1063
|
-
var mergeAffixExceptions = mergeAffixExceptions_1;
|
|
1064
|
-
var mergeRemainingFullStops = mergeRemainingFullStops_1;
|
|
1065
|
-
var makeInitialWhiteSpaceSiblings = makeInitialWhiteSpaceSiblings_1;
|
|
1066
|
-
var makeFinalWhiteSpaceSiblings = makeFinalWhiteSpaceSiblings_1;
|
|
1067
|
-
var breakImplicitSentences = breakImplicitSentences_1;
|
|
1068
|
-
var removeEmptyNodes = removeEmptyNodes_1;
|
|
1069
|
-
var patchPosition = patchPosition_1;
|
|
1070
|
-
var parseEnglish = ParseEnglish;
|
|
1071
|
-
ParserPrototype.prototype = Parser.prototype;
|
|
1072
|
-
var proto = new ParserPrototype();
|
|
1073
|
-
ParseEnglish.prototype = proto;
|
|
1074
|
-
proto.tokenizeSentencePlugins = [visitChildren(mergeEnglishElisionExceptions)].concat(proto.tokenizeSentencePlugins);
|
|
1075
|
-
proto.tokenizeParagraphPlugins = [modifyChildren(mergeEnglishPrefixExceptions)].concat([mergeNonWordSentences, mergeAffixSymbol, mergeInitialLowerCaseLetterSentences, mergeInitialDigitSentences, mergeAffixExceptions, mergeRemainingFullStops, makeInitialWhiteSpaceSiblings, makeFinalWhiteSpaceSiblings, breakImplicitSentences, removeEmptyNodes, patchPosition]);
|
|
1076
|
-
function ParseEnglish(doc, file) {
|
|
1077
|
-
if (!(this instanceof ParseEnglish)) {
|
|
1078
|
-
return new ParseEnglish(doc, file);
|
|
1079
|
-
}
|
|
1080
|
-
Parser.apply(this, arguments);
|
|
1081
|
-
}
|
|
1082
|
-
function ParserPrototype() {}
|
|
1083
|
-
var abbreviations = new RegExp('^(' + 'al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|' + 'fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz' + 'inc|ltd|' + 'bbls?|cu|doz|fl|ft|gal|gr|gro|in|kt|lbs?|mi|oz|pt|qt|sq|tbsp|' + 'tsp|yds?|' + 'sec|min|hr|mon|tue|tues|wed|thu|thurs|fri|sat|sun|jan|feb|mar|' + 'apr|jun|jul|aug|sep|sept|oct|nov|dec' + ')$');
|
|
1084
|
-
var abbreviationsSensitive = new RegExp('^(' + 'Mr|Mrs|Miss|Ms|Mss|Mses|Mlle|Mme|M|Messrs|Mmes|Jr|Sr|Snr|' + 'Dr|Mgr|Atty|Prof|Hon|Rev|Fr|Msgr|Sr|Br|St|Pres|Supt|Rep|Sen|' + 'Gov|Amb|Treas|Sec|Amd|Brig|Gen|Cdr|Col|Capt|Lt|Maj|Sgt|Po|Wo|Ph|' + 'Ave|Blvd|Mt|Rd|Bldgs?|Nat|Natl|Rt|Rte|Co|Pk|Sq|Dr|Pt|St|' + 'Ft|Pen|Terr|Hwy|Fwy|Pkwy|' + 'Ala|Ariz|Ark|Cal|Calif|Col|Colo|Conn|Del|Fla|Ga|Ida|Id|Ill|Ind|' + 'Ia|Kan|Kans|Ken|Ky|La|Me|Md|Mass|Mich|Minn|Miss|Mo|Mont|Neb|' + 'Nebr|Nev|Mex|Dak|Okla|Ok|Ore|Penna|Penn|Pa|Tenn|Tex|Ut|Vt|Va|' + 'Wash|Wis|Wisc|Wyo|' + 'Alta|Man|Ont|Qu\u00E9|Que|Sask|Yuk|' + 'Beds|Berks|Bucks|Cambs|Ches|Corn|Cumb|Derbys|Derbs|Dev|Dor|Dur|' + 'Glos|Hants|Here|Heref|Herts|Hunts|Lancs|Leics|Lincs|Mx|Middx|Mddx|' + 'Norf|Northants|Northumb|Northd|Notts|Oxon|Rut|Shrops|Salop|Som|' + 'Staffs|Staf|Suff|Sy|Sx|Ssx|Warks|War|Warw|Westm|Wilts|Worcs|Yorks' + ')$');
|
|
1085
|
-
var elisionPrefix = new RegExp('^(' + 'o|ol' + ')$');
|
|
1086
|
-
var elisionAffix = new RegExp('^(' + 'im|er|em|cause|' + 'twas|tis|twere|' + '\\d\\ds?' + ')$');
|
|
1087
|
-
var apostrophe = /^['\u2019]$/;
|
|
1088
|
-
function mergeEnglishPrefixExceptions(sentence, index, paragraph) {
|
|
1089
|
-
var children = sentence.children;
|
|
1090
|
-
var period = children[children.length - 1];
|
|
1091
|
-
var word = children[children.length - 2];
|
|
1092
|
-
var value;
|
|
1093
|
-
var next;
|
|
1094
|
-
if (period && toString(period) === '.' && word && word.type === 'WordNode') {
|
|
1095
|
-
value = toString(word);
|
|
1096
|
-
if (abbreviations.test(lower(value)) || abbreviationsSensitive.test(value)) {
|
|
1097
|
-
word.children.push(period);
|
|
1098
|
-
children.pop();
|
|
1099
|
-
if (period.position && word.position) {
|
|
1100
|
-
word.position.end = period.position.end;
|
|
1101
|
-
}
|
|
1102
|
-
next = paragraph.children[index + 1];
|
|
1103
|
-
if (next) {
|
|
1104
|
-
sentence.children = children.concat(next.children);
|
|
1105
|
-
paragraph.children.splice(index + 1, 1);
|
|
1106
|
-
if (next.position && sentence.position) {
|
|
1107
|
-
sentence.position.end = next.position.end;
|
|
1108
|
-
}
|
|
1109
|
-
return index - 1;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
function mergeEnglishElisionExceptions(child, index, sentence) {
|
|
1115
|
-
var siblings;
|
|
1116
|
-
var sibling;
|
|
1117
|
-
var other;
|
|
1118
|
-
var length;
|
|
1119
|
-
var value;
|
|
1120
|
-
if (child.type !== 'PunctuationNode' && child.type !== 'SymbolNode') {
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
siblings = sentence.children;
|
|
1124
|
-
length = siblings.length;
|
|
1125
|
-
value = toString(child);
|
|
1126
|
-
if (value === '/') {
|
|
1127
|
-
sibling = siblings[index - 1];
|
|
1128
|
-
if (sibling && lower(toString(sibling)) === 'w') {
|
|
1129
|
-
siblings.splice(index, 1);
|
|
1130
|
-
sibling.children.push(child);
|
|
1131
|
-
if (sibling.position && child.position) {
|
|
1132
|
-
sibling.position.end = child.position.end;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
} else if (apostrophe.test(value)) {
|
|
1136
|
-
sibling = siblings[index - 1];
|
|
1137
|
-
if (index > 2 && index < length - 1 && sibling.type === 'WordNode' && siblings[index - 2].type === 'WhiteSpaceNode' && siblings[index + 1].type === 'WhiteSpaceNode' && elisionPrefix.test(lower(toString(sibling)))) {
|
|
1138
|
-
siblings.splice(index, 1);
|
|
1139
|
-
sibling.children.push(child);
|
|
1140
|
-
if (sibling.position && child.position) {
|
|
1141
|
-
sibling.position.end = child.position.end;
|
|
1142
|
-
}
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
if (index !== length - 1 && siblings[index + 1].type === 'WordNode' && (index === 0 || siblings[index - 1].type !== 'WordNode')) {
|
|
1146
|
-
sibling = siblings[index + 1];
|
|
1147
|
-
value = lower(toString(sibling));
|
|
1148
|
-
if (elisionAffix.test(value)) {
|
|
1149
|
-
siblings.splice(index, 1);
|
|
1150
|
-
sibling.children = [child].concat(sibling.children);
|
|
1151
|
-
if (sibling.position && child.position) {
|
|
1152
|
-
sibling.position.start = child.position.start;
|
|
1153
|
-
}
|
|
1154
|
-
} else if (value === 'n' && index < length - 2 && apostrophe.test(toString(siblings[index + 2]))) {
|
|
1155
|
-
other = siblings[index + 2];
|
|
1156
|
-
siblings.splice(index, 1);
|
|
1157
|
-
siblings.splice(index + 1, 1);
|
|
1158
|
-
sibling.children = [child].concat(sibling.children, other);
|
|
1159
|
-
if (sibling.position) {
|
|
1160
|
-
if (child.position) {
|
|
1161
|
-
sibling.position.start = child.position.start;
|
|
1162
|
-
}
|
|
1163
|
-
if (other.position) {
|
|
1164
|
-
sibling.position.end = other.position.end;
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
function lower(value) {
|
|
1172
|
-
return value.toLowerCase();
|
|
1173
|
-
}
|
|
1174
|
-
const {compact: compact} = _dll_lodash;
|
|
1175
|
-
const {clone: clone$2} = _dll_lodash;
|
|
1176
|
-
const g = (str, node) => {
|
|
1177
|
-
if (node.children) {
|
|
1178
|
-
return node.children.reduce(g, str);
|
|
1179
|
-
} else if (node.value) {
|
|
1180
|
-
return str + node.value;
|
|
1181
|
-
} else {
|
|
1182
|
-
return str;
|
|
1183
|
-
}
|
|
1184
|
-
};
|
|
1185
|
-
const getParagraph = p => g('', p);
|
|
1186
|
-
const getSentence = s => g('', s);
|
|
1187
|
-
const getWord = w => g('', w);
|
|
1188
|
-
const paragraphs = text => {
|
|
1189
|
-
const tree = new parseEnglish().parse(text);
|
|
1190
|
-
const out = tree.children.reduce((acc, child) => {
|
|
1191
|
-
if (child.type === 'ParagraphNode') {
|
|
1192
|
-
const paragraph = {
|
|
1193
|
-
text: getParagraph(child),
|
|
1194
|
-
start: child.position.start.offset,
|
|
1195
|
-
end: child.position.end.offset
|
|
1196
|
-
};
|
|
1197
|
-
return acc.concat([paragraph]);
|
|
1198
|
-
} else {
|
|
1199
|
-
return acc;
|
|
1200
|
-
}
|
|
1201
|
-
}, []);
|
|
1202
|
-
return out;
|
|
1203
|
-
};
|
|
1204
|
-
const handleSentence = (child, acc) => {
|
|
1205
|
-
const sentenceChilds = [];
|
|
1206
|
-
let newAcc = child.children.reduce(function (acc, child) {
|
|
1207
|
-
if (child.type === 'WhiteSpaceNode' && child.value === '\n') {
|
|
1208
|
-
if (sentenceChilds.length) {
|
|
1209
|
-
const firstWord = sentenceChilds[0];
|
|
1210
|
-
const sentence = {
|
|
1211
|
-
text: sentenceChilds.map(d => getSentence(d)).join(''),
|
|
1212
|
-
start: firstWord.position.start.offset,
|
|
1213
|
-
end: child.position.start.offset
|
|
1214
|
-
};
|
|
1215
|
-
sentenceChilds.splice(0, sentenceChilds.length);
|
|
1216
|
-
return acc.concat([sentence]);
|
|
1217
|
-
}
|
|
1218
|
-
} else {
|
|
1219
|
-
sentenceChilds.push(child);
|
|
1220
|
-
}
|
|
1221
|
-
return acc;
|
|
1222
|
-
}, acc);
|
|
1223
|
-
if (sentenceChilds.length) {
|
|
1224
|
-
const firstWord = sentenceChilds[0];
|
|
1225
|
-
const lastWord = sentenceChilds[sentenceChilds.length - 1];
|
|
1226
|
-
const sentence = {
|
|
1227
|
-
text: sentenceChilds.map(d => getSentence(d)).join(''),
|
|
1228
|
-
start: firstWord.position.start.offset,
|
|
1229
|
-
end: lastWord.position.end.offset
|
|
1230
|
-
};
|
|
1231
|
-
newAcc = newAcc.concat([sentence]);
|
|
1232
|
-
sentenceChilds.splice(0, sentenceChilds.length);
|
|
1233
|
-
}
|
|
1234
|
-
return newAcc;
|
|
1235
|
-
};
|
|
1236
|
-
const sentences = text => {
|
|
1237
|
-
const tree = new parseEnglish().parse(text);
|
|
1238
|
-
const out = tree.children.reduce((acc, child) => {
|
|
1239
|
-
if (child.type === 'ParagraphNode') {
|
|
1240
|
-
return child.children.reduce((acc, child) => {
|
|
1241
|
-
if (child.type === 'SentenceNode') {
|
|
1242
|
-
const newAcc = handleSentence(child, acc);
|
|
1243
|
-
return newAcc || acc;
|
|
1244
|
-
} else {
|
|
1245
|
-
return acc;
|
|
1246
|
-
}
|
|
1247
|
-
}, acc);
|
|
1248
|
-
} else {
|
|
1249
|
-
return acc;
|
|
1250
|
-
}
|
|
1251
|
-
}, []);
|
|
1252
|
-
return out;
|
|
1253
|
-
};
|
|
1254
|
-
const words = text => {
|
|
1255
|
-
const tree = new parseEnglish().parse(text);
|
|
1256
|
-
const out = tree.children.reduce((acc, child) => {
|
|
1257
|
-
if (child.type === 'ParagraphNode') {
|
|
1258
|
-
return child.children.reduce((acc, child) => {
|
|
1259
|
-
if (child.type === 'SentenceNode') {
|
|
1260
|
-
return child.children.reduce((acc, child) => {
|
|
1261
|
-
if (child.type === 'WordNode') {
|
|
1262
|
-
const node = {
|
|
1263
|
-
text: getWord(child),
|
|
1264
|
-
start: child.position.start.offset,
|
|
1265
|
-
end: child.position.end.offset
|
|
1266
|
-
};
|
|
1267
|
-
return acc.concat([node]);
|
|
1268
|
-
} else {
|
|
1269
|
-
return acc;
|
|
1270
|
-
}
|
|
1271
|
-
}, acc);
|
|
1272
|
-
} else {
|
|
1273
|
-
return acc;
|
|
1274
|
-
}
|
|
1275
|
-
}, acc);
|
|
1276
|
-
} else {
|
|
1277
|
-
return acc;
|
|
1278
|
-
}
|
|
1279
|
-
}, []);
|
|
1280
|
-
return out;
|
|
1281
|
-
};
|
|
1282
|
-
class Intersection {
|
|
1283
|
-
constructor(results) {
|
|
1284
|
-
this.results = results;
|
|
1285
|
-
}
|
|
1286
|
-
get hasOverlap() {
|
|
1287
|
-
return this.results.filter(r => r.type === 'overlap').length > 0;
|
|
1288
|
-
}
|
|
1289
|
-
get surroundedTokens() {
|
|
1290
|
-
return this.results.filter(r => r.type === 'within-selection').map(t => t.token);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
const intersection = (selection, tokens) => {
|
|
1294
|
-
const {start, end} = selection;
|
|
1295
|
-
const startsWithin = t => start >= t.start && start < t.end;
|
|
1296
|
-
const endsWithin = t => end > t.start && end <= t.end;
|
|
1297
|
-
const mapped = tokens.map(t => {
|
|
1298
|
-
if (start === t.start && end === t.end) {
|
|
1299
|
-
return {
|
|
1300
|
-
token: t,
|
|
1301
|
-
type: 'exact-fit'
|
|
1302
|
-
};
|
|
1303
|
-
} else if (start <= t.start && end >= t.end) {
|
|
1304
|
-
return {
|
|
1305
|
-
token: t,
|
|
1306
|
-
type: 'within-selection'
|
|
1307
|
-
};
|
|
1308
|
-
} else if (startsWithin(t) || endsWithin(t)) {
|
|
1309
|
-
return {
|
|
1310
|
-
token: t,
|
|
1311
|
-
type: 'overlap'
|
|
1312
|
-
};
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
return new Intersection(compact(mapped));
|
|
1316
|
-
};
|
|
1317
|
-
const sort = tokens => {
|
|
1318
|
-
if (!Array.isArray(tokens)) {
|
|
1319
|
-
return tokens;
|
|
1320
|
-
} else {
|
|
1321
|
-
const out = clone$2(tokens);
|
|
1322
|
-
out.sort((a, b) => {
|
|
1323
|
-
const s = a.start < b.start ? -1 : a.start > b.start ? 1 : 0;
|
|
1324
|
-
const e = a.end < b.end ? -1 : a.end > b.end ? 1 : 0;
|
|
1325
|
-
if (s === -1 && e !== -1) {
|
|
1326
|
-
throw new Error(`sort does not support intersecting tokens. a: ${a.start}-${a.end}, b: ${b.start}-${b.end}`);
|
|
1327
|
-
}
|
|
1328
|
-
return s;
|
|
1329
|
-
});
|
|
1330
|
-
return out;
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
const normalize = (textToNormalize, tokens) => {
|
|
1334
|
-
const text = textToNormalize || '';
|
|
1335
|
-
if (!Array.isArray(tokens) || tokens.length === 0) {
|
|
1336
|
-
return [{
|
|
1337
|
-
text,
|
|
1338
|
-
start: 0,
|
|
1339
|
-
end: text.length
|
|
1340
|
-
}];
|
|
1341
|
-
}
|
|
1342
|
-
const out = sort(tokens).reduce((acc, t, index, outer) => {
|
|
1343
|
-
let tokens = [];
|
|
1344
|
-
const lastIndex = acc.lastIndex;
|
|
1345
|
-
if (t.start === lastIndex) {
|
|
1346
|
-
tokens = [{
|
|
1347
|
-
text: text.substring(lastIndex, t.end),
|
|
1348
|
-
start: lastIndex,
|
|
1349
|
-
end: t.end,
|
|
1350
|
-
predefined: true,
|
|
1351
|
-
correct: t.correct
|
|
1352
|
-
}];
|
|
1353
|
-
} else if (lastIndex < t.start) {
|
|
1354
|
-
tokens = [{
|
|
1355
|
-
text: text.substring(lastIndex, t.start),
|
|
1356
|
-
start: lastIndex,
|
|
1357
|
-
end: t.start
|
|
1358
|
-
}, {
|
|
1359
|
-
text: text.substring(t.start, t.end),
|
|
1360
|
-
start: t.start,
|
|
1361
|
-
end: t.end,
|
|
1362
|
-
predefined: true,
|
|
1363
|
-
correct: t.correct
|
|
1364
|
-
}];
|
|
1365
|
-
}
|
|
1366
|
-
if (index === outer.length - 1 && t.end < text.length) {
|
|
1367
|
-
const last = {
|
|
1368
|
-
text: text.substring(t.end),
|
|
1369
|
-
start: t.end,
|
|
1370
|
-
end: text.length
|
|
1371
|
-
};
|
|
1372
|
-
tokens.push(last);
|
|
1373
|
-
}
|
|
1374
|
-
return {
|
|
1375
|
-
lastIndex: tokens.length ? tokens[tokens.length - 1].end : lastIndex,
|
|
1376
|
-
result: acc.result.concat(tokens)
|
|
1377
|
-
};
|
|
1378
|
-
}, {
|
|
1379
|
-
result: [],
|
|
1380
|
-
lastIndex: 0
|
|
1381
|
-
});
|
|
1382
|
-
return out.result;
|
|
1383
|
-
};
|
|
1384
|
-
const noSelect = () => ({
|
|
1385
|
-
cursor: 'default',
|
|
1386
|
-
'-webkit-user-select': 'none',
|
|
1387
|
-
'-moz-user-select': 'none',
|
|
1388
|
-
'-ms-user-select': 'none',
|
|
1389
|
-
'user-select': 'none'
|
|
1390
|
-
});
|
|
1391
|
-
const clearSelection = () => {
|
|
1392
|
-
if (document.getSelection) {
|
|
1393
|
-
document.getSelection().removeAllRanges();
|
|
1394
|
-
document.getSelection().addRange(document.createRange());
|
|
1395
|
-
} else if (window.getSelection) {
|
|
1396
|
-
if (window.getSelection().removeAllRanges) {
|
|
1397
|
-
window.getSelection().removeAllRanges();
|
|
1398
|
-
window.getSelection().addRange(document.createRange());
|
|
1399
|
-
} else if (window.getSelection().empty) {
|
|
1400
|
-
window.getSelection().empty();
|
|
1401
|
-
}
|
|
1402
|
-
} else if (document.selection) {
|
|
1403
|
-
document.selection.empty();
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
const getCaretCharacterOffsetWithin = element => {
|
|
1407
|
-
var caretOffset = 0;
|
|
1408
|
-
var doc = element.ownerDocument || element.document;
|
|
1409
|
-
var win = doc.defaultView || doc.parentWindow;
|
|
1410
|
-
var sel;
|
|
1411
|
-
if (typeof win.getSelection !== 'undefined') {
|
|
1412
|
-
sel = win.getSelection();
|
|
1413
|
-
if (sel.rangeCount > 0) {
|
|
1414
|
-
var range = win.getSelection().getRangeAt(0);
|
|
1415
|
-
var selected = range.toString().length;
|
|
1416
|
-
var preCaretRange = range.cloneRange();
|
|
1417
|
-
preCaretRange.selectNodeContents(element);
|
|
1418
|
-
preCaretRange.setEnd(range.endContainer, range.endOffset);
|
|
1419
|
-
if (selected) {
|
|
1420
|
-
caretOffset = preCaretRange.toString().length - selected;
|
|
1421
|
-
} else {
|
|
1422
|
-
caretOffset = preCaretRange.toString().length;
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
} else if ((sel = doc.selection) && sel.type !== 'Control') {
|
|
1426
|
-
var textRange = sel.createRange();
|
|
1427
|
-
var preCaretTextRange = doc.body.createTextRange();
|
|
1428
|
-
preCaretTextRange.moveToElementText(element);
|
|
1429
|
-
preCaretTextRange.setEndPoint('EndToEnd', textRange);
|
|
1430
|
-
caretOffset = preCaretTextRange.text.length;
|
|
1431
|
-
}
|
|
1432
|
-
return caretOffset;
|
|
1433
|
-
};
|
|
1434
|
-
const React$6 = _dll_react;
|
|
1435
|
-
const PropTypes$5 = _dll_prop_types;
|
|
1436
|
-
const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
|
|
1437
|
-
const {colors: {yellow: yellow}} = _dll_material_ui__core;
|
|
1438
|
-
const {colors: {green: green}} = _dll_material_ui__core;
|
|
1439
|
-
const debug$4 = _dll_debug;
|
|
1440
|
-
const classNames$3 = _dll_classnames;
|
|
1441
|
-
const _jsxFileName$5 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/tokenizer/token-text.jsx";
|
|
1442
|
-
const log$4 = debug$4('@pie-lib:text-select:token-text');
|
|
1443
|
-
const Text = withStyles$4(() => ({
|
|
1444
|
-
predefined: {
|
|
1445
|
-
cursor: 'pointer',
|
|
1446
|
-
backgroundColor: yellow[100],
|
|
1447
|
-
border: `dashed 0px ${yellow[700]}`
|
|
1448
|
-
},
|
|
1449
|
-
correct: {
|
|
1450
|
-
backgroundColor: green[500]
|
|
1451
|
-
}
|
|
1452
|
-
}))(({text, predefined, classes, onClick, correct}) => {
|
|
1453
|
-
const formattedText = (text || '').replace(/\n/g, '<br>');
|
|
1454
|
-
if (predefined) {
|
|
1455
|
-
const className = classNames$3(classes.predefined, correct && classes.correct);
|
|
1456
|
-
return React$6.createElement('span', {
|
|
1457
|
-
onClick: onClick,
|
|
1458
|
-
className: className,
|
|
1459
|
-
dangerouslySetInnerHTML: {
|
|
1460
|
-
__html: formattedText
|
|
1461
|
-
},
|
|
1462
|
-
__self: undefined,
|
|
1463
|
-
__source: {
|
|
1464
|
-
fileName: _jsxFileName$5,
|
|
1465
|
-
lineNumber: 30
|
|
1466
|
-
}
|
|
1467
|
-
});
|
|
1468
|
-
} else {
|
|
1469
|
-
return React$6.createElement('span', {
|
|
1470
|
-
dangerouslySetInnerHTML: {
|
|
1471
|
-
__html: formattedText
|
|
1472
|
-
},
|
|
1473
|
-
__self: undefined,
|
|
1474
|
-
__source: {
|
|
1475
|
-
fileName: _jsxFileName$5,
|
|
1476
|
-
lineNumber: 37
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
}
|
|
1480
|
-
});
|
|
1481
|
-
const notAllowedCharacters = ['\n', ' ', '\t'];
|
|
1482
|
-
class TokenText extends React$6.Component {
|
|
1483
|
-
constructor(...args) {
|
|
1484
|
-
super(...args);
|
|
1485
|
-
TokenText.prototype.__init.call(this);
|
|
1486
|
-
}
|
|
1487
|
-
static __initStatic() {
|
|
1488
|
-
this.propTypes = {
|
|
1489
|
-
text: PropTypes$5.string.isRequired,
|
|
1490
|
-
tokens: PropTypes$5.array.isRequired,
|
|
1491
|
-
onTokenClick: PropTypes$5.func.isRequired,
|
|
1492
|
-
onSelectToken: PropTypes$5.func.isRequired,
|
|
1493
|
-
className: PropTypes$5.string
|
|
1494
|
-
};
|
|
1495
|
-
}
|
|
1496
|
-
__init() {
|
|
1497
|
-
this.onClick = event => {
|
|
1498
|
-
const {onSelectToken, text, tokens} = this.props;
|
|
1499
|
-
event.preventDefault();
|
|
1500
|
-
if (typeof window === 'undefined') {
|
|
1501
|
-
return;
|
|
1502
|
-
}
|
|
1503
|
-
const selection = window.getSelection();
|
|
1504
|
-
const textSelected = selection.toString();
|
|
1505
|
-
if (textSelected.length > 0 && notAllowedCharacters.indexOf(textSelected) < 0) {
|
|
1506
|
-
if (this.root) {
|
|
1507
|
-
let offset = getCaretCharacterOffsetWithin(this.root);
|
|
1508
|
-
const newLineOffset = text.slice(offset).indexOf(textSelected);
|
|
1509
|
-
offset += newLineOffset;
|
|
1510
|
-
if (offset !== undefined) {
|
|
1511
|
-
const endIndex = offset + textSelected.length;
|
|
1512
|
-
if (endIndex <= text.length) {
|
|
1513
|
-
const i = intersection({
|
|
1514
|
-
start: offset,
|
|
1515
|
-
end: endIndex
|
|
1516
|
-
}, tokens);
|
|
1517
|
-
if (i.hasOverlap) {
|
|
1518
|
-
log$4('hasOverlap - do nothing');
|
|
1519
|
-
clearSelection();
|
|
1520
|
-
} else {
|
|
1521
|
-
const tokensToRemove = i.surroundedTokens;
|
|
1522
|
-
const token = {
|
|
1523
|
-
text: textSelected,
|
|
1524
|
-
start: offset,
|
|
1525
|
-
end: endIndex
|
|
1526
|
-
};
|
|
1527
|
-
onSelectToken(token, tokensToRemove);
|
|
1528
|
-
clearSelection();
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
};
|
|
1535
|
-
}
|
|
1536
|
-
render() {
|
|
1537
|
-
const {text, tokens, className, onTokenClick} = this.props;
|
|
1538
|
-
const normalized = normalize(text, tokens);
|
|
1539
|
-
return React$6.createElement('div', {
|
|
1540
|
-
className: className,
|
|
1541
|
-
ref: r => this.root = r,
|
|
1542
|
-
onClick: this.onClick,
|
|
1543
|
-
__self: this,
|
|
1544
|
-
__source: {
|
|
1545
|
-
fileName: _jsxFileName$5,
|
|
1546
|
-
lineNumber: 123
|
|
1547
|
-
}
|
|
1548
|
-
}, normalized.map((t, index) => {
|
|
1549
|
-
return React$6.createElement(Text, {
|
|
1550
|
-
key: index,
|
|
1551
|
-
...t,
|
|
1552
|
-
onClick: () => onTokenClick(t),
|
|
1553
|
-
__self: this,
|
|
1554
|
-
__source: {
|
|
1555
|
-
fileName: _jsxFileName$5,
|
|
1556
|
-
lineNumber: 125
|
|
1557
|
-
}
|
|
1558
|
-
});
|
|
1559
|
-
}));
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
TokenText.__initStatic();
|
|
1563
|
-
const React$5 = _dll_react;
|
|
1564
|
-
const PropTypes$4 = _dll_prop_types;
|
|
1565
|
-
const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
|
|
1566
|
-
const {clone: clone$1} = _dll_lodash;
|
|
1567
|
-
const {isEqual: isEqual$1} = _dll_lodash;
|
|
1568
|
-
const {differenceWith: differenceWith} = _dll_lodash;
|
|
1569
|
-
const classNames$2 = _dll_classnames;
|
|
1570
|
-
const _jsxFileName$4 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/tokenizer/index.jsx";
|
|
1571
|
-
class Tokenizer extends React$5.Component {
|
|
1572
|
-
static __initStatic() {
|
|
1573
|
-
this.propTypes = {
|
|
1574
|
-
text: PropTypes$4.string.isRequired,
|
|
1575
|
-
tokens: PropTypes$4.arrayOf(PropTypes$4.shape({
|
|
1576
|
-
text: PropTypes$4.string,
|
|
1577
|
-
correct: PropTypes$4.bool,
|
|
1578
|
-
start: PropTypes$4.number,
|
|
1579
|
-
end: PropTypes$4.number
|
|
1580
|
-
})),
|
|
1581
|
-
classes: PropTypes$4.object.isRequired,
|
|
1582
|
-
className: PropTypes$4.string,
|
|
1583
|
-
onChange: PropTypes$4.func.isRequired
|
|
1584
|
-
};
|
|
1585
|
-
}
|
|
1586
|
-
static __initStatic2() {
|
|
1587
|
-
this.defaultProps = {};
|
|
1588
|
-
}
|
|
1589
|
-
constructor(props) {
|
|
1590
|
-
super(props);
|
|
1591
|
-
Tokenizer.prototype.__init.call(this);
|
|
1592
|
-
Tokenizer.prototype.__init2.call(this);
|
|
1593
|
-
Tokenizer.prototype.__init3.call(this);
|
|
1594
|
-
Tokenizer.prototype.__init4.call(this);
|
|
1595
|
-
Tokenizer.prototype.__init5.call(this);
|
|
1596
|
-
Tokenizer.prototype.__init6.call(this);
|
|
1597
|
-
Tokenizer.prototype.__init7.call(this);
|
|
1598
|
-
Tokenizer.prototype.__init8.call(this);
|
|
1599
|
-
Tokenizer.prototype.__init9.call(this);
|
|
1600
|
-
this.state = {
|
|
1601
|
-
setCorrectMode: false,
|
|
1602
|
-
mode: ''
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
__init() {
|
|
1606
|
-
this.onChangeHandler = (token, mode) => {
|
|
1607
|
-
this.props.onChange(token, mode);
|
|
1608
|
-
this.setState({
|
|
1609
|
-
mode
|
|
1610
|
-
});
|
|
1611
|
-
};
|
|
1612
|
-
}
|
|
1613
|
-
__init2() {
|
|
1614
|
-
this.toggleCorrectMode = () => this.setState({
|
|
1615
|
-
setCorrectMode: !this.state.setCorrectMode
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
__init3() {
|
|
1619
|
-
this.clear = () => {
|
|
1620
|
-
this.onChangeHandler([], '');
|
|
1621
|
-
};
|
|
1622
|
-
}
|
|
1623
|
-
__init4() {
|
|
1624
|
-
this.buildTokens = (type, fn) => {
|
|
1625
|
-
const {text} = this.props;
|
|
1626
|
-
const tokens = fn(text);
|
|
1627
|
-
this.onChangeHandler(tokens, type);
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
__init5() {
|
|
1631
|
-
this.selectToken = (newToken, tokensToRemove) => {
|
|
1632
|
-
const {tokens} = this.props;
|
|
1633
|
-
const update = differenceWith(clone$1(tokens), tokensToRemove, isEqual$1);
|
|
1634
|
-
update.push(newToken);
|
|
1635
|
-
this.onChangeHandler(update, this.state.mode);
|
|
1636
|
-
};
|
|
1637
|
-
}
|
|
1638
|
-
__init6() {
|
|
1639
|
-
this.tokenClick = token => {
|
|
1640
|
-
const {setCorrectMode} = this.state;
|
|
1641
|
-
if (setCorrectMode) {
|
|
1642
|
-
this.setCorrect(token);
|
|
1643
|
-
} else {
|
|
1644
|
-
this.removeToken(token);
|
|
1645
|
-
}
|
|
1646
|
-
};
|
|
1647
|
-
}
|
|
1648
|
-
__init7() {
|
|
1649
|
-
this.tokenIndex = token => {
|
|
1650
|
-
const {tokens} = this.props;
|
|
1651
|
-
return tokens.findIndex(t => {
|
|
1652
|
-
return t.text == token.text && t.start == token.start && t.end == token.end;
|
|
1653
|
-
});
|
|
1654
|
-
};
|
|
1655
|
-
}
|
|
1656
|
-
__init8() {
|
|
1657
|
-
this.setCorrect = token => {
|
|
1658
|
-
const {tokens} = this.props;
|
|
1659
|
-
const index = this.tokenIndex(token);
|
|
1660
|
-
if (index !== -1) {
|
|
1661
|
-
const t = tokens[index];
|
|
1662
|
-
t.correct = !t.correct;
|
|
1663
|
-
const update = clone$1(tokens);
|
|
1664
|
-
update.splice(index, 1, t);
|
|
1665
|
-
this.onChangeHandler(update, this.state.mode);
|
|
1666
|
-
}
|
|
1667
|
-
};
|
|
1668
|
-
}
|
|
1669
|
-
__init9() {
|
|
1670
|
-
this.removeToken = token => {
|
|
1671
|
-
const {tokens} = this.props;
|
|
1672
|
-
const index = this.tokenIndex(token);
|
|
1673
|
-
if (index !== -1) {
|
|
1674
|
-
const update = clone$1(tokens);
|
|
1675
|
-
update.splice(index, 1);
|
|
1676
|
-
this.onChangeHandler(update, this.state.mode);
|
|
1677
|
-
}
|
|
1678
|
-
};
|
|
1679
|
-
}
|
|
1680
|
-
render() {
|
|
1681
|
-
const {text, tokens, classes, className} = this.props;
|
|
1682
|
-
const {setCorrectMode} = this.state;
|
|
1683
|
-
const tokenClassName = classNames$2(classes.text, setCorrectMode && classes.noselect);
|
|
1684
|
-
const rootName = classNames$2(classes.tokenizer, className);
|
|
1685
|
-
return React$5.createElement('div', {
|
|
1686
|
-
className: rootName,
|
|
1687
|
-
__self: this,
|
|
1688
|
-
__source: {
|
|
1689
|
-
fileName: _jsxFileName$4,
|
|
1690
|
-
lineNumber: 123
|
|
1691
|
-
}
|
|
1692
|
-
}, React$5.createElement(Controls$1, {
|
|
1693
|
-
onClear: this.clear,
|
|
1694
|
-
onWords: () => this.buildTokens('words', words),
|
|
1695
|
-
onSentences: () => this.buildTokens('sentence', sentences),
|
|
1696
|
-
onParagraphs: () => this.buildTokens('paragraphs', paragraphs),
|
|
1697
|
-
setCorrectMode: setCorrectMode,
|
|
1698
|
-
onToggleCorrectMode: this.toggleCorrectMode,
|
|
1699
|
-
__self: this,
|
|
1700
|
-
__source: {
|
|
1701
|
-
fileName: _jsxFileName$4,
|
|
1702
|
-
lineNumber: 124
|
|
1703
|
-
}
|
|
1704
|
-
}), React$5.createElement(TokenText, {
|
|
1705
|
-
className: tokenClassName,
|
|
1706
|
-
text: text,
|
|
1707
|
-
tokens: tokens,
|
|
1708
|
-
onTokenClick: this.tokenClick,
|
|
1709
|
-
onSelectToken: this.selectToken,
|
|
1710
|
-
__self: this,
|
|
1711
|
-
__source: {
|
|
1712
|
-
fileName: _jsxFileName$4,
|
|
1713
|
-
lineNumber: 132
|
|
1714
|
-
}
|
|
1715
|
-
}));
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
Tokenizer.__initStatic();
|
|
1719
|
-
Tokenizer.__initStatic2();
|
|
1720
|
-
withStyles$3(theme => ({
|
|
1721
|
-
text: {
|
|
1722
|
-
whiteSpace: 'pre-wrap',
|
|
1723
|
-
marginTop: theme.spacing.unit,
|
|
1724
|
-
paddingTop: theme.spacing.unit,
|
|
1725
|
-
paddingBottom: theme.spacing.unit
|
|
1726
|
-
},
|
|
1727
|
-
noselect: {
|
|
1728
|
-
...noSelect()
|
|
1729
|
-
}
|
|
1730
|
-
}))(Tokenizer);
|
|
1731
|
-
const React$4 = _dll_react;
|
|
1732
|
-
const PropTypes$3 = _dll_prop_types;
|
|
1733
|
-
const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
|
|
1734
|
-
const classNames$1 = _dll_classnames;
|
|
1735
|
-
const {color: color$1} = _dll_pie_lib__render_ui;
|
|
1736
|
-
const _jsxFileName$3 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/token-select/token.jsx";
|
|
1737
|
-
const TokenTypes = {
|
|
1738
|
-
text: PropTypes$3.string,
|
|
1739
|
-
selectable: PropTypes$3.bool
|
|
1740
|
-
};
|
|
1741
|
-
class Token extends React$4.Component {
|
|
1742
|
-
static __initStatic() {
|
|
1743
|
-
this.rootClassName = 'tokenRootClass';
|
|
1744
|
-
}
|
|
1745
|
-
static __initStatic2() {
|
|
1746
|
-
this.propTypes = {
|
|
1747
|
-
...TokenTypes,
|
|
1748
|
-
classes: PropTypes$3.object.isRequired,
|
|
1749
|
-
className: PropTypes$3.string,
|
|
1750
|
-
disabled: PropTypes$3.bool,
|
|
1751
|
-
highlight: PropTypes$3.bool,
|
|
1752
|
-
correct: PropTypes$3.bool,
|
|
1753
|
-
text: PropTypes$3.string.isRequired
|
|
1754
|
-
};
|
|
1755
|
-
}
|
|
1756
|
-
static __initStatic3() {
|
|
1757
|
-
this.defaultProps = {
|
|
1758
|
-
selectable: false,
|
|
1759
|
-
text: ''
|
|
1760
|
-
};
|
|
1761
|
-
}
|
|
1762
|
-
render() {
|
|
1763
|
-
const {text, selectable, selected, classes, className: classNameProp, disabled, index, highlight, correct, animationsDisabled} = this.props;
|
|
1764
|
-
let className;
|
|
1765
|
-
if (correct === undefined && selected && disabled) {
|
|
1766
|
-
className = classNames$1(classes.token, classes.selected, classes.disabledBlack);
|
|
1767
|
-
} else if (correct !== undefined) {
|
|
1768
|
-
className = classNames$1(Token.rootClassName, classes.custom, correct === true && classes.correct, correct === false && classes.incorrect);
|
|
1769
|
-
} else {
|
|
1770
|
-
className = classNames$1(Token.rootClassName, classes.token, disabled && classes.disabled, selectable && !disabled && classes.selectable, selected && !disabled && classes.selected, selected && disabled && classes.disabledAndSelected, highlight && selectable && !disabled && !selected && classes.highlight, animationsDisabled && classes.print, classNameProp);
|
|
1771
|
-
}
|
|
1772
|
-
return React$4.createElement('span', {
|
|
1773
|
-
className: className,
|
|
1774
|
-
dangerouslySetInnerHTML: {
|
|
1775
|
-
__html: (text || '').replace(/\n/g, '<br>')
|
|
1776
|
-
},
|
|
1777
|
-
'data-indexkey': index,
|
|
1778
|
-
__self: this,
|
|
1779
|
-
__source: {
|
|
1780
|
-
fileName: _jsxFileName$3,
|
|
1781
|
-
lineNumber: 70
|
|
1782
|
-
}
|
|
1783
|
-
});
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
Token.__initStatic();
|
|
1787
|
-
Token.__initStatic2();
|
|
1788
|
-
Token.__initStatic3();
|
|
1789
|
-
var Token$1 = withStyles$2(theme => {
|
|
1790
|
-
return {
|
|
1791
|
-
token: {
|
|
1792
|
-
cursor: 'pointer',
|
|
1793
|
-
textIndent: 0,
|
|
1794
|
-
padding: theme.spacing.unit / 2,
|
|
1795
|
-
paddingRight: 0,
|
|
1796
|
-
paddingLeft: 0,
|
|
1797
|
-
transition: 'background-color 100ms ease-in'
|
|
1798
|
-
},
|
|
1799
|
-
disabled: {
|
|
1800
|
-
cursor: 'inherit',
|
|
1801
|
-
color: 'grey'
|
|
1802
|
-
},
|
|
1803
|
-
disabledBlack: {
|
|
1804
|
-
cursor: 'inherit'
|
|
1805
|
-
},
|
|
1806
|
-
disabledAndSelected: {
|
|
1807
|
-
backgroundColor: 'pink'
|
|
1808
|
-
},
|
|
1809
|
-
selectable: {
|
|
1810
|
-
'&:hover': {
|
|
1811
|
-
backgroundColor: color$1.primaryLight(),
|
|
1812
|
-
'& > *': {
|
|
1813
|
-
backgroundColor: color$1.primaryLight()
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
},
|
|
1817
|
-
selected: {
|
|
1818
|
-
lineHeight: 2,
|
|
1819
|
-
marginTop: theme.spacing.unit / 2,
|
|
1820
|
-
'&:hover': {
|
|
1821
|
-
backgroundColor: color$1.primaryLight()
|
|
1822
|
-
},
|
|
1823
|
-
backgroundColor: color$1.primaryLight(),
|
|
1824
|
-
'& > *': {
|
|
1825
|
-
backgroundColor: color$1.primaryLight()
|
|
1826
|
-
}
|
|
1827
|
-
},
|
|
1828
|
-
highlight: {
|
|
1829
|
-
border: 'dashed 2px gray',
|
|
1830
|
-
lineHeight: 2,
|
|
1831
|
-
boxSizing: 'border-box',
|
|
1832
|
-
marginTop: theme.spacing.unit / 2,
|
|
1833
|
-
display: 'inline-block',
|
|
1834
|
-
padding: theme.spacing.unit
|
|
1835
|
-
},
|
|
1836
|
-
print: {
|
|
1837
|
-
border: 'dashed 2px gray',
|
|
1838
|
-
lineHeight: 2,
|
|
1839
|
-
boxSizing: 'border-box',
|
|
1840
|
-
marginTop: theme.spacing.unit / 2,
|
|
1841
|
-
display: 'inline-block',
|
|
1842
|
-
padding: theme.spacing.unit,
|
|
1843
|
-
color: color$1.text()
|
|
1844
|
-
},
|
|
1845
|
-
custom: {
|
|
1846
|
-
display: 'initial'
|
|
1847
|
-
},
|
|
1848
|
-
correct: {
|
|
1849
|
-
backgroundColor: color$1.correct()
|
|
1850
|
-
},
|
|
1851
|
-
incorrect: {
|
|
1852
|
-
backgroundColor: color$1.incorrect()
|
|
1853
|
-
}
|
|
1854
|
-
};
|
|
1855
|
-
})(Token);
|
|
1856
|
-
const React$3 = _dll_react;
|
|
1857
|
-
const PropTypes$2 = _dll_prop_types;
|
|
1858
|
-
const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
|
|
1859
|
-
const classNames = _dll_classnames;
|
|
1860
|
-
const {clone: clone} = _dll_lodash;
|
|
1861
|
-
const {isEqual: isEqual} = _dll_lodash;
|
|
1862
|
-
const debug$3 = _dll_debug;
|
|
1863
|
-
const {renderToString: renderToString} = _dll_react_dom_server;
|
|
1864
|
-
const _jsxFileName$2 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/token-select/index.jsx";
|
|
1865
|
-
const log$3 = debug$3('@pie-lib:text-select:token-select');
|
|
1866
|
-
class TokenSelect extends React$3.Component {
|
|
1867
|
-
constructor(...args) {
|
|
1868
|
-
super(...args);
|
|
1869
|
-
TokenSelect.prototype.__init.call(this);
|
|
1870
|
-
TokenSelect.prototype.__init2.call(this);
|
|
1871
|
-
TokenSelect.prototype.__init3.call(this);
|
|
1872
|
-
TokenSelect.prototype.__init4.call(this);
|
|
1873
|
-
}
|
|
1874
|
-
static __initStatic() {
|
|
1875
|
-
this.propTypes = {
|
|
1876
|
-
tokens: PropTypes$2.arrayOf(PropTypes$2.shape(TokenTypes)).isRequired,
|
|
1877
|
-
className: PropTypes$2.string,
|
|
1878
|
-
classes: PropTypes$2.object.isRequired,
|
|
1879
|
-
onChange: PropTypes$2.func.isRequired,
|
|
1880
|
-
disabled: PropTypes$2.bool,
|
|
1881
|
-
highlightChoices: PropTypes$2.bool,
|
|
1882
|
-
animationsDisabled: PropTypes$2.bool,
|
|
1883
|
-
maxNoOfSelections: PropTypes$2.number
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
static __initStatic2() {
|
|
1887
|
-
this.defaultProps = {
|
|
1888
|
-
highlightChoices: false,
|
|
1889
|
-
maxNoOfSelections: 0,
|
|
1890
|
-
tokens: []
|
|
1891
|
-
};
|
|
1892
|
-
}
|
|
1893
|
-
__init() {
|
|
1894
|
-
this.selectedCount = () => this.props.tokens.filter(t => t.selected).length;
|
|
1895
|
-
}
|
|
1896
|
-
__init2() {
|
|
1897
|
-
this.canSelectMore = selectedCount => {
|
|
1898
|
-
const {maxNoOfSelections} = this.props;
|
|
1899
|
-
if (maxNoOfSelections === 1) {
|
|
1900
|
-
return true;
|
|
1901
|
-
}
|
|
1902
|
-
log$3('[canSelectMore] maxNoOfSelections: ', maxNoOfSelections, 'selectedCount: ', selectedCount);
|
|
1903
|
-
return maxNoOfSelections <= 0 || isFinite(maxNoOfSelections) && selectedCount < maxNoOfSelections;
|
|
1904
|
-
};
|
|
1905
|
-
}
|
|
1906
|
-
__init3() {
|
|
1907
|
-
this.toggleToken = event => {
|
|
1908
|
-
const {target} = event;
|
|
1909
|
-
const {tokens, animationsDisabled} = this.props;
|
|
1910
|
-
const tokensCloned = clone(tokens);
|
|
1911
|
-
const targetSpanWrapper = target.closest(`.${Token$1.rootClassName}`);
|
|
1912
|
-
const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;
|
|
1913
|
-
const t = targetedTokenIndex && tokensCloned[targetedTokenIndex];
|
|
1914
|
-
if (t && t.correct === undefined && !animationsDisabled) {
|
|
1915
|
-
const {onChange, maxNoOfSelections} = this.props;
|
|
1916
|
-
const selected = !t.selected;
|
|
1917
|
-
if (maxNoOfSelections === 1 && this.selectedCount() === 1) {
|
|
1918
|
-
const selectedToken = (tokens || []).filter(t => t.selected);
|
|
1919
|
-
const updatedTokens = tokensCloned.map(token => {
|
|
1920
|
-
if (isEqual(token, selectedToken[0])) {
|
|
1921
|
-
return {
|
|
1922
|
-
...token,
|
|
1923
|
-
selected: false
|
|
1924
|
-
};
|
|
1925
|
-
}
|
|
1926
|
-
return {
|
|
1927
|
-
...token,
|
|
1928
|
-
selectable: true
|
|
1929
|
-
};
|
|
1930
|
-
});
|
|
1931
|
-
const update = {
|
|
1932
|
-
...t,
|
|
1933
|
-
selected: !t.selected
|
|
1934
|
-
};
|
|
1935
|
-
updatedTokens.splice(targetedTokenIndex, 1, update);
|
|
1936
|
-
onChange(updatedTokens);
|
|
1937
|
-
} else {
|
|
1938
|
-
if (selected && maxNoOfSelections > 0 && this.selectedCount() >= maxNoOfSelections) {
|
|
1939
|
-
log$3('skip toggle max reached');
|
|
1940
|
-
return;
|
|
1941
|
-
}
|
|
1942
|
-
const update = {
|
|
1943
|
-
...t,
|
|
1944
|
-
selected: !t.selected
|
|
1945
|
-
};
|
|
1946
|
-
tokensCloned.splice(targetedTokenIndex, 1, update);
|
|
1947
|
-
onChange(tokensCloned);
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
};
|
|
1951
|
-
}
|
|
1952
|
-
__init4() {
|
|
1953
|
-
this.generateTokensInHtml = () => {
|
|
1954
|
-
const {tokens, disabled, highlightChoices, animationsDisabled} = this.props;
|
|
1955
|
-
const selectedCount = this.selectedCount();
|
|
1956
|
-
const isLineBreak = text => text === '\n';
|
|
1957
|
-
const isNewParagraph = text => text === '\n\n';
|
|
1958
|
-
const reducer = (accumulator, t, index) => {
|
|
1959
|
-
const selectable = t.selected || t.selectable && this.canSelectMore(selectedCount);
|
|
1960
|
-
const showCorrectAnswer = t.correct !== undefined && (t.selectable || t.selected);
|
|
1961
|
-
let finalAcc = accumulator;
|
|
1962
|
-
if (isNewParagraph(t.text)) {
|
|
1963
|
-
return finalAcc + '</p><p>';
|
|
1964
|
-
}
|
|
1965
|
-
if (isLineBreak(t.text)) {
|
|
1966
|
-
return finalAcc + '<br>';
|
|
1967
|
-
}
|
|
1968
|
-
if (selectable && !disabled || showCorrectAnswer || t.selected || animationsDisabled && t.predefined) {
|
|
1969
|
-
return finalAcc + renderToString(React$3.createElement(Token$1, {
|
|
1970
|
-
key: index,
|
|
1971
|
-
disabled: disabled,
|
|
1972
|
-
index: index,
|
|
1973
|
-
...t,
|
|
1974
|
-
selectable: selectable,
|
|
1975
|
-
highlight: highlightChoices,
|
|
1976
|
-
animationsDisabled: animationsDisabled,
|
|
1977
|
-
__self: this,
|
|
1978
|
-
__source: {
|
|
1979
|
-
fileName: _jsxFileName$2,
|
|
1980
|
-
lineNumber: 125
|
|
1981
|
-
}
|
|
1982
|
-
}));
|
|
1983
|
-
} else {
|
|
1984
|
-
return accumulator + t.text;
|
|
1985
|
-
}
|
|
1986
|
-
};
|
|
1987
|
-
const reduceResult = (tokens || []).reduce(reducer, '<p>');
|
|
1988
|
-
return reduceResult + '</p>';
|
|
1989
|
-
};
|
|
1990
|
-
}
|
|
1991
|
-
render() {
|
|
1992
|
-
const {classes, className: classNameProp} = this.props;
|
|
1993
|
-
const className = classNames(classes.tokenSelect, classNameProp);
|
|
1994
|
-
const html = this.generateTokensInHtml();
|
|
1995
|
-
return React$3.createElement('div', {
|
|
1996
|
-
className: className,
|
|
1997
|
-
dangerouslySetInnerHTML: {
|
|
1998
|
-
__html: html
|
|
1999
|
-
},
|
|
2000
|
-
onClick: this.toggleToken,
|
|
2001
|
-
__self: this,
|
|
2002
|
-
__source: {
|
|
2003
|
-
fileName: _jsxFileName$2,
|
|
2004
|
-
lineNumber: 152
|
|
2005
|
-
}
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
TokenSelect.__initStatic();
|
|
2010
|
-
TokenSelect.__initStatic2();
|
|
2011
|
-
var TokenSelect$1 = withStyles$1(() => ({
|
|
2012
|
-
tokenSelect: {
|
|
2013
|
-
backgroundColor: 'none',
|
|
2014
|
-
whiteSpace: 'pre',
|
|
2015
|
-
...noSelect(),
|
|
2016
|
-
'& p': {
|
|
2017
|
-
whiteSpace: 'break-spaces'
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
}))(TokenSelect);
|
|
2021
|
-
const React$2 = _dll_react;
|
|
2022
|
-
const PropTypes$1 = _dll_prop_types;
|
|
2023
|
-
const debug$2 = _dll_debug;
|
|
2024
|
-
const _jsxFileName$1 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/text-select.jsx";
|
|
2025
|
-
const log$2 = debug$2('@pie-lib:text-select');
|
|
2026
|
-
class TextSelect extends React$2.Component {
|
|
2027
|
-
constructor(...args) {
|
|
2028
|
-
super(...args);
|
|
2029
|
-
TextSelect.prototype.__init.call(this);
|
|
2030
|
-
}
|
|
2031
|
-
static __initStatic() {
|
|
2032
|
-
this.propTypes = {
|
|
2033
|
-
onChange: PropTypes$1.func,
|
|
2034
|
-
disabled: PropTypes$1.bool,
|
|
2035
|
-
tokens: PropTypes$1.arrayOf(PropTypes$1.shape(TokenTypes)).isRequired,
|
|
2036
|
-
selectedTokens: PropTypes$1.arrayOf(PropTypes$1.shape(TokenTypes)).isRequired,
|
|
2037
|
-
text: PropTypes$1.string.isRequired,
|
|
2038
|
-
className: PropTypes$1.string,
|
|
2039
|
-
highlightChoices: PropTypes$1.bool,
|
|
2040
|
-
animationsDisabled: PropTypes$1.bool,
|
|
2041
|
-
maxNoOfSelections: PropTypes$1.number
|
|
2042
|
-
};
|
|
2043
|
-
}
|
|
2044
|
-
__init() {
|
|
2045
|
-
this.change = tokens => {
|
|
2046
|
-
const {onChange} = this.props;
|
|
2047
|
-
if (!onChange) {
|
|
2048
|
-
return;
|
|
2049
|
-
}
|
|
2050
|
-
const out = tokens.filter(t => t.selected).map(t => ({
|
|
2051
|
-
start: t.start,
|
|
2052
|
-
end: t.end
|
|
2053
|
-
}));
|
|
2054
|
-
onChange(out);
|
|
2055
|
-
};
|
|
2056
|
-
}
|
|
2057
|
-
render() {
|
|
2058
|
-
const {text, disabled, tokens, selectedTokens, className, highlightChoices, maxNoOfSelections, animationsDisabled} = this.props;
|
|
2059
|
-
const normalized = normalize(text, tokens);
|
|
2060
|
-
log$2('normalized: ', normalized);
|
|
2061
|
-
const prepped = normalized.map(t => {
|
|
2062
|
-
const selectedIndex = selectedTokens.findIndex(s => {
|
|
2063
|
-
return s.start === t.start && s.end === t.end;
|
|
2064
|
-
});
|
|
2065
|
-
const selected = selectedIndex !== -1;
|
|
2066
|
-
const correct = selected ? t.correct : undefined;
|
|
2067
|
-
return {
|
|
2068
|
-
...t,
|
|
2069
|
-
selectable: !disabled && t.predefined,
|
|
2070
|
-
selected,
|
|
2071
|
-
correct
|
|
2072
|
-
};
|
|
2073
|
-
});
|
|
2074
|
-
return React$2.createElement(TokenSelect$1, {
|
|
2075
|
-
highlightChoices: !disabled && highlightChoices,
|
|
2076
|
-
className: className,
|
|
2077
|
-
tokens: prepped,
|
|
2078
|
-
disabled: disabled,
|
|
2079
|
-
onChange: this.change,
|
|
2080
|
-
maxNoOfSelections: maxNoOfSelections,
|
|
2081
|
-
animationsDisabled: animationsDisabled,
|
|
2082
|
-
__self: this,
|
|
2083
|
-
__source: {
|
|
2084
|
-
fileName: _jsxFileName$1,
|
|
2085
|
-
lineNumber: 66
|
|
2086
|
-
}
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
TextSelect.__initStatic();
|
|
2091
|
-
var createElementFromHTML = function createElementFromHTML() {
|
|
2092
|
-
var htmlString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
2093
|
-
var div = document.createElement('div');
|
|
2094
|
-
div.innerHTML = htmlString.trim();
|
|
2095
|
-
return div;
|
|
2096
|
-
};
|
|
2097
|
-
var parseParagraph = function parseParagraph(paragraph, end) {
|
|
2098
|
-
if (end) {
|
|
2099
|
-
return paragraph.innerHTML;
|
|
2100
|
-
}
|
|
2101
|
-
return ('').concat(paragraph.innerHTML, '\n\n');
|
|
2102
|
-
};
|
|
2103
|
-
var parseParagraphs = function parseParagraphs(dom) {
|
|
2104
|
-
var paragraphs = dom.querySelectorAll('div[separator=true]');
|
|
2105
|
-
var str = '';
|
|
2106
|
-
paragraphs.forEach(function (par, index) {
|
|
2107
|
-
str += parseParagraph(par, index === paragraphs.length - 1);
|
|
2108
|
-
});
|
|
2109
|
-
return str || null;
|
|
2110
|
-
};
|
|
2111
|
-
var prepareText = function prepareText(text) {
|
|
2112
|
-
var txtDom = createElementFromHTML(text);
|
|
2113
|
-
var div = document.createElement('div');
|
|
2114
|
-
div.innerHTML = ('<div separator=\'true\'>').concat(txtDom.innerHTML, '</div>');
|
|
2115
|
-
txtDom = div;
|
|
2116
|
-
var allDomElements = Array.from(txtDom.querySelectorAll('*'));
|
|
2117
|
-
if (allDomElements.length === 0) {
|
|
2118
|
-
return text;
|
|
2119
|
-
}
|
|
2120
|
-
return parseParagraphs(txtDom);
|
|
2121
|
-
};
|
|
2122
|
-
var generateModel = model => {
|
|
2123
|
-
if (!model) return model;
|
|
2124
|
-
const modelText = prepareText(model.text || '');
|
|
2125
|
-
const newTokens = (model.tokens || []).reduce((acc, token = {}) => {
|
|
2126
|
-
const tokenText = prepareText((model.text || '').slice(token.start, token.end));
|
|
2127
|
-
if (!tokenText) {
|
|
2128
|
-
return [...acc, token];
|
|
2129
|
-
}
|
|
2130
|
-
const getStartIndex = start => {
|
|
2131
|
-
let length = start;
|
|
2132
|
-
while (length >= 0) {
|
|
2133
|
-
let newStartIndex = modelText.slice(length).indexOf(tokenText);
|
|
2134
|
-
if (newStartIndex >= 0) {
|
|
2135
|
-
return newStartIndex + length;
|
|
2136
|
-
}
|
|
2137
|
-
length--;
|
|
2138
|
-
}
|
|
2139
|
-
return 0;
|
|
2140
|
-
};
|
|
2141
|
-
const lastToken = acc[acc.length - 1];
|
|
2142
|
-
const newStart = getStartIndex(lastToken ? lastToken.end : token.start);
|
|
2143
|
-
const newEnd = newStart + tokenText.length;
|
|
2144
|
-
return [...acc, {
|
|
2145
|
-
...token,
|
|
2146
|
-
text: tokenText,
|
|
2147
|
-
start: newStart,
|
|
2148
|
-
end: newEnd,
|
|
2149
|
-
oldStart: token.start,
|
|
2150
|
-
oldEnd: token.end
|
|
2151
|
-
}];
|
|
2152
|
-
}, []);
|
|
2153
|
-
return {
|
|
2154
|
-
...model,
|
|
2155
|
-
tokens: newTokens,
|
|
2156
|
-
text: modelText
|
|
2157
|
-
};
|
|
2158
|
-
};
|
|
2159
|
-
const React$1 = _dll_react;
|
|
2160
|
-
const PropTypes = _dll_prop_types;
|
|
2161
|
-
const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
|
|
2162
|
-
const {color: color} = _dll_pie_lib__render_ui;
|
|
2163
|
-
const {Feedback: Feedback} = _dll_pie_lib__render_ui;
|
|
2164
|
-
const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
|
|
2165
|
-
const {hasText: hasText} = _dll_pie_lib__render_ui;
|
|
2166
|
-
const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
|
|
2167
|
-
const {withStyles: withStyles} = _dll_material_ui__core_styles;
|
|
2168
|
-
const debug$1 = _dll_debug;
|
|
2169
|
-
const _jsxFileName = "/home/circleci/repo/packages/select-text/src/main.jsx";
|
|
2170
|
-
const log$1 = debug$1('@pie-ui:select-text');
|
|
2171
|
-
const Types = {
|
|
2172
|
-
model: PropTypes.object,
|
|
2173
|
-
session: PropTypes.object,
|
|
2174
|
-
onSelectionChange: PropTypes.func.isRequired
|
|
2175
|
-
};
|
|
2176
|
-
class Main extends React$1.Component {
|
|
2177
|
-
static __initStatic() {
|
|
2178
|
-
this.propTypes = {
|
|
2179
|
-
...Types,
|
|
2180
|
-
classes: PropTypes.object.isRequired
|
|
2181
|
-
};
|
|
2182
|
-
}
|
|
2183
|
-
static __initStatic2() {
|
|
2184
|
-
this.defaultProps = {};
|
|
2185
|
-
}
|
|
2186
|
-
constructor(props) {
|
|
2187
|
-
super(props);
|
|
2188
|
-
Main.prototype.__init.call(this);
|
|
2189
|
-
Main.prototype.__init2.call(this);
|
|
2190
|
-
this.state = {
|
|
2191
|
-
showCorrectAnswer: this.props.model.alwaysShowCorrect || false,
|
|
2192
|
-
model: generateModel(props.model)
|
|
2193
|
-
};
|
|
2194
|
-
}
|
|
2195
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
2196
|
-
this.setState({
|
|
2197
|
-
showCorrectAnswer: !!nextProps.model.alwaysShowCorrect,
|
|
2198
|
-
model: generateModel(nextProps.model)
|
|
2199
|
-
});
|
|
2200
|
-
}
|
|
2201
|
-
__init() {
|
|
2202
|
-
this.toggleShowCorrect = () => {
|
|
2203
|
-
this.setState({
|
|
2204
|
-
showCorrectAnswer: !this.state.showCorrectAnswer
|
|
2205
|
-
});
|
|
2206
|
-
};
|
|
2207
|
-
}
|
|
2208
|
-
__init2() {
|
|
2209
|
-
this.correctAnswer = () => {
|
|
2210
|
-
const {model} = this.state;
|
|
2211
|
-
return model.tokens.filter(t => t.correct);
|
|
2212
|
-
};
|
|
2213
|
-
}
|
|
2214
|
-
render() {
|
|
2215
|
-
const {session, onSelectionChange, classes} = this.props;
|
|
2216
|
-
const {showCorrectAnswer, model} = this.state;
|
|
2217
|
-
const selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;
|
|
2218
|
-
log$1('[render] selectedTokens:', selectedTokens);
|
|
2219
|
-
return React$1.createElement('div', {
|
|
2220
|
-
className: classes.mainContainer,
|
|
2221
|
-
__self: this,
|
|
2222
|
-
__source: {
|
|
2223
|
-
fileName: _jsxFileName,
|
|
2224
|
-
lineNumber: 61
|
|
2225
|
-
}
|
|
2226
|
-
}, model.teacherInstructions && hasText(model.teacherInstructions) && React$1.createElement(React$1.Fragment, {
|
|
2227
|
-
__self: this,
|
|
2228
|
-
__source: {
|
|
2229
|
-
fileName: _jsxFileName,
|
|
2230
|
-
lineNumber: 64
|
|
2231
|
-
}
|
|
2232
|
-
}, !model.animationsDisabled ? React$1.createElement(Collapsible, {
|
|
2233
|
-
labels: {
|
|
2234
|
-
hidden: 'Show Teacher Instructions',
|
|
2235
|
-
visible: 'Hide Teacher Instructions'
|
|
2236
|
-
},
|
|
2237
|
-
className: classes.collapsible,
|
|
2238
|
-
__self: this,
|
|
2239
|
-
__source: {
|
|
2240
|
-
fileName: _jsxFileName,
|
|
2241
|
-
lineNumber: 65
|
|
2242
|
-
}
|
|
2243
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
2244
|
-
prompt: model.teacherInstructions,
|
|
2245
|
-
__self: this,
|
|
2246
|
-
__source: {
|
|
2247
|
-
fileName: _jsxFileName,
|
|
2248
|
-
lineNumber: 69
|
|
2249
|
-
}
|
|
2250
|
-
})) : React$1.createElement(PreviewPrompt, {
|
|
2251
|
-
prompt: model.teacherInstructions,
|
|
2252
|
-
__self: this,
|
|
2253
|
-
__source: {
|
|
2254
|
-
fileName: _jsxFileName,
|
|
2255
|
-
lineNumber: 72
|
|
2256
|
-
}
|
|
2257
|
-
}), React$1.createElement('br', {
|
|
2258
|
-
__self: this,
|
|
2259
|
-
__source: {
|
|
2260
|
-
fileName: _jsxFileName,
|
|
2261
|
-
lineNumber: 74
|
|
2262
|
-
}
|
|
2263
|
-
})), React$1.createElement('div', {
|
|
2264
|
-
className: classes.prompt,
|
|
2265
|
-
__self: this,
|
|
2266
|
-
__source: {
|
|
2267
|
-
fileName: _jsxFileName,
|
|
2268
|
-
lineNumber: 78
|
|
2269
|
-
}
|
|
2270
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
2271
|
-
prompt: model.prompt,
|
|
2272
|
-
__self: this,
|
|
2273
|
-
__source: {
|
|
2274
|
-
fileName: _jsxFileName,
|
|
2275
|
-
lineNumber: 79
|
|
2276
|
-
}
|
|
2277
|
-
})), !model.alwaysShowCorrect && React$1.createElement(CorrectAnswerToggle, {
|
|
2278
|
-
show: model.disabled && model.incorrect,
|
|
2279
|
-
toggled: showCorrectAnswer,
|
|
2280
|
-
onToggle: this.toggleShowCorrect,
|
|
2281
|
-
__self: this,
|
|
2282
|
-
__source: {
|
|
2283
|
-
fileName: _jsxFileName,
|
|
2284
|
-
lineNumber: 82
|
|
2285
|
-
}
|
|
2286
|
-
}), React$1.createElement(TextSelect, {
|
|
2287
|
-
className: classes.textSelect,
|
|
2288
|
-
disabled: model.disabled,
|
|
2289
|
-
text: model.text,
|
|
2290
|
-
tokens: model.tokens,
|
|
2291
|
-
selectedTokens: selectedTokens,
|
|
2292
|
-
onChange: selection => {
|
|
2293
|
-
const newSelections = selection.map(select => {
|
|
2294
|
-
const token = model.tokens.find(({start, end}) => select.start === start && select.end === end);
|
|
2295
|
-
if (token) {
|
|
2296
|
-
return token;
|
|
2297
|
-
}
|
|
2298
|
-
return select;
|
|
2299
|
-
});
|
|
2300
|
-
onSelectionChange(newSelections);
|
|
2301
|
-
},
|
|
2302
|
-
highlightChoices: model.highlightChoices,
|
|
2303
|
-
maxNoOfSelections: model.maxSelections,
|
|
2304
|
-
animationsDisabled: model.animationsDisabled,
|
|
2305
|
-
__self: this,
|
|
2306
|
-
__source: {
|
|
2307
|
-
fileName: _jsxFileName,
|
|
2308
|
-
lineNumber: 88
|
|
2309
|
-
}
|
|
2310
|
-
}), model.rationale && hasText(model.rationale) && React$1.createElement(React$1.Fragment, {
|
|
2311
|
-
__self: this,
|
|
2312
|
-
__source: {
|
|
2313
|
-
fileName: _jsxFileName,
|
|
2314
|
-
lineNumber: 114
|
|
2315
|
-
}
|
|
2316
|
-
}, !model.animationsDisabled ? React$1.createElement(Collapsible, {
|
|
2317
|
-
labels: {
|
|
2318
|
-
hidden: 'Show Rationale',
|
|
2319
|
-
visible: 'Hide Rationale'
|
|
2320
|
-
},
|
|
2321
|
-
className: classes.collapsible,
|
|
2322
|
-
className: classes.collapsible,
|
|
2323
|
-
__self: this,
|
|
2324
|
-
__source: {
|
|
2325
|
-
fileName: _jsxFileName,
|
|
2326
|
-
lineNumber: 115
|
|
2327
|
-
}
|
|
2328
|
-
}, React$1.createElement(PreviewPrompt, {
|
|
2329
|
-
prompt: model.rationale,
|
|
2330
|
-
__self: this,
|
|
2331
|
-
__source: {
|
|
2332
|
-
fileName: _jsxFileName,
|
|
2333
|
-
lineNumber: 119
|
|
2334
|
-
}
|
|
2335
|
-
})) : React$1.createElement(PreviewPrompt, {
|
|
2336
|
-
prompt: model.rationale,
|
|
2337
|
-
__self: this,
|
|
2338
|
-
__source: {
|
|
2339
|
-
fileName: _jsxFileName,
|
|
2340
|
-
lineNumber: 121
|
|
2341
|
-
}
|
|
2342
|
-
})), model.correctness && model.feedback && !showCorrectAnswer && React$1.createElement(Feedback, {
|
|
2343
|
-
correctness: model.correctness,
|
|
2344
|
-
feedback: model.feedback,
|
|
2345
|
-
__self: this,
|
|
2346
|
-
__source: {
|
|
2347
|
-
fileName: _jsxFileName,
|
|
2348
|
-
lineNumber: 126
|
|
2349
|
-
}
|
|
2350
|
-
}));
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
Main.__initStatic();
|
|
2354
|
-
Main.__initStatic2();
|
|
2355
|
-
const StyledMain = withStyles(theme => ({
|
|
2356
|
-
mainContainer: {
|
|
2357
|
-
paddingLeft: theme.spacing.unit,
|
|
2358
|
-
paddingRight: theme.spacing.unit,
|
|
2359
|
-
paddingBottom: theme.spacing.unit,
|
|
2360
|
-
color: color.text(),
|
|
2361
|
-
backgroundColor: color.background()
|
|
2362
|
-
},
|
|
2363
|
-
textSelect: {
|
|
2364
|
-
marginBottom: theme.spacing.unit,
|
|
2365
|
-
marginTop: theme.spacing.unit,
|
|
2366
|
-
whiteSpace: 'normal'
|
|
2367
|
-
},
|
|
2368
|
-
prompt: {
|
|
2369
|
-
verticalAlign: 'middle',
|
|
2370
|
-
marginBottom: theme.spacing.unit
|
|
2371
|
-
},
|
|
2372
|
-
collapsible: {
|
|
2373
|
-
paddingTop: theme.spacing.unit * 2,
|
|
2374
|
-
paddingBottom: theme.spacing.unit * 3
|
|
2375
|
-
}
|
|
2376
|
-
}))(Main);
|
|
2377
|
-
class Stateful extends React$1.Component {
|
|
2378
|
-
static __initStatic3() {
|
|
2379
|
-
this.propTypes = Types;
|
|
2380
|
-
}
|
|
2381
|
-
constructor(props) {
|
|
2382
|
-
super(props);
|
|
2383
|
-
Stateful.prototype.__init3.call(this);
|
|
2384
|
-
this.state = {
|
|
2385
|
-
model: props.model,
|
|
2386
|
-
session: props.session
|
|
2387
|
-
};
|
|
2388
|
-
}
|
|
2389
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
2390
|
-
this.setState({
|
|
2391
|
-
model: nextProps.model,
|
|
2392
|
-
session: nextProps.session
|
|
2393
|
-
});
|
|
2394
|
-
}
|
|
2395
|
-
__init3() {
|
|
2396
|
-
this.change = selectedTokens => {
|
|
2397
|
-
const session = {
|
|
2398
|
-
...this.state.session,
|
|
2399
|
-
selectedTokens
|
|
2400
|
-
};
|
|
2401
|
-
this.setState({
|
|
2402
|
-
session
|
|
2403
|
-
}, () => {
|
|
2404
|
-
this.props.onSelectionChange(this.state.session.selectedTokens);
|
|
2405
|
-
});
|
|
2406
|
-
};
|
|
2407
|
-
}
|
|
2408
|
-
render() {
|
|
2409
|
-
const {model, session} = this.state;
|
|
2410
|
-
return React$1.createElement(StyledMain, {
|
|
2411
|
-
model: model,
|
|
2412
|
-
session: session,
|
|
2413
|
-
onSelectionChange: this.change,
|
|
2414
|
-
__self: this,
|
|
2415
|
-
__source: {
|
|
2416
|
-
fileName: _jsxFileName,
|
|
2417
|
-
lineNumber: 181
|
|
2418
|
-
}
|
|
2419
|
-
});
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
Stateful.__initStatic3();
|
|
2423
|
-
const React = _dll_react;
|
|
2424
|
-
const ReactDOM = _dll_react_dom;
|
|
2425
|
-
const {debounce: debounce} = _dll_lodash;
|
|
2426
|
-
const debug = _dll_debug;
|
|
2427
|
-
const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
|
|
2428
|
-
const log = debug('pie-element:select-text:print');
|
|
2429
|
-
const preparePrintModel = (model, opts) => {
|
|
2430
|
-
const instr = opts.role === 'instructor';
|
|
2431
|
-
model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
|
|
2432
|
-
model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
|
|
2433
|
-
model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;
|
|
2434
|
-
model.showTeacherInstructions = instr;
|
|
2435
|
-
model.alwaysShowCorrect = instr;
|
|
2436
|
-
model.mode = instr ? 'evaluate' : model.mode;
|
|
2437
|
-
model.disabled = true;
|
|
2438
|
-
model.animationsDisabled = true;
|
|
2439
|
-
model.highlightChoices = true;
|
|
2440
|
-
model.feedback = undefined;
|
|
2441
|
-
return model;
|
|
2442
|
-
};
|
|
2443
|
-
class SelectTextPrint extends HTMLElement {
|
|
2444
|
-
constructor() {
|
|
2445
|
-
super();
|
|
2446
|
-
this._options = null;
|
|
2447
|
-
this._model = null;
|
|
2448
|
-
this._session = {};
|
|
2449
|
-
this._session.selectedTokens = [];
|
|
2450
|
-
this._rerender = debounce(() => {
|
|
2451
|
-
if (this._model && this._session) {
|
|
2452
|
-
const printModel = preparePrintModel(this._model, this._options);
|
|
2453
|
-
const element = this._options && React.createElement(Stateful, {
|
|
2454
|
-
model: printModel,
|
|
2455
|
-
session: {
|
|
2456
|
-
selectedTokens: []
|
|
2457
|
-
},
|
|
2458
|
-
onSelectionChange: () => {}
|
|
2459
|
-
});
|
|
2460
|
-
ReactDOM.render(element, this, () => {
|
|
2461
|
-
log('render complete - render math');
|
|
2462
|
-
renderMath(this);
|
|
2463
|
-
});
|
|
2464
|
-
} else {
|
|
2465
|
-
log('skip');
|
|
2466
|
-
}
|
|
2467
|
-
}, 50, {
|
|
2468
|
-
leading: false,
|
|
2469
|
-
trailing: true
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
set options(o) {
|
|
2473
|
-
this._options = o;
|
|
2474
|
-
}
|
|
2475
|
-
set model(s) {
|
|
2476
|
-
this._model = s;
|
|
2477
|
-
this._rerender();
|
|
2478
|
-
}
|
|
2479
|
-
connectedCallback() {}
|
|
2480
|
-
}
|
|
2481
|
-
export {SelectTextPrint as default};
|