@soomo/react-text-annotator 3.2.0-staging.4 → 3.2.0-staging.5

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.
Files changed (37) hide show
  1. package/dist/react-text-annotator.es10.js +497 -78
  2. package/dist/react-text-annotator.es10.js.map +1 -1
  3. package/dist/react-text-annotator.es11.js +77 -40
  4. package/dist/react-text-annotator.es11.js.map +1 -1
  5. package/dist/react-text-annotator.es12.js +41 -21
  6. package/dist/react-text-annotator.es12.js.map +1 -1
  7. package/dist/react-text-annotator.es13.js +19 -1637
  8. package/dist/react-text-annotator.es13.js.map +1 -1
  9. package/dist/react-text-annotator.es14.js +1642 -9
  10. package/dist/react-text-annotator.es14.js.map +1 -1
  11. package/dist/react-text-annotator.es15.js +13 -0
  12. package/dist/react-text-annotator.es15.js.map +1 -0
  13. package/dist/react-text-annotator.es17.js +566 -244
  14. package/dist/react-text-annotator.es17.js.map +1 -1
  15. package/dist/react-text-annotator.es18.js +252 -471
  16. package/dist/react-text-annotator.es18.js.map +1 -1
  17. package/dist/react-text-annotator.es2.js +1 -1
  18. package/dist/react-text-annotator.es25.js +111 -124
  19. package/dist/react-text-annotator.es25.js.map +1 -1
  20. package/dist/react-text-annotator.es26.js +285 -140
  21. package/dist/react-text-annotator.es26.js.map +1 -1
  22. package/dist/react-text-annotator.es27.js +43 -296
  23. package/dist/react-text-annotator.es27.js.map +1 -1
  24. package/dist/react-text-annotator.es28.js +19 -113
  25. package/dist/react-text-annotator.es28.js.map +1 -1
  26. package/dist/react-text-annotator.es29.js +105 -287
  27. package/dist/react-text-annotator.es29.js.map +1 -1
  28. package/dist/react-text-annotator.es30.js +154 -48
  29. package/dist/react-text-annotator.es30.js.map +1 -1
  30. package/dist/react-text-annotator.es31.js +310 -19
  31. package/dist/react-text-annotator.es31.js.map +1 -1
  32. package/dist/react-text-annotator.es4.js +2 -2
  33. package/dist/react-text-annotator.es5.js +1 -1
  34. package/dist/react-text-annotator.es7.js +4 -4
  35. package/package.json +2 -2
  36. package/dist/react-text-annotator.es16.js +0 -607
  37. package/dist/react-text-annotator.es16.js.map +0 -1
@@ -1,85 +1,504 @@
1
- const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7e3;
2
- let $319e236875307eab$var$liveAnnouncer = null;
3
- function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
4
- if (!$319e236875307eab$var$liveAnnouncer) {
5
- $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
6
- if (!(typeof IS_REACT_ACT_ENVIRONMENT === "boolean" ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== "undefined")) setTimeout(() => {
7
- if ($319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.isAttached()) $319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
8
- }, 100);
9
- else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
10
- } else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
11
- }
12
- function $319e236875307eab$export$d8686216b8b81b2f() {
13
- if ($319e236875307eab$var$liveAnnouncer) {
14
- $319e236875307eab$var$liveAnnouncer.destroy();
15
- $319e236875307eab$var$liveAnnouncer = null;
1
+ import defaultBehaviors from "./react-text-annotator.es25.js";
2
+ import * as utilities from "./react-text-annotator.es26.js";
3
+ import { hideContent, defineCustomElement, tagName } from "./react-text-annotator.es26.js";
4
+ import { addBehaviors, addBehavior, removeBehavior } from "./react-text-annotator.es27.js";
5
+ import { learnElementNames, learnCustomElementNames } from "./react-text-annotator.es28.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
+ }
16
54
  }
17
- }
18
- class $319e236875307eab$var$LiveAnnouncer {
19
- isAttached() {
20
- var _this_node;
21
- return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;
22
- }
23
- createLog(ariaLive) {
24
- let node = document.createElement("div");
25
- node.setAttribute("role", "log");
26
- node.setAttribute("aria-live", ariaLive);
27
- node.setAttribute("aria-relevant", "additions");
28
- return node;
29
- }
30
- destroy() {
31
- if (!this.node) return;
32
- document.body.removeChild(this.node);
33
- this.node = null;
34
- }
35
- announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
36
- var _this_assertiveLog, _this_politeLog;
37
- if (!this.node) return;
38
- let node = document.createElement("div");
39
- if (typeof message === "object") {
40
- node.setAttribute("role", "img");
41
- node.setAttribute("aria-labelledby", message["aria-labelledby"]);
42
- } else node.textContent = message;
43
- if (assertiveness === "assertive") (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 ? void 0 : _this_assertiveLog.appendChild(node);
44
- else (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 ? void 0 : _this_politeLog.appendChild(node);
45
- if (message !== "") setTimeout(() => {
46
- node.remove();
47
- }, timeout);
48
- }
49
- clear(assertiveness) {
50
- if (!this.node) return;
51
- if ((!assertiveness || assertiveness === "assertive") && this.assertiveLog) this.assertiveLog.innerHTML = "";
52
- if ((!assertiveness || assertiveness === "polite") && this.politeLog) this.politeLog.innerHTML = "";
53
- }
54
- constructor() {
55
- this.node = null;
56
- this.assertiveLog = null;
57
- this.politeLog = null;
58
- if (typeof document !== "undefined") {
59
- this.node = document.createElement("div");
60
- this.node.dataset.liveAnnouncer = "true";
61
- Object.assign(this.node.style, {
62
- border: 0,
63
- clip: "rect(0 0 0 0)",
64
- clipPath: "inset(50%)",
65
- height: "1px",
66
- margin: "-1px",
67
- overflow: "hidden",
68
- padding: 0,
69
- position: "absolute",
70
- width: "1px",
71
- whiteSpace: "nowrap"
72
- });
73
- this.assertiveLog = this.createLog("assertive");
74
- this.node.appendChild(this.assertiveLog);
75
- this.politeLog = this.createLog("polite");
76
- this.node.appendChild(this.politeLog);
77
- document.body.prepend(this.node);
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" && el.namespaceURI == "http://www.tei-c.org/ns/1.0") {
119
+ let getLevel = function(el2) {
120
+ let count = 0;
121
+ let ancestor = el2.parentElement;
122
+ while (ancestor) {
123
+ let children = ancestor.children;
124
+ let i = 0;
125
+ while (i < children.length) {
126
+ if (children[i].tagName.toLowerCase() === "head" && children[i].namespaceURI === "http://www.tei-c.org/ns/1.0") {
127
+ count++;
128
+ break;
129
+ }
130
+ i++;
131
+ }
132
+ ancestor = ancestor.parentElement;
133
+ }
134
+ return count;
135
+ };
136
+ newElement.setAttribute("data-level", getLevel(el));
137
+ }
138
+ if (el.localName == "tagsDecl") {
139
+ let style = this.document.createElement("style");
140
+ for (let node of Array.from(el.childNodes)) {
141
+ if (node.nodeType == 1 && node.localName == "rendition" && node.getAttribute("scheme") == "css") {
142
+ let rule = "";
143
+ if (node.hasAttribute("selector")) {
144
+ rule += node.getAttribute("selector").replace(/([^#, >]+\w*)/g, "tei-$1").replace(/#tei-/g, "#") + "{\n";
145
+ rule += node.textContent;
146
+ } else {
147
+ rule += "." + node.getAttribute("xml:id") + "{\n";
148
+ rule += node.textContent;
149
+ }
150
+ rule += "\n}\n";
151
+ style.appendChild(this.document.createTextNode(rule));
152
+ }
153
+ }
154
+ if (style.childNodes.length > 0) {
155
+ newElement.appendChild(style);
156
+ this.hasStyle = true;
157
+ }
158
+ }
159
+ if (el.localName == "prefixDef") {
160
+ this.prefixDefs.push(el.getAttribute("ident"));
161
+ this.prefixDefs[el.getAttribute("ident")] = {
162
+ "matchPattern": el.getAttribute("matchPattern"),
163
+ "replacementPattern": el.getAttribute("replacementPattern")
164
+ };
165
+ }
166
+ for (let node of Array.from(el.childNodes)) {
167
+ if (node.nodeType == 1) {
168
+ newElement.appendChild(convertEl(node));
169
+ } else {
170
+ newElement.appendChild(node.cloneNode());
171
+ }
172
+ }
173
+ if (perElementFn) {
174
+ perElementFn(newElement, el);
175
+ }
176
+ return newElement;
177
+ };
178
+ this.dom = this.document.createDocumentFragment();
179
+ for (let node of Array.from(XML_dom.childNodes)) {
180
+ if (node.nodeType == 1) {
181
+ this.dom.appendChild(convertEl(node));
182
+ }
183
+ if (node.nodeType == 7) {
184
+ this.dom.appendChild(this.document.importNode(node, true));
185
+ }
186
+ if (node.nodeType == 8) {
187
+ this.dom.appendChild(this.document.importNode(node, true));
188
+ }
189
+ }
190
+ this.utilities.dom = this.dom.firstElementChild;
191
+ if (callback) {
192
+ callback(this.dom, this);
193
+ if (window) {
194
+ window.dispatchEvent(ceteiceanLoad);
195
+ }
196
+ } else {
197
+ if (typeof window !== "undefined") {
198
+ window.dispatchEvent(ceteiceanLoad);
199
+ }
200
+ return this.dom;
201
+ }
202
+ }
203
+ /*
204
+ Converts the supplied XML DOM into HTML5 Custom Elements. If a callback
205
+ function is supplied, calls it on the result.
206
+ */
207
+ domToHTML5(XML_dom, callback, perElementFn) {
208
+ this.preprocess(XML_dom, null, perElementFn);
209
+ this.applyBehaviors();
210
+ this.done = true;
211
+ if (callback) {
212
+ callback(this.dom, this);
213
+ if (window) {
214
+ window.dispatchEvent(ceteiceanLoad);
215
+ }
216
+ } else {
217
+ if (typeof window !== "undefined") {
218
+ window.dispatchEvent(ceteiceanLoad);
219
+ }
220
+ return this.dom;
221
+ }
222
+ }
223
+ /*
224
+ Convenience method for HTML pages containing pre-processed CETEIcean Custom
225
+ Elements. Usage:
226
+ const c = new CETEI();
227
+ c.processPage();
228
+ */
229
+ processPage() {
230
+ this.els = learnCustomElementNames(this.document);
231
+ this.applyBehaviors();
232
+ if (window) {
233
+ window.dispatchEvent(ceteiceanLoad);
234
+ }
235
+ }
236
+ /*
237
+ To change a namespace -> prefix mapping, the namespace must first be
238
+ unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,
239
+ the TEI namespace must be unset before it can be set to the empty string.
240
+ */
241
+ unsetNamespace(ns) {
242
+ this.namespaces.delete(ns);
243
+ }
244
+ /*
245
+ Sets the base URL for the document. Used to rewrite relative links in the
246
+ XML source (which may be in a completely different location from the HTML
247
+ wrapper).
248
+ */
249
+ setBaseUrl(base) {
250
+ this.base = base;
251
+ }
252
+ /*
253
+ Appends any element returned by the function passed in the first
254
+ parameter to the element in the second parameter. If the function
255
+ returns nothing, this is a no-op aside from any side effects caused
256
+ by the provided function.
257
+
258
+ Called by getHandler() and fallback()
259
+ */
260
+ append(fn, elt) {
261
+ let self = this;
262
+ if (elt && !elt.hasAttribute("data-processed")) {
263
+ let content = fn.call(self.utilities, elt);
264
+ if (content) {
265
+ self.appendBasic(elt, content);
266
+ }
267
+ } else {
268
+ return function() {
269
+ if (!this.hasAttribute("data-processed")) {
270
+ let content = fn.call(self.utilities, this);
271
+ if (content) {
272
+ self.appendBasic(this, content);
273
+ }
274
+ }
275
+ };
276
+ }
277
+ }
278
+ appendBasic(elt, content) {
279
+ if (this.discardContent) {
280
+ elt.innerHTML = "";
281
+ } else {
282
+ hideContent(elt, true);
283
+ }
284
+ elt.appendChild(content);
285
+ }
286
+ // Given an element, return its qualified name as defined in a behaviors object
287
+ bName(e) {
288
+ return e.tagName.substring(0, e.tagName.indexOf("-")).toLowerCase() + ":" + e.getAttribute("data-origname");
289
+ }
290
+ /*
291
+ Private method called by append(). Takes a child element and a name, and recurses through the
292
+ child's siblings until an element with that name is found, returning true if it is and false if not.
293
+ */
294
+ childExists(elt, name) {
295
+ if (elt && elt.nodeName == name) {
296
+ return true;
297
+ } else {
298
+ return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);
299
+ }
300
+ }
301
+ /*
302
+ Takes a template in the form of either an array of 1 or 2
303
+ strings or an object with CSS selector keys and either functions
304
+ or arrays as described above. Returns a closure around a function
305
+ that can be called in the element constructor or applied to an
306
+ individual element. An empty array is considered a no-op.
307
+
308
+ Called by the getHandler() and getFallback() methods
309
+ */
310
+ decorator(template) {
311
+ if (Array.isArray(template) && template.length == 0) {
312
+ return function(e) {
313
+ };
78
314
  }
315
+ if (Array.isArray(template) && !Array.isArray(template[0])) {
316
+ return this.applyDecorator(template);
317
+ }
318
+ let self = this;
319
+ return function(elt) {
320
+ for (let rule of template) {
321
+ if (elt.matches(rule[0]) || rule[0] === "_") {
322
+ if (Array.isArray(rule[1])) {
323
+ return self.decorator(rule[1]).call(this, elt);
324
+ } else {
325
+ return rule[1].call(this, elt);
326
+ }
327
+ }
328
+ }
329
+ };
330
+ }
331
+ applyDecorator(strings) {
332
+ let self = this;
333
+ return function(elt) {
334
+ let copy = [];
335
+ for (let i = 0; i < strings.length; i++) {
336
+ copy.push(self.template(strings[i], elt));
337
+ }
338
+ return self.insert(elt, copy);
339
+ };
340
+ }
341
+ /*
342
+ Returns the fallback function for the given element name.
343
+ Called by fallback().
344
+ */
345
+ getFallback(behaviors, fn) {
346
+ if (behaviors[fn]) {
347
+ if (behaviors[fn] instanceof Function) {
348
+ return behaviors[fn];
349
+ } else {
350
+ return this.decorator(behaviors[fn]);
351
+ }
352
+ }
353
+ }
354
+ /*
355
+ Returns the handler function for the given element name
356
+ Called by define().
357
+ */
358
+ getHandler(behaviors, fn) {
359
+ if (behaviors[fn]) {
360
+ if (behaviors[fn] instanceof Function) {
361
+ return this.append(behaviors[fn]);
362
+ } else {
363
+ return this.append(this.decorator(behaviors[fn]));
364
+ }
365
+ }
366
+ }
367
+ insert(elt, strings) {
368
+ let content = this.document.createElement("cetei-content");
369
+ for (let node of Array.from(elt.childNodes)) {
370
+ if (node.nodeType === 1 && !node.hasAttribute("data-processed")) {
371
+ this.processElement(node);
372
+ }
373
+ }
374
+ if (strings[0].match("<[^>]+>") && strings[1] && strings[1].match("<[^>]+>")) {
375
+ content.innerHTML = strings[0] + elt.innerHTML + (strings[1] ? strings[1] : "");
376
+ } else {
377
+ content.innerHTML = strings[0];
378
+ content.setAttribute("data-before", strings[0].replace(/<[^>]+>/g, "").length);
379
+ for (let node of Array.from(elt.childNodes)) {
380
+ content.appendChild(node.cloneNode(true));
381
+ }
382
+ if (strings.length > 1) {
383
+ content.innerHTML += strings[1];
384
+ content.setAttribute("data-after", strings[1].replace(/<[^>]+>/g, "").length);
385
+ }
386
+ }
387
+ if (content.childNodes.length < 2) {
388
+ return content.firstChild;
389
+ } else {
390
+ return content;
391
+ }
392
+ }
393
+ // Runs behaviors recursively on the supplied element and children
394
+ processElement(elt) {
395
+ if (elt.hasAttribute("data-origname") && !elt.hasAttribute("data-processed")) {
396
+ let fn = this.getFallback(this.bName(elt));
397
+ if (fn) {
398
+ this.append(fn, elt);
399
+ elt.setAttribute("data-processed", "");
400
+ }
401
+ }
402
+ for (let node of Array.from(elt.childNodes)) {
403
+ if (node.nodeType === 1) {
404
+ this.processElement(node);
405
+ }
406
+ }
407
+ }
408
+ template(str, elt) {
409
+ let result = str;
410
+ if (str.search(/\$(\w*)(@([a-zA-Z:]+))/)) {
411
+ let re = /\$(\w*)@([a-zA-Z:]+)/g;
412
+ let replacements;
413
+ while (replacements = re.exec(str)) {
414
+ if (elt.hasAttribute(replacements[2])) {
415
+ if (replacements[1] && this.utilities[replacements[1]]) {
416
+ result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));
417
+ } else {
418
+ result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
419
+ }
420
+ } else {
421
+ result = result.replace(replacements[0], "");
422
+ }
423
+ }
424
+ }
425
+ return result;
426
+ }
427
+ // Define or apply behaviors for the document
428
+ applyBehaviors() {
429
+ if (typeof window !== "undefined" && window.customElements) {
430
+ this.define.call(this, this.els);
431
+ } else {
432
+ this.fallback.call(this, this.els);
433
+ }
434
+ }
435
+ /*
436
+ Registers the list of elements provided with the browser.
437
+ Called by makeHTML5(), but can be called independently if, for example,
438
+ you've created Custom Elements via an XSLT transformation instead.
439
+ */
440
+ define(names) {
441
+ for (let name of names) {
442
+ const fn = this.getHandler(this.behaviors, name);
443
+ defineCustomElement(name, fn, this.debug);
444
+ }
445
+ }
446
+ /*
447
+ Provides fallback functionality for environments where Custom Elements
448
+ are not supported.
449
+
450
+ Like define(), this is called by makeHTML5(), but can be called
451
+ independently.
452
+ */
453
+ fallback(names) {
454
+ for (let name of names) {
455
+ let fn = this.getFallback(this.behaviors, name);
456
+ if (fn) {
457
+ for (let elt of Array.from((this.dom && !this.done ? this.dom : this.document).querySelectorAll(tagName(name)))) {
458
+ if (!elt.hasAttribute("data-processed")) {
459
+ this.append(fn, elt);
460
+ elt.setAttribute("data-processed", "");
461
+ }
462
+ }
463
+ }
464
+ }
465
+ }
466
+ /**********************
467
+ * Utility functions *
468
+ **********************/
469
+ static savePosition() {
470
+ window.sessionStorage.setItem(window.location + "-scroll", window.scrollY);
471
+ }
472
+ static restorePosition() {
473
+ if (!window.location.hash) {
474
+ let scroll;
475
+ if (scroll = window.sessionStorage.getItem(window.location + "-scroll")) {
476
+ window.sessionStorage.removeItem(window.location + "-scroll");
477
+ setTimeout(function() {
478
+ window.scrollTo(0, scroll);
479
+ }, 100);
480
+ }
481
+ } else {
482
+ setTimeout(function() {
483
+ let h = this.document.querySelector(window.decodeURI(window.location.hash));
484
+ if (h) {
485
+ h.scrollIntoView();
486
+ }
487
+ }, 100);
488
+ }
489
+ }
490
+ }
491
+ try {
492
+ if (typeof window !== "undefined") {
493
+ window.CETEI = CETEI;
494
+ window.addEventListener("beforeunload", CETEI.savePosition);
495
+ var ceteiceanLoad = new Event("ceteiceanload");
496
+ window.addEventListener("ceteiceanload", CETEI.restorePosition);
79
497
  }
498
+ } catch (e) {
499
+ console.log(e);
80
500
  }
81
501
  export {
82
- $319e236875307eab$export$a9b970dcc4ae71a9 as announce,
83
- $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer
502
+ CETEI as default
84
503
  };
85
504
  //# sourceMappingURL=react-text-annotator.es10.js.map