@pie-element/select-text 6.6.1 → 6.6.4

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.
@@ -1,2797 +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_material_ui__icons, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.15/module/index.js";
2
- import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.2.2/module/index.js";
3
- import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.5.2/module/index.js";
4
- const React$7 = _dll_react;
5
- const PropTypes$6 = _dll_prop_types;
6
- const {Button: Button} = _dll_material_ui__core;
7
- const {Switch: Switch} = _dll_material_ui__core;
8
- const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
9
- const {withStyles: withStyles$5} = _dll_material_ui__core_styles;
10
- const _jsxFileName$6 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/tokenizer/controls.jsx";
11
- class Controls extends React$7.Component {
12
- static __initStatic() {
13
- this.propTypes = {
14
- classes: PropTypes$6.object.isRequired,
15
- onClear: PropTypes$6.func.isRequired,
16
- onWords: PropTypes$6.func.isRequired,
17
- onSentences: PropTypes$6.func.isRequired,
18
- onParagraphs: PropTypes$6.func.isRequired,
19
- setCorrectMode: PropTypes$6.bool.isRequired,
20
- onToggleCorrectMode: PropTypes$6.func.isRequired
21
- };
22
- }
23
- static __initStatic2() {
24
- this.defaultProps = {};
25
- }
26
- render() {
27
- const {classes, onClear, onWords, onSentences, onParagraphs, setCorrectMode, onToggleCorrectMode} = this.props;
28
- return React$7.createElement('div', {
29
- className: classes.controls,
30
- __self: this,
31
- __source: {
32
- fileName: _jsxFileName$6,
33
- lineNumber: 33
34
- }
35
- }, React$7.createElement('div', {
36
- __self: this,
37
- __source: {
38
- fileName: _jsxFileName$6,
39
- lineNumber: 34
40
- }
41
- }, React$7.createElement(Button, {
42
- onClick: onWords,
43
- className: classes.button,
44
- size: "small",
45
- color: "primary",
46
- disabled: setCorrectMode,
47
- __self: this,
48
- __source: {
49
- fileName: _jsxFileName$6,
50
- lineNumber: 35
51
- }
52
- }, "Words"), React$7.createElement(Button, {
53
- onClick: onSentences,
54
- className: classes.button,
55
- size: "small",
56
- color: "primary",
57
- disabled: setCorrectMode,
58
- __self: this,
59
- __source: {
60
- fileName: _jsxFileName$6,
61
- lineNumber: 44
62
- }
63
- }, "Sentences"), React$7.createElement(Button, {
64
- onClick: onParagraphs,
65
- className: classes.button,
66
- size: "small",
67
- color: "primary",
68
- disabled: setCorrectMode,
69
- __self: this,
70
- __source: {
71
- fileName: _jsxFileName$6,
72
- lineNumber: 53
73
- }
74
- }, "Paragraphs"), React$7.createElement(Button, {
75
- className: classes.button,
76
- size: "small",
77
- color: "secondary",
78
- onClick: onClear,
79
- disabled: setCorrectMode,
80
- __self: this,
81
- __source: {
82
- fileName: _jsxFileName$6,
83
- lineNumber: 62
84
- }
85
- }, "Clear")), React$7.createElement(FormControlLabel, {
86
- control: React$7.createElement(Switch, {
87
- checked: setCorrectMode,
88
- onChange: onToggleCorrectMode,
89
- __self: this,
90
- __source: {
91
- fileName: _jsxFileName$6,
92
- lineNumber: 73
93
- }
94
- }),
95
- label: "Set correct answers",
96
- __self: this,
97
- __source: {
98
- fileName: _jsxFileName$6,
99
- lineNumber: 72
100
- }
101
- }));
102
- }
103
- }
104
- Controls.__initStatic();
105
- Controls.__initStatic2();
106
- var Controls$1 = withStyles$5(theme => ({
107
- button: {
108
- marginRight: theme.spacing.unit
109
- },
110
- controls: {
111
- display: 'flex',
112
- alignItems: 'center',
113
- justifyContent: 'space-between'
114
- }
115
- }))(Controls);
116
- var nlcstToString_1 = nlcstToString;
117
- function nlcstToString(node, separator) {
118
- var sep = separator || '';
119
- var values;
120
- var length;
121
- var children;
122
- if (!node || !(('length' in node)) && !node.type) {
123
- throw new Error('Expected node, not `' + node + '`');
124
- }
125
- if (typeof node.value === 'string') {
126
- return node.value;
127
- }
128
- children = ('length' in node) ? node : node.children;
129
- length = children.length;
130
- if (length === 1 && ('value' in children[0])) {
131
- return children[0].value;
132
- }
133
- values = [];
134
- while (length--) {
135
- values[length] = nlcstToString(children[length], sep);
136
- }
137
- return values.join(sep);
138
- }
139
- var unistUtilVisitChildren = visitChildren$4;
140
- function visitChildren$4(callback) {
141
- return visitor;
142
- function visitor(parent) {
143
- var index = -1;
144
- var children = parent && parent.children;
145
- if (!children) {
146
- throw new Error('Missing children in `parent` for `visitor`');
147
- }
148
- while ((++index in children)) {
149
- callback(children[index], index, parent);
150
- }
151
- }
152
- }
153
- var arrayIterate = iterate$2;
154
- var own = ({}).hasOwnProperty;
155
- function iterate$2(values, callback, context) {
156
- var index = -1;
157
- var result;
158
- if (!values) {
159
- throw new Error('Iterate requires that |this| not be ' + values);
160
- }
161
- if (!own.call(values, 'length')) {
162
- throw new Error('Iterate requires that |this| has a `length`');
163
- }
164
- if (typeof callback !== 'function') {
165
- throw new Error('`callback` must be a function');
166
- }
167
- while (++index < values.length) {
168
- if (!((index in values))) {
169
- continue;
170
- }
171
- result = callback.call(context, values[index], index, values);
172
- if (typeof result === 'number') {
173
- if (result < 0) {
174
- index = 0;
175
- }
176
- index = result - 1;
177
- }
178
- }
179
- }
180
- var iterate$1 = arrayIterate;
181
- var unistUtilModifyChildren$1 = modifierFactory$1;
182
- function modifierFactory$1(callback) {
183
- return iteratorFactory$1(wrapperFactory$1(callback));
184
- }
185
- function iteratorFactory$1(callback) {
186
- return iterator;
187
- function iterator(parent) {
188
- var children = parent && parent.children;
189
- if (!children) {
190
- throw new Error('Missing children in `parent` for `modifier`');
191
- }
192
- return iterate$1(children, callback, parent);
193
- }
194
- }
195
- function wrapperFactory$1(callback) {
196
- return wrapper;
197
- function wrapper(value, index) {
198
- return callback(value, index, this);
199
- }
200
- }
201
- var toString$d = nlcstToString_1;
202
- var tokenizer$1 = tokenizerFactory;
203
- function tokenizerFactory(childType, expression) {
204
- return tokenizer;
205
- function tokenizer(node) {
206
- var children = [];
207
- var tokens = node.children;
208
- var type = node.type;
209
- var length = tokens.length;
210
- var index = -1;
211
- var lastIndex = length - 1;
212
- var start = 0;
213
- var first;
214
- var last;
215
- var parent;
216
- while (++index < length) {
217
- if (index === lastIndex || tokens[index].type === childType && expression.test(toString$d(tokens[index]))) {
218
- first = tokens[start];
219
- last = tokens[index];
220
- parent = {
221
- type: type,
222
- children: tokens.slice(start, index + 1)
223
- };
224
- if (first.position && last.position) {
225
- parent.position = {
226
- start: first.position.start,
227
- end: last.position.end
228
- };
229
- }
230
- children.push(parent);
231
- start = index + 1;
232
- }
233
- }
234
- return children;
235
- }
236
- }
237
- var tokenizer = tokenizer$1;
238
- var parser = parserFactory;
239
- function parserFactory(options) {
240
- var type = options.type;
241
- var tokenizerProperty = options.tokenizer;
242
- var delimiter = options.delimiter;
243
- var tokenize = delimiter && tokenizer(options.delimiterType, delimiter);
244
- return parser;
245
- function parser(value) {
246
- var children = this[tokenizerProperty](value);
247
- return {
248
- type: type,
249
- children: tokenize ? tokenize(children) : children
250
- };
251
- }
252
- }
253
- var expressions$8 = {
254
- 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*$/,
255
- newLine: /^[ \t]*((\r?\n|\r)[\t ]*)+$/,
256
- newLineMulti: /^[ \t]*((\r?\n|\r)[\t ]*){2,}$/,
257
- terminalMarker: /^([!.?\u2026\u203D]+)$/,
258
- wordSymbolInner: /^([&'\-.:=?@\xAD\xB7\u2010\u2011\u2019\u2027]|_+)$/,
259
- 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])+$/,
260
- digitStart: /^\d/,
261
- 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])/,
262
- surrogates: /[\uD800-\uDFFF]/,
263
- 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]/,
264
- 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]/,
265
- whiteSpace: /[\t-\r \x85\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
266
- };
267
- var iterate = arrayIterate;
268
- var unistUtilModifyChildren = modifierFactory;
269
- function modifierFactory(callback) {
270
- return iteratorFactory(wrapperFactory(callback));
271
- }
272
- function iteratorFactory(callback) {
273
- return iterator;
274
- function iterator(parent) {
275
- var children = parent && parent.children;
276
- if (!children) {
277
- throw new Error('Missing children in `parent` for `modifier`');
278
- }
279
- iterate(children, callback, parent);
280
- }
281
- }
282
- function wrapperFactory(callback) {
283
- return wrapper;
284
- function wrapper(value, index) {
285
- return callback(value, index, this);
286
- }
287
- }
288
- var toString$c = nlcstToString_1;
289
- var modifyChildren$f = unistUtilModifyChildren;
290
- var mergeInitialWordSymbol_1 = modifyChildren$f(mergeInitialWordSymbol);
291
- function mergeInitialWordSymbol(child, index, parent) {
292
- var children;
293
- var next;
294
- if (child.type !== 'SymbolNode' && child.type !== 'PunctuationNode' || toString$c(child) !== '&') {
295
- return;
296
- }
297
- children = parent.children;
298
- next = children[index + 1];
299
- if (index !== 0 && children[index - 1].type === 'WordNode' || !(next && next.type === 'WordNode')) {
300
- return;
301
- }
302
- children.splice(index, 1);
303
- next.children.unshift(child);
304
- if (next.position && child.position) {
305
- next.position.start = child.position.start;
306
- }
307
- return index - 1;
308
- }
309
- var toString$b = nlcstToString_1;
310
- var modifyChildren$e = unistUtilModifyChildren;
311
- var mergeFinalWordSymbol_1 = modifyChildren$e(mergeFinalWordSymbol$1);
312
- function mergeFinalWordSymbol$1(child, index, parent) {
313
- var children;
314
- var previous;
315
- var next;
316
- if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && toString$b(child) === '-') {
317
- children = parent.children;
318
- previous = children[index - 1];
319
- next = children[index + 1];
320
- if ((!next || next.type !== 'WordNode') && previous && previous.type === 'WordNode') {
321
- children.splice(index, 1);
322
- previous.children.push(child);
323
- if (previous.position && child.position) {
324
- previous.position.end = child.position.end;
325
- }
326
- return index;
327
- }
328
- }
329
- }
330
- var toString$a = nlcstToString_1;
331
- var modifyChildren$d = unistUtilModifyChildren;
332
- var expressions$7 = expressions$8;
333
- var mergeInnerWordSymbol_1 = modifyChildren$d(mergeInnerWordSymbol);
334
- var wordSymbolInner = expressions$7.wordSymbolInner;
335
- function mergeInnerWordSymbol(child, index, parent) {
336
- var siblings;
337
- var sibling;
338
- var previous;
339
- var last;
340
- var position;
341
- var tokens;
342
- var queue;
343
- if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode')) {
344
- siblings = parent.children;
345
- previous = siblings[index - 1];
346
- if (previous && previous.type === 'WordNode') {
347
- position = index - 1;
348
- tokens = [];
349
- queue = [];
350
- while (siblings[++position]) {
351
- sibling = siblings[position];
352
- if (sibling.type === 'WordNode') {
353
- tokens = tokens.concat(queue, sibling.children);
354
- queue = [];
355
- } else if ((sibling.type === 'SymbolNode' || sibling.type === 'PunctuationNode') && wordSymbolInner.test(toString$a(sibling))) {
356
- queue.push(sibling);
357
- } else {
358
- break;
359
- }
360
- }
361
- if (tokens.length !== 0) {
362
- if (queue.length !== 0) {
363
- position -= queue.length;
364
- }
365
- siblings.splice(index, position - index);
366
- previous.children = previous.children.concat(tokens);
367
- last = tokens[tokens.length - 1];
368
- if (previous.position && last.position) {
369
- previous.position.end = last.position.end;
370
- }
371
- return index;
372
- }
373
- }
374
- }
375
- }
376
- var toString$9 = nlcstToString_1;
377
- var modifyChildren$c = unistUtilModifyChildren;
378
- var mergeInnerWordSlash_1 = modifyChildren$c(mergeInnerWordSlash);
379
- var slash = '/';
380
- function mergeInnerWordSlash(child, index, parent) {
381
- var siblings = parent.children;
382
- var previous;
383
- var next;
384
- var previousValue;
385
- var nextValue;
386
- var queue;
387
- var tail;
388
- var count;
389
- previous = siblings[index - 1];
390
- next = siblings[index + 1];
391
- if (previous && previous.type === 'WordNode' && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && toString$9(child) === slash) {
392
- previousValue = toString$9(previous);
393
- tail = child;
394
- queue = [child];
395
- count = 1;
396
- if (next && next.type === 'WordNode') {
397
- nextValue = toString$9(next);
398
- tail = next;
399
- queue = queue.concat(next.children);
400
- count++;
401
- }
402
- if (previousValue.length < 3 && (!nextValue || nextValue.length < 3)) {
403
- previous.children = previous.children.concat(queue);
404
- siblings.splice(index, count);
405
- if (previous.position && tail.position) {
406
- previous.position.end = tail.position.end;
407
- }
408
- return index;
409
- }
410
- }
411
- }
412
- var toString$8 = nlcstToString_1;
413
- var modifyChildren$b = unistUtilModifyChildren;
414
- var expressions$6 = expressions$8;
415
- var mergeInitialisms_1 = modifyChildren$b(mergeInitialisms);
416
- var numerical = expressions$6.numerical;
417
- function mergeInitialisms(child, index, parent) {
418
- var siblings;
419
- var previous;
420
- var children;
421
- var length;
422
- var position;
423
- var otherChild;
424
- var isAllDigits;
425
- var value;
426
- if (index !== 0 && toString$8(child) === '.') {
427
- siblings = parent.children;
428
- previous = siblings[index - 1];
429
- children = previous.children;
430
- length = children && children.length;
431
- if (previous.type === 'WordNode' && length !== 1 && length % 2 !== 0) {
432
- position = length;
433
- isAllDigits = true;
434
- while (children[--position]) {
435
- otherChild = children[position];
436
- value = toString$8(otherChild);
437
- if (position % 2 === 0) {
438
- if (value.length > 1) {
439
- return;
440
- }
441
- if (!numerical.test(value)) {
442
- isAllDigits = false;
443
- }
444
- } else if (value !== '.') {
445
- if (position < length - 2) {
446
- break;
447
- } else {
448
- return;
449
- }
450
- }
451
- }
452
- if (!isAllDigits) {
453
- siblings.splice(index, 1);
454
- children.push(child);
455
- if (previous.position && child.position) {
456
- previous.position.end = child.position.end;
457
- }
458
- return index;
459
- }
460
- }
461
- }
462
- }
463
- var modifyChildren$a = unistUtilModifyChildren;
464
- var mergeWords = modifyChildren$a(mergeFinalWordSymbol);
465
- function mergeFinalWordSymbol(child, index, parent) {
466
- var siblings = parent.children;
467
- var next;
468
- if (child.type === 'WordNode') {
469
- next = siblings[index + 1];
470
- if (next && next.type === 'WordNode') {
471
- siblings.splice(index + 1, 1);
472
- child.children = child.children.concat(next.children);
473
- if (next.position && child.position) {
474
- child.position.end = next.position.end;
475
- }
476
- return index;
477
- }
478
- }
479
- }
480
- var visitChildren$3 = unistUtilVisitChildren;
481
- var patchPosition_1 = visitChildren$3(patchPosition$1);
482
- function patchPosition$1(child, index, node) {
483
- var siblings = node.children;
484
- if (!child.position) {
485
- return;
486
- }
487
- if (index === 0 && (!node.position || !node.position.start)) {
488
- patch(node);
489
- node.position.start = child.position.start;
490
- }
491
- if (index === siblings.length - 1 && (!node.position || !node.position.end)) {
492
- patch(node);
493
- node.position.end = child.position.end;
494
- }
495
- }
496
- function patch(node) {
497
- if (!node.position) {
498
- node.position = {};
499
- }
500
- }
501
- var modifyChildren$9 = unistUtilModifyChildren;
502
- var mergeNonWordSentences_1 = modifyChildren$9(mergeNonWordSentences$1);
503
- function mergeNonWordSentences$1(child, index, parent) {
504
- var children = child.children;
505
- var position = -1;
506
- var previous;
507
- var next;
508
- while (children[++position]) {
509
- if (children[position].type === 'WordNode') {
510
- return;
511
- }
512
- }
513
- previous = parent.children[index - 1];
514
- if (previous) {
515
- previous.children = previous.children.concat(children);
516
- parent.children.splice(index, 1);
517
- if (previous.position && child.position) {
518
- previous.position.end = child.position.end;
519
- }
520
- return index;
521
- }
522
- next = parent.children[index + 1];
523
- if (next) {
524
- next.children = children.concat(next.children);
525
- if (next.position && child.position) {
526
- next.position.start = child.position.start;
527
- }
528
- parent.children.splice(index, 1);
529
- }
530
- }
531
- var toString$7 = nlcstToString_1;
532
- var modifyChildren$8 = unistUtilModifyChildren;
533
- var expressions$5 = expressions$8;
534
- var mergeAffixSymbol_1 = modifyChildren$8(mergeAffixSymbol$1);
535
- var affixSymbol = expressions$5.affixSymbol;
536
- function mergeAffixSymbol$1(child, index, parent) {
537
- var children = child.children;
538
- var first;
539
- var second;
540
- var previous;
541
- if (children && children.length !== 0 && index !== 0) {
542
- first = children[0];
543
- second = children[1];
544
- previous = parent.children[index - 1];
545
- if ((first.type === 'SymbolNode' || first.type === 'PunctuationNode') && affixSymbol.test(toString$7(first))) {
546
- previous.children.push(children.shift());
547
- if (first.position && previous.position) {
548
- previous.position.end = first.position.end;
549
- }
550
- if (second && second.position && child.position) {
551
- child.position.start = second.position.start;
552
- }
553
- return index - 1;
554
- }
555
- }
556
- }
557
- var toString$6 = nlcstToString_1;
558
- var modifyChildren$7 = unistUtilModifyChildren;
559
- var expressions$4 = expressions$8;
560
- var mergeInitialLowerCaseLetterSentences_1 = modifyChildren$7(mergeInitialLowerCaseLetterSentences$1);
561
- var lowerInitial = expressions$4.lowerInitial;
562
- function mergeInitialLowerCaseLetterSentences$1(child, index, parent) {
563
- var children = child.children;
564
- var position;
565
- var node;
566
- var siblings;
567
- var previous;
568
- if (children && children.length !== 0 && index !== 0) {
569
- position = -1;
570
- while (children[++position]) {
571
- node = children[position];
572
- if (node.type === 'WordNode') {
573
- if (!lowerInitial.test(toString$6(node))) {
574
- return;
575
- }
576
- siblings = parent.children;
577
- previous = siblings[index - 1];
578
- previous.children = previous.children.concat(children);
579
- siblings.splice(index, 1);
580
- if (previous.position && child.position) {
581
- previous.position.end = child.position.end;
582
- }
583
- return index;
584
- }
585
- if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
586
- return;
587
- }
588
- }
589
- }
590
- }
591
- var toString$5 = nlcstToString_1;
592
- var modifyChildren$6 = unistUtilModifyChildren;
593
- var expressions$3 = expressions$8;
594
- var mergeInitialDigitSentences_1 = modifyChildren$6(mergeInitialDigitSentences$1);
595
- var digit = expressions$3.digitStart;
596
- function mergeInitialDigitSentences$1(child, index, parent) {
597
- var children = child.children;
598
- var siblings = parent.children;
599
- var previous = siblings[index - 1];
600
- var head = children[0];
601
- if (previous && head && head.type === 'WordNode' && digit.test(toString$5(head))) {
602
- previous.children = previous.children.concat(children);
603
- siblings.splice(index, 1);
604
- if (previous.position && child.position) {
605
- previous.position.end = child.position.end;
606
- }
607
- return index;
608
- }
609
- }
610
- var toString$4 = nlcstToString_1;
611
- var modifyChildren$5 = unistUtilModifyChildren;
612
- var mergePrefixExceptions_1 = modifyChildren$5(mergePrefixExceptions);
613
- 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' + ')$');
614
- function mergePrefixExceptions(child, index, parent) {
615
- var children = child.children;
616
- var period;
617
- var node;
618
- var next;
619
- if (children && children.length > 1) {
620
- period = children[children.length - 1];
621
- if (period && toString$4(period) === '.') {
622
- node = children[children.length - 2];
623
- if (node && node.type === 'WordNode' && abbreviationPrefix.test(toString$4(node).toLowerCase())) {
624
- node.children.push(period);
625
- children.pop();
626
- if (period.position && node.position) {
627
- node.position.end = period.position.end;
628
- }
629
- next = parent.children[index + 1];
630
- if (next) {
631
- child.children = children.concat(next.children);
632
- parent.children.splice(index + 1, 1);
633
- if (next.position && child.position) {
634
- child.position.end = next.position.end;
635
- }
636
- return index - 1;
637
- }
638
- }
639
- }
640
- }
641
- }
642
- var toString$3 = nlcstToString_1;
643
- var modifyChildren$4 = unistUtilModifyChildren;
644
- var mergeAffixExceptions_1 = modifyChildren$4(mergeAffixExceptions$1);
645
- function mergeAffixExceptions$1(child, index, parent) {
646
- var children = child.children;
647
- var node;
648
- var position;
649
- var value;
650
- var previousChild;
651
- if (!children || children.length === 0 || index === 0) {
652
- return;
653
- }
654
- position = -1;
655
- while (children[++position]) {
656
- node = children[position];
657
- if (node.type === 'WordNode') {
658
- return;
659
- }
660
- if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
661
- value = toString$3(node);
662
- if (value !== ',' && value !== ';') {
663
- return;
664
- }
665
- previousChild = parent.children[index - 1];
666
- previousChild.children = previousChild.children.concat(children);
667
- if (previousChild.position && child.position) {
668
- previousChild.position.end = child.position.end;
669
- }
670
- parent.children.splice(index, 1);
671
- return index;
672
- }
673
- }
674
- }
675
- var toString$2 = nlcstToString_1;
676
- var visitChildren$2 = unistUtilVisitChildren;
677
- var expressions$2 = expressions$8;
678
- var mergeRemainingFullStops_1 = visitChildren$2(mergeRemainingFullStops$1);
679
- var terminalMarker = expressions$2.terminalMarker;
680
- function mergeRemainingFullStops$1(child) {
681
- var children = child.children;
682
- var position = children.length;
683
- var hasFoundDelimiter = false;
684
- var grandchild;
685
- var previous;
686
- var next;
687
- var nextNext;
688
- while (children[--position]) {
689
- grandchild = children[position];
690
- if (grandchild.type !== 'SymbolNode' && grandchild.type !== 'PunctuationNode') {
691
- if (grandchild.type === 'WordNode') {
692
- hasFoundDelimiter = true;
693
- }
694
- continue;
695
- }
696
- if (!terminalMarker.test(toString$2(grandchild))) {
697
- continue;
698
- }
699
- if (!hasFoundDelimiter) {
700
- hasFoundDelimiter = true;
701
- continue;
702
- }
703
- if (toString$2(grandchild) !== '.') {
704
- continue;
705
- }
706
- previous = children[position - 1];
707
- next = children[position + 1];
708
- if (previous && previous.type === 'WordNode') {
709
- nextNext = children[position + 2];
710
- if (next && nextNext && next.type === 'WhiteSpaceNode' && toString$2(nextNext) === '.') {
711
- continue;
712
- }
713
- children.splice(position, 1);
714
- previous.children.push(grandchild);
715
- if (grandchild.position && previous.position) {
716
- previous.position.end = grandchild.position.end;
717
- }
718
- position--;
719
- } else if (next && next.type === 'WordNode') {
720
- children.splice(position, 1);
721
- next.children.unshift(grandchild);
722
- if (grandchild.position && next.position) {
723
- next.position.start = grandchild.position.start;
724
- }
725
- }
726
- }
727
- }
728
- var visitChildren$1 = unistUtilVisitChildren;
729
- var makeInitialWhiteSpaceSiblings_1 = visitChildren$1(makeInitialWhiteSpaceSiblings$1);
730
- function makeInitialWhiteSpaceSiblings$1(child, index, parent) {
731
- var children = child.children;
732
- var next;
733
- if (children && children.length !== 0 && children[0].type === 'WhiteSpaceNode') {
734
- parent.children.splice(index, 0, children.shift());
735
- next = children[0];
736
- if (next && next.position && child.position) {
737
- child.position.start = next.position.start;
738
- }
739
- }
740
- }
741
- var modifyChildren$3 = unistUtilModifyChildren;
742
- var makeFinalWhiteSpaceSiblings_1 = modifyChildren$3(makeFinalWhiteSpaceSiblings$1);
743
- function makeFinalWhiteSpaceSiblings$1(child, index, parent) {
744
- var children = child.children;
745
- var previous;
746
- if (children && children.length !== 0 && children[children.length - 1].type === 'WhiteSpaceNode') {
747
- parent.children.splice(index + 1, 0, child.children.pop());
748
- previous = children[children.length - 1];
749
- if (previous && previous.position && child.position) {
750
- child.position.end = previous.position.end;
751
- }
752
- return index;
753
- }
754
- }
755
- var toString$1 = nlcstToString_1;
756
- var modifyChildren$2 = unistUtilModifyChildren;
757
- var expressions$1 = expressions$8;
758
- var breakImplicitSentences_1 = modifyChildren$2(breakImplicitSentences$1);
759
- var multiNewLine = expressions$1.newLineMulti;
760
- function breakImplicitSentences$1(child, index, parent) {
761
- var children;
762
- var position;
763
- var length;
764
- var tail;
765
- var head;
766
- var end;
767
- var insertion;
768
- var node;
769
- if (child.type !== 'SentenceNode') {
770
- return;
771
- }
772
- children = child.children;
773
- length = children.length - 1;
774
- position = 0;
775
- while (++position < length) {
776
- node = children[position];
777
- if (node.type !== 'WhiteSpaceNode' || !multiNewLine.test(toString$1(node))) {
778
- continue;
779
- }
780
- child.children = children.slice(0, position);
781
- insertion = {
782
- type: 'SentenceNode',
783
- children: children.slice(position + 1)
784
- };
785
- tail = children[position - 1];
786
- head = children[position + 1];
787
- parent.children.splice(index + 1, 0, node, insertion);
788
- if (child.position && tail.position && head.position) {
789
- end = child.position.end;
790
- child.position.end = tail.position.end;
791
- insertion.position = {
792
- start: head.position.start,
793
- end: end
794
- };
795
- }
796
- return index + 1;
797
- }
798
- }
799
- var modifyChildren$1 = unistUtilModifyChildren;
800
- var removeEmptyNodes_1 = modifyChildren$1(removeEmptyNodes$1);
801
- function removeEmptyNodes$1(child, index, parent) {
802
- if (('children' in child) && child.children.length === 0) {
803
- parent.children.splice(index, 1);
804
- return index;
805
- }
806
- }
807
- var createParser = parser;
808
- var expressions = expressions$8;
809
- var lib$1 = ParseLatin;
810
- function ParseLatin(doc, file) {
811
- var value = file || doc;
812
- if (!(this instanceof ParseLatin)) {
813
- return new ParseLatin(doc, file);
814
- }
815
- this.doc = value ? String(value) : null;
816
- }
817
- var proto$1 = ParseLatin.prototype;
818
- proto$1.position = true;
819
- proto$1.tokenizeSymbol = createTextFactory('Symbol');
820
- proto$1.tokenizeWhiteSpace = createTextFactory('WhiteSpace');
821
- proto$1.tokenizePunctuation = createTextFactory('Punctuation');
822
- proto$1.tokenizeSource = createTextFactory('Source');
823
- proto$1.tokenizeText = createTextFactory('Text');
824
- proto$1.run = run;
825
- proto$1.use = useFactory(function (context, key, plugins) {
826
- context[key] = context[key].concat(plugins);
827
- });
828
- proto$1.useFirst = useFactory(function (context, key, plugins) {
829
- context[key] = plugins.concat(context[key]);
830
- });
831
- proto$1.parse = function (value) {
832
- return this.tokenizeRoot(value || this.doc);
833
- };
834
- proto$1.tokenize = function (value) {
835
- return tokenize(this, value);
836
- };
837
- pluggable(ParseLatin, 'tokenizeWord', function (value, eat) {
838
- var add = (eat || noopEat)('');
839
- var parent = {
840
- type: 'WordNode',
841
- children: []
842
- };
843
- this.tokenizeText(value, eat, parent);
844
- return add(parent);
845
- });
846
- pluggable(ParseLatin, 'tokenizeSentence', createParser({
847
- type: 'SentenceNode',
848
- tokenizer: 'tokenize'
849
- }));
850
- pluggable(ParseLatin, 'tokenizeParagraph', createParser({
851
- type: 'ParagraphNode',
852
- delimiter: expressions.terminalMarker,
853
- delimiterType: 'PunctuationNode',
854
- tokenizer: 'tokenizeSentence'
855
- }));
856
- pluggable(ParseLatin, 'tokenizeRoot', createParser({
857
- type: 'RootNode',
858
- delimiter: expressions.newLine,
859
- delimiterType: 'WhiteSpaceNode',
860
- tokenizer: 'tokenizeParagraph'
861
- }));
862
- proto$1.use('tokenizeSentence', [mergeInitialWordSymbol_1, mergeFinalWordSymbol_1, mergeInnerWordSymbol_1, mergeInnerWordSlash_1, mergeInitialisms_1, mergeWords, patchPosition_1]);
863
- 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]);
864
- proto$1.use('tokenizeRoot', [makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, removeEmptyNodes_1, patchPosition_1]);
865
- function createTextFactory(type) {
866
- type += 'Node';
867
- return createText;
868
- function createText(value, eat, parent) {
869
- if (value === null || value === undefined) {
870
- value = '';
871
- }
872
- return (eat || noopEat)(value)({
873
- type: type,
874
- value: String(value)
875
- }, parent);
876
- }
877
- }
878
- function run(key, nodes) {
879
- var wareKey = key + 'Plugins';
880
- var plugins = this[wareKey];
881
- var index = -1;
882
- if (plugins) {
883
- while (plugins[++index]) {
884
- plugins[index](nodes);
885
- }
886
- }
887
- return nodes;
888
- }
889
- function pluggable(Constructor, key, callback) {
890
- Constructor.prototype[key] = function () {
891
- return this.run(key, callback.apply(this, arguments));
892
- };
893
- }
894
- function useFactory(callback) {
895
- return use;
896
- function use(key, plugins) {
897
- var self = this;
898
- var wareKey;
899
- if (!((key in self))) {
900
- throw new Error('Illegal Invocation: Unsupported `key` for ' + '`use(key, plugins)`. Make sure `key` is a ' + 'supported function');
901
- }
902
- if (!plugins) {
903
- return;
904
- }
905
- wareKey = key + 'Plugins';
906
- if (typeof plugins === 'function') {
907
- plugins = [plugins];
908
- } else {
909
- plugins = plugins.concat();
910
- }
911
- if (!self[wareKey]) {
912
- self[wareKey] = [];
913
- }
914
- callback(self, wareKey, plugins);
915
- }
916
- }
917
- var wordRe = expressions.word;
918
- var surrogatesRe = expressions.surrogates;
919
- var punctuationRe = expressions.punctuation;
920
- var whiteSpaceRe = expressions.whiteSpace;
921
- function tokenize(parser, value) {
922
- var tokens;
923
- var offset;
924
- var line;
925
- var column;
926
- var index;
927
- var length;
928
- var character;
929
- var queue;
930
- var previous;
931
- var left;
932
- var right;
933
- var eater;
934
- if (value === null || value === undefined) {
935
- value = '';
936
- } else if (value instanceof String) {
937
- value = value.toString();
938
- }
939
- if (typeof value !== 'string') {
940
- if (('length' in value) && (!value[0] || value[0].type)) {
941
- return value;
942
- }
943
- throw new Error("Illegal invocation: '" + value + "' is not a valid argument for 'ParseLatin'");
944
- }
945
- tokens = [];
946
- if (!value) {
947
- return tokens;
948
- }
949
- index = 0;
950
- offset = 0;
951
- line = 1;
952
- column = 1;
953
- eater = parser.position ? eat : noPositionEat;
954
- length = value.length;
955
- previous = '';
956
- queue = '';
957
- while (index < length) {
958
- character = value.charAt(index);
959
- if (whiteSpaceRe.test(character)) {
960
- right = 'WhiteSpace';
961
- } else if (punctuationRe.test(character)) {
962
- right = 'Punctuation';
963
- } else if (wordRe.test(character)) {
964
- right = 'Word';
965
- } else {
966
- right = 'Symbol';
967
- }
968
- tick();
969
- previous = character;
970
- character = '';
971
- left = right;
972
- right = null;
973
- index++;
974
- }
975
- tick();
976
- return tokens;
977
- function tick() {
978
- if (left === right && (left === 'Word' || left === 'WhiteSpace' || character === previous || surrogatesRe.test(character))) {
979
- queue += character;
980
- } else {
981
- if (queue) {
982
- parser['tokenize' + left](queue, eater);
983
- }
984
- queue = character;
985
- }
986
- }
987
- function eat(subvalue) {
988
- var pos = position();
989
- update(subvalue);
990
- return apply;
991
- function apply() {
992
- return pos(add.apply(null, arguments));
993
- }
994
- }
995
- function noPositionEat() {
996
- return apply;
997
- function apply() {
998
- return add.apply(null, arguments);
999
- }
1000
- }
1001
- function add(node, parent) {
1002
- if (parent) {
1003
- parent.children.push(node);
1004
- } else {
1005
- tokens.push(node);
1006
- }
1007
- return node;
1008
- }
1009
- function position() {
1010
- var before = now();
1011
- function patch(node) {
1012
- node.position = new Position(before);
1013
- return node;
1014
- }
1015
- return patch;
1016
- }
1017
- function update(subvalue) {
1018
- var subvalueLength = subvalue.length;
1019
- var character = -1;
1020
- var lastIndex = -1;
1021
- offset += subvalueLength;
1022
- while (++character < subvalueLength) {
1023
- if (subvalue.charAt(character) === '\n') {
1024
- lastIndex = character;
1025
- line++;
1026
- }
1027
- }
1028
- if (lastIndex === -1) {
1029
- column += subvalueLength;
1030
- } else {
1031
- column = subvalueLength - lastIndex;
1032
- }
1033
- }
1034
- function Position(start) {
1035
- this.start = start;
1036
- this.end = now();
1037
- }
1038
- function now() {
1039
- return {
1040
- line: line,
1041
- column: column,
1042
- offset: offset
1043
- };
1044
- }
1045
- }
1046
- function noopAdd(node, parent) {
1047
- if (parent) {
1048
- parent.children.push(node);
1049
- }
1050
- return node;
1051
- }
1052
- function noopEat() {
1053
- return noopAdd;
1054
- }
1055
- var parseLatin = lib$1;
1056
- var toString = nlcstToString_1;
1057
- var visitChildren = unistUtilVisitChildren;
1058
- var modifyChildren = unistUtilModifyChildren$1;
1059
- var Parser = parseLatin;
1060
- var mergeNonWordSentences = mergeNonWordSentences_1;
1061
- var mergeAffixSymbol = mergeAffixSymbol_1;
1062
- var mergeInitialLowerCaseLetterSentences = mergeInitialLowerCaseLetterSentences_1;
1063
- var mergeInitialDigitSentences = mergeInitialDigitSentences_1;
1064
- var mergeAffixExceptions = mergeAffixExceptions_1;
1065
- var mergeRemainingFullStops = mergeRemainingFullStops_1;
1066
- var makeInitialWhiteSpaceSiblings = makeInitialWhiteSpaceSiblings_1;
1067
- var makeFinalWhiteSpaceSiblings = makeFinalWhiteSpaceSiblings_1;
1068
- var breakImplicitSentences = breakImplicitSentences_1;
1069
- var removeEmptyNodes = removeEmptyNodes_1;
1070
- var patchPosition = patchPosition_1;
1071
- var parseEnglish = ParseEnglish;
1072
- ParserPrototype.prototype = Parser.prototype;
1073
- var proto = new ParserPrototype();
1074
- ParseEnglish.prototype = proto;
1075
- proto.tokenizeSentencePlugins = [visitChildren(mergeEnglishElisionExceptions)].concat(proto.tokenizeSentencePlugins);
1076
- proto.tokenizeParagraphPlugins = [modifyChildren(mergeEnglishPrefixExceptions)].concat([mergeNonWordSentences, mergeAffixSymbol, mergeInitialLowerCaseLetterSentences, mergeInitialDigitSentences, mergeAffixExceptions, mergeRemainingFullStops, makeInitialWhiteSpaceSiblings, makeFinalWhiteSpaceSiblings, breakImplicitSentences, removeEmptyNodes, patchPosition]);
1077
- function ParseEnglish(doc, file) {
1078
- if (!(this instanceof ParseEnglish)) {
1079
- return new ParseEnglish(doc, file);
1080
- }
1081
- Parser.apply(this, arguments);
1082
- }
1083
- function ParserPrototype() {}
1084
- 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' + ')$');
1085
- 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' + ')$');
1086
- var elisionPrefix = new RegExp('^(' + 'o|ol' + ')$');
1087
- var elisionAffix = new RegExp('^(' + 'im|er|em|cause|' + 'twas|tis|twere|' + '\\d\\ds?' + ')$');
1088
- var apostrophe = /^['\u2019]$/;
1089
- function mergeEnglishPrefixExceptions(sentence, index, paragraph) {
1090
- var children = sentence.children;
1091
- var period = children[children.length - 1];
1092
- var word = children[children.length - 2];
1093
- var value;
1094
- var next;
1095
- if (period && toString(period) === '.' && word && word.type === 'WordNode') {
1096
- value = toString(word);
1097
- if (abbreviations.test(lower(value)) || abbreviationsSensitive.test(value)) {
1098
- word.children.push(period);
1099
- children.pop();
1100
- if (period.position && word.position) {
1101
- word.position.end = period.position.end;
1102
- }
1103
- next = paragraph.children[index + 1];
1104
- if (next) {
1105
- sentence.children = children.concat(next.children);
1106
- paragraph.children.splice(index + 1, 1);
1107
- if (next.position && sentence.position) {
1108
- sentence.position.end = next.position.end;
1109
- }
1110
- return index - 1;
1111
- }
1112
- }
1113
- }
1114
- }
1115
- function mergeEnglishElisionExceptions(child, index, sentence) {
1116
- var siblings;
1117
- var sibling;
1118
- var other;
1119
- var length;
1120
- var value;
1121
- if (child.type !== 'PunctuationNode' && child.type !== 'SymbolNode') {
1122
- return;
1123
- }
1124
- siblings = sentence.children;
1125
- length = siblings.length;
1126
- value = toString(child);
1127
- if (value === '/') {
1128
- sibling = siblings[index - 1];
1129
- if (sibling && lower(toString(sibling)) === 'w') {
1130
- siblings.splice(index, 1);
1131
- sibling.children.push(child);
1132
- if (sibling.position && child.position) {
1133
- sibling.position.end = child.position.end;
1134
- }
1135
- }
1136
- } else if (apostrophe.test(value)) {
1137
- sibling = siblings[index - 1];
1138
- if (index > 2 && index < length - 1 && sibling.type === 'WordNode' && siblings[index - 2].type === 'WhiteSpaceNode' && siblings[index + 1].type === 'WhiteSpaceNode' && elisionPrefix.test(lower(toString(sibling)))) {
1139
- siblings.splice(index, 1);
1140
- sibling.children.push(child);
1141
- if (sibling.position && child.position) {
1142
- sibling.position.end = child.position.end;
1143
- }
1144
- return;
1145
- }
1146
- if (index !== length - 1 && siblings[index + 1].type === 'WordNode' && (index === 0 || siblings[index - 1].type !== 'WordNode')) {
1147
- sibling = siblings[index + 1];
1148
- value = lower(toString(sibling));
1149
- if (elisionAffix.test(value)) {
1150
- siblings.splice(index, 1);
1151
- sibling.children = [child].concat(sibling.children);
1152
- if (sibling.position && child.position) {
1153
- sibling.position.start = child.position.start;
1154
- }
1155
- } else if (value === 'n' && index < length - 2 && apostrophe.test(toString(siblings[index + 2]))) {
1156
- other = siblings[index + 2];
1157
- siblings.splice(index, 1);
1158
- siblings.splice(index + 1, 1);
1159
- sibling.children = [child].concat(sibling.children, other);
1160
- if (sibling.position) {
1161
- if (child.position) {
1162
- sibling.position.start = child.position.start;
1163
- }
1164
- if (other.position) {
1165
- sibling.position.end = other.position.end;
1166
- }
1167
- }
1168
- }
1169
- }
1170
- }
1171
- }
1172
- function lower(value) {
1173
- return value.toLowerCase();
1174
- }
1175
- const {compact: compact} = _dll_lodash;
1176
- const {clone: clone$2} = _dll_lodash;
1177
- const g = (str, node) => {
1178
- if (node.children) {
1179
- return node.children.reduce(g, str);
1180
- } else if (node.value) {
1181
- return str + node.value;
1182
- } else {
1183
- return str;
1184
- }
1185
- };
1186
- const getParagraph = p => g('', p);
1187
- const getSentence = s => g('', s);
1188
- const getWord = w => g('', w);
1189
- const paragraphs = text => {
1190
- const tree = new parseEnglish().parse(text);
1191
- const out = tree.children.reduce((acc, child) => {
1192
- if (child.type === 'ParagraphNode') {
1193
- const paragraph = {
1194
- text: getParagraph(child),
1195
- start: child.position.start.offset,
1196
- end: child.position.end.offset
1197
- };
1198
- return acc.concat([paragraph]);
1199
- } else {
1200
- return acc;
1201
- }
1202
- }, []);
1203
- return out;
1204
- };
1205
- const handleSentence = (child, acc) => {
1206
- const sentenceChilds = [];
1207
- let newAcc = child.children.reduce(function (acc, child) {
1208
- if (child.type === 'WhiteSpaceNode' && child.value === '\n') {
1209
- if (sentenceChilds.length) {
1210
- const firstWord = sentenceChilds[0];
1211
- const sentence = {
1212
- text: sentenceChilds.map(d => getSentence(d)).join(''),
1213
- start: firstWord.position.start.offset,
1214
- end: child.position.start.offset
1215
- };
1216
- sentenceChilds.splice(0, sentenceChilds.length);
1217
- return acc.concat([sentence]);
1218
- }
1219
- } else {
1220
- sentenceChilds.push(child);
1221
- }
1222
- return acc;
1223
- }, acc);
1224
- if (sentenceChilds.length) {
1225
- const firstWord = sentenceChilds[0];
1226
- const lastWord = sentenceChilds[sentenceChilds.length - 1];
1227
- const sentence = {
1228
- text: sentenceChilds.map(d => getSentence(d)).join(''),
1229
- start: firstWord.position.start.offset,
1230
- end: lastWord.position.end.offset
1231
- };
1232
- newAcc = newAcc.concat([sentence]);
1233
- sentenceChilds.splice(0, sentenceChilds.length);
1234
- }
1235
- return newAcc;
1236
- };
1237
- const sentences = text => {
1238
- const tree = new parseEnglish().parse(text);
1239
- const out = tree.children.reduce((acc, child) => {
1240
- if (child.type === 'ParagraphNode') {
1241
- return child.children.reduce((acc, child) => {
1242
- if (child.type === 'SentenceNode') {
1243
- const newAcc = handleSentence(child, acc);
1244
- return newAcc || acc;
1245
- } else {
1246
- return acc;
1247
- }
1248
- }, acc);
1249
- } else {
1250
- return acc;
1251
- }
1252
- }, []);
1253
- return out;
1254
- };
1255
- const words = text => {
1256
- const tree = new parseEnglish().parse(text);
1257
- const out = tree.children.reduce((acc, child) => {
1258
- if (child.type === 'ParagraphNode') {
1259
- return child.children.reduce((acc, child) => {
1260
- if (child.type === 'SentenceNode') {
1261
- return child.children.reduce((acc, child) => {
1262
- if (child.type === 'WordNode') {
1263
- const node = {
1264
- text: getWord(child),
1265
- start: child.position.start.offset,
1266
- end: child.position.end.offset
1267
- };
1268
- return acc.concat([node]);
1269
- } else {
1270
- return acc;
1271
- }
1272
- }, acc);
1273
- } else {
1274
- return acc;
1275
- }
1276
- }, acc);
1277
- } else {
1278
- return acc;
1279
- }
1280
- }, []);
1281
- return out;
1282
- };
1283
- class Intersection {
1284
- constructor(results) {
1285
- this.results = results;
1286
- }
1287
- get hasOverlap() {
1288
- return this.results.filter(r => r.type === 'overlap').length > 0;
1289
- }
1290
- get surroundedTokens() {
1291
- return this.results.filter(r => r.type === 'within-selection').map(t => t.token);
1292
- }
1293
- }
1294
- const intersection = (selection, tokens) => {
1295
- const {start, end} = selection;
1296
- const startsWithin = t => start >= t.start && start < t.end;
1297
- const endsWithin = t => end > t.start && end <= t.end;
1298
- const mapped = tokens.map(t => {
1299
- if (start === t.start && end === t.end) {
1300
- return {
1301
- token: t,
1302
- type: 'exact-fit'
1303
- };
1304
- } else if (start <= t.start && end >= t.end) {
1305
- return {
1306
- token: t,
1307
- type: 'within-selection'
1308
- };
1309
- } else if (startsWithin(t) || endsWithin(t)) {
1310
- return {
1311
- token: t,
1312
- type: 'overlap'
1313
- };
1314
- }
1315
- });
1316
- return new Intersection(compact(mapped));
1317
- };
1318
- const sort = tokens => {
1319
- if (!Array.isArray(tokens)) {
1320
- return tokens;
1321
- } else {
1322
- const out = clone$2(tokens);
1323
- out.sort((a, b) => {
1324
- const s = a.start < b.start ? -1 : a.start > b.start ? 1 : 0;
1325
- const e = a.end < b.end ? -1 : a.end > b.end ? 1 : 0;
1326
- if (s === -1 && e !== -1) {
1327
- throw new Error(`sort does not support intersecting tokens. a: ${a.start}-${a.end}, b: ${b.start}-${b.end}`);
1328
- }
1329
- return s;
1330
- });
1331
- return out;
1332
- }
1333
- };
1334
- const normalize = (textToNormalize, tokens) => {
1335
- const text = textToNormalize || '';
1336
- if (!Array.isArray(tokens) || tokens.length === 0) {
1337
- return [{
1338
- text,
1339
- start: 0,
1340
- end: text.length
1341
- }];
1342
- }
1343
- const out = sort(tokens).reduce((acc, t, index, outer) => {
1344
- let tokens = [];
1345
- const lastIndex = acc.lastIndex;
1346
- if (t.start === lastIndex) {
1347
- tokens = [{
1348
- text: text.substring(lastIndex, t.end),
1349
- start: lastIndex,
1350
- end: t.end,
1351
- predefined: true,
1352
- correct: t.correct
1353
- }];
1354
- } else if (lastIndex < t.start) {
1355
- tokens = [{
1356
- text: text.substring(lastIndex, t.start),
1357
- start: lastIndex,
1358
- end: t.start
1359
- }, {
1360
- text: text.substring(t.start, t.end),
1361
- start: t.start,
1362
- end: t.end,
1363
- predefined: true,
1364
- correct: t.correct
1365
- }];
1366
- }
1367
- if (index === outer.length - 1 && t.end < text.length) {
1368
- const last = {
1369
- text: text.substring(t.end),
1370
- start: t.end,
1371
- end: text.length
1372
- };
1373
- tokens.push(last);
1374
- }
1375
- return {
1376
- lastIndex: tokens.length ? tokens[tokens.length - 1].end : lastIndex,
1377
- result: acc.result.concat(tokens)
1378
- };
1379
- }, {
1380
- result: [],
1381
- lastIndex: 0
1382
- });
1383
- return out.result;
1384
- };
1385
- const noSelect = () => ({
1386
- cursor: 'default',
1387
- '-webkit-user-select': 'none',
1388
- '-moz-user-select': 'none',
1389
- '-ms-user-select': 'none',
1390
- 'user-select': 'none'
1391
- });
1392
- const clearSelection = () => {
1393
- if (document.getSelection) {
1394
- document.getSelection().removeAllRanges();
1395
- document.getSelection().addRange(document.createRange());
1396
- } else if (window.getSelection) {
1397
- if (window.getSelection().removeAllRanges) {
1398
- window.getSelection().removeAllRanges();
1399
- window.getSelection().addRange(document.createRange());
1400
- } else if (window.getSelection().empty) {
1401
- window.getSelection().empty();
1402
- }
1403
- } else if (document.selection) {
1404
- document.selection.empty();
1405
- }
1406
- };
1407
- const getCaretCharacterOffsetWithin = element => {
1408
- var caretOffset = 0;
1409
- var doc = element.ownerDocument || element.document;
1410
- var win = doc.defaultView || doc.parentWindow;
1411
- var sel;
1412
- if (typeof win.getSelection !== 'undefined') {
1413
- sel = win.getSelection();
1414
- if (sel.rangeCount > 0) {
1415
- var range = win.getSelection().getRangeAt(0);
1416
- var selected = range.toString().length;
1417
- var preCaretRange = range.cloneRange();
1418
- preCaretRange.selectNodeContents(element);
1419
- preCaretRange.setEnd(range.endContainer, range.endOffset);
1420
- if (selected) {
1421
- caretOffset = preCaretRange.toString().length - selected;
1422
- } else {
1423
- caretOffset = preCaretRange.toString().length;
1424
- }
1425
- }
1426
- } else if ((sel = doc.selection) && sel.type !== 'Control') {
1427
- var textRange = sel.createRange();
1428
- var preCaretTextRange = doc.body.createTextRange();
1429
- preCaretTextRange.moveToElementText(element);
1430
- preCaretTextRange.setEndPoint('EndToEnd', textRange);
1431
- caretOffset = preCaretTextRange.text.length;
1432
- }
1433
- return caretOffset;
1434
- };
1435
- const React$6 = _dll_react;
1436
- const PropTypes$5 = _dll_prop_types;
1437
- const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
1438
- const {colors: {yellow: yellow}} = _dll_material_ui__core;
1439
- const {colors: {green: green}} = _dll_material_ui__core;
1440
- const debug$3 = _dll_debug;
1441
- const classNames$3 = _dll_classnames;
1442
- const _jsxFileName$5 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/tokenizer/token-text.jsx";
1443
- const log$3 = debug$3('@pie-lib:text-select:token-text');
1444
- const Text = withStyles$4(() => ({
1445
- predefined: {
1446
- cursor: 'pointer',
1447
- backgroundColor: yellow[100],
1448
- border: `dashed 0px ${yellow[700]}`
1449
- },
1450
- correct: {
1451
- backgroundColor: green[500]
1452
- }
1453
- }))(({text, predefined, classes, onClick, correct}) => {
1454
- const formattedText = (text || '').replace(/\n/g, '<br>');
1455
- if (predefined) {
1456
- const className = classNames$3(classes.predefined, correct && classes.correct);
1457
- return React$6.createElement('span', {
1458
- onClick: onClick,
1459
- className: className,
1460
- dangerouslySetInnerHTML: {
1461
- __html: formattedText
1462
- },
1463
- __self: undefined,
1464
- __source: {
1465
- fileName: _jsxFileName$5,
1466
- lineNumber: 30
1467
- }
1468
- });
1469
- } else {
1470
- return React$6.createElement('span', {
1471
- dangerouslySetInnerHTML: {
1472
- __html: formattedText
1473
- },
1474
- __self: undefined,
1475
- __source: {
1476
- fileName: _jsxFileName$5,
1477
- lineNumber: 37
1478
- }
1479
- });
1480
- }
1481
- });
1482
- const notAllowedCharacters = ['\n', ' ', '\t'];
1483
- class TokenText extends React$6.Component {
1484
- constructor(...args) {
1485
- super(...args);
1486
- TokenText.prototype.__init.call(this);
1487
- }
1488
- static __initStatic() {
1489
- this.propTypes = {
1490
- text: PropTypes$5.string.isRequired,
1491
- tokens: PropTypes$5.array.isRequired,
1492
- onTokenClick: PropTypes$5.func.isRequired,
1493
- onSelectToken: PropTypes$5.func.isRequired,
1494
- className: PropTypes$5.string
1495
- };
1496
- }
1497
- __init() {
1498
- this.onClick = event => {
1499
- const {onSelectToken, text, tokens} = this.props;
1500
- event.preventDefault();
1501
- if (typeof window === 'undefined') {
1502
- return;
1503
- }
1504
- const selection = window.getSelection();
1505
- const textSelected = selection.toString();
1506
- if (textSelected.length > 0 && notAllowedCharacters.indexOf(textSelected) < 0) {
1507
- if (this.root) {
1508
- let offset = getCaretCharacterOffsetWithin(this.root);
1509
- const newLineOffset = text.slice(offset).indexOf(textSelected);
1510
- offset += newLineOffset;
1511
- if (offset !== undefined) {
1512
- const endIndex = offset + textSelected.length;
1513
- if (endIndex <= text.length) {
1514
- const i = intersection({
1515
- start: offset,
1516
- end: endIndex
1517
- }, tokens);
1518
- if (i.hasOverlap) {
1519
- log$3('hasOverlap - do nothing');
1520
- clearSelection();
1521
- } else {
1522
- const tokensToRemove = i.surroundedTokens;
1523
- const token = {
1524
- text: textSelected,
1525
- start: offset,
1526
- end: endIndex
1527
- };
1528
- onSelectToken(token, tokensToRemove);
1529
- clearSelection();
1530
- }
1531
- }
1532
- }
1533
- }
1534
- }
1535
- };
1536
- }
1537
- render() {
1538
- const {text, tokens, className, onTokenClick} = this.props;
1539
- const normalized = normalize(text, tokens);
1540
- return React$6.createElement('div', {
1541
- className: className,
1542
- ref: r => this.root = r,
1543
- onClick: this.onClick,
1544
- __self: this,
1545
- __source: {
1546
- fileName: _jsxFileName$5,
1547
- lineNumber: 123
1548
- }
1549
- }, normalized.map((t, index) => {
1550
- return React$6.createElement(Text, {
1551
- key: index,
1552
- ...t,
1553
- onClick: () => onTokenClick(t),
1554
- __self: this,
1555
- __source: {
1556
- fileName: _jsxFileName$5,
1557
- lineNumber: 125
1558
- }
1559
- });
1560
- }));
1561
- }
1562
- }
1563
- TokenText.__initStatic();
1564
- const React$5 = _dll_react;
1565
- const PropTypes$4 = _dll_prop_types;
1566
- const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
1567
- const {clone: clone$1} = _dll_lodash;
1568
- const {isEqual: isEqual$1} = _dll_lodash;
1569
- const {differenceWith: differenceWith} = _dll_lodash;
1570
- const classNames$2 = _dll_classnames;
1571
- const _jsxFileName$4 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/tokenizer/index.jsx";
1572
- class Tokenizer extends React$5.Component {
1573
- static __initStatic() {
1574
- this.propTypes = {
1575
- text: PropTypes$4.string.isRequired,
1576
- tokens: PropTypes$4.arrayOf(PropTypes$4.shape({
1577
- text: PropTypes$4.string,
1578
- correct: PropTypes$4.bool,
1579
- start: PropTypes$4.number,
1580
- end: PropTypes$4.number
1581
- })),
1582
- classes: PropTypes$4.object.isRequired,
1583
- className: PropTypes$4.string,
1584
- onChange: PropTypes$4.func.isRequired
1585
- };
1586
- }
1587
- static __initStatic2() {
1588
- this.defaultProps = {};
1589
- }
1590
- constructor(props) {
1591
- super(props);
1592
- Tokenizer.prototype.__init.call(this);
1593
- Tokenizer.prototype.__init2.call(this);
1594
- Tokenizer.prototype.__init3.call(this);
1595
- Tokenizer.prototype.__init4.call(this);
1596
- Tokenizer.prototype.__init5.call(this);
1597
- Tokenizer.prototype.__init6.call(this);
1598
- Tokenizer.prototype.__init7.call(this);
1599
- Tokenizer.prototype.__init8.call(this);
1600
- Tokenizer.prototype.__init9.call(this);
1601
- this.state = {
1602
- setCorrectMode: false,
1603
- mode: ''
1604
- };
1605
- }
1606
- __init() {
1607
- this.onChangeHandler = (token, mode) => {
1608
- this.props.onChange(token, mode);
1609
- this.setState({
1610
- mode
1611
- });
1612
- };
1613
- }
1614
- __init2() {
1615
- this.toggleCorrectMode = () => this.setState({
1616
- setCorrectMode: !this.state.setCorrectMode
1617
- });
1618
- }
1619
- __init3() {
1620
- this.clear = () => {
1621
- this.onChangeHandler([], '');
1622
- };
1623
- }
1624
- __init4() {
1625
- this.buildTokens = (type, fn) => {
1626
- const {text} = this.props;
1627
- const tokens = fn(text);
1628
- this.onChangeHandler(tokens, type);
1629
- };
1630
- }
1631
- __init5() {
1632
- this.selectToken = (newToken, tokensToRemove) => {
1633
- const {tokens} = this.props;
1634
- const update = differenceWith(clone$1(tokens), tokensToRemove, isEqual$1);
1635
- update.push(newToken);
1636
- this.onChangeHandler(update, this.state.mode);
1637
- };
1638
- }
1639
- __init6() {
1640
- this.tokenClick = token => {
1641
- const {setCorrectMode} = this.state;
1642
- if (setCorrectMode) {
1643
- this.setCorrect(token);
1644
- } else {
1645
- this.removeToken(token);
1646
- }
1647
- };
1648
- }
1649
- __init7() {
1650
- this.tokenIndex = token => {
1651
- const {tokens} = this.props;
1652
- return tokens.findIndex(t => {
1653
- return t.text == token.text && t.start == token.start && t.end == token.end;
1654
- });
1655
- };
1656
- }
1657
- __init8() {
1658
- this.setCorrect = token => {
1659
- const {tokens} = this.props;
1660
- const index = this.tokenIndex(token);
1661
- if (index !== -1) {
1662
- const t = tokens[index];
1663
- t.correct = !t.correct;
1664
- const update = clone$1(tokens);
1665
- update.splice(index, 1, t);
1666
- this.onChangeHandler(update, this.state.mode);
1667
- }
1668
- };
1669
- }
1670
- __init9() {
1671
- this.removeToken = token => {
1672
- const {tokens} = this.props;
1673
- const index = this.tokenIndex(token);
1674
- if (index !== -1) {
1675
- const update = clone$1(tokens);
1676
- update.splice(index, 1);
1677
- this.onChangeHandler(update, this.state.mode);
1678
- }
1679
- };
1680
- }
1681
- render() {
1682
- const {text, tokens, classes, className} = this.props;
1683
- const {setCorrectMode} = this.state;
1684
- const tokenClassName = classNames$2(classes.text, setCorrectMode && classes.noselect);
1685
- const rootName = classNames$2(classes.tokenizer, className);
1686
- return React$5.createElement('div', {
1687
- className: rootName,
1688
- __self: this,
1689
- __source: {
1690
- fileName: _jsxFileName$4,
1691
- lineNumber: 123
1692
- }
1693
- }, React$5.createElement(Controls$1, {
1694
- onClear: this.clear,
1695
- onWords: () => this.buildTokens('words', words),
1696
- onSentences: () => this.buildTokens('sentence', sentences),
1697
- onParagraphs: () => this.buildTokens('paragraphs', paragraphs),
1698
- setCorrectMode: setCorrectMode,
1699
- onToggleCorrectMode: this.toggleCorrectMode,
1700
- __self: this,
1701
- __source: {
1702
- fileName: _jsxFileName$4,
1703
- lineNumber: 124
1704
- }
1705
- }), React$5.createElement(TokenText, {
1706
- className: tokenClassName,
1707
- text: text,
1708
- tokens: tokens,
1709
- onTokenClick: this.tokenClick,
1710
- onSelectToken: this.selectToken,
1711
- __self: this,
1712
- __source: {
1713
- fileName: _jsxFileName$4,
1714
- lineNumber: 132
1715
- }
1716
- }));
1717
- }
1718
- }
1719
- Tokenizer.__initStatic();
1720
- Tokenizer.__initStatic2();
1721
- var Tokenizer$1 = withStyles$3(theme => ({
1722
- text: {
1723
- whiteSpace: 'pre-wrap',
1724
- marginTop: theme.spacing.unit,
1725
- paddingTop: theme.spacing.unit,
1726
- paddingBottom: theme.spacing.unit
1727
- },
1728
- noselect: {
1729
- ...noSelect()
1730
- }
1731
- }))(Tokenizer);
1732
- const React$4 = _dll_react;
1733
- const PropTypes$3 = _dll_prop_types;
1734
- const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
1735
- const classNames$1 = _dll_classnames;
1736
- const {color: color} = _dll_pie_lib__render_ui;
1737
- const _jsxFileName$3 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/token-select/token.jsx";
1738
- const TokenTypes = {
1739
- text: PropTypes$3.string,
1740
- selectable: PropTypes$3.bool
1741
- };
1742
- class Token extends React$4.Component {
1743
- static __initStatic() {
1744
- this.rootClassName = 'tokenRootClass';
1745
- }
1746
- static __initStatic2() {
1747
- this.propTypes = {
1748
- ...TokenTypes,
1749
- classes: PropTypes$3.object.isRequired,
1750
- className: PropTypes$3.string,
1751
- disabled: PropTypes$3.bool,
1752
- highlight: PropTypes$3.bool,
1753
- correct: PropTypes$3.bool,
1754
- text: PropTypes$3.string.isRequired
1755
- };
1756
- }
1757
- static __initStatic3() {
1758
- this.defaultProps = {
1759
- selectable: false,
1760
- text: ''
1761
- };
1762
- }
1763
- render() {
1764
- const {text, selectable, selected, classes, className: classNameProp, disabled, index, highlight, correct, animationsDisabled} = this.props;
1765
- let className;
1766
- if (correct === undefined && selected && disabled) {
1767
- className = classNames$1(classes.token, classes.selected, classes.disabledBlack);
1768
- } else if (correct !== undefined) {
1769
- className = classNames$1(Token.rootClassName, classes.custom, correct === true && classes.correct, correct === false && classes.incorrect);
1770
- } else {
1771
- 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);
1772
- }
1773
- return React$4.createElement('span', {
1774
- className: className,
1775
- dangerouslySetInnerHTML: {
1776
- __html: (text || '').replace(/\n/g, '<br>')
1777
- },
1778
- 'data-indexkey': index,
1779
- __self: this,
1780
- __source: {
1781
- fileName: _jsxFileName$3,
1782
- lineNumber: 70
1783
- }
1784
- });
1785
- }
1786
- }
1787
- Token.__initStatic();
1788
- Token.__initStatic2();
1789
- Token.__initStatic3();
1790
- var Token$1 = withStyles$2(theme => {
1791
- return {
1792
- token: {
1793
- cursor: 'pointer',
1794
- textIndent: 0,
1795
- padding: theme.spacing.unit / 2,
1796
- paddingRight: 0,
1797
- paddingLeft: 0,
1798
- transition: 'background-color 100ms ease-in'
1799
- },
1800
- disabled: {
1801
- cursor: 'inherit',
1802
- color: 'grey'
1803
- },
1804
- disabledBlack: {
1805
- cursor: 'inherit'
1806
- },
1807
- disabledAndSelected: {
1808
- backgroundColor: 'pink'
1809
- },
1810
- selectable: {
1811
- '&:hover': {
1812
- backgroundColor: color.primaryLight(),
1813
- '& > *': {
1814
- backgroundColor: color.primaryLight()
1815
- }
1816
- }
1817
- },
1818
- selected: {
1819
- lineHeight: 2,
1820
- marginTop: theme.spacing.unit / 2,
1821
- '&:hover': {
1822
- backgroundColor: color.primaryLight()
1823
- },
1824
- backgroundColor: color.primaryLight(),
1825
- '& > *': {
1826
- backgroundColor: color.primaryLight()
1827
- }
1828
- },
1829
- highlight: {
1830
- border: 'dashed 2px gray',
1831
- lineHeight: 2,
1832
- boxSizing: 'border-box',
1833
- marginTop: theme.spacing.unit / 2,
1834
- display: 'inline-block',
1835
- padding: theme.spacing.unit
1836
- },
1837
- print: {
1838
- border: 'dashed 2px gray',
1839
- lineHeight: 2,
1840
- boxSizing: 'border-box',
1841
- marginTop: theme.spacing.unit / 2,
1842
- display: 'inline-block',
1843
- padding: theme.spacing.unit,
1844
- color: color.text()
1845
- },
1846
- custom: {
1847
- display: 'initial'
1848
- },
1849
- correct: {
1850
- backgroundColor: color.correct()
1851
- },
1852
- incorrect: {
1853
- backgroundColor: color.incorrect()
1854
- }
1855
- };
1856
- })(Token);
1857
- const React$3 = _dll_react;
1858
- const PropTypes$2 = _dll_prop_types;
1859
- const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
1860
- const classNames = _dll_classnames;
1861
- const {clone: clone} = _dll_lodash;
1862
- const {isEqual: isEqual} = _dll_lodash;
1863
- const debug$2 = _dll_debug;
1864
- const {renderToString: renderToString} = _dll_react_dom_server;
1865
- const _jsxFileName$2 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/token-select/index.jsx";
1866
- const log$2 = debug$2('@pie-lib:text-select:token-select');
1867
- class TokenSelect extends React$3.Component {
1868
- constructor(...args) {
1869
- super(...args);
1870
- TokenSelect.prototype.__init.call(this);
1871
- TokenSelect.prototype.__init2.call(this);
1872
- TokenSelect.prototype.__init3.call(this);
1873
- TokenSelect.prototype.__init4.call(this);
1874
- }
1875
- static __initStatic() {
1876
- this.propTypes = {
1877
- tokens: PropTypes$2.arrayOf(PropTypes$2.shape(TokenTypes)).isRequired,
1878
- className: PropTypes$2.string,
1879
- classes: PropTypes$2.object.isRequired,
1880
- onChange: PropTypes$2.func.isRequired,
1881
- disabled: PropTypes$2.bool,
1882
- highlightChoices: PropTypes$2.bool,
1883
- animationsDisabled: PropTypes$2.bool,
1884
- maxNoOfSelections: PropTypes$2.number
1885
- };
1886
- }
1887
- static __initStatic2() {
1888
- this.defaultProps = {
1889
- highlightChoices: false,
1890
- maxNoOfSelections: 0,
1891
- tokens: []
1892
- };
1893
- }
1894
- __init() {
1895
- this.selectedCount = () => this.props.tokens.filter(t => t.selected).length;
1896
- }
1897
- __init2() {
1898
- this.canSelectMore = selectedCount => {
1899
- const {maxNoOfSelections} = this.props;
1900
- if (maxNoOfSelections === 1) {
1901
- return true;
1902
- }
1903
- log$2('[canSelectMore] maxNoOfSelections: ', maxNoOfSelections, 'selectedCount: ', selectedCount);
1904
- return maxNoOfSelections <= 0 || isFinite(maxNoOfSelections) && selectedCount < maxNoOfSelections;
1905
- };
1906
- }
1907
- __init3() {
1908
- this.toggleToken = event => {
1909
- const {target} = event;
1910
- const {tokens, animationsDisabled} = this.props;
1911
- const tokensCloned = clone(tokens);
1912
- const targetSpanWrapper = target.closest(`.${Token$1.rootClassName}`);
1913
- const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;
1914
- const t = targetedTokenIndex && tokensCloned[targetedTokenIndex];
1915
- if (t && t.correct === undefined && !animationsDisabled) {
1916
- const {onChange, maxNoOfSelections} = this.props;
1917
- const selected = !t.selected;
1918
- if (maxNoOfSelections === 1 && this.selectedCount() === 1) {
1919
- const selectedToken = (tokens || []).filter(t => t.selected);
1920
- const updatedTokens = tokensCloned.map(token => {
1921
- if (isEqual(token, selectedToken[0])) {
1922
- return {
1923
- ...token,
1924
- selected: false
1925
- };
1926
- }
1927
- return {
1928
- ...token,
1929
- selectable: true
1930
- };
1931
- });
1932
- const update = {
1933
- ...t,
1934
- selected: !t.selected
1935
- };
1936
- updatedTokens.splice(targetedTokenIndex, 1, update);
1937
- onChange(updatedTokens);
1938
- } else {
1939
- if (selected && maxNoOfSelections > 0 && this.selectedCount() >= maxNoOfSelections) {
1940
- log$2('skip toggle max reached');
1941
- return;
1942
- }
1943
- const update = {
1944
- ...t,
1945
- selected: !t.selected
1946
- };
1947
- tokensCloned.splice(targetedTokenIndex, 1, update);
1948
- onChange(tokensCloned);
1949
- }
1950
- }
1951
- };
1952
- }
1953
- __init4() {
1954
- this.generateTokensInHtml = () => {
1955
- const {tokens, disabled, highlightChoices, animationsDisabled} = this.props;
1956
- const selectedCount = this.selectedCount();
1957
- const isLineBreak = text => text === '\n';
1958
- const isNewParagraph = text => text === '\n\n';
1959
- const reducer = (accumulator, t, index) => {
1960
- const selectable = t.selected || t.selectable && this.canSelectMore(selectedCount);
1961
- const showCorrectAnswer = t.correct !== undefined && (t.selectable || t.selected);
1962
- let finalAcc = accumulator;
1963
- if (isNewParagraph(t.text)) {
1964
- return finalAcc + '</p><p>';
1965
- }
1966
- if (isLineBreak(t.text)) {
1967
- return finalAcc + '<br>';
1968
- }
1969
- if (selectable && !disabled || showCorrectAnswer || t.selected || animationsDisabled && t.predefined) {
1970
- return finalAcc + renderToString(React$3.createElement(Token$1, {
1971
- key: index,
1972
- disabled: disabled,
1973
- index: index,
1974
- ...t,
1975
- selectable: selectable,
1976
- highlight: highlightChoices,
1977
- animationsDisabled: animationsDisabled,
1978
- __self: this,
1979
- __source: {
1980
- fileName: _jsxFileName$2,
1981
- lineNumber: 125
1982
- }
1983
- }));
1984
- } else {
1985
- return accumulator + t.text;
1986
- }
1987
- };
1988
- const reduceResult = (tokens || []).reduce(reducer, '<p>');
1989
- return reduceResult + '</p>';
1990
- };
1991
- }
1992
- render() {
1993
- const {classes, className: classNameProp} = this.props;
1994
- const className = classNames(classes.tokenSelect, classNameProp);
1995
- const html = this.generateTokensInHtml();
1996
- return React$3.createElement('div', {
1997
- className: className,
1998
- dangerouslySetInnerHTML: {
1999
- __html: html
2000
- },
2001
- onClick: this.toggleToken,
2002
- __self: this,
2003
- __source: {
2004
- fileName: _jsxFileName$2,
2005
- lineNumber: 152
2006
- }
2007
- });
2008
- }
2009
- }
2010
- TokenSelect.__initStatic();
2011
- TokenSelect.__initStatic2();
2012
- var TokenSelect$1 = withStyles$1(() => ({
2013
- tokenSelect: {
2014
- backgroundColor: 'none',
2015
- whiteSpace: 'pre',
2016
- ...noSelect(),
2017
- '& p': {
2018
- whiteSpace: 'break-spaces'
2019
- }
2020
- }
2021
- }))(TokenSelect);
2022
- const React$2 = _dll_react;
2023
- const PropTypes$1 = _dll_prop_types;
2024
- const debug$1 = _dll_debug;
2025
- const _jsxFileName$1 = "/home/circleci/repo/node_modules/@pie-lib/text-select/src/text-select.jsx";
2026
- const log$1 = debug$1('@pie-lib:text-select');
2027
- class TextSelect extends React$2.Component {
2028
- constructor(...args) {
2029
- super(...args);
2030
- TextSelect.prototype.__init.call(this);
2031
- }
2032
- static __initStatic() {
2033
- this.propTypes = {
2034
- onChange: PropTypes$1.func,
2035
- disabled: PropTypes$1.bool,
2036
- tokens: PropTypes$1.arrayOf(PropTypes$1.shape(TokenTypes)).isRequired,
2037
- selectedTokens: PropTypes$1.arrayOf(PropTypes$1.shape(TokenTypes)).isRequired,
2038
- text: PropTypes$1.string.isRequired,
2039
- className: PropTypes$1.string,
2040
- highlightChoices: PropTypes$1.bool,
2041
- animationsDisabled: PropTypes$1.bool,
2042
- maxNoOfSelections: PropTypes$1.number
2043
- };
2044
- }
2045
- __init() {
2046
- this.change = tokens => {
2047
- const {onChange} = this.props;
2048
- if (!onChange) {
2049
- return;
2050
- }
2051
- const out = tokens.filter(t => t.selected).map(t => ({
2052
- start: t.start,
2053
- end: t.end
2054
- }));
2055
- onChange(out);
2056
- };
2057
- }
2058
- render() {
2059
- const {text, disabled, tokens, selectedTokens, className, highlightChoices, maxNoOfSelections, animationsDisabled} = this.props;
2060
- const normalized = normalize(text, tokens);
2061
- log$1('normalized: ', normalized);
2062
- const prepped = normalized.map(t => {
2063
- const selectedIndex = selectedTokens.findIndex(s => {
2064
- return s.start === t.start && s.end === t.end;
2065
- });
2066
- const selected = selectedIndex !== -1;
2067
- const correct = selected ? t.correct : undefined;
2068
- return {
2069
- ...t,
2070
- selectable: !disabled && t.predefined,
2071
- selected,
2072
- correct
2073
- };
2074
- });
2075
- return React$2.createElement(TokenSelect$1, {
2076
- highlightChoices: !disabled && highlightChoices,
2077
- className: className,
2078
- tokens: prepped,
2079
- disabled: disabled,
2080
- onChange: this.change,
2081
- maxNoOfSelections: maxNoOfSelections,
2082
- animationsDisabled: animationsDisabled,
2083
- __self: this,
2084
- __source: {
2085
- fileName: _jsxFileName$1,
2086
- lineNumber: 66
2087
- }
2088
- });
2089
- }
2090
- }
2091
- TextSelect.__initStatic();
2092
- var createElementFromHTML = function createElementFromHTML() {
2093
- var htmlString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2094
- var div = document.createElement('div');
2095
- div.innerHTML = htmlString.trim();
2096
- return div;
2097
- };
2098
- var parseParagraph = function parseParagraph(paragraph, end) {
2099
- if (end) {
2100
- return paragraph.innerHTML;
2101
- }
2102
- return ('').concat(paragraph.innerHTML, '\n\n');
2103
- };
2104
- var parseParagraphs = function parseParagraphs(dom) {
2105
- var paragraphs = dom.querySelectorAll('div[separator=true]');
2106
- var str = '';
2107
- paragraphs.forEach(function (par, index) {
2108
- str += parseParagraph(par, index === paragraphs.length - 1);
2109
- });
2110
- return str || null;
2111
- };
2112
- var prepareText = function prepareText(text) {
2113
- var txtDom = createElementFromHTML(text);
2114
- var div = document.createElement('div');
2115
- div.innerHTML = ('<div separator=\'true\'>').concat(txtDom.innerHTML, '</div>');
2116
- txtDom = div;
2117
- var allDomElements = Array.from(txtDom.querySelectorAll('*'));
2118
- if (allDomElements.length === 0) {
2119
- return text;
2120
- }
2121
- return parseParagraphs(txtDom);
2122
- };
2123
- const generateModel = model => {
2124
- if (!model) return model;
2125
- const modelText = prepareText(model.text || '');
2126
- const newTokens = (model.tokens || []).reduce((acc, token = {}) => {
2127
- const tokenText = prepareText((model.text || '').slice(token.start, token.end));
2128
- if (!tokenText) {
2129
- return [...acc, token];
2130
- }
2131
- const getStartIndex = start => {
2132
- let length = start;
2133
- while (length >= 0) {
2134
- let newStartIndex = modelText.slice(length).indexOf(tokenText);
2135
- if (newStartIndex >= 0) {
2136
- return newStartIndex + length;
2137
- }
2138
- length--;
2139
- }
2140
- return 0;
2141
- };
2142
- const lastToken = acc[acc.length - 1];
2143
- const newStart = getStartIndex(lastToken ? lastToken.end : token.start);
2144
- const newEnd = newStart + tokenText.length;
2145
- return [...acc, {
2146
- ...token,
2147
- text: tokenText,
2148
- start: newStart,
2149
- end: newEnd,
2150
- oldStart: token.start,
2151
- oldEnd: token.end
2152
- }];
2153
- }, []);
2154
- return {
2155
- ...model,
2156
- tokens: newTokens,
2157
- text: modelText
2158
- };
2159
- };
2160
- const generateValidationMessage = config => {
2161
- const {minTokens, maxTokens, maxSelections} = config;
2162
- const tokensMessage = `\nThere should be at least ${minTokens} ` + (maxTokens ? `and at most ${maxTokens} ` : '') + 'tokens defined.';
2163
- const selectionsMessage = `\nThere should be at least 1 ` + (maxSelections ? `and at most ${maxSelections} ` : '') + 'token' + (maxSelections ? 's' : '') + ' selected.';
2164
- const message = 'Validation requirements:' + tokensMessage + selectionsMessage;
2165
- return message;
2166
- };
2167
- const React$1 = _dll_react;
2168
- const PropTypes = _dll_prop_types;
2169
- const {TextField: TextField} = _dll_material_ui__core;
2170
- const {Chip: Chip} = _dll_material_ui__core;
2171
- const {Tooltip: Tooltip} = _dll_material_ui__core;
2172
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
2173
- const {cloneDeep: cloneDeep} = _dll_lodash;
2174
- const {debounce: debounce} = _dll_lodash;
2175
- const {Info: Info} = _dll_material_ui__icons;
2176
- const debug = _dll_debug;
2177
- const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
2178
- const {NumberTextField: NumberTextField} = _dll_pie_lib__config_ui;
2179
- const {FeedbackConfig: FeedbackConfig} = _dll_pie_lib__config_ui;
2180
- const {settings: settings} = _dll_pie_lib__config_ui;
2181
- const {layout: layout} = _dll_pie_lib__config_ui;
2182
- const EditableHtml = _dll_pie_lib__editable_html;
2183
- const _jsxFileName = "/home/circleci/repo/packages/select-text/configure/src/design.jsx";
2184
- const {Panel, toggle, radio} = settings;
2185
- const log = debug('@pie-element:select-text:configure');
2186
- class Design extends React$1.Component {
2187
- static __initStatic() {
2188
- this.propTypes = {
2189
- model: PropTypes.object.isRequired,
2190
- configuration: PropTypes.object.isRequired,
2191
- classes: PropTypes.object.isRequired,
2192
- onModelChanged: PropTypes.func.isRequired,
2193
- onConfigurationChanged: PropTypes.func.isRequired,
2194
- imageSupport: PropTypes.shape({
2195
- add: PropTypes.func.isRequired,
2196
- delete: PropTypes.func.isRequired
2197
- })
2198
- };
2199
- }
2200
- static __initStatic2() {
2201
- this.defaultProps = {};
2202
- }
2203
- constructor(props) {
2204
- super(props);
2205
- Design.prototype.__init.call(this);
2206
- Design.prototype.__init2.call(this);
2207
- Design.prototype.__init3.call(this);
2208
- Design.prototype.__init4.call(this);
2209
- Design.prototype.__init5.call(this);
2210
- Design.prototype.__init6.call(this);
2211
- Design.prototype.__init7.call(this);
2212
- Design.prototype.__init8.call(this);
2213
- Design.prototype.__init9.call(this);
2214
- Design.prototype.__init10.call(this);
2215
- const {model} = this.props;
2216
- this.state = {
2217
- text: model && model.text || ''
2218
- };
2219
- }
2220
- UNSAFE_componentWillReceiveProps(nProps) {
2221
- const {model} = nProps;
2222
- if (model && model.text) {
2223
- this.setState({
2224
- text: model.text
2225
- });
2226
- }
2227
- }
2228
- __init() {
2229
- this.updateText = debounce(val => {
2230
- this.apply(u => {
2231
- u.text = val;
2232
- u.tokens = [];
2233
- });
2234
- }, 200);
2235
- }
2236
- __init2() {
2237
- this.changeText = event => {
2238
- const value = event.target.value;
2239
- const preparedText = value;
2240
- this.setState({
2241
- text: value
2242
- });
2243
- this.updateText(preparedText);
2244
- };
2245
- }
2246
- __init3() {
2247
- this.changeTokens = (tokens, mode) => {
2248
- this.apply(u => {
2249
- u.tokens = tokens;
2250
- u.mode = mode;
2251
- const correctTokenCount = tokens.filter(t => t.correct).length;
2252
- const max = isFinite(u.maxSelections) ? u.maxSelections : 0;
2253
- u.maxSelections = Math.max(max, correctTokenCount);
2254
- });
2255
- };
2256
- }
2257
- __init4() {
2258
- this.changeMaxSelections = (event, max) => {
2259
- this.apply(u => u.maxSelections = max);
2260
- };
2261
- }
2262
- __init5() {
2263
- this.apply = fn => {
2264
- const {onModelChanged, model} = this.props;
2265
- const update = cloneDeep(model);
2266
- fn(update);
2267
- onModelChanged(update);
2268
- };
2269
- }
2270
- __init6() {
2271
- this.changeFeedback = feedback => {
2272
- this.apply(u => u.feedback = feedback);
2273
- };
2274
- }
2275
- __init7() {
2276
- this.changePartialScoring = partialScoring => {
2277
- const {onModelChanged, model} = this.props;
2278
- const update = cloneDeep(model);
2279
- update.partialScoring = partialScoring;
2280
- onModelChanged(update);
2281
- };
2282
- }
2283
- __init8() {
2284
- this.onPromptChanged = prompt => {
2285
- const {onModelChanged, model} = this.props;
2286
- const update = cloneDeep(model);
2287
- update.prompt = prompt;
2288
- onModelChanged(update);
2289
- };
2290
- }
2291
- __init9() {
2292
- this.onTeacherInstructionsChanged = teacherInstructions => {
2293
- const {onModelChanged, model} = this.props;
2294
- const update = cloneDeep(model);
2295
- update.teacherInstructions = teacherInstructions;
2296
- onModelChanged(update);
2297
- };
2298
- }
2299
- __init10() {
2300
- this.onRationaleChanged = rationale => {
2301
- const {onModelChanged, model} = this.props;
2302
- onModelChanged({
2303
- ...model,
2304
- rationale
2305
- });
2306
- };
2307
- }
2308
- render() {
2309
- const {text: textValue} = this.state;
2310
- const {model, classes, imageSupport, onModelChanged, configuration, onConfigurationChanged} = this.props;
2311
- const {prompt = {}, text = {}, tokens = {}, mode = {}, feedback = {}, partialScoring = {}, selections = {}, selectionCount = {}, correctAnswer = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, scoringType = {}, spellCheck = {}, highlightChoices = {}} = configuration || ({});
2312
- const {teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled, feedbackEnabled, errors} = model || ({});
2313
- const toolbarOpts = {};
2314
- const {tokensError, selectionsError} = errors || ({});
2315
- const validationMessage = generateValidationMessage(configuration);
2316
- switch (model.toolbarEditorPosition) {
2317
- case 'top':
2318
- toolbarOpts.position = 'top';
2319
- break;
2320
- default:
2321
- toolbarOpts.position = 'bottom';
2322
- break;
2323
- }
2324
- let {tokens: tokensModel} = model;
2325
- tokensModel = tokensModel || [];
2326
- log('[render] maxSelections:', model.maxSelections);
2327
- return React$1.createElement(layout.ConfigLayout, {
2328
- settings: React$1.createElement(Panel, {
2329
- model: model,
2330
- configuration: configuration,
2331
- onChangeModel: model => onModelChanged(model),
2332
- onChangeConfiguration: onConfigurationChanged,
2333
- groups: {
2334
- Settings: {
2335
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
2336
- highlightChoices: highlightChoices.settings && toggle(highlightChoices.label),
2337
- feedbackEnabled: feedback.settings && toggle(feedback.label)
2338
- },
2339
- Properties: {
2340
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
2341
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
2342
- promptEnabled: prompt.settings && toggle(prompt.label),
2343
- rationaleEnabled: rationale.settings && toggle(rationale.label),
2344
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
2345
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
2346
- }
2347
- },
2348
- __self: this,
2349
- __source: {
2350
- fileName: _jsxFileName,
2351
- lineNumber: 188
2352
- }
2353
- }),
2354
- __self: this,
2355
- __source: {
2356
- fileName: _jsxFileName,
2357
- lineNumber: 186
2358
- }
2359
- }, React$1.createElement('div', {
2360
- className: classes.container,
2361
- __self: this,
2362
- __source: {
2363
- fileName: _jsxFileName,
2364
- lineNumber: 221
2365
- }
2366
- }, teacherInstructionsEnabled && React$1.createElement(InputContainer, {
2367
- label: teacherInstructions.label,
2368
- className: classes.promptHolder,
2369
- __self: this,
2370
- __source: {
2371
- fileName: _jsxFileName,
2372
- lineNumber: 223
2373
- }
2374
- }, React$1.createElement(EditableHtml, {
2375
- className: classes.prompt,
2376
- markup: model.teacherInstructions || '',
2377
- onChange: this.onTeacherInstructionsChanged,
2378
- imageSupport: imageSupport,
2379
- nonEmpty: false,
2380
- toolbarOpts: toolbarOpts,
2381
- spellCheck: spellCheckEnabled,
2382
- __self: this,
2383
- __source: {
2384
- fileName: _jsxFileName,
2385
- lineNumber: 227
2386
- }
2387
- })), promptEnabled && React$1.createElement(InputContainer, {
2388
- label: prompt.label || '',
2389
- className: classes.promptHolder,
2390
- __self: this,
2391
- __source: {
2392
- fileName: _jsxFileName,
2393
- lineNumber: 240
2394
- }
2395
- }, React$1.createElement(EditableHtml, {
2396
- className: classes.prompt,
2397
- markup: model.prompt,
2398
- onChange: this.onPromptChanged,
2399
- imageSupport: imageSupport,
2400
- toolbarOpts: toolbarOpts,
2401
- spellCheck: spellCheckEnabled,
2402
- __self: this,
2403
- __source: {
2404
- fileName: _jsxFileName,
2405
- lineNumber: 244
2406
- }
2407
- })), rationaleEnabled && React$1.createElement(InputContainer, {
2408
- label: rationale.label || '',
2409
- className: classes.promptHolder,
2410
- __self: this,
2411
- __source: {
2412
- fileName: _jsxFileName,
2413
- lineNumber: 256
2414
- }
2415
- }, React$1.createElement(EditableHtml, {
2416
- className: classes.prompt,
2417
- markup: model.rationale || '',
2418
- onChange: this.onRationaleChanged,
2419
- imageSupport: imageSupport,
2420
- toolbarOpts: toolbarOpts,
2421
- spellCheck: spellCheckEnabled,
2422
- __self: this,
2423
- __source: {
2424
- fileName: _jsxFileName,
2425
- lineNumber: 260
2426
- }
2427
- })), text.settings && React$1.createElement(TextField, {
2428
- label: text.label,
2429
- className: classes.input,
2430
- multiline: true,
2431
- value: textValue,
2432
- onChange: this.changeText,
2433
- spellCheck: spellCheckEnabled,
2434
- __self: this,
2435
- __source: {
2436
- fileName: _jsxFileName,
2437
- lineNumber: 272
2438
- }
2439
- }), React$1.createElement(Tooltip, {
2440
- classes: {
2441
- tooltip: classes.tooltip
2442
- },
2443
- disableFocusListener: true,
2444
- disableTouchListener: true,
2445
- placement: 'left',
2446
- title: validationMessage,
2447
- __self: this,
2448
- __source: {
2449
- fileName: _jsxFileName,
2450
- lineNumber: 282
2451
- }
2452
- }, React$1.createElement(Info, {
2453
- fontSize: 'small',
2454
- color: 'primary',
2455
- style: {
2456
- float: 'right'
2457
- },
2458
- __self: this,
2459
- __source: {
2460
- fileName: _jsxFileName,
2461
- lineNumber: 289
2462
- }
2463
- })), tokensError && React$1.createElement('div', {
2464
- className: classes.errorText,
2465
- __self: this,
2466
- __source: {
2467
- fileName: _jsxFileName,
2468
- lineNumber: 292
2469
- }
2470
- }, tokensError), selectionsError && React$1.createElement('div', {
2471
- className: classes.errorText,
2472
- __self: this,
2473
- __source: {
2474
- fileName: _jsxFileName,
2475
- lineNumber: 293
2476
- }
2477
- }, selectionsError), tokens.settings && React$1.createElement(InputContainer, {
2478
- label: tokens.label || '',
2479
- className: classes.tokenizerContainer,
2480
- __self: this,
2481
- __source: {
2482
- fileName: _jsxFileName,
2483
- lineNumber: 296
2484
- }
2485
- }, React$1.createElement(Tokenizer$1, {
2486
- className: classes.tokenizer,
2487
- text: model.text,
2488
- tokens: tokensModel,
2489
- onChange: this.changeTokens,
2490
- __self: this,
2491
- __source: {
2492
- fileName: _jsxFileName,
2493
- lineNumber: 300
2494
- }
2495
- })), mode.settings && React$1.createElement(Chip, {
2496
- label: `${mode.label}: ${model.mode ? model.mode : 'None'}`,
2497
- className: classes.chip,
2498
- __self: this,
2499
- __source: {
2500
- fileName: _jsxFileName,
2501
- lineNumber: 310
2502
- }
2503
- }), selections.settings && React$1.createElement(Chip, {
2504
- label: `${selections.label}: ${tokensModel.length}`,
2505
- className: classes.chip,
2506
- __self: this,
2507
- __source: {
2508
- fileName: _jsxFileName,
2509
- lineNumber: 317
2510
- }
2511
- }), correctAnswer.settings && React$1.createElement(Chip, {
2512
- label: `${correctAnswer.label}: ${tokensModel.filter(t => t.correct).length}`,
2513
- className: classes.chip,
2514
- __self: this,
2515
- __source: {
2516
- fileName: _jsxFileName,
2517
- lineNumber: 324
2518
- }
2519
- }), selectionCount.settings && React$1.createElement(NumberTextField, {
2520
- min: tokensModel.filter(t => t.correct).length || 0,
2521
- label: `${selectionCount.label} (0:any)`,
2522
- max: tokensModel.length,
2523
- value: model.maxSelections,
2524
- onChange: this.changeMaxSelections,
2525
- className: classes.numberField,
2526
- __self: this,
2527
- __source: {
2528
- fileName: _jsxFileName,
2529
- lineNumber: 333
2530
- }
2531
- }), feedbackEnabled && React$1.createElement(FeedbackConfig, {
2532
- feedback: model.feedback,
2533
- onChange: this.changeFeedback,
2534
- toolbarOpts: toolbarOpts,
2535
- __self: this,
2536
- __source: {
2537
- fileName: _jsxFileName,
2538
- lineNumber: 344
2539
- }
2540
- })));
2541
- }
2542
- }
2543
- Design.__initStatic();
2544
- Design.__initStatic2();
2545
- var Main = withStyles(theme => ({
2546
- container: {
2547
- paddingTop: theme.spacing.unit
2548
- },
2549
- tokenizerContainer: {
2550
- paddingRight: 0,
2551
- marginRight: 0,
2552
- '&:after': {
2553
- position: 'absolute',
2554
- bottom: 0,
2555
- left: 0,
2556
- right: 0,
2557
- height: '1px',
2558
- content: '""',
2559
- backgroundColor: theme.palette.primary.main
2560
- },
2561
- marginBottom: theme.spacing.unit
2562
- },
2563
- chip: {
2564
- marginRight: theme.spacing.unit * 2
2565
- },
2566
- input: {
2567
- width: '100%',
2568
- paddingBottom: theme.spacing.unit * 3
2569
- },
2570
- tokenizer: {
2571
- marginTop: theme.spacing.unit * 2
2572
- },
2573
- mainOpts: {
2574
- width: '100%',
2575
- justifyContent: 'space-between',
2576
- display: 'flex',
2577
- alignItems: 'baseline'
2578
- },
2579
- promptHolder: {
2580
- width: '100%',
2581
- paddingBottom: theme.spacing.unit * 2,
2582
- marginBottom: theme.spacing.unit * 2
2583
- },
2584
- prompt: {
2585
- paddingTop: theme.spacing.unit * 2,
2586
- width: '100%'
2587
- },
2588
- numberField: {
2589
- width: '180px'
2590
- },
2591
- tooltip: {
2592
- fontSize: '12px',
2593
- whiteSpace: 'pre',
2594
- maxWidth: '500px'
2595
- },
2596
- errorText: {
2597
- fontSize: '12px',
2598
- color: 'red',
2599
- padding: '5px 0'
2600
- }
2601
- }))(Design);
2602
- var lib = {};
2603
- Object.defineProperty(lib, "__esModule", {
2604
- value: true
2605
- });
2606
- class ModelUpdatedEvent extends CustomEvent {
2607
- constructor(update, reset = false) {
2608
- super(ModelUpdatedEvent.TYPE, {
2609
- bubbles: true,
2610
- detail: {
2611
- update,
2612
- reset
2613
- }
2614
- });
2615
- this.update = update;
2616
- this.reset = reset;
2617
- }
2618
- }
2619
- ModelUpdatedEvent.TYPE = 'model.updated';
2620
- var ModelUpdatedEvent_1 = lib.ModelUpdatedEvent = ModelUpdatedEvent;
2621
- class DeleteImageEvent extends CustomEvent {
2622
- constructor(src, done) {
2623
- super(DeleteImageEvent.TYPE, {
2624
- bubbles: true,
2625
- detail: {
2626
- src,
2627
- done
2628
- }
2629
- });
2630
- this.src = src;
2631
- this.done = done;
2632
- }
2633
- }
2634
- DeleteImageEvent.TYPE = 'delete.image';
2635
- var DeleteImageEvent_1 = lib.DeleteImageEvent = DeleteImageEvent;
2636
- class InsertImageEvent extends CustomEvent {
2637
- constructor(handler) {
2638
- super(InsertImageEvent.TYPE, {
2639
- bubbles: true,
2640
- detail: handler
2641
- });
2642
- this.handler = handler;
2643
- }
2644
- }
2645
- InsertImageEvent.TYPE = 'insert.image';
2646
- var InsertImageEvent_1 = lib.InsertImageEvent = InsertImageEvent;
2647
- const tokens = () => [{
2648
- text: '',
2649
- start: 0,
2650
- end: 0
2651
- }];
2652
- var defaultValues = {
2653
- model: {
2654
- highlightChoices: false,
2655
- partialScoring: false,
2656
- maxSelections: 2,
2657
- mode: 'sentence',
2658
- prompt: 'Question Prompt goes here',
2659
- text: '',
2660
- tokens: tokens(),
2661
- scoringType: 'auto',
2662
- feedbackEnabled: true,
2663
- rationaleEnabled: true,
2664
- promptEnabled: true,
2665
- teacherInstructionsEnabled: true,
2666
- studentInstructionsEnabled: true,
2667
- toolbarEditorPosition: 'bottom'
2668
- },
2669
- configuration: {
2670
- selectionCount: {
2671
- settings: true,
2672
- label: 'Selection count'
2673
- },
2674
- correctAnswer: {
2675
- settings: true,
2676
- label: 'Correct Answers'
2677
- },
2678
- selections: {
2679
- settings: true,
2680
- label: 'Selections Available'
2681
- },
2682
- highlightChoices: {
2683
- settings: true,
2684
- label: 'Highlight choices'
2685
- },
2686
- rationale: {
2687
- settings: true,
2688
- label: 'Rationale'
2689
- },
2690
- scoringType: {
2691
- settings: false,
2692
- label: 'Scoring Type'
2693
- },
2694
- studentInstructions: {
2695
- settings: false,
2696
- label: 'Student Instructions'
2697
- },
2698
- teacherInstructions: {
2699
- settings: true,
2700
- label: 'Teacher Instructions'
2701
- },
2702
- prompt: {
2703
- label: 'Prompt',
2704
- settings: true
2705
- },
2706
- text: {
2707
- settings: true,
2708
- label: 'Content'
2709
- },
2710
- tokens: {
2711
- settings: true,
2712
- label: 'Tokens'
2713
- },
2714
- feedback: {
2715
- settings: true,
2716
- label: 'Feedback'
2717
- },
2718
- spellCheck: {
2719
- label: 'Spellcheck',
2720
- settings: false,
2721
- enabled: true
2722
- },
2723
- partialScoring: {
2724
- settings: false,
2725
- label: 'Allow Partial Scoring'
2726
- },
2727
- mode: {
2728
- settings: true,
2729
- label: 'Mode'
2730
- },
2731
- minTokens: 2
2732
- }
2733
- };
2734
- const React = _dll_react;
2735
- const ReactDOM = _dll_react_dom;
2736
- class SelectTextConfigure extends HTMLElement {
2737
- static __initStatic() {
2738
- this.createDefaultModel = (model = {}) => {
2739
- const newModel = {
2740
- ...defaultValues.model,
2741
- ...model
2742
- };
2743
- return generateModel(newModel);
2744
- };
2745
- }
2746
- constructor() {
2747
- super();
2748
- this._model = SelectTextConfigure.createDefaultModel();
2749
- this._configuration = defaultValues.configuration;
2750
- }
2751
- set model(m) {
2752
- this._model = SelectTextConfigure.createDefaultModel(m);
2753
- this.render();
2754
- }
2755
- set configuration(c) {
2756
- this._configuration = c;
2757
- this.render();
2758
- }
2759
- connectedCallback() {
2760
- this.render();
2761
- }
2762
- modelChanged(m) {
2763
- this._model = m;
2764
- this.dispatchEvent(new ModelUpdatedEvent_1(this._model), true);
2765
- this.render();
2766
- }
2767
- onConfigurationChanged(c) {
2768
- this._configuration = c;
2769
- if (this._model) {
2770
- this.dispatchEvent(new ModelUpdatedEvent_1(this._model), false);
2771
- }
2772
- this.render();
2773
- }
2774
- insertImage(handler) {
2775
- this.dispatchEvent(new InsertImageEvent_1(handler));
2776
- }
2777
- onDeleteImage(src, done) {
2778
- this.dispatchEvent(new DeleteImageEvent_1(src, done));
2779
- }
2780
- render() {
2781
- if (this._model) {
2782
- const el = React.createElement(Main, {
2783
- model: this._model,
2784
- configuration: this._configuration,
2785
- onModelChanged: this.modelChanged.bind(this),
2786
- onConfigurationChanged: this.onConfigurationChanged.bind(this),
2787
- imageSupport: {
2788
- add: this.insertImage.bind(this),
2789
- delete: this.onDeleteImage.bind(this)
2790
- }
2791
- });
2792
- ReactDOM.render(el, this);
2793
- }
2794
- }
2795
- }
2796
- SelectTextConfigure.__initStatic();
2797
- export {SelectTextConfigure as default};