@soomo/react-text-annotator 3.0.0-staging.9 → 3.1.0-staging.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TextAnnotator.d.ts +4 -5
- package/dist/TextAnnotator.d.ts.map +1 -1
- package/dist/TextAnnotatorPlugin.d.ts +1 -2
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +15 -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/TextAnnotatorPopup/isMobile.d.ts +2 -0
- package/dist/TextAnnotatorPopup/isMobile.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +2 -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/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.css +31 -1
- package/dist/react-text-annotator.es.js +9 -5
- package/dist/react-text-annotator.es.js.map +1 -1
- package/dist/react-text-annotator.es10.js +442 -521
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +9 -488
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +1448 -2
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es14.js +238 -891
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +554 -197
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es16.js +72 -126
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +43 -112
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +2 -309
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es19.js +29 -56
- package/dist/react-text-annotator.es19.js.map +1 -1
- package/dist/react-text-annotator.es2.js +2 -2
- package/dist/react-text-annotator.es20.js +897 -19
- package/dist/react-text-annotator.es20.js.map +1 -1
- package/dist/react-text-annotator.es23.js +113 -120
- package/dist/react-text-annotator.es23.js.map +1 -1
- package/dist/react-text-annotator.es24.js +276 -519
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js +61 -0
- package/dist/react-text-annotator.es25.js.map +1 -0
- package/dist/react-text-annotator.es26.js +23 -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 +167 -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 +566 -0
- package/dist/react-text-annotator.es31.js.map +1 -0
- package/dist/react-text-annotator.es4.js +38 -28
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +24 -72
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +127 -10
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +546 -1
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +10 -24
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/tei/TEIAnnotator.d.ts +2 -3
- package/package.json +23 -17
- package/dist/TextAnnotatorPopup.d.ts +0 -15
- package/dist/TextAnnotatorPopup.d.ts.map +0 -1
- package/dist/react-text-annotator.es13.js +0 -38
- package/dist/react-text-annotator.es13.js.map +0 -1
- package/dist/react-text-annotator.es9.js +0 -199
- package/dist/react-text-annotator.es9.js.map +0 -1
- package/dist/utils.d.ts +0 -14
- package/dist/utils.d.ts.map +0 -1
|
@@ -1,569 +1,490 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const domElement = unwrapElement(element);
|
|
27
|
-
if (!isHTMLElement(domElement)) {
|
|
28
|
-
return createCoords(1);
|
|
29
|
-
}
|
|
30
|
-
const rect = domElement.getBoundingClientRect();
|
|
31
|
-
const {
|
|
32
|
-
width,
|
|
33
|
-
height,
|
|
34
|
-
$
|
|
35
|
-
} = getCssDimensions(domElement);
|
|
36
|
-
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
37
|
-
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
38
|
-
if (!x || !Number.isFinite(x)) {
|
|
39
|
-
x = 1;
|
|
40
|
-
}
|
|
41
|
-
if (!y || !Number.isFinite(y)) {
|
|
42
|
-
y = 1;
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
x,
|
|
46
|
-
y
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
50
|
-
function getVisualOffsets(element) {
|
|
51
|
-
const win = getWindow(element);
|
|
52
|
-
if (!isWebKit() || !win.visualViewport) {
|
|
53
|
-
return noOffsets;
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
x: win.visualViewport.offsetLeft,
|
|
57
|
-
y: win.visualViewport.offsetTop
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
61
|
-
if (isFixed === void 0) {
|
|
62
|
-
isFixed = false;
|
|
63
|
-
}
|
|
64
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return isFixed;
|
|
68
|
-
}
|
|
69
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
70
|
-
if (includeScale === void 0) {
|
|
71
|
-
includeScale = false;
|
|
72
|
-
}
|
|
73
|
-
if (isFixedStrategy === void 0) {
|
|
74
|
-
isFixedStrategy = false;
|
|
75
|
-
}
|
|
76
|
-
const clientRect = element.getBoundingClientRect();
|
|
77
|
-
const domElement = unwrapElement(element);
|
|
78
|
-
let scale = createCoords(1);
|
|
79
|
-
if (includeScale) {
|
|
80
|
-
if (offsetParent) {
|
|
81
|
-
if (isElement(offsetParent)) {
|
|
82
|
-
scale = getScale(offsetParent);
|
|
1
|
+
import defaultBehaviors from "./react-text-annotator.es23.js";
|
|
2
|
+
import * as utilities from "./react-text-annotator.es24.js";
|
|
3
|
+
import { hideContent, defineCustomElement, tagName } from "./react-text-annotator.es24.js";
|
|
4
|
+
import { addBehaviors, addBehavior, removeBehavior } from "./react-text-annotator.es25.js";
|
|
5
|
+
import { learnElementNames, learnCustomElementNames } from "./react-text-annotator.es26.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];
|
|
83
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;
|
|
84
37
|
} else {
|
|
85
|
-
|
|
38
|
+
try {
|
|
39
|
+
if (window) {
|
|
40
|
+
this.base = window.location.href.replace(/\/[^\/]*$/, "/");
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
this.base = "";
|
|
44
|
+
}
|
|
86
45
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const win = getWindow(domElement);
|
|
95
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
96
|
-
let currentWin = win;
|
|
97
|
-
let currentIFrame = currentWin.frameElement;
|
|
98
|
-
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
99
|
-
const iframeScale = getScale(currentIFrame);
|
|
100
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
101
|
-
const css = getComputedStyle(currentIFrame);
|
|
102
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
103
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
104
|
-
x *= iframeScale.x;
|
|
105
|
-
y *= iframeScale.y;
|
|
106
|
-
width *= iframeScale.x;
|
|
107
|
-
height *= iframeScale.y;
|
|
108
|
-
x += left;
|
|
109
|
-
y += top;
|
|
110
|
-
currentWin = getWindow(currentIFrame);
|
|
111
|
-
currentIFrame = currentWin.frameElement;
|
|
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
|
+
}
|
|
112
53
|
}
|
|
113
54
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return topLayerSelectors.some((selector) => {
|
|
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
|
+
}
|
|
124
64
|
try {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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);
|
|
128
75
|
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
132
|
-
let {
|
|
133
|
-
elements,
|
|
134
|
-
rect,
|
|
135
|
-
offsetParent,
|
|
136
|
-
strategy
|
|
137
|
-
} = _ref;
|
|
138
|
-
const isFixed = strategy === "fixed";
|
|
139
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
140
|
-
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
141
|
-
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
142
|
-
return rect;
|
|
143
76
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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;
|
|
132
|
+
} else {
|
|
133
|
+
rule += "." + node.getAttribute("xml:id") + "{\n";
|
|
134
|
+
rule += node.textContent;
|
|
135
|
+
}
|
|
136
|
+
rule += "\n}\n";
|
|
137
|
+
style.appendChild(this.document.createTextNode(rule));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (style.childNodes.length > 0) {
|
|
141
|
+
newElement.appendChild(style);
|
|
142
|
+
this.hasStyle = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
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")
|
|
150
|
+
};
|
|
151
|
+
}
|
|
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());
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (perElementFn) {
|
|
160
|
+
perElementFn(newElement, el);
|
|
161
|
+
}
|
|
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));
|
|
168
|
+
}
|
|
169
|
+
if (node.nodeType == 7) {
|
|
170
|
+
this.dom.appendChild(this.document.importNode(node, true));
|
|
171
|
+
}
|
|
172
|
+
if (node.nodeType == 8) {
|
|
173
|
+
this.dom.appendChild(this.document.importNode(node, true));
|
|
174
|
+
}
|
|
154
175
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
this.utilities.dom = this.dom.firstElementChild;
|
|
177
|
+
if (callback) {
|
|
178
|
+
callback(this.dom, this);
|
|
179
|
+
if (window) {
|
|
180
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
if (typeof window !== "undefined") {
|
|
184
|
+
window.dispatchEvent(ceteiceanLoad);
|
|
185
|
+
}
|
|
186
|
+
return this.dom;
|
|
160
187
|
}
|
|
161
188
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
181
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
182
|
-
const y = -scroll.scrollTop;
|
|
183
|
-
if (getComputedStyle(body).direction === "rtl") {
|
|
184
|
-
x += max(html.clientWidth, body.clientWidth) - width;
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
width,
|
|
188
|
-
height,
|
|
189
|
-
x,
|
|
190
|
-
y
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function getViewportRect(element, strategy) {
|
|
194
|
-
const win = getWindow(element);
|
|
195
|
-
const html = getDocumentElement(element);
|
|
196
|
-
const visualViewport = win.visualViewport;
|
|
197
|
-
let width = html.clientWidth;
|
|
198
|
-
let height = html.clientHeight;
|
|
199
|
-
let x = 0;
|
|
200
|
-
let y = 0;
|
|
201
|
-
if (visualViewport) {
|
|
202
|
-
width = visualViewport.width;
|
|
203
|
-
height = visualViewport.height;
|
|
204
|
-
const visualViewportBased = isWebKit();
|
|
205
|
-
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
206
|
-
x = visualViewport.offsetLeft;
|
|
207
|
-
y = visualViewport.offsetTop;
|
|
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;
|
|
208
207
|
}
|
|
209
208
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const width = element.clientWidth * scale.x;
|
|
223
|
-
const height = element.clientHeight * scale.y;
|
|
224
|
-
const x = left * scale.x;
|
|
225
|
-
const y = top * scale.y;
|
|
226
|
-
return {
|
|
227
|
-
width,
|
|
228
|
-
height,
|
|
229
|
-
x,
|
|
230
|
-
y
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
234
|
-
let rect;
|
|
235
|
-
if (clippingAncestor === "viewport") {
|
|
236
|
-
rect = getViewportRect(element, strategy);
|
|
237
|
-
} else if (clippingAncestor === "document") {
|
|
238
|
-
rect = getDocumentRect(getDocumentElement(element));
|
|
239
|
-
} else if (isElement(clippingAncestor)) {
|
|
240
|
-
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
241
|
-
} else {
|
|
242
|
-
const visualOffsets = getVisualOffsets(element);
|
|
243
|
-
rect = {
|
|
244
|
-
...clippingAncestor,
|
|
245
|
-
x: clippingAncestor.x - visualOffsets.x,
|
|
246
|
-
y: clippingAncestor.y - visualOffsets.y
|
|
247
|
-
};
|
|
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
|
+
}
|
|
248
221
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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);
|
|
255
229
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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;
|
|
262
237
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
+
}
|
|
276
253
|
} else {
|
|
277
|
-
|
|
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);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
278
262
|
}
|
|
279
|
-
currentNode = getParentNode(currentNode);
|
|
280
263
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
element,
|
|
287
|
-
boundary,
|
|
288
|
-
rootBoundary,
|
|
289
|
-
strategy
|
|
290
|
-
} = _ref;
|
|
291
|
-
const elementClippingAncestors = boundary === "clippingAncestors" ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
292
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
293
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
294
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
295
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
296
|
-
accRect.top = max(rect.top, accRect.top);
|
|
297
|
-
accRect.right = min(rect.right, accRect.right);
|
|
298
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
299
|
-
accRect.left = max(rect.left, accRect.left);
|
|
300
|
-
return accRect;
|
|
301
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
302
|
-
return {
|
|
303
|
-
width: clippingRect.right - clippingRect.left,
|
|
304
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
305
|
-
x: clippingRect.left,
|
|
306
|
-
y: clippingRect.top
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
function getDimensions(element) {
|
|
310
|
-
const {
|
|
311
|
-
width,
|
|
312
|
-
height
|
|
313
|
-
} = getCssDimensions(element);
|
|
314
|
-
return {
|
|
315
|
-
width,
|
|
316
|
-
height
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
320
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
321
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
322
|
-
const isFixed = strategy === "fixed";
|
|
323
|
-
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
324
|
-
let scroll = {
|
|
325
|
-
scrollLeft: 0,
|
|
326
|
-
scrollTop: 0
|
|
327
|
-
};
|
|
328
|
-
const offsets = createCoords(0);
|
|
329
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
330
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
331
|
-
scroll = getNodeScroll(offsetParent);
|
|
332
|
-
}
|
|
333
|
-
if (isOffsetParentAnElement) {
|
|
334
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
335
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
336
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
337
|
-
} else if (documentElement) {
|
|
338
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
264
|
+
appendBasic(elt, content) {
|
|
265
|
+
if (this.discardContent) {
|
|
266
|
+
elt.innerHTML = "";
|
|
267
|
+
} else {
|
|
268
|
+
hideContent(elt, true);
|
|
339
269
|
}
|
|
270
|
+
elt.appendChild(content);
|
|
340
271
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
x,
|
|
345
|
-
y,
|
|
346
|
-
width: rect.width,
|
|
347
|
-
height: rect.height
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
351
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
|
|
352
|
-
return null;
|
|
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");
|
|
353
275
|
}
|
|
354
|
-
|
|
355
|
-
|
|
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
|
+
}
|
|
356
286
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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);
|
|
310
|
+
} else {
|
|
311
|
+
return rule[1].call(this, elt);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
363
316
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
+
};
|
|
367
326
|
}
|
|
368
|
-
|
|
369
|
-
|
|
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
|
+
}
|
|
370
339
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
width: floatingDimensions.width,
|
|
383
|
-
height: floatingDimensions.height
|
|
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
|
+
}
|
|
384
351
|
}
|
|
385
|
-
};
|
|
386
|
-
};
|
|
387
|
-
function isRTL(element) {
|
|
388
|
-
return getComputedStyle(element).direction === "rtl";
|
|
389
|
-
}
|
|
390
|
-
const platform = {
|
|
391
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
392
|
-
getDocumentElement,
|
|
393
|
-
getClippingRect,
|
|
394
|
-
getOffsetParent,
|
|
395
|
-
getElementRects,
|
|
396
|
-
getClientRects,
|
|
397
|
-
getDimensions,
|
|
398
|
-
getScale,
|
|
399
|
-
isElement,
|
|
400
|
-
isRTL
|
|
401
|
-
};
|
|
402
|
-
function observeMove(element, onMove) {
|
|
403
|
-
let io = null;
|
|
404
|
-
let timeoutId;
|
|
405
|
-
const root = getDocumentElement(element);
|
|
406
|
-
function cleanup() {
|
|
407
|
-
var _io;
|
|
408
|
-
clearTimeout(timeoutId);
|
|
409
|
-
(_io = io) == null || _io.disconnect();
|
|
410
|
-
io = null;
|
|
411
352
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|
+
}
|
|
415
359
|
}
|
|
416
|
-
if (
|
|
417
|
-
|
|
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
|
+
}
|
|
418
372
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
width,
|
|
424
|
-
height
|
|
425
|
-
} = element.getBoundingClientRect();
|
|
426
|
-
if (!skip) {
|
|
427
|
-
onMove();
|
|
373
|
+
if (content.childNodes.length < 2) {
|
|
374
|
+
return content.firstChild;
|
|
375
|
+
} else {
|
|
376
|
+
return content;
|
|
428
377
|
}
|
|
429
|
-
|
|
430
|
-
|
|
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
|
+
}
|
|
431
387
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
refresh(false, 1e-7);
|
|
451
|
-
}, 1e3);
|
|
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])));
|
|
403
|
+
} else {
|
|
404
|
+
result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
|
|
405
|
+
}
|
|
452
406
|
} else {
|
|
453
|
-
|
|
407
|
+
result = result.replace(replacements[0], "");
|
|
454
408
|
}
|
|
455
409
|
}
|
|
456
|
-
isFirstUpdate = false;
|
|
457
410
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
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);
|
|
466
419
|
}
|
|
467
|
-
io.observe(element);
|
|
468
420
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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
|
+
}
|
|
475
431
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (elementResize) {
|
|
495
|
-
resizeObserver = new ResizeObserver((_ref) => {
|
|
496
|
-
let [firstEntry] = _ref;
|
|
497
|
-
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
498
|
-
resizeObserver.unobserve(floating);
|
|
499
|
-
cancelAnimationFrame(reobserveFrame);
|
|
500
|
-
reobserveFrame = requestAnimationFrame(() => {
|
|
501
|
-
var _resizeObserver;
|
|
502
|
-
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
update();
|
|
506
|
-
});
|
|
507
|
-
if (referenceEl && !animationFrame) {
|
|
508
|
-
resizeObserver.observe(referenceEl);
|
|
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
|
+
}
|
|
509
450
|
}
|
|
510
|
-
resizeObserver.observe(floating);
|
|
511
451
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
452
|
+
/**********************
|
|
453
|
+
* Utility functions *
|
|
454
|
+
**********************/
|
|
455
|
+
static savePosition() {
|
|
456
|
+
window.sessionStorage.setItem(window.location + "-scroll", window.scrollY);
|
|
516
457
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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);
|
|
521
474
|
}
|
|
522
|
-
prevRefRect = nextRefRect;
|
|
523
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
524
475
|
}
|
|
525
|
-
update();
|
|
526
|
-
return () => {
|
|
527
|
-
var _resizeObserver2;
|
|
528
|
-
ancestors.forEach((ancestor) => {
|
|
529
|
-
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
530
|
-
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
531
|
-
});
|
|
532
|
-
cleanupIo == null || cleanupIo();
|
|
533
|
-
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
534
|
-
resizeObserver = null;
|
|
535
|
-
if (animationFrame) {
|
|
536
|
-
cancelAnimationFrame(frameId);
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
476
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const platformWithCache = {
|
|
551
|
-
...mergedOptions.platform,
|
|
552
|
-
_c: cache
|
|
553
|
-
};
|
|
554
|
-
return computePosition$1(reference, floating, {
|
|
555
|
-
...mergedOptions,
|
|
556
|
-
platform: platformWithCache
|
|
557
|
-
});
|
|
558
|
-
};
|
|
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);
|
|
483
|
+
}
|
|
484
|
+
} catch (e) {
|
|
485
|
+
console.log(e);
|
|
486
|
+
}
|
|
559
487
|
export {
|
|
560
|
-
|
|
561
|
-
autoUpdate,
|
|
562
|
-
computePosition,
|
|
563
|
-
getOverflowAncestors,
|
|
564
|
-
inline,
|
|
565
|
-
offset,
|
|
566
|
-
platform,
|
|
567
|
-
shift
|
|
488
|
+
CETEI as default
|
|
568
489
|
};
|
|
569
490
|
//# sourceMappingURL=react-text-annotator.es10.js.map
|