@soomo/react-text-annotator 3.0.0-staging.4 → 3.0.0-staging.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TextAnnotator.d.ts +3 -3
- package/dist/TextAnnotator.d.ts.map +1 -1
- package/dist/TextAnnotatorPlugin.d.ts +1 -2
- package/dist/TextAnnotatorPlugin.d.ts.map +1 -1
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +16 -0
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -0
- package/dist/TextAnnotatorPopup/index.d.ts +2 -0
- package/dist/TextAnnotatorPopup/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAnnouncePopupNavigation.d.ts +10 -0
- package/dist/hooks/useAnnouncePopupNavigation.d.ts.map +1 -0
- package/dist/hooks/useRestoreSelectionCaret.d.ts +13 -0
- package/dist/hooks/useRestoreSelectionCaret.d.ts.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.css +31 -1
- package/dist/react-text-annotator.es.js +14 -4
- package/dist/react-text-annotator.es.js.map +1 -1
- package/dist/react-text-annotator.es11.js +459 -861
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +64 -2
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +45 -2
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +1444 -107
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es16.js +228 -45
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +565 -16
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +5 -0
- package/dist/react-text-annotator.es18.js.map +1 -0
- package/dist/{react-text-annotator.es10.js → react-text-annotator.es19.js} +7 -11
- package/dist/{react-text-annotator.es10.js.map → react-text-annotator.es19.js.map} +1 -1
- package/dist/react-text-annotator.es2.js +2 -2
- package/dist/react-text-annotator.es20.js +901 -0
- package/dist/react-text-annotator.es20.js.map +1 -0
- package/dist/react-text-annotator.es21.js +117 -0
- package/dist/react-text-annotator.es21.js.map +1 -0
- package/dist/{react-text-annotator.es15.js → react-text-annotator.es22.js} +1 -1
- package/dist/{react-text-annotator.es15.js.map → react-text-annotator.es22.js.map} +1 -1
- package/dist/react-text-annotator.es23.js +61 -0
- package/dist/react-text-annotator.es23.js.map +1 -0
- package/dist/react-text-annotator.es24.js +23 -0
- package/dist/react-text-annotator.es24.js.map +1 -0
- package/dist/react-text-annotator.es25.js +5 -0
- package/dist/react-text-annotator.es25.js.map +1 -0
- package/dist/react-text-annotator.es26.js +5 -0
- package/dist/react-text-annotator.es26.js.map +1 -0
- package/dist/react-text-annotator.es27.js +130 -0
- package/dist/react-text-annotator.es27.js.map +1 -0
- package/dist/react-text-annotator.es28.js +155 -0
- package/dist/react-text-annotator.es28.js.map +1 -0
- package/dist/react-text-annotator.es29.js +314 -0
- package/dist/react-text-annotator.es29.js.map +1 -0
- package/dist/react-text-annotator.es3.js +2 -2
- package/dist/react-text-annotator.es30.js +152 -0
- package/dist/react-text-annotator.es30.js.map +1 -0
- package/dist/react-text-annotator.es31.js +563 -0
- package/dist/react-text-annotator.es31.js.map +1 -0
- package/dist/react-text-annotator.es4.js +29 -27
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +38 -48
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +25 -10
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +134 -1
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +177 -486
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/react-text-annotator.es9.js +10 -2
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/dist/tei/TEIAnnotator.d.ts +2 -2
- package/package.json +23 -15
- package/dist/TextAnnotatorPopup.d.ts +0 -14
- package/dist/TextAnnotatorPopup.d.ts.map +0 -1
|
@@ -1,892 +1,490 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return "StrictMode";
|
|
133
|
-
case REACT_SUSPENSE_TYPE:
|
|
134
|
-
return "Suspense";
|
|
135
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
136
|
-
return "SuspenseList";
|
|
137
|
-
}
|
|
138
|
-
if (typeof type === "object") {
|
|
139
|
-
switch (type.$$typeof) {
|
|
140
|
-
case REACT_CONTEXT_TYPE:
|
|
141
|
-
var context = type;
|
|
142
|
-
return getContextName(context) + ".Consumer";
|
|
143
|
-
case REACT_PROVIDER_TYPE:
|
|
144
|
-
var provider = type;
|
|
145
|
-
return getContextName(provider._context) + ".Provider";
|
|
146
|
-
case REACT_FORWARD_REF_TYPE:
|
|
147
|
-
return getWrappedName(type, type.render, "ForwardRef");
|
|
148
|
-
case REACT_MEMO_TYPE:
|
|
149
|
-
var outerName = type.displayName || null;
|
|
150
|
-
if (outerName !== null) {
|
|
151
|
-
return outerName;
|
|
152
|
-
}
|
|
153
|
-
return getComponentNameFromType(type.type) || "Memo";
|
|
154
|
-
case REACT_LAZY_TYPE: {
|
|
155
|
-
var lazyComponent = type;
|
|
156
|
-
var payload = lazyComponent._payload;
|
|
157
|
-
var init = lazyComponent._init;
|
|
158
|
-
try {
|
|
159
|
-
return getComponentNameFromType(init(payload));
|
|
160
|
-
} catch (x) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
var assign = Object.assign;
|
|
169
|
-
var disabledDepth = 0;
|
|
170
|
-
var prevLog;
|
|
171
|
-
var prevInfo;
|
|
172
|
-
var prevWarn;
|
|
173
|
-
var prevError;
|
|
174
|
-
var prevGroup;
|
|
175
|
-
var prevGroupCollapsed;
|
|
176
|
-
var prevGroupEnd;
|
|
177
|
-
function disabledLog() {
|
|
178
|
-
}
|
|
179
|
-
disabledLog.__reactDisabledLog = true;
|
|
180
|
-
function disableLogs() {
|
|
181
|
-
{
|
|
182
|
-
if (disabledDepth === 0) {
|
|
183
|
-
prevLog = console.log;
|
|
184
|
-
prevInfo = console.info;
|
|
185
|
-
prevWarn = console.warn;
|
|
186
|
-
prevError = console.error;
|
|
187
|
-
prevGroup = console.group;
|
|
188
|
-
prevGroupCollapsed = console.groupCollapsed;
|
|
189
|
-
prevGroupEnd = console.groupEnd;
|
|
190
|
-
var props = {
|
|
191
|
-
configurable: true,
|
|
192
|
-
enumerable: true,
|
|
193
|
-
value: disabledLog,
|
|
194
|
-
writable: true
|
|
195
|
-
};
|
|
196
|
-
Object.defineProperties(console, {
|
|
197
|
-
info: props,
|
|
198
|
-
log: props,
|
|
199
|
-
warn: props,
|
|
200
|
-
error: props,
|
|
201
|
-
group: props,
|
|
202
|
-
groupCollapsed: props,
|
|
203
|
-
groupEnd: props
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
disabledDepth++;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function reenableLogs() {
|
|
210
|
-
{
|
|
211
|
-
disabledDepth--;
|
|
212
|
-
if (disabledDepth === 0) {
|
|
213
|
-
var props = {
|
|
214
|
-
configurable: true,
|
|
215
|
-
enumerable: true,
|
|
216
|
-
writable: true
|
|
217
|
-
};
|
|
218
|
-
Object.defineProperties(console, {
|
|
219
|
-
log: assign({}, props, {
|
|
220
|
-
value: prevLog
|
|
221
|
-
}),
|
|
222
|
-
info: assign({}, props, {
|
|
223
|
-
value: prevInfo
|
|
224
|
-
}),
|
|
225
|
-
warn: assign({}, props, {
|
|
226
|
-
value: prevWarn
|
|
227
|
-
}),
|
|
228
|
-
error: assign({}, props, {
|
|
229
|
-
value: prevError
|
|
230
|
-
}),
|
|
231
|
-
group: assign({}, props, {
|
|
232
|
-
value: prevGroup
|
|
233
|
-
}),
|
|
234
|
-
groupCollapsed: assign({}, props, {
|
|
235
|
-
value: prevGroupCollapsed
|
|
236
|
-
}),
|
|
237
|
-
groupEnd: assign({}, props, {
|
|
238
|
-
value: prevGroupEnd
|
|
239
|
-
})
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
if (disabledDepth < 0) {
|
|
243
|
-
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
248
|
-
var prefix;
|
|
249
|
-
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
250
|
-
{
|
|
251
|
-
if (prefix === void 0) {
|
|
252
|
-
try {
|
|
253
|
-
throw Error();
|
|
254
|
-
} catch (x) {
|
|
255
|
-
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
256
|
-
prefix = match && match[1] || "";
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return "\n" + prefix + name;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
var reentry = false;
|
|
263
|
-
var componentFrameCache;
|
|
264
|
-
{
|
|
265
|
-
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
|
266
|
-
componentFrameCache = new PossiblyWeakMap();
|
|
267
|
-
}
|
|
268
|
-
function describeNativeComponentFrame(fn, construct) {
|
|
269
|
-
if (!fn || reentry) {
|
|
270
|
-
return "";
|
|
271
|
-
}
|
|
272
|
-
{
|
|
273
|
-
var frame = componentFrameCache.get(fn);
|
|
274
|
-
if (frame !== void 0) {
|
|
275
|
-
return frame;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
var control;
|
|
279
|
-
reentry = true;
|
|
280
|
-
var previousPrepareStackTrace = Error.prepareStackTrace;
|
|
281
|
-
Error.prepareStackTrace = void 0;
|
|
282
|
-
var previousDispatcher;
|
|
283
|
-
{
|
|
284
|
-
previousDispatcher = ReactCurrentDispatcher.current;
|
|
285
|
-
ReactCurrentDispatcher.current = null;
|
|
286
|
-
disableLogs();
|
|
287
|
-
}
|
|
288
|
-
try {
|
|
289
|
-
if (construct) {
|
|
290
|
-
var Fake = function() {
|
|
291
|
-
throw Error();
|
|
292
|
-
};
|
|
293
|
-
Object.defineProperty(Fake.prototype, "props", {
|
|
294
|
-
set: function() {
|
|
295
|
-
throw Error();
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
if (typeof Reflect === "object" && Reflect.construct) {
|
|
299
|
-
try {
|
|
300
|
-
Reflect.construct(Fake, []);
|
|
301
|
-
} catch (x) {
|
|
302
|
-
control = x;
|
|
303
|
-
}
|
|
304
|
-
Reflect.construct(fn, [], Fake);
|
|
1
|
+
import defaultBehaviors from "./react-text-annotator.es21.js";
|
|
2
|
+
import * as utilities from "./react-text-annotator.es22.js";
|
|
3
|
+
import { hideContent, defineCustomElement, tagName } from "./react-text-annotator.es22.js";
|
|
4
|
+
import { addBehaviors, addBehavior, removeBehavior } from "./react-text-annotator.es23.js";
|
|
5
|
+
import { learnElementNames, learnCustomElementNames } from "./react-text-annotator.es24.js";
|
|
6
|
+
class CETEI {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options ? options : {};
|
|
9
|
+
this.document = this.options.documentObject ? this.options.documentObject : void 0;
|
|
10
|
+
if (this.document === void 0) {
|
|
11
|
+
if (typeof window !== "undefined" && window.document) {
|
|
12
|
+
this.document = window.document;
|
|
13
|
+
} else if (typeof global !== "undefined" && global.document) {
|
|
14
|
+
this.document = global.document;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
this.addBehaviors = addBehaviors.bind(this);
|
|
18
|
+
this.addBehavior = addBehavior.bind(this);
|
|
19
|
+
this.removeBehavior = removeBehavior.bind(this);
|
|
20
|
+
this.utilities = {};
|
|
21
|
+
for (const u of Object.keys(utilities)) {
|
|
22
|
+
if (["getPrefixDef", "rw", "resolveURI"].includes(u)) {
|
|
23
|
+
this.utilities[u] = utilities[u].bind(this);
|
|
24
|
+
} else {
|
|
25
|
+
this.utilities[u] = utilities[u];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
this.els = [];
|
|
29
|
+
this.namespaces = /* @__PURE__ */ new Map();
|
|
30
|
+
this.behaviors = {};
|
|
31
|
+
this.hasStyle = false;
|
|
32
|
+
this.prefixDefs = [];
|
|
33
|
+
this.debug = this.options.debug === true ? true : false;
|
|
34
|
+
this.discardContent = this.options.discardContent === true ? true : false;
|
|
35
|
+
if (this.options.base) {
|
|
36
|
+
this.base = this.options.base;
|
|
37
|
+
} else {
|
|
38
|
+
try {
|
|
39
|
+
if (window) {
|
|
40
|
+
this.base = window.location.href.replace(/\/[^\/]*$/, "/");
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
this.base = "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!this.options.omitDefaultBehaviors) {
|
|
47
|
+
this.addBehaviors(defaultBehaviors);
|
|
48
|
+
}
|
|
49
|
+
if (this.options.ignoreFragmentId) {
|
|
50
|
+
if (window) {
|
|
51
|
+
window.removeEventListener("ceteiceanload", CETEI.restorePosition);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/*
|
|
56
|
+
Returns a Promise that fetches an XML source document from the URL
|
|
57
|
+
provided in the first parameter and then calls the makeHTML5 method
|
|
58
|
+
on the returned document.
|
|
59
|
+
*/
|
|
60
|
+
async getHTML5(XML_url, callback, perElementFn) {
|
|
61
|
+
if (window && window.location.href.startsWith(this.base) && XML_url.indexOf("/") >= 0) {
|
|
62
|
+
this.base = XML_url.replace(/\/[^\/]*$/, "/");
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const response = await fetch(XML_url);
|
|
66
|
+
if (response.ok) {
|
|
67
|
+
const XML = await response.text();
|
|
68
|
+
return this.makeHTML5(XML, callback, perElementFn);
|
|
69
|
+
} else {
|
|
70
|
+
console.log(`Could not get XML file ${XML_url}.
|
|
71
|
+
Server returned ${response.status}: ${response.statusText}`);
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.log(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/*
|
|
78
|
+
Converts the supplied XML string into HTML5 Custom Elements. If a callback
|
|
79
|
+
function is supplied, calls it on the result.
|
|
80
|
+
*/
|
|
81
|
+
makeHTML5(XML, callback, perElementFn) {
|
|
82
|
+
this.XML_dom = new DOMParser().parseFromString(XML, "text/xml");
|
|
83
|
+
return this.domToHTML5(this.XML_dom, callback, perElementFn);
|
|
84
|
+
}
|
|
85
|
+
preprocess(XML_dom, callback, perElementFn) {
|
|
86
|
+
this.els = learnElementNames(XML_dom, this.namespaces);
|
|
87
|
+
let convertEl = (el) => {
|
|
88
|
+
let newElement;
|
|
89
|
+
if (this.namespaces.has(el.namespaceURI ? el.namespaceURI : "")) {
|
|
90
|
+
let prefix = this.namespaces.get(el.namespaceURI ? el.namespaceURI : "");
|
|
91
|
+
newElement = this.document.createElement(`${prefix}-${el.localName.toLowerCase()}`);
|
|
92
|
+
} else {
|
|
93
|
+
newElement = this.document.importNode(el, false);
|
|
94
|
+
}
|
|
95
|
+
for (let att of Array.from(el.attributes)) {
|
|
96
|
+
if (att.name == "xmlns") {
|
|
97
|
+
newElement.setAttribute("data-xmlns", att.value);
|
|
98
|
+
} else {
|
|
99
|
+
newElement.setAttribute(att.name, att.value);
|
|
100
|
+
}
|
|
101
|
+
if (att.name == "xml:id") {
|
|
102
|
+
newElement.setAttribute("id", att.value);
|
|
103
|
+
}
|
|
104
|
+
if (att.name == "xml:lang") {
|
|
105
|
+
newElement.setAttribute("lang", att.value);
|
|
106
|
+
}
|
|
107
|
+
if (att.name == "rendition") {
|
|
108
|
+
newElement.setAttribute("class", att.value.replace(/#/g, ""));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
newElement.setAttribute("data-origname", el.localName);
|
|
112
|
+
if (el.hasAttributes()) {
|
|
113
|
+
newElement.setAttribute("data-origatts", el.getAttributeNames().join(" "));
|
|
114
|
+
}
|
|
115
|
+
if (el.childNodes.length == 0) {
|
|
116
|
+
newElement.setAttribute("data-empty", "");
|
|
117
|
+
}
|
|
118
|
+
if (el.localName == "head") {
|
|
119
|
+
let level = XML_dom.evaluate("count(ancestor::*[tei:head])", el, function(ns) {
|
|
120
|
+
if (ns == "tei") return "http://www.tei-c.org/ns/1.0";
|
|
121
|
+
}, 1, null);
|
|
122
|
+
newElement.setAttribute("data-level", level.numberValue);
|
|
123
|
+
}
|
|
124
|
+
if (el.localName == "tagsDecl") {
|
|
125
|
+
let style = this.document.createElement("style");
|
|
126
|
+
for (let node of Array.from(el.childNodes)) {
|
|
127
|
+
if (node.nodeType == 1 && node.localName == "rendition" && node.getAttribute("scheme") == "css") {
|
|
128
|
+
let rule = "";
|
|
129
|
+
if (node.hasAttribute("selector")) {
|
|
130
|
+
rule += node.getAttribute("selector").replace(/([^#, >]+\w*)/g, "tei-$1").replace(/#tei-/g, "#") + "{\n";
|
|
131
|
+
rule += node.textContent;
|
|
305
132
|
} else {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
} catch (x) {
|
|
309
|
-
control = x;
|
|
310
|
-
}
|
|
311
|
-
fn.call(Fake.prototype);
|
|
133
|
+
rule += "." + node.getAttribute("xml:id") + "{\n";
|
|
134
|
+
rule += node.textContent;
|
|
312
135
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
throw Error();
|
|
316
|
-
} catch (x) {
|
|
317
|
-
control = x;
|
|
318
|
-
}
|
|
319
|
-
fn();
|
|
320
|
-
}
|
|
321
|
-
} catch (sample) {
|
|
322
|
-
if (sample && control && typeof sample.stack === "string") {
|
|
323
|
-
var sampleLines = sample.stack.split("\n");
|
|
324
|
-
var controlLines = control.stack.split("\n");
|
|
325
|
-
var s = sampleLines.length - 1;
|
|
326
|
-
var c = controlLines.length - 1;
|
|
327
|
-
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
328
|
-
c--;
|
|
329
|
-
}
|
|
330
|
-
for (; s >= 1 && c >= 0; s--, c--) {
|
|
331
|
-
if (sampleLines[s] !== controlLines[c]) {
|
|
332
|
-
if (s !== 1 || c !== 1) {
|
|
333
|
-
do {
|
|
334
|
-
s--;
|
|
335
|
-
c--;
|
|
336
|
-
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
337
|
-
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
|
|
338
|
-
if (fn.displayName && _frame.includes("<anonymous>")) {
|
|
339
|
-
_frame = _frame.replace("<anonymous>", fn.displayName);
|
|
340
|
-
}
|
|
341
|
-
{
|
|
342
|
-
if (typeof fn === "function") {
|
|
343
|
-
componentFrameCache.set(fn, _frame);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return _frame;
|
|
347
|
-
}
|
|
348
|
-
} while (s >= 1 && c >= 0);
|
|
349
|
-
}
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
} finally {
|
|
355
|
-
reentry = false;
|
|
356
|
-
{
|
|
357
|
-
ReactCurrentDispatcher.current = previousDispatcher;
|
|
358
|
-
reenableLogs();
|
|
136
|
+
rule += "\n}\n";
|
|
137
|
+
style.appendChild(this.document.createTextNode(rule));
|
|
359
138
|
}
|
|
360
|
-
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
361
139
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (typeof fn === "function") {
|
|
366
|
-
componentFrameCache.set(fn, syntheticFrame);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return syntheticFrame;
|
|
370
|
-
}
|
|
371
|
-
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
372
|
-
{
|
|
373
|
-
return describeNativeComponentFrame(fn, false);
|
|
140
|
+
if (style.childNodes.length > 0) {
|
|
141
|
+
newElement.appendChild(style);
|
|
142
|
+
this.hasStyle = true;
|
|
374
143
|
}
|
|
375
144
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (type == null) {
|
|
382
|
-
return "";
|
|
383
|
-
}
|
|
384
|
-
if (typeof type === "function") {
|
|
385
|
-
{
|
|
386
|
-
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
if (typeof type === "string") {
|
|
390
|
-
return describeBuiltInComponentFrame(type);
|
|
391
|
-
}
|
|
392
|
-
switch (type) {
|
|
393
|
-
case REACT_SUSPENSE_TYPE:
|
|
394
|
-
return describeBuiltInComponentFrame("Suspense");
|
|
395
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
396
|
-
return describeBuiltInComponentFrame("SuspenseList");
|
|
397
|
-
}
|
|
398
|
-
if (typeof type === "object") {
|
|
399
|
-
switch (type.$$typeof) {
|
|
400
|
-
case REACT_FORWARD_REF_TYPE:
|
|
401
|
-
return describeFunctionComponentFrame(type.render);
|
|
402
|
-
case REACT_MEMO_TYPE:
|
|
403
|
-
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
404
|
-
case REACT_LAZY_TYPE: {
|
|
405
|
-
var lazyComponent = type;
|
|
406
|
-
var payload = lazyComponent._payload;
|
|
407
|
-
var init = lazyComponent._init;
|
|
408
|
-
try {
|
|
409
|
-
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
410
|
-
} catch (x) {
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return "";
|
|
416
|
-
}
|
|
417
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
418
|
-
var loggedTypeFailures = {};
|
|
419
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
420
|
-
function setCurrentlyValidatingElement(element) {
|
|
421
|
-
{
|
|
422
|
-
if (element) {
|
|
423
|
-
var owner = element._owner;
|
|
424
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
425
|
-
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
426
|
-
} else {
|
|
427
|
-
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
432
|
-
{
|
|
433
|
-
var has = Function.call.bind(hasOwnProperty);
|
|
434
|
-
for (var typeSpecName in typeSpecs) {
|
|
435
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
436
|
-
var error$1 = void 0;
|
|
437
|
-
try {
|
|
438
|
-
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
439
|
-
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
440
|
-
err.name = "Invariant Violation";
|
|
441
|
-
throw err;
|
|
442
|
-
}
|
|
443
|
-
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
444
|
-
} catch (ex) {
|
|
445
|
-
error$1 = ex;
|
|
446
|
-
}
|
|
447
|
-
if (error$1 && !(error$1 instanceof Error)) {
|
|
448
|
-
setCurrentlyValidatingElement(element);
|
|
449
|
-
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
|
450
|
-
setCurrentlyValidatingElement(null);
|
|
451
|
-
}
|
|
452
|
-
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
453
|
-
loggedTypeFailures[error$1.message] = true;
|
|
454
|
-
setCurrentlyValidatingElement(element);
|
|
455
|
-
error("Failed %s type: %s", location, error$1.message);
|
|
456
|
-
setCurrentlyValidatingElement(null);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
var isArrayImpl = Array.isArray;
|
|
463
|
-
function isArray(a) {
|
|
464
|
-
return isArrayImpl(a);
|
|
465
|
-
}
|
|
466
|
-
function typeName(value) {
|
|
467
|
-
{
|
|
468
|
-
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
|
|
469
|
-
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
470
|
-
return type;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
function willCoercionThrow(value) {
|
|
474
|
-
{
|
|
475
|
-
try {
|
|
476
|
-
testStringCoercion(value);
|
|
477
|
-
return false;
|
|
478
|
-
} catch (e) {
|
|
479
|
-
return true;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
function testStringCoercion(value) {
|
|
484
|
-
return "" + value;
|
|
485
|
-
}
|
|
486
|
-
function checkKeyStringCoercion(value) {
|
|
487
|
-
{
|
|
488
|
-
if (willCoercionThrow(value)) {
|
|
489
|
-
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
|
490
|
-
return testStringCoercion(value);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
495
|
-
var RESERVED_PROPS = {
|
|
496
|
-
key: true,
|
|
497
|
-
ref: true,
|
|
498
|
-
__self: true,
|
|
499
|
-
__source: true
|
|
500
|
-
};
|
|
501
|
-
var specialPropKeyWarningShown;
|
|
502
|
-
var specialPropRefWarningShown;
|
|
503
|
-
var didWarnAboutStringRefs;
|
|
504
|
-
{
|
|
505
|
-
didWarnAboutStringRefs = {};
|
|
506
|
-
}
|
|
507
|
-
function hasValidRef(config) {
|
|
508
|
-
{
|
|
509
|
-
if (hasOwnProperty.call(config, "ref")) {
|
|
510
|
-
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
|
511
|
-
if (getter && getter.isReactWarning) {
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return config.ref !== void 0;
|
|
517
|
-
}
|
|
518
|
-
function hasValidKey(config) {
|
|
519
|
-
{
|
|
520
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
521
|
-
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
522
|
-
if (getter && getter.isReactWarning) {
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return config.key !== void 0;
|
|
528
|
-
}
|
|
529
|
-
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
530
|
-
{
|
|
531
|
-
if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
532
|
-
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
533
|
-
if (!didWarnAboutStringRefs[componentName]) {
|
|
534
|
-
error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
|
535
|
-
didWarnAboutStringRefs[componentName] = true;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
541
|
-
{
|
|
542
|
-
var warnAboutAccessingKey = function() {
|
|
543
|
-
if (!specialPropKeyWarningShown) {
|
|
544
|
-
specialPropKeyWarningShown = true;
|
|
545
|
-
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
549
|
-
Object.defineProperty(props, "key", {
|
|
550
|
-
get: warnAboutAccessingKey,
|
|
551
|
-
configurable: true
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
function defineRefPropWarningGetter(props, displayName) {
|
|
556
|
-
{
|
|
557
|
-
var warnAboutAccessingRef = function() {
|
|
558
|
-
if (!specialPropRefWarningShown) {
|
|
559
|
-
specialPropRefWarningShown = true;
|
|
560
|
-
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
warnAboutAccessingRef.isReactWarning = true;
|
|
564
|
-
Object.defineProperty(props, "ref", {
|
|
565
|
-
get: warnAboutAccessingRef,
|
|
566
|
-
configurable: true
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
var ReactElement = function(type, key, ref, self, source, owner, props) {
|
|
571
|
-
var element = {
|
|
572
|
-
// This tag allows us to uniquely identify this as a React Element
|
|
573
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
574
|
-
// Built-in properties that belong on the element
|
|
575
|
-
type,
|
|
576
|
-
key,
|
|
577
|
-
ref,
|
|
578
|
-
props,
|
|
579
|
-
// Record the component responsible for creating this element.
|
|
580
|
-
_owner: owner
|
|
145
|
+
if (el.localName == "prefixDef") {
|
|
146
|
+
this.prefixDefs.push(el.getAttribute("ident"));
|
|
147
|
+
this.prefixDefs[el.getAttribute("ident")] = {
|
|
148
|
+
"matchPattern": el.getAttribute("matchPattern"),
|
|
149
|
+
"replacementPattern": el.getAttribute("replacementPattern")
|
|
581
150
|
};
|
|
582
|
-
{
|
|
583
|
-
element._store = {};
|
|
584
|
-
Object.defineProperty(element._store, "validated", {
|
|
585
|
-
configurable: false,
|
|
586
|
-
enumerable: false,
|
|
587
|
-
writable: true,
|
|
588
|
-
value: false
|
|
589
|
-
});
|
|
590
|
-
Object.defineProperty(element, "_self", {
|
|
591
|
-
configurable: false,
|
|
592
|
-
enumerable: false,
|
|
593
|
-
writable: false,
|
|
594
|
-
value: self
|
|
595
|
-
});
|
|
596
|
-
Object.defineProperty(element, "_source", {
|
|
597
|
-
configurable: false,
|
|
598
|
-
enumerable: false,
|
|
599
|
-
writable: false,
|
|
600
|
-
value: source
|
|
601
|
-
});
|
|
602
|
-
if (Object.freeze) {
|
|
603
|
-
Object.freeze(element.props);
|
|
604
|
-
Object.freeze(element);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
return element;
|
|
608
|
-
};
|
|
609
|
-
function jsxDEV(type, config, maybeKey, source, self) {
|
|
610
|
-
{
|
|
611
|
-
var propName;
|
|
612
|
-
var props = {};
|
|
613
|
-
var key = null;
|
|
614
|
-
var ref = null;
|
|
615
|
-
if (maybeKey !== void 0) {
|
|
616
|
-
{
|
|
617
|
-
checkKeyStringCoercion(maybeKey);
|
|
618
|
-
}
|
|
619
|
-
key = "" + maybeKey;
|
|
620
|
-
}
|
|
621
|
-
if (hasValidKey(config)) {
|
|
622
|
-
{
|
|
623
|
-
checkKeyStringCoercion(config.key);
|
|
624
|
-
}
|
|
625
|
-
key = "" + config.key;
|
|
626
|
-
}
|
|
627
|
-
if (hasValidRef(config)) {
|
|
628
|
-
ref = config.ref;
|
|
629
|
-
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
630
|
-
}
|
|
631
|
-
for (propName in config) {
|
|
632
|
-
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
633
|
-
props[propName] = config[propName];
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
if (type && type.defaultProps) {
|
|
637
|
-
var defaultProps = type.defaultProps;
|
|
638
|
-
for (propName in defaultProps) {
|
|
639
|
-
if (props[propName] === void 0) {
|
|
640
|
-
props[propName] = defaultProps[propName];
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
if (key || ref) {
|
|
645
|
-
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
|
646
|
-
if (key) {
|
|
647
|
-
defineKeyPropWarningGetter(props, displayName);
|
|
648
|
-
}
|
|
649
|
-
if (ref) {
|
|
650
|
-
defineRefPropWarningGetter(props, displayName);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
654
|
-
}
|
|
655
151
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
{
|
|
660
|
-
|
|
661
|
-
var owner = element._owner;
|
|
662
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
663
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
664
|
-
} else {
|
|
665
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
666
|
-
}
|
|
152
|
+
for (let node of Array.from(el.childNodes)) {
|
|
153
|
+
if (node.nodeType == 1) {
|
|
154
|
+
newElement.appendChild(convertEl(node));
|
|
155
|
+
} else {
|
|
156
|
+
newElement.appendChild(node.cloneNode());
|
|
667
157
|
}
|
|
668
158
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
propTypesMisspellWarningShown = false;
|
|
159
|
+
if (perElementFn) {
|
|
160
|
+
perElementFn(newElement, el);
|
|
672
161
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
162
|
+
return newElement;
|
|
163
|
+
};
|
|
164
|
+
this.dom = this.document.createDocumentFragment();
|
|
165
|
+
for (let node of Array.from(XML_dom.childNodes)) {
|
|
166
|
+
if (node.nodeType == 1) {
|
|
167
|
+
this.dom.appendChild(convertEl(node));
|
|
677
168
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
if (ReactCurrentOwner$1.current) {
|
|
681
|
-
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
|
682
|
-
if (name) {
|
|
683
|
-
return "\n\nCheck the render method of `" + name + "`.";
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return "";
|
|
687
|
-
}
|
|
169
|
+
if (node.nodeType == 7) {
|
|
170
|
+
this.dom.appendChild(this.document.importNode(node, true));
|
|
688
171
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
if (source !== void 0) {
|
|
692
|
-
var fileName = source.fileName.replace(/^.*[\\\/]/, "");
|
|
693
|
-
var lineNumber = source.lineNumber;
|
|
694
|
-
return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
|
|
695
|
-
}
|
|
696
|
-
return "";
|
|
697
|
-
}
|
|
172
|
+
if (node.nodeType == 8) {
|
|
173
|
+
this.dom.appendChild(this.document.importNode(node, true));
|
|
698
174
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
if (parentName) {
|
|
706
|
-
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return info;
|
|
710
|
-
}
|
|
175
|
+
}
|
|
176
|
+
this.utilities.dom = this.dom.firstElementChild;
|
|
177
|
+
if (callback) {
|
|
178
|
+
callback(this.dom, this);
|
|
179
|
+
if (window) {
|
|
180
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
711
181
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
element._store.validated = true;
|
|
718
|
-
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
719
|
-
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
723
|
-
var childOwner = "";
|
|
724
|
-
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
725
|
-
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
726
|
-
}
|
|
727
|
-
setCurrentlyValidatingElement$1(element);
|
|
728
|
-
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
729
|
-
setCurrentlyValidatingElement$1(null);
|
|
730
|
-
}
|
|
182
|
+
} else {
|
|
183
|
+
if (typeof window !== "undefined") {
|
|
184
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
731
185
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
186
|
+
return this.dom;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/*
|
|
190
|
+
Converts the supplied XML DOM into HTML5 Custom Elements. If a callback
|
|
191
|
+
function is supplied, calls it on the result.
|
|
192
|
+
*/
|
|
193
|
+
domToHTML5(XML_dom, callback, perElementFn) {
|
|
194
|
+
this.preprocess(XML_dom, null, perElementFn);
|
|
195
|
+
this.applyBehaviors();
|
|
196
|
+
this.done = true;
|
|
197
|
+
if (callback) {
|
|
198
|
+
callback(this.dom, this);
|
|
199
|
+
if (window) {
|
|
200
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
if (typeof window !== "undefined") {
|
|
204
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
205
|
+
}
|
|
206
|
+
return this.dom;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/*
|
|
210
|
+
Convenience method for HTML pages containing pre-processed CETEIcean Custom
|
|
211
|
+
Elements. Usage:
|
|
212
|
+
const c = new CETEI();
|
|
213
|
+
c.processPage();
|
|
214
|
+
*/
|
|
215
|
+
processPage() {
|
|
216
|
+
this.els = learnCustomElementNames(this.document);
|
|
217
|
+
this.applyBehaviors();
|
|
218
|
+
if (window) {
|
|
219
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/*
|
|
223
|
+
To change a namespace -> prefix mapping, the namespace must first be
|
|
224
|
+
unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,
|
|
225
|
+
the TEI namespace must be unset before it can be set to the empty string.
|
|
226
|
+
*/
|
|
227
|
+
unsetNamespace(ns) {
|
|
228
|
+
this.namespaces.delete(ns);
|
|
229
|
+
}
|
|
230
|
+
/*
|
|
231
|
+
Sets the base URL for the document. Used to rewrite relative links in the
|
|
232
|
+
XML source (which may be in a completely different location from the HTML
|
|
233
|
+
wrapper).
|
|
234
|
+
*/
|
|
235
|
+
setBaseUrl(base) {
|
|
236
|
+
this.base = base;
|
|
237
|
+
}
|
|
238
|
+
/*
|
|
239
|
+
Appends any element returned by the function passed in the first
|
|
240
|
+
parameter to the element in the second parameter. If the function
|
|
241
|
+
returns nothing, this is a no-op aside from any side effects caused
|
|
242
|
+
by the provided function.
|
|
243
|
+
|
|
244
|
+
Called by getHandler() and fallback()
|
|
245
|
+
*/
|
|
246
|
+
append(fn, elt) {
|
|
247
|
+
let self = this;
|
|
248
|
+
if (elt && !elt.hasAttribute("data-processed")) {
|
|
249
|
+
let content = fn.call(self.utilities, elt);
|
|
250
|
+
if (content) {
|
|
251
|
+
self.appendBasic(elt, content);
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
return function() {
|
|
255
|
+
if (!this.hasAttribute("data-processed")) {
|
|
256
|
+
let content = fn.call(self.utilities, this);
|
|
257
|
+
if (content) {
|
|
258
|
+
self.appendBasic(this, content);
|
|
761
259
|
}
|
|
762
260
|
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
appendBasic(elt, content) {
|
|
265
|
+
if (this.discardContent) {
|
|
266
|
+
elt.innerHTML = "";
|
|
267
|
+
} else {
|
|
268
|
+
hideContent(elt, true);
|
|
269
|
+
}
|
|
270
|
+
elt.appendChild(content);
|
|
271
|
+
}
|
|
272
|
+
// Given an element, return its qualified name as defined in a behaviors object
|
|
273
|
+
bName(e) {
|
|
274
|
+
return e.tagName.substring(0, e.tagName.indexOf("-")).toLowerCase() + ":" + e.getAttribute("data-origname");
|
|
275
|
+
}
|
|
276
|
+
/*
|
|
277
|
+
Private method called by append(). Takes a child element and a name, and recurses through the
|
|
278
|
+
child's siblings until an element with that name is found, returning true if it is and false if not.
|
|
279
|
+
*/
|
|
280
|
+
childExists(elt, name) {
|
|
281
|
+
if (elt && elt.nodeName == name) {
|
|
282
|
+
return true;
|
|
283
|
+
} else {
|
|
284
|
+
return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/*
|
|
288
|
+
Takes a template in the form of either an array of 1 or 2
|
|
289
|
+
strings or an object with CSS selector keys and either functions
|
|
290
|
+
or arrays as described above. Returns a closure around a function
|
|
291
|
+
that can be called in the element constructor or applied to an
|
|
292
|
+
individual element. An empty array is considered a no-op.
|
|
293
|
+
|
|
294
|
+
Called by the getHandler() and getFallback() methods
|
|
295
|
+
*/
|
|
296
|
+
decorator(template) {
|
|
297
|
+
if (Array.isArray(template) && template.length == 0) {
|
|
298
|
+
return function(e) {
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (Array.isArray(template) && !Array.isArray(template[0])) {
|
|
302
|
+
return this.applyDecorator(template);
|
|
303
|
+
}
|
|
304
|
+
let self = this;
|
|
305
|
+
return function(elt) {
|
|
306
|
+
for (let rule of template) {
|
|
307
|
+
if (elt.matches(rule[0]) || rule[0] === "_") {
|
|
308
|
+
if (Array.isArray(rule[1])) {
|
|
309
|
+
return self.decorator(rule[1]).call(this, elt);
|
|
777
310
|
} else {
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
if (propTypes) {
|
|
781
|
-
var name = getComponentNameFromType(type);
|
|
782
|
-
checkPropTypes(propTypes, element.props, "prop", name, element);
|
|
783
|
-
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
|
784
|
-
propTypesMisspellWarningShown = true;
|
|
785
|
-
var _name = getComponentNameFromType(type);
|
|
786
|
-
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
|
|
787
|
-
}
|
|
788
|
-
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
|
|
789
|
-
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
311
|
+
return rule[1].call(this, elt);
|
|
790
312
|
}
|
|
791
313
|
}
|
|
792
314
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
applyDecorator(strings) {
|
|
318
|
+
let self = this;
|
|
319
|
+
return function(elt) {
|
|
320
|
+
let copy = [];
|
|
321
|
+
for (let i = 0; i < strings.length; i++) {
|
|
322
|
+
copy.push(self.template(strings[i], elt));
|
|
323
|
+
}
|
|
324
|
+
return self.insert(elt, copy);
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/*
|
|
328
|
+
Returns the fallback function for the given element name.
|
|
329
|
+
Called by fallback().
|
|
330
|
+
*/
|
|
331
|
+
getFallback(behaviors, fn) {
|
|
332
|
+
if (behaviors[fn]) {
|
|
333
|
+
if (behaviors[fn] instanceof Function) {
|
|
334
|
+
return behaviors[fn];
|
|
335
|
+
} else {
|
|
336
|
+
return this.decorator(behaviors[fn]);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/*
|
|
341
|
+
Returns the handler function for the given element name
|
|
342
|
+
Called by define().
|
|
343
|
+
*/
|
|
344
|
+
getHandler(behaviors, fn) {
|
|
345
|
+
if (behaviors[fn]) {
|
|
346
|
+
if (behaviors[fn] instanceof Function) {
|
|
347
|
+
return this.append(behaviors[fn]);
|
|
348
|
+
} else {
|
|
349
|
+
return this.append(this.decorator(behaviors[fn]));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
insert(elt, strings) {
|
|
354
|
+
let content = this.document.createElement("cetei-content");
|
|
355
|
+
for (let node of Array.from(elt.childNodes)) {
|
|
356
|
+
if (node.nodeType === 1 && !node.hasAttribute("data-processed")) {
|
|
357
|
+
this.processElement(node);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (strings[0].match("<[^>]+>") && strings[1] && strings[1].match("<[^>]+>")) {
|
|
361
|
+
content.innerHTML = strings[0] + elt.innerHTML + (strings[1] ? strings[1] : "");
|
|
362
|
+
} else {
|
|
363
|
+
content.innerHTML = strings[0];
|
|
364
|
+
content.setAttribute("data-before", strings[0].replace(/<[^>]+>/g, "").length);
|
|
365
|
+
for (let node of Array.from(elt.childNodes)) {
|
|
366
|
+
content.appendChild(node.cloneNode(true));
|
|
367
|
+
}
|
|
368
|
+
if (strings.length > 1) {
|
|
369
|
+
content.innerHTML += strings[1];
|
|
370
|
+
content.setAttribute("data-after", strings[1].replace(/<[^>]+>/g, "").length);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (content.childNodes.length < 2) {
|
|
374
|
+
return content.firstChild;
|
|
375
|
+
} else {
|
|
376
|
+
return content;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// Runs behaviors recursively on the supplied element and children
|
|
380
|
+
processElement(elt) {
|
|
381
|
+
if (elt.hasAttribute("data-origname") && !elt.hasAttribute("data-processed")) {
|
|
382
|
+
let fn = this.getFallback(this.bName(elt));
|
|
383
|
+
if (fn) {
|
|
384
|
+
this.append(fn, elt);
|
|
385
|
+
elt.setAttribute("data-processed", "");
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
for (let node of Array.from(elt.childNodes)) {
|
|
389
|
+
if (node.nodeType === 1) {
|
|
390
|
+
this.processElement(node);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
template(str, elt) {
|
|
395
|
+
let result = str;
|
|
396
|
+
if (str.search(/\$(\w*)(@([a-zA-Z:]+))/)) {
|
|
397
|
+
let re = /\$(\w*)@([a-zA-Z:]+)/g;
|
|
398
|
+
let replacements;
|
|
399
|
+
while (replacements = re.exec(str)) {
|
|
400
|
+
if (elt.hasAttribute(replacements[2])) {
|
|
401
|
+
if (replacements[1] && this.utilities[replacements[1]]) {
|
|
402
|
+
result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));
|
|
864
403
|
} else {
|
|
865
|
-
|
|
404
|
+
result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
|
|
866
405
|
}
|
|
867
|
-
|
|
406
|
+
} else {
|
|
407
|
+
result = result.replace(replacements[0], "");
|
|
868
408
|
}
|
|
869
409
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
// Define or apply behaviors for the document
|
|
414
|
+
applyBehaviors() {
|
|
415
|
+
if (typeof window !== "undefined" && window.customElements) {
|
|
416
|
+
this.define.call(this, this.els);
|
|
417
|
+
} else {
|
|
418
|
+
this.fallback.call(this, this.els);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/*
|
|
422
|
+
Registers the list of elements provided with the browser.
|
|
423
|
+
Called by makeHTML5(), but can be called independently if, for example,
|
|
424
|
+
you've created Custom Elements via an XSLT transformation instead.
|
|
425
|
+
*/
|
|
426
|
+
define(names) {
|
|
427
|
+
for (let name of names) {
|
|
428
|
+
const fn = this.getHandler(this.behaviors, name);
|
|
429
|
+
defineCustomElement(name, fn, this.debug);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/*
|
|
433
|
+
Provides fallback functionality for environments where Custom Elements
|
|
434
|
+
are not supported.
|
|
435
|
+
|
|
436
|
+
Like define(), this is called by makeHTML5(), but can be called
|
|
437
|
+
independently.
|
|
438
|
+
*/
|
|
439
|
+
fallback(names) {
|
|
440
|
+
for (let name of names) {
|
|
441
|
+
let fn = this.getFallback(this.behaviors, name);
|
|
442
|
+
if (fn) {
|
|
443
|
+
for (let elt of Array.from((this.dom && !this.done ? this.dom : this.document).querySelectorAll(tagName(name)))) {
|
|
444
|
+
if (!elt.hasAttribute("data-processed")) {
|
|
445
|
+
this.append(fn, elt);
|
|
446
|
+
elt.setAttribute("data-processed", "");
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/**********************
|
|
453
|
+
* Utility functions *
|
|
454
|
+
**********************/
|
|
455
|
+
static savePosition() {
|
|
456
|
+
window.sessionStorage.setItem(window.location + "-scroll", window.scrollY);
|
|
457
|
+
}
|
|
458
|
+
static restorePosition() {
|
|
459
|
+
if (!window.location.hash) {
|
|
460
|
+
let scroll;
|
|
461
|
+
if (scroll = window.sessionStorage.getItem(window.location + "-scroll")) {
|
|
462
|
+
window.sessionStorage.removeItem(window.location + "-scroll");
|
|
463
|
+
setTimeout(function() {
|
|
464
|
+
window.scrollTo(0, scroll);
|
|
465
|
+
}, 100);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
setTimeout(function() {
|
|
469
|
+
let h = this.document.querySelector(window.decodeURI(window.location.hash));
|
|
470
|
+
if (h) {
|
|
471
|
+
h.scrollIntoView();
|
|
472
|
+
}
|
|
473
|
+
}, 100);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
if (typeof window !== "undefined") {
|
|
479
|
+
window.CETEI = CETEI;
|
|
480
|
+
window.addEventListener("beforeunload", CETEI.savePosition);
|
|
481
|
+
var ceteiceanLoad = new Event("ceteiceanload");
|
|
482
|
+
window.addEventListener("ceteiceanload", CETEI.restorePosition);
|
|
886
483
|
}
|
|
887
|
-
|
|
484
|
+
} catch (e) {
|
|
485
|
+
console.log(e);
|
|
888
486
|
}
|
|
889
487
|
export {
|
|
890
|
-
|
|
488
|
+
CETEI as default
|
|
891
489
|
};
|
|
892
490
|
//# sourceMappingURL=react-text-annotator.es11.js.map
|