@soomo/react-text-annotator 3.0.0-staging.37 → 3.0.0-staging.39
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/{TextAnnotatorPopup.d.ts → TextAnnotatorPopup/TextAnnotatorPopup.d.ts} +3 -2
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -0
- package/dist/TextAnnotatorPopup/index.d.ts +2 -0
- package/dist/TextAnnotatorPopup/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAnnouncePopupNavigation.d.ts +8 -0
- package/dist/hooks/useAnnouncePopupNavigation.d.ts.map +1 -0
- package/dist/hooks/useRestoreSelectionCaret.d.ts +13 -0
- package/dist/hooks/useRestoreSelectionCaret.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.css +31 -1
- package/dist/react-text-annotator.es.js +8 -4
- package/dist/react-text-annotator.es.js.map +1 -1
- package/dist/react-text-annotator.es11.js +445 -527
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +60 -483
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +45 -2
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +1450 -30
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es16.js +227 -37
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +537 -115
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +2 -2
- package/dist/react-text-annotator.es19.js +31 -2
- 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 +893 -109
- package/dist/react-text-annotator.es20.js.map +1 -1
- package/dist/react-text-annotator.es21.js +2 -309
- package/dist/react-text-annotator.es21.js.map +1 -1
- package/dist/react-text-annotator.es22.js +2 -58
- package/dist/react-text-annotator.es22.js.map +1 -1
- package/dist/react-text-annotator.es23.js +113 -19
- package/dist/react-text-annotator.es23.js.map +1 -1
- package/dist/react-text-annotator.es24.js +290 -130
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js +43 -545
- package/dist/react-text-annotator.es25.js.map +1 -1
- 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 +155 -0
- package/dist/react-text-annotator.es28.js.map +1 -0
- package/dist/react-text-annotator.es29.js +314 -0
- package/dist/react-text-annotator.es29.js.map +1 -0
- package/dist/react-text-annotator.es3.js +2 -2
- package/dist/react-text-annotator.es30.js +152 -0
- package/dist/react-text-annotator.es30.js.map +1 -0
- package/dist/react-text-annotator.es31.js +563 -0
- package/dist/react-text-annotator.es31.js.map +1 -0
- package/dist/react-text-annotator.es4.js +30 -23
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +36 -78
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +24 -178
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +126 -10
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +182 -0
- package/dist/react-text-annotator.es8.js.map +1 -0
- package/dist/react-text-annotator.es9.js +10 -670
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/package.json +5 -3
- package/dist/TextAnnotatorPopup.d.ts.map +0 -1
- package/dist/react-text-annotator.es10.js +0 -244
- package/dist/react-text-annotator.es10.js.map +0 -1
- package/dist/react-text-annotator.es15.js +0 -901
- package/dist/react-text-annotator.es15.js.map +0 -1
|
@@ -1,23 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const defaultBehaviors = {
|
|
2
|
+
"namespaces": {
|
|
3
|
+
"tei": "http://www.tei-c.org/ns/1.0",
|
|
4
|
+
"teieg": "http://www.tei-c.org/ns/Examples",
|
|
5
|
+
"rng": "http://relaxng.org/ns/structure/1.0"
|
|
6
|
+
},
|
|
7
|
+
"tei": {
|
|
8
|
+
"eg": ["<pre>", "</pre>"],
|
|
9
|
+
// inserts a link inside <ptr> using the @target; the link in the
|
|
10
|
+
// @href is piped through the rw (rewrite) function before insertion
|
|
11
|
+
"ptr": ['<a href="$rw@target">$@target</a>'],
|
|
12
|
+
// wraps the content of the <ref> in an HTML link with the @target in
|
|
13
|
+
// the @href. If there are multiple @targets, only the first is used.
|
|
14
|
+
"ref": [
|
|
15
|
+
["[target]", ['<a href="$rw@target">', "</a>"]]
|
|
16
|
+
],
|
|
17
|
+
// creates an img tag with the @url as the src attribute
|
|
18
|
+
"graphic": function(elt) {
|
|
19
|
+
let content = new Image();
|
|
20
|
+
content.src = this.rw(elt.getAttribute("url"));
|
|
21
|
+
if (elt.hasAttribute("width")) {
|
|
22
|
+
content.setAttribute("width", elt.getAttribute("width"));
|
|
23
|
+
}
|
|
24
|
+
if (elt.hasAttribute("height")) {
|
|
25
|
+
content.setAttribute("height", elt.getAttribute("height"));
|
|
26
|
+
}
|
|
27
|
+
return content;
|
|
28
|
+
},
|
|
29
|
+
"list": [
|
|
30
|
+
// will only run on a list where @type="gloss"
|
|
31
|
+
[
|
|
32
|
+
"[type=gloss]",
|
|
33
|
+
function(elt) {
|
|
34
|
+
const doc = elt.ownerDocument;
|
|
35
|
+
let dl = doc.createElement("dl");
|
|
36
|
+
for (let child of Array.from(elt.children)) {
|
|
37
|
+
if (child.nodeType == 1) {
|
|
38
|
+
if (child.localName == "tei-label") {
|
|
39
|
+
let dt = doc.createElement("dt");
|
|
40
|
+
dt.innerHTML = child.innerHTML;
|
|
41
|
+
dl.appendChild(dt);
|
|
42
|
+
}
|
|
43
|
+
if (child.localName == "tei-item") {
|
|
44
|
+
let dd = doc.createElement("dd");
|
|
45
|
+
dd.innerHTML = child.innerHTML;
|
|
46
|
+
dl.appendChild(dd);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return dl;
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
],
|
|
54
|
+
"note": [
|
|
55
|
+
// Make endnotes
|
|
56
|
+
["[place=end]", function(elt) {
|
|
57
|
+
const doc = elt.ownerDocument;
|
|
58
|
+
if (!this.noteIndex) {
|
|
59
|
+
this["noteIndex"] = 1;
|
|
60
|
+
} else {
|
|
61
|
+
this.noteIndex++;
|
|
62
|
+
}
|
|
63
|
+
let id = "_note_" + this.noteIndex;
|
|
64
|
+
let link = doc.createElement("a");
|
|
65
|
+
link.setAttribute("id", "src" + id);
|
|
66
|
+
link.setAttribute("href", "#" + id);
|
|
67
|
+
link.innerHTML = this.noteIndex;
|
|
68
|
+
let content = doc.createElement("sup");
|
|
69
|
+
content.appendChild(link);
|
|
70
|
+
let notes = doc.querySelector("ol.notes");
|
|
71
|
+
if (!notes) {
|
|
72
|
+
notes = doc.createElement("ol");
|
|
73
|
+
notes.setAttribute("class", "notes");
|
|
74
|
+
this.dom.appendChild(notes);
|
|
75
|
+
}
|
|
76
|
+
let note = doc.createElement("li");
|
|
77
|
+
note.id = id;
|
|
78
|
+
note.innerHTML = elt.innerHTML;
|
|
79
|
+
notes.appendChild(note);
|
|
80
|
+
return content;
|
|
81
|
+
}],
|
|
82
|
+
["_", ["(", ")"]]
|
|
83
|
+
],
|
|
84
|
+
// Hide the teiHeader by default
|
|
85
|
+
"teiHeader": function(e) {
|
|
86
|
+
this.hideContent(e, false);
|
|
87
|
+
},
|
|
88
|
+
// Make the title element the HTML title
|
|
89
|
+
"title": [
|
|
90
|
+
["tei-titlestmt>tei-title", function(elt) {
|
|
91
|
+
const doc = elt.ownerDocument;
|
|
92
|
+
let title = doc.createElement("title");
|
|
93
|
+
title.innerHTML = elt.innerText;
|
|
94
|
+
doc.querySelector("head").appendChild(title);
|
|
95
|
+
}]
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
"teieg": {
|
|
99
|
+
"egXML": function(elt) {
|
|
100
|
+
const doc = elt.ownerDocument;
|
|
101
|
+
let pre = doc.createElement("pre");
|
|
102
|
+
let code = doc.createElement("code");
|
|
103
|
+
pre.appendChild(code);
|
|
104
|
+
let content = this.serialize(elt, true).replace(/</g, "<");
|
|
105
|
+
let ws = content.match(/^[\t ]+/);
|
|
106
|
+
if (ws) {
|
|
107
|
+
content = content.replace(new RegExp("^" + ws[0], "mg"), "");
|
|
108
|
+
}
|
|
109
|
+
code.innerHTML = content;
|
|
110
|
+
return pre;
|
|
7
111
|
}
|
|
8
|
-
|
|
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
|
-
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
19
114
|
export {
|
|
20
|
-
|
|
21
|
-
learnElementNames
|
|
115
|
+
defaultBehaviors as default
|
|
22
116
|
};
|
|
23
117
|
//# sourceMappingURL=react-text-annotator.es23.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es23.js","sources":["../../../node_modules/CETEIcean/src/
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es23.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 = new Image();\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":"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","x_google_ignoreList":[0]}
|
|
@@ -1,152 +1,312 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
bottom: "top",
|
|
13
|
-
top: "bottom"
|
|
14
|
-
};
|
|
15
|
-
const oppositeAlignmentMap = {
|
|
16
|
-
start: "end",
|
|
17
|
-
end: "start"
|
|
18
|
-
};
|
|
19
|
-
function clamp(start, value, end) {
|
|
20
|
-
return max(start, min(value, end));
|
|
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;
|
|
21
12
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
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;
|
|
56
|
+
};
|
|
57
|
+
return clone(node);
|
|
24
58
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
59
|
+
function first(urls) {
|
|
60
|
+
return urls.replace(/ .*$/, "");
|
|
27
61
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
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
|
+
}
|
|
30
89
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
90
|
+
function normalizeURI(urls) {
|
|
91
|
+
return this.rw(this.first(urls));
|
|
33
92
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
93
|
+
function repeat(str, times) {
|
|
94
|
+
let result = "";
|
|
95
|
+
for (let i = 0; i < times; i++) {
|
|
96
|
+
result += str;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
36
99
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
100
|
+
function resolveURI(uri) {
|
|
101
|
+
let prefixdef = this.prefixDefs[uri.substring(0, uri.indexOf(":"))];
|
|
102
|
+
return uri.replace(new RegExp(prefixdef["matchPattern"]), prefixdef["replacementPattern"]);
|
|
39
103
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
104
|
+
function getPrefixDef(prefix) {
|
|
105
|
+
return this.prefixDefs[prefix];
|
|
42
106
|
}
|
|
43
|
-
function
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
49
|
-
const length = getAxisLength(alignmentAxis);
|
|
50
|
-
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
51
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
52
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
107
|
+
function rw(url) {
|
|
108
|
+
if (!url.match(/^(?:http|mailto|file|\/|#).*$/)) {
|
|
109
|
+
return this.base + first(url);
|
|
110
|
+
} else {
|
|
111
|
+
return url;
|
|
53
112
|
}
|
|
54
|
-
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
55
113
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
114
|
+
function resetAndSerialize(el, stripElt, ws) {
|
|
115
|
+
return serialize(copyAndReset(el), stripElt, ws);
|
|
59
116
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const bt = ["bottom", "top"];
|
|
68
|
-
switch (side) {
|
|
69
|
-
case "top":
|
|
70
|
-
case "bottom":
|
|
71
|
-
if (rtl) return isStart ? rl : lr;
|
|
72
|
-
return isStart ? lr : rl;
|
|
73
|
-
case "left":
|
|
74
|
-
case "right":
|
|
75
|
-
return isStart ? tb : bt;
|
|
76
|
-
default:
|
|
77
|
-
return [];
|
|
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';
|
|
78
124
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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 += "/>";
|
|
87
147
|
}
|
|
88
148
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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;
|
|
93
192
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
left: 0,
|
|
100
|
-
...padding
|
|
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);
|
|
101
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;
|
|
102
257
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
105
|
-
top: padding,
|
|
106
|
-
right: padding,
|
|
107
|
-
bottom: padding,
|
|
108
|
-
left: padding
|
|
109
|
-
};
|
|
258
|
+
function unEscapeEntities(str) {
|
|
259
|
+
return str.replace(/>/, ">").replace(/"/, '"').replace(/'/, "'").replace(/&/, "&");
|
|
110
260
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
+
}
|
|
128
294
|
}
|
|
129
295
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
getSide,
|
|
146
|
-
getSideAxis,
|
|
147
|
-
max,
|
|
148
|
-
min,
|
|
149
|
-
rectToClientRect,
|
|
150
|
-
round
|
|
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
|
|
151
311
|
};
|
|
152
312
|
//# sourceMappingURL=react-text-annotator.es24.js.map
|