@soomo/react-text-annotator 3.2.0-staging.0 → 3.2.0-staging.2
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/react-text-annotator.es10.js +78 -497
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +40 -77
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +21 -41
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +495 -19
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es2.js +1 -1
- package/dist/react-text-annotator.es21.js +1 -1
- package/dist/react-text-annotator.es22.js +1 -1
- package/dist/react-text-annotator.es23.js +2 -114
- package/dist/react-text-annotator.es23.js.map +1 -1
- package/dist/react-text-annotator.es24.js +2 -309
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js +109 -53
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es26.js +306 -17
- package/dist/react-text-annotator.es26.js.map +1 -1
- package/dist/react-text-annotator.es27.js +58 -2
- package/dist/react-text-annotator.es27.js.map +1 -1
- package/dist/react-text-annotator.es28.js +20 -2
- package/dist/react-text-annotator.es28.js.map +1 -1
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es5.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es25.js","sources":["../../../node_modules/CETEIcean/src/
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es25.js","sources":["../../../node_modules/CETEIcean/src/defaultBehaviors.js"],"sourcesContent":["export default {\n \"namespaces\": {\n \"tei\": \"http://www.tei-c.org/ns/1.0\",\n \"teieg\": \"http://www.tei-c.org/ns/Examples\",\n \"rng\": \"http://relaxng.org/ns/structure/1.0\" \n },\n \"tei\": {\n \"eg\": [\"<pre>\",\"</pre>\"],\n // inserts a link inside <ptr> using the @target; the link in the\n // @href is piped through the rw (rewrite) function before insertion\n \"ptr\": [\"<a href=\\\"$rw@target\\\">$@target</a>\"],\n // wraps the content of the <ref> in an HTML link with the @target in \n // the @href. If there are multiple @targets, only the first is used.\n \"ref\": [\n [\"[target]\", [\"<a href=\\\"$rw@target\\\">\",\"</a>\"]]\n ],\n // creates an img tag with the @url as the src attribute\n \"graphic\": function(elt) {\n let content = elt.ownerDocument.createElement(\"img\");\n content.src = this.rw(elt.getAttribute(\"url\"));\n if (elt.hasAttribute(\"width\")) {\n content.setAttribute(\"width\",elt.getAttribute(\"width\"));\n }\n if (elt.hasAttribute(\"height\")) {\n content.setAttribute(\"height\",elt.getAttribute(\"height\"));\n }\n return content;\n },\n \"list\": [\n // will only run on a list where @type=\"gloss\"\n [\"[type=gloss]\", function(elt) {\n const doc = elt.ownerDocument;\n let dl = doc.createElement(\"dl\");\n for (let child of Array.from(elt.children)) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (child.nodeType == 1) {\n if (child.localName == \"tei-label\") {\n let dt = doc.createElement(\"dt\");\n dt.innerHTML = child.innerHTML;\n dl.appendChild(dt);\n }\n if (child.localName == \"tei-item\") {\n let dd = doc.createElement(\"dd\");\n dd.innerHTML = child.innerHTML;\n dl.appendChild(dd);\n }\n }\n }\n return dl;\n }\n ]],\n \"note\": [\n // Make endnotes\n [\"[place=end]\", function(elt){\n const doc = elt.ownerDocument;\n if (!this.noteIndex){\n this[\"noteIndex\"] = 1;\n } else {\n this.noteIndex++;\n }\n let id = \"_note_\" + this.noteIndex;\n let link = doc.createElement(\"a\");\n link.setAttribute(\"id\", \"src\" + id);\n link.setAttribute(\"href\", \"#\" + id);\n link.innerHTML = this.noteIndex;\n let content = doc.createElement(\"sup\");\n content.appendChild(link);\n let notes = doc.querySelector(\"ol.notes\");\n if (!notes) {\n notes = doc.createElement(\"ol\");\n notes.setAttribute(\"class\", \"notes\");\n this.dom.appendChild(notes);\n }\n let note = doc.createElement(\"li\");\n note.id = id;\n note.innerHTML = elt.innerHTML;\n notes.appendChild(note);\n return content;\n }],\n [\"_\", [\"(\",\")\"]]\n ],\n // Hide the teiHeader by default\n \"teiHeader\": function(e) {\n this.hideContent(e, false);\n },\n // Make the title element the HTML title\n \"title\": [\n [\"tei-titlestmt>tei-title\", function(elt) {\n const doc = elt.ownerDocument;\n let title = doc.createElement(\"title\");\n title.innerHTML = elt.innerText;\n doc.querySelector(\"head\").appendChild(title);\n }]\n ],\n },\n \"teieg\": {\n \"egXML\": function(elt) {\n const doc = elt.ownerDocument;\n let pre = doc.createElement(\"pre\");\n let code = doc.createElement(\"code\");\n pre.appendChild(code);\n let content = this.serialize(elt, true).replace(/</g, \"<\");\n let ws = content.match(/^[\\t ]+/);\n if (ws) {\n content = content.replace(new RegExp(\"^\" + ws[0], \"mg\"), \"\");\n }\n code.innerHTML = content;\n return pre;\n }\n }\n}\n"],"names":[],"mappings":"AAAA,MAAe,mBAAA;AAAA,EACb,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,EACR;AAAA,EACD,OAAO;AAAA,IACL,MAAM,CAAC,SAAQ,QAAQ;AAAA;AAAA;AAAA,IAGvB,OAAO,CAAC,mCAAqC;AAAA;AAAA;AAAA,IAG7C,OAAO;AAAA,MACL,CAAC,YAAY,CAAC,yBAA0B,MAAM,CAAC;AAAA,IAChD;AAAA;AAAA,IAED,WAAW,SAAS,KAAK;AACvB,UAAI,UAAU,IAAI,cAAc,cAAc,KAAK;AACnD,cAAQ,MAAM,KAAK,GAAG,IAAI,aAAa,KAAK,CAAC;AAC7C,UAAI,IAAI,aAAa,OAAO,GAAG;AAC7B,gBAAQ,aAAa,SAAQ,IAAI,aAAa,OAAO,CAAC;AAAA,MAC9D;AACM,UAAI,IAAI,aAAa,QAAQ,GAAG;AAC9B,gBAAQ,aAAa,UAAS,IAAI,aAAa,QAAQ,CAAC;AAAA,MAChE;AACM,aAAO;AAAA,IACR;A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tB,eAAO;AAAA,MACf,CAAO;AAAA,MACD,CAAC,KAAK,CAAC,KAAI,GAAG,CAAC;AAAA,IAChB;AAAA;AAAA,IAED,aAAa,SAAS,GAAG;AACvB,WAAK,YAAY,GAAG,KAAK;AAAA,IAC1B;AAAA;AAAA,IAED,SAAS;AAAA,MACP,CAAC,2BAA2B,SAAS,KAAK;AACxC,cAAM,MAAM,IAAI;AAChB,YAAI,QAAQ,IAAI,cAAc,OAAO;AACrC,cAAM,YAAY,IAAI;AACtB,YAAI,cAAc,MAAM,EAAE,YAAY,KAAK;AAAA,MAC5C,CAAA;AAAA,IACF;AAAA,EACF;AAAA,EACD,SAAS;AAAA,IACP,SAAS,SAAS,KAAK;AACrB,YAAM,MAAM,IAAI;AAChB,UAAI,MAAM,IAAI,cAAc,KAAK;AACjC,UAAI,OAAO,IAAI,cAAc,MAAM;AACnC,UAAI,YAAY,IAAI;AACpB,UAAI,UAAU,KAAK,UAAU,KAAK,IAAI,EAAE,QAAQ,MAAM,MAAM;AAC5D,UAAI,KAAK,QAAQ,MAAM,SAAS;AAChC,UAAI,IAAI;AACN,kBAAU,QAAQ,QAAQ,IAAI,OAAO,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE;AAAA,MACnE;AACM,WAAK,YAAY;AACjB,aAAO;AAAA,IACb;AAAA,EACA;AACA;","x_google_ignoreList":[0]}
|
|
@@ -1,23 +1,312 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function getOrdinality(elt, name) {
|
|
2
|
+
let pos = 1;
|
|
3
|
+
let e = elt;
|
|
4
|
+
while (e && e.previousElementSibling !== null && (name ? e.previousElementSibling.localName == name : true)) {
|
|
5
|
+
pos++;
|
|
6
|
+
e = e.previousElementSibling;
|
|
7
|
+
if (!e.previousElementSibling) {
|
|
8
|
+
break;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return pos;
|
|
12
|
+
}
|
|
13
|
+
function copyAndReset(node) {
|
|
14
|
+
const doc = node.ownerDocument;
|
|
15
|
+
let clone = (n) => {
|
|
16
|
+
let result;
|
|
17
|
+
switch (n.nodeType) {
|
|
18
|
+
case 1:
|
|
19
|
+
result = doc.createElement(n.nodeName);
|
|
20
|
+
break;
|
|
21
|
+
case 9:
|
|
22
|
+
result = doc.implementation.createDocument();
|
|
23
|
+
break;
|
|
24
|
+
case 11:
|
|
25
|
+
result = doc.createDocumentFragment();
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
result = n.cloneNode(true);
|
|
29
|
+
}
|
|
30
|
+
if (n.attributes) {
|
|
31
|
+
for (let att of Array.from(n.attributes)) {
|
|
32
|
+
if (att.name !== "data-processed") {
|
|
33
|
+
result.setAttribute(att.name, att.value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (let nd of Array.from(n.childNodes)) {
|
|
38
|
+
if (nd.nodeType == 1) {
|
|
39
|
+
if (nd.hasAttribute("data-original")) {
|
|
40
|
+
for (let childNode of Array.from(nd.childNodes)) {
|
|
41
|
+
let child = result.appendChild(clone(childNode));
|
|
42
|
+
if (child.nodeType === 1 && child.hasAttribute("data-origid")) {
|
|
43
|
+
child.setAttribute("id", child.getAttribute("data-origid"));
|
|
44
|
+
child.removeAttribute("data-origid");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
} else if (nd.hasAttribute("data-origname")) {
|
|
49
|
+
result.appendChild(clone(nd));
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
result.appendChild(nd.cloneNode());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
9
56
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
57
|
+
return clone(node);
|
|
58
|
+
}
|
|
59
|
+
function first(urls) {
|
|
60
|
+
return urls.replace(/ .*$/, "");
|
|
61
|
+
}
|
|
62
|
+
function hideContent(elt, rewriteIds = true) {
|
|
63
|
+
const doc = elt.ownerDocument;
|
|
64
|
+
if (elt.childNodes.length > 0) {
|
|
65
|
+
let hidden = doc.createElement("cetei-original");
|
|
66
|
+
elt.appendChild(hidden);
|
|
67
|
+
hidden.setAttribute("hidden", "");
|
|
68
|
+
hidden.setAttribute("data-original", "");
|
|
69
|
+
for (let node of Array.from(elt.childNodes)) {
|
|
70
|
+
if (node !== hidden) {
|
|
71
|
+
if (node.nodeType === 1) {
|
|
72
|
+
node.setAttribute("data-processed", "");
|
|
73
|
+
for (let e of node.querySelectorAll("*")) {
|
|
74
|
+
e.setAttribute("data-processed", "");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
hidden.appendChild(elt.removeChild(node));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (rewriteIds) {
|
|
81
|
+
for (let e of Array.from(hidden.querySelectorAll("*"))) {
|
|
82
|
+
if (e.hasAttribute("id")) {
|
|
83
|
+
e.setAttribute("data-origid", e.getAttribute("id"));
|
|
84
|
+
e.removeAttribute("id");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function normalizeURI(urls) {
|
|
91
|
+
return this.rw(this.first(urls));
|
|
92
|
+
}
|
|
93
|
+
function repeat(str, times) {
|
|
94
|
+
let result = "";
|
|
95
|
+
for (let i = 0; i < times; i++) {
|
|
96
|
+
result += str;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
function resolveURI(uri) {
|
|
101
|
+
let prefixdef = this.prefixDefs[uri.substring(0, uri.indexOf(":"))];
|
|
102
|
+
return uri.replace(new RegExp(prefixdef["matchPattern"]), prefixdef["replacementPattern"]);
|
|
15
103
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
104
|
+
function getPrefixDef(prefix) {
|
|
105
|
+
return this.prefixDefs[prefix];
|
|
106
|
+
}
|
|
107
|
+
function rw(url) {
|
|
108
|
+
if (!url.trim().match(/^(?:http|mailto|file|\/|#).*$/)) {
|
|
109
|
+
return this.base + first(url.trim());
|
|
110
|
+
} else {
|
|
111
|
+
return url;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function resetAndSerialize(el, stripElt, ws) {
|
|
115
|
+
return serialize(copyAndReset(el), stripElt, ws);
|
|
116
|
+
}
|
|
117
|
+
function serialize(el, stripElt, ws) {
|
|
118
|
+
let str = "";
|
|
119
|
+
const ignorable = (txt) => {
|
|
120
|
+
return !/[^\t\n\r ]/.test(txt);
|
|
121
|
+
};
|
|
122
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
123
|
+
str += '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
124
|
+
}
|
|
125
|
+
if (!stripElt && el.nodeType == 1) {
|
|
126
|
+
if (typeof ws === "string" && ws !== "") {
|
|
127
|
+
str += "\n" + ws + "<";
|
|
128
|
+
} else {
|
|
129
|
+
str += "<";
|
|
130
|
+
}
|
|
131
|
+
str += el.getAttribute("data-origname");
|
|
132
|
+
let attrNames = el.hasAttribute("data-origatts") ? el.getAttribute("data-origatts").split(" ") : [];
|
|
133
|
+
for (let attr of Array.from(el.attributes)) {
|
|
134
|
+
if (!attr.name.startsWith("data-") && !["id", "lang", "class"].includes(attr.name)) {
|
|
135
|
+
str += " " + attrNames.find(function(e) {
|
|
136
|
+
return e.toLowerCase() == attr.name;
|
|
137
|
+
}) + '="' + attr.value + '"';
|
|
138
|
+
}
|
|
139
|
+
if (attr.name == "data-xmlns") {
|
|
140
|
+
str += ' xmlns="' + attr.value + '"';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (el.childNodes.length > 0) {
|
|
144
|
+
str += ">";
|
|
145
|
+
} else {
|
|
146
|
+
str += "/>";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (let node of Array.from(el.childNodes)) {
|
|
150
|
+
switch (node.nodeType) {
|
|
151
|
+
case 1:
|
|
152
|
+
if (typeof ws === "string") {
|
|
153
|
+
str += serialize(node, false, ws + " ");
|
|
154
|
+
} else {
|
|
155
|
+
str += serialize(node, false, ws);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case 7:
|
|
159
|
+
str += `<?${node.nodeName} ${node.nodeValue}?>`;
|
|
160
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
161
|
+
str += "\n";
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case 8:
|
|
165
|
+
str += `<!--${node.nodeValue}-->`;
|
|
166
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
167
|
+
str += "\n";
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
if (stripElt && ignorable(node.nodeValue)) {
|
|
172
|
+
str += node.nodeValue.replace(/^\s*\n/, "");
|
|
173
|
+
}
|
|
174
|
+
if (typeof ws === "string" && ignorable(node.nodeValue)) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
str += node.nodeValue;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!stripElt && el.nodeType == 1 && el.childNodes.length > 0) {
|
|
181
|
+
if (typeof ws === "string") {
|
|
182
|
+
str += "\n" + ws + "</";
|
|
183
|
+
} else {
|
|
184
|
+
str += "</";
|
|
185
|
+
}
|
|
186
|
+
str += el.getAttribute("data-origname") + ">";
|
|
187
|
+
}
|
|
188
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
189
|
+
str += "\n";
|
|
190
|
+
}
|
|
191
|
+
return str;
|
|
192
|
+
}
|
|
193
|
+
function serializeHTML(el, stripElt, ws) {
|
|
194
|
+
const EMPTY_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"];
|
|
195
|
+
let str = "";
|
|
196
|
+
const ignorable = (txt) => {
|
|
197
|
+
return !/[^\t\n\r ]/.test(txt);
|
|
198
|
+
};
|
|
199
|
+
if (!stripElt && el.nodeType == 1) {
|
|
200
|
+
if (typeof ws === "string" && ws !== "") {
|
|
201
|
+
str += "\n" + ws + "<";
|
|
202
|
+
} else {
|
|
203
|
+
str += "<";
|
|
204
|
+
}
|
|
205
|
+
str += el.nodeName;
|
|
206
|
+
for (let attr of Array.from(el.attributes)) {
|
|
207
|
+
str += " " + attr.name + '="' + attr.value + '"';
|
|
208
|
+
}
|
|
209
|
+
str += ">";
|
|
210
|
+
}
|
|
211
|
+
for (let node of Array.from(el.childNodes)) {
|
|
212
|
+
switch (node.nodeType) {
|
|
213
|
+
case 1:
|
|
214
|
+
if (typeof ws === "string") {
|
|
215
|
+
str += serializeHTML(node, false, ws + " ");
|
|
216
|
+
} else {
|
|
217
|
+
str += serializeHTML(node, false, ws);
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case 7:
|
|
221
|
+
str += `<?${node.nodeName} ${node.nodeValue}?>`;
|
|
222
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
223
|
+
str += "\n";
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case 8:
|
|
227
|
+
str += `<!--${node.nodeValue}-->`;
|
|
228
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
229
|
+
str += "\n";
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
default:
|
|
233
|
+
if (stripElt && ignorable(node.nodeValue)) {
|
|
234
|
+
str += node.nodeValue.replace(/^\s*\n/, "");
|
|
235
|
+
}
|
|
236
|
+
if (typeof ws === "string" && ignorable(node.nodeValue)) {
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
str += node.nodeValue.replace(/</g, "<");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (!EMPTY_ELEMENTS.includes(el.nodeName)) {
|
|
243
|
+
if (!stripElt && el.nodeType == 1) {
|
|
244
|
+
if (typeof ws === "string") {
|
|
245
|
+
str += `
|
|
246
|
+
${ws}</`;
|
|
247
|
+
} else {
|
|
248
|
+
str += "</";
|
|
249
|
+
}
|
|
250
|
+
str += `${el.nodeName}>`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
254
|
+
str += "\n";
|
|
255
|
+
}
|
|
256
|
+
return str;
|
|
257
|
+
}
|
|
258
|
+
function unEscapeEntities(str) {
|
|
259
|
+
return str.replace(/>/, ">").replace(/"/, '"').replace(/'/, "'").replace(/&/, "&");
|
|
260
|
+
}
|
|
261
|
+
function tagName(name) {
|
|
262
|
+
if (name.includes(":"), 1) {
|
|
263
|
+
return name.replace(/:/, "-").toLowerCase();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function defineCustomElement(name, behavior = null, debug = false) {
|
|
267
|
+
try {
|
|
268
|
+
window.customElements.define(tagName(name), class extends HTMLElement {
|
|
269
|
+
constructor() {
|
|
270
|
+
super();
|
|
271
|
+
if (!this.matches(":defined")) {
|
|
272
|
+
if (behavior) {
|
|
273
|
+
behavior.call(this);
|
|
274
|
+
this.setAttribute("data-processed", "");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// Process new elements when they are connected to the browser DOM
|
|
279
|
+
connectedCallback() {
|
|
280
|
+
if (!this.hasAttribute("data-processed")) {
|
|
281
|
+
if (behavior) {
|
|
282
|
+
behavior.call(this);
|
|
283
|
+
this.setAttribute("data-processed", "");
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
} catch (error) {
|
|
289
|
+
if (debug) {
|
|
290
|
+
console.log(tagName(name) + " couldn't be registered or is already registered.");
|
|
291
|
+
console.log(error);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
18
294
|
}
|
|
19
295
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
296
|
+
copyAndReset,
|
|
297
|
+
defineCustomElement,
|
|
298
|
+
first,
|
|
299
|
+
getOrdinality,
|
|
300
|
+
getPrefixDef,
|
|
301
|
+
hideContent,
|
|
302
|
+
normalizeURI,
|
|
303
|
+
repeat,
|
|
304
|
+
resetAndSerialize,
|
|
305
|
+
resolveURI,
|
|
306
|
+
rw,
|
|
307
|
+
serialize,
|
|
308
|
+
serializeHTML,
|
|
309
|
+
tagName,
|
|
310
|
+
unEscapeEntities
|
|
22
311
|
};
|
|
23
312
|
//# sourceMappingURL=react-text-annotator.es26.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es26.js","sources":["../../../node_modules/CETEIcean/src/dom.js"],"sourcesContent":["export function learnElementNames(XML_dom, namespaces) {\n const root = XML_dom.documentElement;\n let i = 1;\n let qname = function(e) { \n if (!namespaces.has(e.namespaceURI ? e.namespaceURI : \"\")) {\n namespaces.set(e.namespaceURI, \"ns\" + i++);\n } \n return namespaces.get(e.namespaceURI ? e.namespaceURI : \"\") + \":\" + e.localName;\n };\n const els = new Set(\n Array.from(root.querySelectorAll(\"*\"), qname));\n \n // Add the root element to the array\n els.add(qname(root));\n return els\n}\n\nexport function learnCustomElementNames(HTML_dom) {\n return new Set(Array.from(HTML_dom.querySelectorAll(\"*[data-origname]\"), e => e.localName.replace(/(\\w+)-.+/,\"$1:\") + e.getAttribute(\"data-origname\")));\n}"],"names":[],"mappings":"AAAO,SAAS,kBAAkB,SAAS,YAAY;AACrD,QAAM,OAAO,QAAQ;AACrB,MAAI,IAAI;AACR,MAAI,QAAQ,SAAS,GAAG;AACtB,QAAI,CAAC,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG;AACzD,iBAAW,IAAI,EAAE,cAAc,OAAO,GAAG;AAAA,IAC1C;AACD,WAAO,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,MAAM,EAAE;AAAA,EACvE;AACD,QAAM,MAAM,IAAI;AAAA,IACd,MAAM,KAAK,KAAK,iBAAiB,GAAG,GAAG,KAAK;AAAA,EAAC;AAG/C,MAAI,IAAI,MAAM,IAAI,CAAC;AACnB,SAAO;AACT;AAEO,SAAS,wBAAwB,UAAU;AAChD,SAAO,IAAI,IAAI,MAAM,KAAK,SAAS,iBAAiB,kBAAkB,GAAG,OAAK,EAAE,UAAU,QAAQ,YAAW,KAAK,IAAI,EAAE,aAAa,eAAe,CAAC,CAAC;AACxJ;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es26.js","sources":["../../../node_modules/CETEIcean/src/utilities.js"],"sourcesContent":["export function getOrdinality(elt, name) {\n let pos = 1;\n let e = elt;\n while (e && e.previousElementSibling !== null && (name ? e.previousElementSibling.localName == name : true)) {\n pos++;\n e = e.previousElementSibling;\n if (!e.previousElementSibling) {\n break;\n }\n }\n return pos;\n}\n\n/* \n Performs a deep copy operation of the input node while stripping\n out child elements introduced by CETEIcean.\n*/ \nexport function copyAndReset(node) {\n const doc = node.ownerDocument;\n let clone = (n) => { \n let result;\n switch (n.nodeType) {\n case 1: // nodeType 1 is Node.ELEMENT_NODE\n result = doc.createElement(n.nodeName);\n break;\n case 9: // nodeType 9 is Node.DOCUMENT_NODE\n result = doc.implementation.createDocument();\n break;\n case 11: // nodeType 11 is Node.DOCUMENT_FRAGMENT_NODE\n result = doc.createDocumentFragment();\n break;\n default:\n result = n.cloneNode(true);\n }\n if (n.attributes) {\n for (let att of Array.from(n.attributes)) {\n if (att.name !== \"data-processed\") {\n result.setAttribute(att.name,att.value);\n }\n }\n }\n for (let nd of Array.from(n.childNodes)){\n // nodeType 1 is Node.ELEMENT_NODE\n if (nd.nodeType == 1) {\n if (nd.hasAttribute(\"data-original\")) {\n for (let childNode of Array.from(nd.childNodes)) {\n let child = result.appendChild(clone(childNode));\n // nodeType 1 is Node.ELEMENT_NODE\n if (child.nodeType === 1 && child.hasAttribute(\"data-origid\")) {\n child.setAttribute(\"id\", child.getAttribute(\"data-origid\"));\n child.removeAttribute(\"data-origid\");\n }\n }\n return result;\n } else if (nd.hasAttribute(\"data-origname\")) {\n result.appendChild(clone(nd));\n }\n } else {\n result.appendChild(nd.cloneNode());\n }\n }\n return result;\n }\n return clone(node);\n}\n\n/* \n Given a space-separated list of URLs (e.g. in a ref with multiple\n targets), returns just the first one.\n*/\nexport function first(urls) {\n return urls.replace(/ .*$/, \"\");\n}\n\n/* \n Wraps the content of the element parameter in a hidden <cetei-original data-original>\n*/\nexport function hideContent(elt, rewriteIds = true) {\n const doc = elt.ownerDocument;\n if (elt.childNodes.length > 0) {\n let hidden = doc.createElement(\"cetei-original\");\n elt.appendChild(hidden);\n hidden.setAttribute(\"hidden\", \"\");\n hidden.setAttribute(\"data-original\", \"\");\n for (let node of Array.from(elt.childNodes)) {\n if (node !== hidden) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1) {\n node.setAttribute(\"data-processed\", \"\");\n for (let e of node.querySelectorAll(\"*\")) {\n e.setAttribute(\"data-processed\", \"\");\n }\n }\n hidden.appendChild(elt.removeChild(node));\n }\n }\n if (rewriteIds) {\n for (let e of Array.from(hidden.querySelectorAll(\"*\"))) {\n if (e.hasAttribute(\"id\")) {\n e.setAttribute(\"data-origid\", e.getAttribute(\"id\"));\n e.removeAttribute(\"id\");\n }\n }\n }\n }\n}\n\nexport function normalizeURI(urls) {\n return this.rw(this.first(urls))\n}\n\n/* \n Takes a string and a number and returns the original string\n printed that number of times.\n*/\nexport function repeat(str, times) {\n let result = \"\";\n for (let i = 0; i < times; i++) {\n result += str;\n }\n return result;\n}\n\n/* \n Resolves URIs that use TEI prefixDefs into full URIs.\n See https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-prefixDef.html\n*/\nexport function resolveURI(uri) {\n let prefixdef = this.prefixDefs[uri.substring(0,uri.indexOf(\":\"))];\n return uri.replace(new RegExp(prefixdef[\"matchPattern\"]), prefixdef[\"replacementPattern\"]);\n}\n\n/*\n Convenience function for getting prefix definitions, Takes a prefix\n and returns an object with \"matchPattern\" and \"replacementPattern\"\n keys.\n*/\nexport function getPrefixDef(prefix) {\n return this.prefixDefs[prefix];\n}\n\n/* \n Takes a relative URL and rewrites it based on the base URL of the\n HTML document\n*/\nexport function rw(url) {\n if (!url.trim().match(/^(?:http|mailto|file|\\/|#).*$/)) {\n return this.base + first(url.trim());\n } else {\n return url;\n }\n}\n\n/*\n Combines the functionality of copyAndReset() and serialize() to return\n a \"clean\" version of the XML markup.\n */\nexport function resetAndSerialize(el, stripElt, ws) {\n return serialize(copyAndReset(el), stripElt, ws);\n}\n\n/* \n Takes an element and serializes it to an XML string or, if the stripElt\n parameter is set, serializes the element's content. The ws parameter, if\n set, will switch on minimal \"pretty-printing\" and indenting of the serialized\n result.\n*/\nexport function serialize(el, stripElt, ws) {\n let str = \"\";\n const ignorable = (txt) => {\n return !(/[^\\t\\n\\r ]/.test(txt));\n }\n if (el.nodeType === 9 || el.nodeType === 11) { // nodeType 9 is Node.DOCUMENT_NODE; nodeType 11 is Node.DOCUMENT_FRAGMENT_NODE\n str += \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n }\n // nodeType 1 is Node.ELEMENT_NODE\n if (!stripElt && el.nodeType == 1) {\n if ((typeof ws === \"string\") && ws !== \"\") {\n str += \"\\n\" + ws + \"<\";\n } else {\n str += \"<\";\n }\n str += el.getAttribute(\"data-origname\");\n // HTML5 lowercases all attribute names; @data-origatts contains the original names\n let attrNames = el.hasAttribute(\"data-origatts\") ? el.getAttribute(\"data-origatts\").split(\" \") : [];\n for (let attr of Array.from(el.attributes)) {\n if (!attr.name.startsWith(\"data-\") && !([\"id\", \"lang\", \"class\"].includes(attr.name))) {\n str += \" \" + attrNames.find(function(e) {return e.toLowerCase() == attr.name}) + \"=\\\"\" + attr.value + \"\\\"\";\n }\n if (attr.name == \"data-xmlns\") {\n str += \" xmlns=\\\"\" + attr.value +\"\\\"\";\n }\n }\n if (el.childNodes.length > 0) {\n str += \">\";\n } else {\n str += \"/>\";\n }\n }\n for (let node of Array.from(el.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE\n // nodeType 8 is Node.COMMENT_NODE\n switch (node.nodeType) {\n case 1:\n if (typeof ws === \"string\") {\n str += serialize(node, false, ws + \" \");\n } else {\n str += serialize(node, false, ws);\n }\n break;\n case 7:\n str += `<?${node.nodeName} ${node.nodeValue}?>`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n case 8:\n str += `<!--${node.nodeValue}-->`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n default:\n if (stripElt && ignorable(node.nodeValue)) {\n str += node.nodeValue.replace(/^\\s*\\n/, \"\");\n }\n if ((typeof ws === \"string\") && ignorable(node.nodeValue)) {\n break;\n }\n str += node.nodeValue;\n }\n }\n if (!stripElt && el.nodeType == 1 && el.childNodes.length > 0) {\n if (typeof ws === \"string\") {\n str += \"\\n\" + ws + \"</\";\n } else {\n str += \"</\";\n }\n str += el.getAttribute(\"data-origname\") + \">\";\n }\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n return str;\n}\n\n/* \n Write out the HTML markup to a string, using HTML conventions.\n */\nexport function serializeHTML(el, stripElt, ws) {\n const EMPTY_ELEMENTS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];\n let str = \"\";\n const ignorable = (txt) => {\n return !(/[^\\t\\n\\r ]/.test(txt));\n }\n // nodeType 1 is Node.ELEMENT_NODE\n if (!stripElt && el.nodeType == 1) {\n if ((typeof ws === \"string\") && ws !== \"\") {\n str += \"\\n\" + ws + \"<\";\n } else {\n str += \"<\";\n }\n str += el.nodeName;\n for (let attr of Array.from(el.attributes)) {\n str += \" \" + attr.name + \"=\\\"\" + attr.value + \"\\\"\";\n }\n str += \">\";\n }\n for (let node of Array.from(el.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE\n // nodeType 8 is Node.COMMENT_NODE\n switch (node.nodeType) {\n case 1:\n if (typeof ws === \"string\") {\n str += serializeHTML(node, false, ws + \" \");\n } else {\n str += serializeHTML(node, false, ws);\n }\n break;\n case 7:\n str += `<?${node.nodeName} ${node.nodeValue}?>`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n case 8:\n str += `<!--${node.nodeValue}-->`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n default:\n if (stripElt && ignorable(node.nodeValue)) {\n str += node.nodeValue.replace(/^\\s*\\n/, \"\");\n }\n if ((typeof ws === \"string\") && ignorable(node.nodeValue)) {\n break;\n }\n str += node.nodeValue.replace(/</g, \"<\");\n }\n }\n if (!EMPTY_ELEMENTS.includes(el.nodeName)) {\n if (!stripElt && el.nodeType == 1) {\n if (typeof ws === \"string\") {\n str += `\\n${ws}</`;\n } else {\n str += \"</\";\n }\n str += `${el.nodeName}>`;\n }\n }\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n return str;\n}\n\nexport function unEscapeEntities(str) {\n return str.replace(/>/, \">\")\n .replace(/"/, \"\\\"\")\n .replace(/'/, \"'\")\n .replace(/&/, \"&\");\n}\n\n// Given a qualified name (e.g. tei:text), return the element name\nexport function tagName(name) {\n if (name.includes(\":\"), 1) {\n return name.replace(/:/,\"-\").toLowerCase();\n } else {\n return \"ceteicean-\" + name.toLowerCase();\n }\n}\n\nexport function defineCustomElement(name, behavior = null, debug = false) {\n /* \n Registers the list of elements provided with the browser.\n Called by makeHTML5(), but can be called independently if, for example,\n you've created Custom Elements via an XSLT transformation instead.\n */\n try {\n window.customElements.define(tagName(name), class extends HTMLElement {\n constructor() {\n super(); \n if (!this.matches(\":defined\")) { // \"Upgraded\" undefined elements can have attributes & children; new elements can't\n if (behavior) {\n behavior.call(this);\n // We don't want to double-process elements, so add a flag\n this.setAttribute(\"data-processed\", \"\");\n }\n }\n }\n // Process new elements when they are connected to the browser DOM\n connectedCallback() {\n if (!this.hasAttribute(\"data-processed\")) {\n if (behavior) {\n behavior.call(this);\n this.setAttribute(\"data-processed\", \"\");\n }\n }\n };\n });\n } catch (error) {\n // When using the same CETEIcean instance for multiple TEI files, this error becomes very common. \n // It's muted by default unless the debug option is set.\n if (debug) {\n console.log(tagName(name) + \" couldn't be registered or is already registered.\");\n console.log(error);\n }\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc,KAAK,MAAM;AACvC,MAAI,MAAM;AACV,MAAI,IAAI;AACR,SAAO,KAAK,EAAE,2BAA2B,SAAS,OAAO,EAAE,uBAAuB,aAAa,OAAO,OAAO;AAC3G;AACA,QAAI,EAAE;AACN,QAAI,CAAC,EAAE,wBAAwB;AAC7B;AAAA,IACN;AAAA,EACA;AACE,SAAO;AACT;AAMO,SAAS,aAAa,MAAM;AACjC,QAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,CAAC,MAAM;AACjB,QAAI;AACJ,YAAQ,EAAE,UAAQ;AAAA,MAChB,KAAK;AACH,iBAAS,IAAI,cAAc,EAAE,QAAQ;AACrC;AAAA,MACF,KAAK;AACH,iBAAS,IAAI,eAAe,eAAgB;AAC5C;AAAA,MACF,KAAK;AACH,iBAAS,IAAI,uBAAwB;AACrC;AAAA,MACF;AACE,iBAAS,EAAE,UAAU,IAAI;AAAA,IACjC;AACI,QAAI,EAAE,YAAY;AAChB,eAAS,OAAO,MAAM,KAAK,EAAE,UAAU,GAAG;AACxC,YAAI,IAAI,SAAS,kBAAkB;AACjC,iBAAO,aAAa,IAAI,MAAK,IAAI,KAAK;AAAA,QAChD;AAAA,MACA;AAAA,IACA;AACI,aAAS,MAAM,MAAM,KAAK,EAAE,UAAU,GAAE;AAEtC,UAAI,GAAG,YAAY,GAAG;AACpB,YAAI,GAAG,aAAa,eAAe,GAAG;AACpC,mBAAS,aAAa,MAAM,KAAK,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,iBAAK,aAAa,kBAAkB,EAAE;AAAA,UAClD;AAAA,QACA;AAAA,MACA;AAAA;AAAA,MAEM,oBAAoB;AAClB,YAAI,CAAC,KAAK,aAAa,gBAAgB,GAAG;AACxC,cAAI,UAAU;AACZ,qBAAS,KAAK,IAAI;AAClB,iBAAK,aAAa,kBAAkB,EAAE;AAAA,UAClD;AAAA,QACA;AAAA,MACO;AAAA,IACP,CAAK;AAAA,EACF,SAAQ,OAAO;AAGd,QAAI,OAAO;AACP,cAAQ,IAAI,QAAQ,IAAI,IAAI,mDAAmD;AAC/E,cAAQ,IAAI,KAAK;AAAA,IACzB;AAAA,EACA;AACA;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
function addBehaviors(bhvs) {
|
|
2
|
+
if (bhvs.namespaces) {
|
|
3
|
+
for (let prefix of Object.keys(bhvs.namespaces)) {
|
|
4
|
+
if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {
|
|
5
|
+
this.namespaces.set(bhvs.namespaces[prefix], prefix);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
for (let prefix of this.namespaces.values()) {
|
|
10
|
+
if (bhvs[prefix]) {
|
|
11
|
+
for (let b of Object.keys(bhvs[prefix])) {
|
|
12
|
+
this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (bhvs["functions"]) {
|
|
17
|
+
for (let fn of Object.keys(bhvs["functions"])) {
|
|
18
|
+
this.utilities[fn] = bhvs["functions"][fn].bind(this.utilities);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (bhvs["handlers"]) {
|
|
22
|
+
console.log("Behavior handlers are no longer used.");
|
|
23
|
+
}
|
|
24
|
+
if (bhvs["fallbacks"]) {
|
|
25
|
+
console.log("Fallback behaviors are no longer used.");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function addBehavior(ns, element, b) {
|
|
29
|
+
let p;
|
|
30
|
+
if (ns === Object(ns)) {
|
|
31
|
+
for (let prefix of Object.keys(ns)) {
|
|
32
|
+
if (!this.namespaces.has(ns[prefix])) {
|
|
33
|
+
this.namespaces.set(ns[prefix], prefix);
|
|
34
|
+
p = prefix;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
p = ns;
|
|
39
|
+
}
|
|
40
|
+
this.behaviors[`${p}:${element}`] = b;
|
|
41
|
+
}
|
|
42
|
+
function removeBehavior(ns, element) {
|
|
43
|
+
let p;
|
|
44
|
+
if (ns === Object(ns)) {
|
|
45
|
+
for (let prefix of Object.keys(ns)) {
|
|
46
|
+
if (!this.namespaces.has(ns[prefix])) {
|
|
47
|
+
this.namespaces.set(ns[prefix], prefix);
|
|
48
|
+
p = prefix;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
p = ns;
|
|
53
|
+
}
|
|
54
|
+
delete this.behaviors[`${p}:${element}`];
|
|
55
|
+
}
|
|
2
56
|
export {
|
|
3
|
-
|
|
57
|
+
addBehavior,
|
|
58
|
+
addBehaviors,
|
|
59
|
+
removeBehavior
|
|
4
60
|
};
|
|
5
61
|
//# sourceMappingURL=react-text-annotator.es27.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es27.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es27.js","sources":["../../../node_modules/CETEIcean/src/behaviors.js"],"sourcesContent":["\n/* \n Add a user-defined set of behaviors to CETEIcean's processing\n workflow. Added behaviors will override predefined behaviors with the\n same name.\n*/\nexport function addBehaviors(bhvs) {\n if (bhvs.namespaces) {\n for (let prefix of Object.keys(bhvs.namespaces)) {\n if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {\n this.namespaces.set(bhvs.namespaces[prefix], prefix);\n }\n }\n }\n for (let prefix of this.namespaces.values()) {\n if (bhvs[prefix]) {\n for (let b of Object.keys(bhvs[prefix])) {\n this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];\n }\n }\n }\n if (bhvs[\"functions\"]) {\n for (let fn of Object.keys(bhvs[\"functions\"])) {\n this.utilities[fn] = bhvs[\"functions\"][fn].bind(this.utilities);\n }\n }\n if (bhvs[\"handlers\"]) {\n console.log(\"Behavior handlers are no longer used.\")\n }\n if (bhvs[\"fallbacks\"]) {\n console.log(\"Fallback behaviors are no longer used.\")\n }\n}\n\n/* \n Adds or replaces an individual behavior. Takes a namespace prefix or namespace definition,\n the element name, and the behavior. E.g.\n addBehavior(\"tei\", \"add\", [\"`\",\"`\"]) for an already-declared namespace or\n addBehavior({\"doc\": \"http://docbook.org/ns/docbook\"}, \"note\", [\"[\",\"]\"]) for a new one\n*/\nexport function addBehavior(ns, element, b) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n this.behaviors[`${p}:${element}`] = b;\n}\n\n/*\n Removes a previously-defined or default behavior. Takes a namespace prefix or namespace definition\n and the element name.\n*/\nexport function removeBehavior(ns, element) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n delete this.behaviors[`${p}:${element}`];\n}\n"],"names":[],"mappings":"AAMO,SAAS,aAAa,MAAM;AACjC,MAAI,KAAK,YAAY;AACnB,aAAS,UAAU,OAAO,KAAK,KAAK,UAAU,GAAG;AAC/C,UAAI,CAAC,KAAK,WAAW,IAAI,KAAK,WAAW,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,WAAW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AAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACZ;AAAA,IACA;AAAA,EACA,OAAS;AACL,QAAI;AAAA,EACR;AACE,SAAO,KAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE;AACzC;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
function learnElementNames(XML_dom, namespaces) {
|
|
2
|
+
const root = XML_dom.documentElement;
|
|
3
|
+
let i = 1;
|
|
4
|
+
let qname = function(e) {
|
|
5
|
+
if (!namespaces.has(e.namespaceURI ? e.namespaceURI : "")) {
|
|
6
|
+
namespaces.set(e.namespaceURI, "ns" + i++);
|
|
7
|
+
}
|
|
8
|
+
return namespaces.get(e.namespaceURI ? e.namespaceURI : "") + ":" + e.localName;
|
|
9
|
+
};
|
|
10
|
+
const els = new Set(
|
|
11
|
+
Array.from(root.querySelectorAll("*"), qname)
|
|
12
|
+
);
|
|
13
|
+
els.add(qname(root));
|
|
14
|
+
return els;
|
|
15
|
+
}
|
|
16
|
+
function learnCustomElementNames(HTML_dom) {
|
|
17
|
+
return new Set(Array.from(HTML_dom.querySelectorAll("*[data-origname]"), (e) => e.localName.replace(/(\w+)-.+/, "$1:") + e.getAttribute("data-origname")));
|
|
18
|
+
}
|
|
2
19
|
export {
|
|
3
|
-
|
|
20
|
+
learnCustomElementNames,
|
|
21
|
+
learnElementNames
|
|
4
22
|
};
|
|
5
23
|
//# sourceMappingURL=react-text-annotator.es28.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es28.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es28.js","sources":["../../../node_modules/CETEIcean/src/dom.js"],"sourcesContent":["export function learnElementNames(XML_dom, namespaces) {\n const root = XML_dom.documentElement;\n let i = 1;\n let qname = function(e) { \n if (!namespaces.has(e.namespaceURI ? e.namespaceURI : \"\")) {\n namespaces.set(e.namespaceURI, \"ns\" + i++);\n } \n return namespaces.get(e.namespaceURI ? e.namespaceURI : \"\") + \":\" + e.localName;\n };\n const els = new Set(\n Array.from(root.querySelectorAll(\"*\"), qname));\n \n // Add the root element to the array\n els.add(qname(root));\n return els\n}\n\nexport function learnCustomElementNames(HTML_dom) {\n return new Set(Array.from(HTML_dom.querySelectorAll(\"*[data-origname]\"), e => e.localName.replace(/(\\w+)-.+/,\"$1:\") + e.getAttribute(\"data-origname\")));\n}"],"names":[],"mappings":"AAAO,SAAS,kBAAkB,SAAS,YAAY;AACrD,QAAM,OAAO,QAAQ;AACrB,MAAI,IAAI;AACR,MAAI,QAAQ,SAAS,GAAG;AACtB,QAAI,CAAC,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG;AACzD,iBAAW,IAAI,EAAE,cAAc,OAAO,GAAG;AAAA,IAC1C;AACD,WAAO,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,MAAM,EAAE;AAAA,EACvE;AACD,QAAM,MAAM,IAAI;AAAA,IACd,MAAM,KAAK,KAAK,iBAAiB,GAAG,GAAG,KAAK;AAAA,EAAC;AAG/C,MAAI,IAAI,MAAM,IAAI,CAAC;AACnB,SAAO;AACT;AAEO,SAAS,wBAAwB,UAAU;AAChD,SAAO,IAAI,IAAI,MAAM,KAAK,SAAS,iBAAiB,kBAAkB,GAAG,OAAK,EAAE,UAAU,QAAQ,YAAW,KAAK,IAAI,EAAE,aAAa,eAAe,CAAC,CAAC;AACxJ;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useMemo, useRef, useEffect } from "react";
|
|
2
2
|
import { useAnnotationStore, useSelection, Origin } from "@annotorious/react";
|
|
3
|
-
import { announce as $319e236875307eab$export$a9b970dcc4ae71a9, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f } from "./react-text-annotator.
|
|
4
|
-
import { exhaustiveUniqueRandom } from "./react-text-annotator.
|
|
3
|
+
import { announce as $319e236875307eab$export$a9b970dcc4ae71a9, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f } from "./react-text-annotator.es10.js";
|
|
4
|
+
import { exhaustiveUniqueRandom } from "./react-text-annotator.es11.js";
|
|
5
5
|
const useAnnouncePopupNavigation = (args) => {
|
|
6
6
|
const {
|
|
7
7
|
message = "Press Tab to move to Notes Dialog",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
|
-
import { dequal } from "./react-text-annotator.
|
|
2
|
+
import { dequal } from "./react-text-annotator.es12.js";
|
|
3
3
|
import { useAnnotationStore, Origin } from "@annotorious/react";
|
|
4
4
|
import { Ignore } from "@annotorious/core";
|
|
5
5
|
const useAnnotationQuoteIdling = (annotationId, options = { timeout: 500 }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soomo/react-text-annotator",
|
|
3
|
-
"version": "3.2.0-staging.
|
|
3
|
+
"version": "3.2.0-staging.2",
|
|
4
4
|
"description": "Recogito Text Annotator React bindings",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@annotorious/react": "^3.3.3",
|
|
50
50
|
"@floating-ui/react": "^0.27.6",
|
|
51
51
|
"@react-aria/live-announcer": "^3.3.4",
|
|
52
|
-
"@soomo/text-annotator": "3.2.0-staging.
|
|
52
|
+
"@soomo/text-annotator": "3.2.0-staging.2",
|
|
53
53
|
"@recogito/text-annotator-tei": "3.0.1",
|
|
54
54
|
"CETEIcean": "^1.9.3",
|
|
55
55
|
"dequal": "^2.0.3",
|