@soomo/react-text-annotator 3.2.0-staging.4 → 3.2.0-staging.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-text-annotator.es10.js +497 -78
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +77 -40
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +41 -21
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +19 -1637
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +1642 -9
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +13 -0
- package/dist/react-text-annotator.es15.js.map +1 -0
- package/dist/react-text-annotator.es17.js +566 -244
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +252 -471
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es2.js +1 -1
- package/dist/react-text-annotator.es25.js +111 -124
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es26.js +285 -140
- package/dist/react-text-annotator.es26.js.map +1 -1
- package/dist/react-text-annotator.es27.js +43 -296
- package/dist/react-text-annotator.es27.js.map +1 -1
- package/dist/react-text-annotator.es28.js +19 -113
- package/dist/react-text-annotator.es28.js.map +1 -1
- package/dist/react-text-annotator.es29.js +105 -287
- package/dist/react-text-annotator.es29.js.map +1 -1
- package/dist/react-text-annotator.es30.js +154 -48
- package/dist/react-text-annotator.es30.js.map +1 -1
- package/dist/react-text-annotator.es31.js +310 -19
- package/dist/react-text-annotator.es31.js.map +1 -1
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es5.js +1 -1
- package/dist/react-text-annotator.es7.js +4 -4
- package/package.json +2 -2
- package/dist/react-text-annotator.es16.js +0 -607
- package/dist/react-text-annotator.es16.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es18.js","sources":["../../../node_modules/CETEIcean/src/CETEI.js"],"sourcesContent":["import defaultBehaviors from './defaultBehaviors.js';\nimport * as utilities from './utilities.js';\nimport {addBehaviors, addBehavior, removeBehavior} from './behaviors.js';\nimport {learnElementNames, learnCustomElementNames} from './dom.js';\n\nclass CETEI {\n constructor(options){\n this.options = options ? options : {}\n\n // Set a local reference to the Document object\n // Determine document in this order of preference: options, window, global \n this.document = this.options.documentObject ? this.options.documentObject : undefined\n if (this.document === undefined) {\n if (typeof window !== 'undefined' && window.document) {\n this.document = window.document\n } else if (typeof global !== 'undefined' && global.document) {\n this.document = global.document\n }\n }\n\n // Bind methods\n this.addBehaviors = addBehaviors.bind(this);\n this.addBehavior = addBehavior.bind(this);\n this.removeBehavior = removeBehavior.bind(this);\n\n // Bind selected utilities\n this.utilities = {}\n for (const u of Object.keys(utilities)) {\n if ([\"getPrefixDef\", \"rw\", \"resolveURI\"].includes(u)) {\n this.utilities[u] = utilities[u].bind(this);\n } else {\n this.utilities[u] = utilities[u];\n }\n }\n\n // Set properties\n this.els = [];\n this.namespaces = new Map();\n this.behaviors = {};\n this.hasStyle = false;\n this.prefixDefs = [];\n this.debug = this.options.debug === true ? true : false;\n this.discardContent = this.options.discardContent === true ? true : false;\n\n if (this.options.base) {\n this.base = this.options.base;\n } else {\n try {\n if (window) {\n this.base = window.location.href.replace(/\\/[^\\/]*$/, \"/\");\n }\n } catch (e) {\n this.base = \"\";\n }\n }\n if (!this.options.omitDefaultBehaviors) {\n this.addBehaviors(defaultBehaviors);\n }\n if (this.options.ignoreFragmentId) {\n if (window) {\n window.removeEventListener(\"ceteiceanload\", CETEI.restorePosition);\n }\n }\n }\n\n /* \n Returns a Promise that fetches an XML source document from the URL\n provided in the first parameter and then calls the makeHTML5 method\n on the returned document.\n */\n async getHTML5(XML_url, callback, perElementFn){\n if (window && window.location.href.startsWith(this.base) && (XML_url.indexOf(\"/\") >= 0)) {\n this.base = XML_url.replace(/\\/[^\\/]*$/, \"/\");\n }\n try {\n const response = await fetch(XML_url);\n if (response.ok) {\n const XML = await response.text();\n return this.makeHTML5(XML, callback, perElementFn);\n } else {\n console.log(`Could not get XML file ${XML_url}.\\nServer returned ${response.status}: ${response.statusText}`);\n }\n }\n catch (error) {\n console.log(error);\n }\n }\n\n /* \n Converts the supplied XML string into HTML5 Custom Elements. If a callback\n function is supplied, calls it on the result.\n */\n makeHTML5(XML, callback, perElementFn){\n // XML is assumed to be a string\n this.XML_dom = ( new DOMParser() ).parseFromString(XML, \"text/xml\");\n return this.domToHTML5(this.XML_dom, callback, perElementFn);\n }\n\n preprocess(XML_dom, callback, perElementFn) {\n this.els = learnElementNames(XML_dom, this.namespaces);\n\n let convertEl = (el) => {\n // Elements with defined namespaces get the prefix mapped to that element. All others keep\n // their namespaces and are copied as-is.\n let newElement;\n if (this.namespaces.has(el.namespaceURI ? el.namespaceURI : \"\")) {\n let prefix = this.namespaces.get(el.namespaceURI ? el.namespaceURI : \"\");\n newElement = this.document.createElement(`${prefix}-${el.localName.toLowerCase()}`);\n } else {\n newElement = this.document.importNode(el, false);\n }\n // Copy attributes; @xmlns, @xml:id, @xml:lang, and\n // @rendition get special handling.\n for (let att of Array.from(el.attributes)) {\n if (att.name == \"xmlns\") {\n //Strip default namespaces, but hang on to the values\n newElement.setAttribute(\"data-xmlns\", att.value);\n } else {\n newElement.setAttribute(att.name, att.value);\n }\n if (att.name == \"xml:id\") {\n newElement.setAttribute(\"id\", att.value);\n }\n if (att.name == \"xml:lang\") {\n newElement.setAttribute(\"lang\", att.value);\n }\n if (att.name == \"rendition\") {\n newElement.setAttribute(\"class\", att.value.replace(/#/g, \"\"));\n }\n }\n // Preserve element name so we can use it later\n newElement.setAttribute(\"data-origname\", el.localName);\n if (el.hasAttributes()) {\n newElement.setAttribute(\"data-origatts\", el.getAttributeNames().join(\" \"));\n }\n // If element is empty, flag it\n if (el.childNodes.length == 0) {\n newElement.setAttribute(\"data-empty\", \"\");\n }\n // <head> elements need to know their level\n if (el.localName == \"head\" && el.namespaceURI == \"http://www.tei-c.org/ns/1.0\") {\n function getLevel(el) {\n let count = 0;\n let ancestor = el.parentElement;\n while (ancestor) {\n let children = ancestor.children;\n let i = 0; \n while (i < children.length) { \n if (children[i].tagName.toLowerCase() === \"head\" && children[i].namespaceURI === \"http://www.tei-c.org/ns/1.0\") {\n count++;\n break; // Only count once\n }\n i++;\n }\n ancestor = ancestor.parentElement; // Move to the next ancestor\n }\n return count;\n }\n newElement.setAttribute(\"data-level\", getLevel(el));\n }\n // Turn <rendition scheme=\"css\"> elements into HTML styles\n if (el.localName == \"tagsDecl\") {\n let style = this.document.createElement(\"style\");\n for (let node of Array.from(el.childNodes)){\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType == 1 && node.localName == \"rendition\" && node.getAttribute(\"scheme\") == \"css\") {\n let rule = \"\";\n if (node.hasAttribute(\"selector\")) {\n //rewrite element names in selectors\n rule += node.getAttribute(\"selector\").replace(/([^#, >]+\\w*)/g, \"tei-$1\").replace(/#tei-/g, \"#\") + \"{\\n\";\n rule += node.textContent;\n } else {\n rule += \".\" + node.getAttribute(\"xml:id\") + \"{\\n\";\n rule += node.textContent;\n }\n rule += \"\\n}\\n\";\n style.appendChild(this.document.createTextNode(rule));\n }\n }\n if (style.childNodes.length > 0) {\n newElement.appendChild(style);\n this.hasStyle = true;\n }\n }\n // Get prefix definitions\n if (el.localName == \"prefixDef\") {\n this.prefixDefs.push(el.getAttribute(\"ident\"));\n this.prefixDefs[el.getAttribute(\"ident\")] = {\n \"matchPattern\": el.getAttribute(\"matchPattern\"),\n \"replacementPattern\": el.getAttribute(\"replacementPattern\")\n };\n }\n for (let node of Array.from(el.childNodes)) {\n // Node.ELEMENT_NODE\n if (node.nodeType == 1 ) {\n newElement.appendChild(convertEl(node));\n }\n else {\n newElement.appendChild(node.cloneNode());\n }\n }\n if (perElementFn) {\n perElementFn(newElement, el);\n }\n return newElement;\n }\n\n this.dom = this.document.createDocumentFragment();\n for (let node of Array.from(XML_dom.childNodes)) {\n // Node.ELEMENT_NODE\n if (node.nodeType == 1) {\n this.dom.appendChild(convertEl(node));\n }\n // Node.PROCESSING_INSTRUCTION_NODE\n if (node.nodeType == 7) {\n this.dom.appendChild(this.document.importNode(node, true));\n }\n // Node.COMMENT_NODE\n if (node.nodeType == 8) {\n this.dom.appendChild(this.document.importNode(node, true));\n }\n }\n // DocumentFragments don't work in the same ways as other nodes, so use the root element.\n this.utilities.dom = this.dom.firstElementChild;\n\n if (callback) {\n callback(this.dom, this);\n if (window) {\n window.dispatchEvent(ceteiceanLoad);\n }\n } else {\n if (typeof window !== 'undefined') {\n window.dispatchEvent(ceteiceanLoad);\n }\n return this.dom;\n }\n }\n\n /* \n Converts the supplied XML DOM into HTML5 Custom Elements. If a callback\n function is supplied, calls it on the result.\n */\n domToHTML5(XML_dom, callback, perElementFn){\n\n this.preprocess(XML_dom, null, perElementFn);\n\n this.applyBehaviors();\n this.done = true;\n if (callback) {\n callback(this.dom, this);\n if (window) {\n window.dispatchEvent(ceteiceanLoad);\n }\n } else {\n if (typeof window !== 'undefined') {\n window.dispatchEvent(ceteiceanLoad);\n }\n return this.dom;\n }\n }\n\n /*\n Convenience method for HTML pages containing pre-processed CETEIcean Custom \n Elements. Usage:\n const c = new CETEI();\n c.processPage();\n */\n processPage() {\n this.els = learnCustomElementNames(this.document);\n this.applyBehaviors();\n if (window) {\n window.dispatchEvent(ceteiceanLoad);\n }\n }\n\n /* \n To change a namespace -> prefix mapping, the namespace must first be \n unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,\n the TEI namespace must be unset before it can be set to the empty string.\n */\n unsetNamespace(ns) {\n this.namespaces.delete(ns);\n }\n\n /* \n Sets the base URL for the document. Used to rewrite relative links in the\n XML source (which may be in a completely different location from the HTML\n wrapper).\n */\n setBaseUrl(base) {\n this.base = base;\n }\n\n /* \n Appends any element returned by the function passed in the first\n parameter to the element in the second parameter. If the function\n returns nothing, this is a no-op aside from any side effects caused\n by the provided function.\n\n Called by getHandler() and fallback()\n */\nappend(fn, elt) {\n let self = this;\n if (elt && !elt.hasAttribute('data-processed')) {\n let content = fn.call(self.utilities, elt);\n if (content) {\n self.appendBasic(elt, content);\n }\n } else {\n return function() {\n if (!this.hasAttribute(\"data-processed\")) {\n let content = fn.call(self.utilities, this);\n if (content) {\n self.appendBasic(this, content);\n }\n }\n }\n }\n}\n\nappendBasic(elt, content) {\n if (this.discardContent) {\n elt.innerHTML = \"\";\n } else {\n utilities.hideContent(elt, true);\n }\n elt.appendChild(content);\n}\n\n// Given an element, return its qualified name as defined in a behaviors object\nbName(e) {\n return e.tagName.substring(0,e.tagName.indexOf(\"-\")).toLowerCase() + \":\" + e.getAttribute(\"data-origname\");\n}\n\n/* \n Private method called by append(). Takes a child element and a name, and recurses through the\n child's siblings until an element with that name is found, returning true if it is and false if not.\n*/\nchildExists(elt, name) {\n if (elt && elt.nodeName == name) {\n return true;\n } else {\n return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);\n }\n}\n\n/* \n Takes a template in the form of either an array of 1 or 2 \n strings or an object with CSS selector keys and either functions\n or arrays as described above. Returns a closure around a function \n that can be called in the element constructor or applied to an \n individual element. An empty array is considered a no-op.\n\n Called by the getHandler() and getFallback() methods\n*/\ndecorator(template) {\n if (Array.isArray(template) && template.length == 0) {\n return function(e) {};\n }\n if (Array.isArray(template) && !Array.isArray(template[0])) {\n return this.applyDecorator(template)\n } \n let self = this;\n return function(elt) {\n for (let rule of template) {\n if (elt.matches(rule[0]) || rule[0] === \"_\") {\n if (Array.isArray(rule[1])) {\n return self.decorator(rule[1]).call(this, elt);\n } else {\n return rule[1].call(this, elt);\n }\n }\n }\n }\n}\n\napplyDecorator(strings) {\n let self = this;\n return function (elt) {\n let copy = [];\n for (let i = 0; i < strings.length; i++) {\n copy.push(self.template(strings[i], elt));\n }\n return self.insert(elt, copy);\n }\n}\n\n/* \n Returns the fallback function for the given element name.\n Called by fallback().\n*/\ngetFallback(behaviors, fn) {\n if (behaviors[fn]) {\n if (behaviors[fn] instanceof Function) {\n return behaviors[fn];\n } else {\n return this.decorator(behaviors[fn]);\n }\n }\n}\n\n/* \n Returns the handler function for the given element name\n Called by define().\n*/\ngetHandler(behaviors, fn) {\n if (behaviors[fn]) {\n if (behaviors[fn] instanceof Function) {\n return this.append(behaviors[fn]);\n } else {\n return this.append(this.decorator(behaviors[fn]));\n }\n }\n}\n\ninsert(elt, strings) {\n let content = this.document.createElement(\"cetei-content\");\n for (let node of Array.from(elt.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1 && !node.hasAttribute(\"data-processed\")) {\n this.processElement(node);\n }\n } \n // If we have before and after tags have them parsed by\n // .innerHTML and then add the content to the resulting child\n if (strings[0].match(\"<[^>]+>\") && strings[1] && strings[1].match(\"<[^>]+>\")) { \n content.innerHTML = strings[0] + elt.innerHTML + (strings[1]?strings[1]:\"\");\n } else {\n content.innerHTML = strings[0];\n content.setAttribute(\"data-before\", strings[0].replace(/<[^>]+>/g,\"\").length);\n for (let node of Array.from(elt.childNodes)) {\n content.appendChild(node.cloneNode(true));\n }\n if (strings.length > 1) {\n content.innerHTML += strings[1];\n content.setAttribute(\"data-after\", strings[1].replace(/<[^>]+>/g,\"\").length);\n } \n }\n if (content.childNodes.length < 2) {\n return content.firstChild;\n } else {\n return content;\n }\n}\n\n// Runs behaviors recursively on the supplied element and children\nprocessElement(elt) {\n if (elt.hasAttribute(\"data-origname\") && ! elt.hasAttribute(\"data-processed\")) {\n let fn = this.getFallback(this.bName(elt));\n if (fn) {\n this.append(fn,elt);\n elt.setAttribute(\"data-processed\", \"\");\n }\n }\n for (let node of Array.from(elt.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1) {\n this.processElement(node);\n }\n }\n}\n\ntemplate(str, elt) {\n let result = str;\n if (str.search(/\\$(\\w*)(@([a-zA-Z:]+))/ )) {\n let re = /\\$(\\w*)@([a-zA-Z:]+)/g;\n let replacements;\n while (replacements = re.exec(str)) {\n if (elt.hasAttribute(replacements[2])) {\n if (replacements[1] && this.utilities[replacements[1]]) {\n result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));\n } else {\n result = result.replace(replacements[0], elt.getAttribute(replacements[2]));\n }\n } else {\n result = result.replace(replacements[0], \"\");\n }\n }\n }\n return result;\n}\n\n// Define or apply behaviors for the document\napplyBehaviors() {\n if (typeof window !== 'undefined' && window.customElements) {\n this.define.call(this, this.els);\n } else {\n this.fallback.call(this, this.els);\n }\n}\n\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*/\ndefine(names) {\n for (let name of names) {\n const fn = this.getHandler(this.behaviors, name);\n utilities.defineCustomElement(name, fn, this.debug);\n }\n}\n\n/* \n Provides fallback functionality for environments where Custom Elements\n are not supported.\n\n Like define(), this is called by makeHTML5(), but can be called\n independently.\n*/\nfallback(names) {\n for (let name of names) {\n let fn = this.getFallback(this.behaviors, name);\n if (fn) {\n for (let elt of Array.from((\n this.dom && !this.done \n ? this.dom\n : this.document\n ).querySelectorAll(utilities.tagName(name)))) {\n if (!elt.hasAttribute(\"data-processed\")) {\n this.append(fn, elt);\n elt.setAttribute(\"data-processed\", \"\");\n }\n }\n }\n }\n}\n\n /**********************\n * Utility functions *\n **********************/\n\n \n static savePosition() {\n window.sessionStorage.setItem(window.location + \"-scroll\", window.scrollY);\n }\n \n static restorePosition() {\n if (!window.location.hash) {\n let scroll;\n if (scroll = window.sessionStorage.getItem(window.location + \"-scroll\")) {\n window.sessionStorage.removeItem(window.location + \"-scroll\");\n setTimeout(function() {\n window.scrollTo(0, scroll);\n }, 100);\n }\n } else {\n setTimeout(function() {\n let h = this.document.querySelector(window.decodeURI(window.location.hash));\n if (h) {\n h.scrollIntoView();\n }\n }, 100);\n }\n }\n\n}\n\ntry {\n if (typeof window !== 'undefined') {\n window.CETEI = CETEI;\n window.addEventListener(\"beforeunload\", CETEI.savePosition);\n var ceteiceanLoad = new Event(\"ceteiceanload\");\n window.addEventListener(\"ceteiceanload\", CETEI.restorePosition);\n }\n} catch (e) {\n console.log(e);\n}\n\nexport default CETEI;\n"],"names":["el","utilities.hideContent","utilities.defineCustomElement","utilities.tagName"],"mappings":";;;;;AAKA,MAAM,MAAM;AAAA,EACV,YAAY,SAAQ;AAClB,SAAK,UAAU,UAAU,UAAU,CAAA;AAInC,SAAK,WAAW,KAAK,QAAQ,iBAAiB,KAAK,QAAQ,iBAAiB;AAC5E,QAAI,KAAK,aAAa,QAAW;AAC/B,UAAI,OAAO,WAAW,eAAe,OAAO,UAAU;AACpD,aAAK,WAAW,OAAO;AAAA,MACxB,WAAU,OAAO,WAAW,eAAe,OAAO,UAAU;AAC3D,aAAK,WAAW,OAAO;AAAA,MAC/B;AAAA,IACA;AAGI,SAAK,eAAe,aAAa,KAAK,IAAI;AAC1C,SAAK,cAAc,YAAY,KAAK,IAAI;AACxC,SAAK,iBAAiB,eAAe,KAAK,IAAI;AAG9C,SAAK,YAAY,CAAA;AACjB,eAAW,KAAK,OAAO,KAAK,SAAS,GAAG;AACtC,UAAI,CAAC,gBAAgB,MAAM,YAAY,EAAE,SAAS,CAAC,GAAG;AACpD,aAAK,UAAU,CAAC,IAAI,UAAU,CAAC,EAAE,KAAK,IAAI;AAAA,MAClD,OAAa;AACL,aAAK,UAAU,CAAC,IAAI,UAAU,CAAC;AAAA,MACvC;AAAA,IACA;AAGI,SAAK,MAAM,CAAE;AACb,SAAK,aAAa,oBAAI,IAAK;AAC3B,SAAK,YAAY,CAAE;AACnB,SAAK,WAAW;AAChB,SAAK,aAAa,CAAE;AACpB,SAAK,QAAQ,KAAK,QAAQ,UAAU,OAAO,OAAO;AAClD,SAAK,iBAAiB,KAAK,QAAQ,mBAAmB,OAAO,OAAO;AAEpE,QAAI,KAAK,QAAQ,MAAM;AACrB,WAAK,OAAO,KAAK,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AACF,MAAI,OAAO,WAAW,aAAa;AAC/B,WAAO,QAAQ;AACf,WAAO,iBAAiB,gBAAgB,MAAM,YAAY;AAC1D,QAAI,gBAAgB,IAAI,MAAM,eAAe;AAC7C,WAAO,iBAAiB,iBAAiB,MAAM,eAAe;AAAA,EACpE;AACA,SAAS,GAAG;AACV,UAAQ,IAAI,CAAC;AACf;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es18.js","sources":["../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs"],"sourcesContent":["import { computePosition, arrow as arrow$2, offset as offset$1, shift as shift$1, limitShift as limitShift$1, flip as flip$1, size as size$1, autoPlacement as autoPlacement$1, hide as hide$1, inline as inline$1 } from '@floating-ui/dom';\nexport { autoUpdate, computePosition, detectOverflow, getOverflowAncestors, platform } from '@floating-ui/dom';\nimport * as React from 'react';\nimport { useLayoutEffect, useEffect } from 'react';\nimport * as ReactDOM from 'react-dom';\n\nvar index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;\n\n// Fork of `fast-deep-equal` that only does the comparisons we need and compares\n// functions\nfunction deepEqual(a, b) {\n if (a === b) {\n return true;\n }\n if (typeof a !== typeof b) {\n return false;\n }\n if (typeof a === 'function' && a.toString() === b.toString()) {\n return true;\n }\n let length;\n let i;\n let keys;\n if (a && b && typeof a === 'object') {\n if (Array.isArray(a)) {\n length = a.length;\n if (length !== b.length) return false;\n for (i = length; i-- !== 0;) {\n if (!deepEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n }\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) {\n return false;\n }\n for (i = length; i-- !== 0;) {\n if (!{}.hasOwnProperty.call(b, keys[i])) {\n return false;\n }\n }\n for (i = length; i-- !== 0;) {\n const key = keys[i];\n if (key === '_owner' && a.$$typeof) {\n continue;\n }\n if (!deepEqual(a[key], b[key])) {\n return false;\n }\n }\n return true;\n }\n return a !== a && b !== b;\n}\n\nfunction getDPR(element) {\n if (typeof window === 'undefined') {\n return 1;\n }\n const win = element.ownerDocument.defaultView || window;\n return win.devicePixelRatio || 1;\n}\n\nfunction roundByDPR(element, value) {\n const dpr = getDPR(element);\n return Math.round(value * dpr) / dpr;\n}\n\nfunction useLatestRef(value) {\n const ref = React.useRef(value);\n index(() => {\n ref.current = value;\n });\n return ref;\n}\n\n/**\n * Provides data to position a floating element.\n * @see https://floating-ui.com/docs/useFloating\n */\nfunction useFloating(options) {\n if (options === void 0) {\n options = {};\n }\n const {\n placement = 'bottom',\n strategy = 'absolute',\n middleware = [],\n platform,\n elements: {\n reference: externalReference,\n floating: externalFloating\n } = {},\n transform = true,\n whileElementsMounted,\n open\n } = options;\n const [data, setData] = React.useState({\n x: 0,\n y: 0,\n strategy,\n placement,\n middlewareData: {},\n isPositioned: false\n });\n const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);\n if (!deepEqual(latestMiddleware, middleware)) {\n setLatestMiddleware(middleware);\n }\n const [_reference, _setReference] = React.useState(null);\n const [_floating, _setFloating] = React.useState(null);\n const setReference = React.useCallback(node => {\n if (node !== referenceRef.current) {\n referenceRef.current = node;\n _setReference(node);\n }\n }, []);\n const setFloating = React.useCallback(node => {\n if (node !== floatingRef.current) {\n floatingRef.current = node;\n _setFloating(node);\n }\n }, []);\n const referenceEl = externalReference || _reference;\n const floatingEl = externalFloating || _floating;\n const referenceRef = React.useRef(null);\n const floatingRef = React.useRef(null);\n const dataRef = React.useRef(data);\n const hasWhileElementsMounted = whileElementsMounted != null;\n const whileElementsMountedRef = useLatestRef(whileElementsMounted);\n const platformRef = useLatestRef(platform);\n const openRef = useLatestRef(open);\n const update = React.useCallback(() => {\n if (!referenceRef.current || !floatingRef.current) {\n return;\n }\n const config = {\n placement,\n strategy,\n middleware: latestMiddleware\n };\n if (platformRef.current) {\n config.platform = platformRef.current;\n }\n computePosition(referenceRef.current, floatingRef.current, config).then(data => {\n const fullData = {\n ...data,\n // The floating element's position may be recomputed while it's closed\n // but still mounted (such as when transitioning out). To ensure\n // `isPositioned` will be `false` initially on the next open, avoid\n // setting it to `true` when `open === false` (must be specified).\n isPositioned: openRef.current !== false\n };\n if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {\n dataRef.current = fullData;\n ReactDOM.flushSync(() => {\n setData(fullData);\n });\n }\n });\n }, [latestMiddleware, placement, strategy, platformRef, openRef]);\n index(() => {\n if (open === false && dataRef.current.isPositioned) {\n dataRef.current.isPositioned = false;\n setData(data => ({\n ...data,\n isPositioned: false\n }));\n }\n }, [open]);\n const isMountedRef = React.useRef(false);\n index(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n index(() => {\n if (referenceEl) referenceRef.current = referenceEl;\n if (floatingEl) floatingRef.current = floatingEl;\n if (referenceEl && floatingEl) {\n if (whileElementsMountedRef.current) {\n return whileElementsMountedRef.current(referenceEl, floatingEl, update);\n }\n update();\n }\n }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);\n const refs = React.useMemo(() => ({\n reference: referenceRef,\n floating: floatingRef,\n setReference,\n setFloating\n }), [setReference, setFloating]);\n const elements = React.useMemo(() => ({\n reference: referenceEl,\n floating: floatingEl\n }), [referenceEl, floatingEl]);\n const floatingStyles = React.useMemo(() => {\n const initialStyles = {\n position: strategy,\n left: 0,\n top: 0\n };\n if (!elements.floating) {\n return initialStyles;\n }\n const x = roundByDPR(elements.floating, data.x);\n const y = roundByDPR(elements.floating, data.y);\n if (transform) {\n return {\n ...initialStyles,\n transform: \"translate(\" + x + \"px, \" + y + \"px)\",\n ...(getDPR(elements.floating) >= 1.5 && {\n willChange: 'transform'\n })\n };\n }\n return {\n position: strategy,\n left: x,\n top: y\n };\n }, [strategy, transform, elements.floating, data.x, data.y]);\n return React.useMemo(() => ({\n ...data,\n update,\n refs,\n elements,\n floatingStyles\n }), [data, update, refs, elements, floatingStyles]);\n}\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * This wraps the core `arrow` middleware to allow React refs as the element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow$1 = options => {\n function isRef(value) {\n return {}.hasOwnProperty.call(value, 'current');\n }\n return {\n name: 'arrow',\n options,\n fn(state) {\n const {\n element,\n padding\n } = typeof options === 'function' ? options(state) : options;\n if (element && isRef(element)) {\n if (element.current != null) {\n return arrow$2({\n element: element.current,\n padding\n }).fn(state);\n }\n return {};\n }\n if (element) {\n return arrow$2({\n element,\n padding\n }).fn(state);\n }\n return {};\n }\n };\n};\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = (options, deps) => ({\n ...offset$1(options),\n options: [options, deps]\n});\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = (options, deps) => ({\n ...shift$1(options),\n options: [options, deps]\n});\n\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = (options, deps) => ({\n ...limitShift$1(options),\n options: [options, deps]\n});\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = (options, deps) => ({\n ...flip$1(options),\n options: [options, deps]\n});\n\n/**\n * Provides data that allows you to change the size of the floating element —\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = (options, deps) => ({\n ...size$1(options),\n options: [options, deps]\n});\n\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = (options, deps) => ({\n ...autoPlacement$1(options),\n options: [options, deps]\n});\n\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = (options, deps) => ({\n ...hide$1(options),\n options: [options, deps]\n});\n\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = (options, deps) => ({\n ...inline$1(options),\n options: [options, deps]\n});\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * This wraps the core `arrow` middleware to allow React refs as the element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = (options, deps) => ({\n ...arrow$1(options),\n options: [options, deps]\n});\n\nexport { arrow, autoPlacement, flip, hide, inline, limitShift, offset, shift, size, useFloating };\n"],"names":["platform","data"],"mappings":";;;;;AAMA,IAAI,QAAQ,OAAO,aAAa,cAAc,kBAAkB;AAIhE,SAAS,UAAU,GAAG,GAAG;AACvB,MAAI,MAAM,GAAG;AACX,WAAO;AAAA,EACX;AACE,MAAI,OAAO,MAAM,OAAO,GAAG;AACzB,WAAO;AAAA,EACX;AACE,MAAI,OAAO,MAAM,cAAc,EAAE,eAAe,EAAE,YAAY;AAC5D,WAAO;AAAA,EACX;AACE,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,KAAK,KAAK,OAAO,MAAM,UAAU;AACnC,QAAI,MAAM,QAAQ,CAAC,GAAG;AACpB,eAAS,EAAE;AACX,UAAI,WAAW,EAAE,OAAQ,QAAO;AAChC,WAAK,IAAI,QAAQ,QAAQ,KAAI;AAC3B,YAAI,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG;AAC1B,iBAAO;AAAA,QACjB;AAAA,MACA;AACM,aAAO;AAAA,IACb;AACI,WAAO,OAAO,KAAK,CAAC;AACpB,aAAS,KAAK;AACd,QAAI,WAAW,OAAO,KAAK,CAAC,EAAE,QAAQ;AACpC,aAAO;AAAA,IACb;AACI,SAAK,IAAI,QAAQ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ACM,aAAO,CAAE;AAAA,IACf;AAAA,EACG;AACH;AASK,MAAC,SAAS,CAAC,SAAS,UAAU;AAAA,EACjC,GAAG,SAAS,OAAO;AAAA,EACnB,SAAS,CAAC,SAAS,IAAI;AACzB;AAOK,MAAC,QAAQ,CAAC,SAAS,UAAU;AAAA,EAChC,GAAG,QAAQ,OAAO;AAAA,EAClB,SAAS,CAAC,SAAS,IAAI;AACzB;AAgBK,MAAC,OAAO,CAAC,SAAS,UAAU;AAAA,EAC/B,GAAG,OAAO,OAAO;AAAA,EACjB,SAAS,CAAC,SAAS,IAAI;AACzB;AAuCK,MAAC,SAAS,CAAC,SAAS,UAAU;AAAA,EACjC,GAAG,SAAS,OAAO;AAAA,EACnB,SAAS,CAAC,SAAS,IAAI;AACzB;AAQK,MAAC,QAAQ,CAAC,SAAS,UAAU;AAAA,EAChC,GAAG,QAAQ,OAAO;AAAA,EAClB,SAAS,CAAC,SAAS,IAAI;AACzB;","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "./react-text-annotator.es8.js";
|
|
2
2
|
import { useRef, useEffect } from "react";
|
|
3
|
-
import CETEI from "./react-text-annotator.
|
|
3
|
+
import CETEI from "./react-text-annotator.es10.js";
|
|
4
4
|
const PRESET_BEHAVIORS = {
|
|
5
5
|
tei: {
|
|
6
6
|
ref: (elem) => {
|
|
@@ -1,130 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
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 = elt.ownerDocument.createElement("img");
|
|
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"));
|
|
23
26
|
}
|
|
24
|
-
|
|
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;
|
|
25
111
|
}
|
|
26
112
|
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
function getPlatform() {
|
|
30
|
-
const uaData = navigator.userAgentData;
|
|
31
|
-
if (uaData != null && uaData.platform) {
|
|
32
|
-
return uaData.platform;
|
|
33
|
-
}
|
|
34
|
-
return navigator.platform;
|
|
35
|
-
}
|
|
36
|
-
function getUserAgent() {
|
|
37
|
-
const uaData = navigator.userAgentData;
|
|
38
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
39
|
-
return uaData.brands.map((_ref) => {
|
|
40
|
-
let {
|
|
41
|
-
brand,
|
|
42
|
-
version
|
|
43
|
-
} = _ref;
|
|
44
|
-
return brand + "/" + version;
|
|
45
|
-
}).join(" ");
|
|
46
|
-
}
|
|
47
|
-
return navigator.userAgent;
|
|
48
|
-
}
|
|
49
|
-
function isVirtualClick(event) {
|
|
50
|
-
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (isAndroid() && event.pointerType) {
|
|
54
|
-
return event.type === "click" && event.buttons === 1;
|
|
55
|
-
}
|
|
56
|
-
return event.detail === 0 && !event.pointerType;
|
|
57
|
-
}
|
|
58
|
-
function isVirtualPointerEvent(event) {
|
|
59
|
-
if (isJSDOM()) return false;
|
|
60
|
-
return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
|
|
61
|
-
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
|
|
62
|
-
}
|
|
63
|
-
function isSafari() {
|
|
64
|
-
return /apple/i.test(navigator.vendor);
|
|
65
|
-
}
|
|
66
|
-
function isAndroid() {
|
|
67
|
-
const re = /android/i;
|
|
68
|
-
return re.test(getPlatform()) || re.test(getUserAgent());
|
|
69
|
-
}
|
|
70
|
-
function isJSDOM() {
|
|
71
|
-
return getUserAgent().includes("jsdom/");
|
|
72
|
-
}
|
|
73
|
-
function isReactEvent(event) {
|
|
74
|
-
return "nativeEvent" in event;
|
|
75
|
-
}
|
|
76
|
-
function isRootElement(element) {
|
|
77
|
-
return element.matches("html,body");
|
|
78
|
-
}
|
|
79
|
-
function getDocument(node) {
|
|
80
|
-
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
81
|
-
}
|
|
82
|
-
function isEventTargetWithin(event, node) {
|
|
83
|
-
if (node == null) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if ("composedPath" in event) {
|
|
87
|
-
return event.composedPath().includes(node);
|
|
88
|
-
}
|
|
89
|
-
const e = event;
|
|
90
|
-
return e.target != null && node.contains(e.target);
|
|
91
|
-
}
|
|
92
|
-
function getTarget(event) {
|
|
93
|
-
if ("composedPath" in event) {
|
|
94
|
-
return event.composedPath()[0];
|
|
95
|
-
}
|
|
96
|
-
return event.target;
|
|
97
|
-
}
|
|
98
|
-
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
99
|
-
function isTypeableElement(element) {
|
|
100
|
-
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
|
|
101
|
-
}
|
|
102
|
-
function stopEvent(event) {
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
event.stopPropagation();
|
|
105
|
-
}
|
|
106
|
-
function isTypeableCombobox(element) {
|
|
107
|
-
if (!element) return false;
|
|
108
|
-
return element.getAttribute("role") === "combobox" && isTypeableElement(element);
|
|
109
|
-
}
|
|
113
|
+
};
|
|
110
114
|
export {
|
|
111
|
-
|
|
112
|
-
activeElement,
|
|
113
|
-
contains,
|
|
114
|
-
getDocument,
|
|
115
|
-
getPlatform,
|
|
116
|
-
getTarget,
|
|
117
|
-
getUserAgent,
|
|
118
|
-
isAndroid,
|
|
119
|
-
isEventTargetWithin,
|
|
120
|
-
isJSDOM,
|
|
121
|
-
isReactEvent,
|
|
122
|
-
isRootElement,
|
|
123
|
-
isSafari,
|
|
124
|
-
isTypeableCombobox,
|
|
125
|
-
isTypeableElement,
|
|
126
|
-
isVirtualClick,
|
|
127
|
-
isVirtualPointerEvent,
|
|
128
|
-
stopEvent
|
|
115
|
+
defaultBehaviors as default
|
|
129
116
|
};
|
|
130
117
|
//# sourceMappingURL=react-text-annotator.es25.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es25.js","sources":["../../../node_modules
|
|
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;AAAA,IACD,QAAQ;AAAA;AAAA,MAEN;AAAA,QAAC;AAAA,QAAgB,SAAS,KAAK;AAC7B,gBAAM,MAAM,IAAI;AAChB,cAAI,KAAK,IAAI,cAAc,IAAI;AAC/B,mBAAS,SAAS,MAAM,KAAK,IAAI,QAAQ,GAAG;AAE1C,gBAAI,MAAM,YAAY,GAAG;AACvB,kBAAI,MAAM,aAAa,aAAa;AAClC,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