@diplodoc/transform 4.70.1 → 4.70.3
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/css/_yfm-only.css.map +1 -1
- package/dist/css/_yfm-only.min.css.map +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/base.min.css.map +1 -1
- package/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css +4 -0
- package/dist/css/yfm.css.map +3 -3
- package/dist/css/yfm.min.css +1 -1
- package/dist/css/yfm.min.css.map +3 -3
- package/dist/js/_yfm-only.js +24 -2
- package/dist/js/_yfm-only.js.map +2 -2
- package/dist/js/_yfm-only.min.js +1 -1
- package/dist/js/_yfm-only.min.js.map +3 -3
- package/dist/js/base.js.map +2 -2
- package/dist/js/base.min.js.map +2 -2
- package/dist/js/yfm.js +37 -3
- package/dist/js/yfm.js.map +2 -2
- package/dist/js/yfm.min.js +3 -3
- package/dist/js/yfm.min.js.map +3 -3
- package/dist/scss/_modal.scss +4 -0
- package/lib/plugins/term/index.js +1 -1
- package/lib/plugins/term/index.js.map +1 -1
- package/lib/sanitize.js +1 -0
- package/lib/sanitize.js.map +1 -1
- package/package.json +1 -1
- package/src/js/term/utils.ts +36 -2
- package/src/js/wide-mode/modal.ts +21 -1
- package/src/scss/_modal.scss +4 -0
- package/src/transform/plugins/term/index.ts +1 -1
- package/src/transform/sanitize.ts +1 -0
package/dist/js/_yfm-only.js
CHANGED
|
@@ -100,7 +100,18 @@
|
|
|
100
100
|
const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0];
|
|
101
101
|
const termId = target.getAttribute("id");
|
|
102
102
|
const termKey = target.getAttribute("term-key");
|
|
103
|
-
const
|
|
103
|
+
const definitionId = `${termKey}_element`;
|
|
104
|
+
const isInModal = target.closest(".wide-container");
|
|
105
|
+
let definitionElement;
|
|
106
|
+
if (isInModal) {
|
|
107
|
+
const modalContent = target.closest(".wide-content");
|
|
108
|
+
if (!modalContent) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
definitionElement = modalContent.querySelector(`[id="${definitionId}"]`);
|
|
112
|
+
} else {
|
|
113
|
+
definitionElement = document.getElementById(definitionId);
|
|
114
|
+
}
|
|
104
115
|
const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute("term-id");
|
|
105
116
|
if (isSameTerm) {
|
|
106
117
|
closeDefinition(openedDefinition);
|
|
@@ -170,7 +181,18 @@
|
|
|
170
181
|
}
|
|
171
182
|
function getTermByDefinition(definition) {
|
|
172
183
|
const termId = definition.getAttribute("term-id");
|
|
173
|
-
|
|
184
|
+
if (!termId) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
const isInModal = definition.closest(".wide-container");
|
|
188
|
+
if (isInModal) {
|
|
189
|
+
const modalContent = definition.closest(".wide-content");
|
|
190
|
+
if (!modalContent) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return modalContent.querySelector(`[id="${termId}"]`);
|
|
194
|
+
}
|
|
195
|
+
return document.getElementById(termId);
|
|
174
196
|
}
|
|
175
197
|
|
|
176
198
|
// src/js/term/index.ts
|
package/dist/js/_yfm-only.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/js/utils.ts", "../../src/js/term/utils.ts", "../../src/js/term/index.ts"],
|
|
4
|
-
"sourcesContent": ["export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionElement = document.getElementById(termKey + '_element');\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n return termId ? document.getElementById(termId) : null;\n}\n", "import {getEventTarget, isCustom} from '../utils';\n\nimport {\n closeDefinition,\n getTermByDefinition,\n openClass,\n openDefinition,\n openDefinitionClass,\n setDefinitionPosition,\n} from './utils';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (getEventTarget(event) || !isCustom(event)) {\n openDefinition(getEventTarget(event) as HTMLElement);\n }\n });\n\n document.addEventListener('keydown', (event) => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (event.key === 'Enter' && document.activeElement) {\n openDefinition(document.activeElement as HTMLElement);\n }\n\n if (event.key === 'Escape' && openedDefinition) {\n closeDefinition(openedDefinition);\n getTermByDefinition(openedDefinition)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n openedDefinition.classList.toggle(openClass);\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;AAAO,MAAM,iBAAiB,CAAC,UAAiB;AAC5C,UAAM,OAAO,MAAM,aAAa;AAChC,WAAO,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,MAAM;AAAA,EACpE;AAEO,MAAM,WAAW,CAAC,UAAiB;AACtC,UAAM,SAAS,eAAe,KAAK;AACnC,WAAO,CAAC,UAAU,CAAE,OAAuB;AAAA,EAC/C;;;ACRO,MAAM,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AACO,MAAM,YAAY;AAClB,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,EAAE,IAAI,MAAM;AAC/E,MAAI,mBA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CAAC;AAE/E,UAAM,SAAS,OAAO,aAAa,IAAI;AACvC,UAAM,UAAU,OAAO,aAAa,UAAU;AAC9C,UAAM,
|
|
4
|
+
"sourcesContent": ["export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionId = `${termKey}_element`;\n\n // Check if term is in modal window\n const isInModal = target.closest('.wide-container');\n\n let definitionElement: HTMLElement | null;\n\n if (isInModal) {\n // Find definition in modal window\n const modalContent = target.closest('.wide-content');\n if (!modalContent) {\n return;\n }\n definitionElement = modalContent.querySelector(`[id=\"${definitionId}\"]`) as HTMLElement;\n } else {\n // Find definition in normal document\n definitionElement = document.getElementById(definitionId);\n }\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n if (!termId) {\n return null;\n }\n\n // Check if definition is in modal window\n const isInModal = definition.closest('.wide-container');\n\n if (isInModal) {\n // Find term in modal window\n const modalContent = definition.closest('.wide-content');\n if (!modalContent) {\n return null;\n }\n return modalContent.querySelector(`[id=\"${termId}\"]`) as HTMLElement;\n }\n\n // Find term in normal document\n return document.getElementById(termId);\n}\n", "import {getEventTarget, isCustom} from '../utils';\n\nimport {\n closeDefinition,\n getTermByDefinition,\n openClass,\n openDefinition,\n openDefinitionClass,\n setDefinitionPosition,\n} from './utils';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (getEventTarget(event) || !isCustom(event)) {\n openDefinition(getEventTarget(event) as HTMLElement);\n }\n });\n\n document.addEventListener('keydown', (event) => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (event.key === 'Enter' && document.activeElement) {\n openDefinition(document.activeElement as HTMLElement);\n }\n\n if (event.key === 'Escape' && openedDefinition) {\n closeDefinition(openedDefinition);\n getTermByDefinition(openedDefinition)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n openedDefinition.classList.toggle(openClass);\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAO,MAAM,iBAAiB,CAAC,UAAiB;AAC5C,UAAM,OAAO,MAAM,aAAa;AAChC,WAAO,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,MAAM;AAAA,EACpE;AAEO,MAAM,WAAW,CAAC,UAAiB;AACtC,UAAM,SAAS,eAAe,KAAK;AACnC,WAAO,CAAC,UAAU,CAAE,OAAuB;AAAA,EAC/C;;;ACRO,MAAM,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AACO,MAAM,YAAY;AAClB,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,EAAE,IAAI,MAAM;AAC/E,MAAI,mBAAmB;AAEhB,WAAS,gBAAgB,mBAAgC,aAAgC;AAC5F,UAAM,SAAS,YAAY,aAAa,IAAI,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,OAAO,GAAG,CAAC;AACvF,2DAAmB,aAAa,WAAW;AAAA,EAC/C;AAEO,WAAS,2BACZ,mBACA,aACI;AACJ,UAAM,WAAW,YAAY,aAAa,WAAW,KAAK;AAC1D,2DAAmB,aAAa,aAAa;AAC7C,2DAAmB,aAAa,cAAc;AAAA,EAClD;AAEO,WAAS,sBACZ,mBACA,aACI;AACJ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AC;AAEH,UAAI,MAAM,QAAQ,WAAW,SAAS,eAAe;AACjD,uBAAe,SAAS,aAA4B;AAAA,MACxD;AAEA,UAAI,MAAM,QAAQ,YAAY,kBAAkB;AAC5C,wBAAgB,gBAAgB;AAChC,kCAAoB,gBAAgB,MAApC,mBAAuC;AAAA,MAC3C;AAAA,IACJ,CAAC;AAED,WAAO,iBAAiB,UAAU,MAAM;AACpC,YAAM,mBAAmB,SAAS;AAAA,QAC9B;AAAA,MACJ,EAAE,CAAC;AAEH,UAAI,CAAC,kBAAkB;AACnB;AAAA,MACJ;AAEA,YAAM,SAAS,iBAAiB,aAAa,SAAS,KAAK;AAC3D,YAAM,cAAc,SAAS,eAAe,MAAM;AAElD,UAAI,CAAC,aAAa;AACd,yBAAiB,UAAU,OAAO,SAAS;AAC3C;AAAA,MACJ;AAEA,4BAAsB,kBAAkB,WAAW;AAAA,IACvD,CAAC;AAAA,EACL;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/js/_yfm-only.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{(()=>{var
|
|
1
|
+
"use strict";(()=>{(()=>{var y=t=>{let e=t.composedPath();return Array.isArray(e)&&e.length>0?e[0]:t.target},I=t=>{let e=y(t);return!e||!e.matches},h={TITLE:".yfm .yfm-term_title",CONTENT:".yfm .yfm-term_dfn"},u="open",f=h.CONTENT.replace(/\./g,"")+" "+u,a=!0;function S(t,e){let n=e.getAttribute("id")||Math.random().toString(36).substr(2,8);t==null||t.setAttribute("term-id",n)}function B(t,e){let n=e.getAttribute("aria-live")||"polite";t==null||t.setAttribute("aria-live",n),t==null||t.setAttribute("aria-modal","true")}function v(t,e){let{x:n,y:o,right:i,left:c,width:s,height:p}=e.getBoundingClientRect(),r=T(e);if(!r)return;let{right:l,left:O}=r.getBoundingClientRect();if((l<c||O>i)&&!a){m(t);return}a&&r&&(r.addEventListener("scroll",L),a=!1);let R=Number(t.getAttribute("relativeX")),k=Number(t.getAttribute("relativeY"));if(R===n&&k===o)return;t.setAttribute("relativeX",String(n)),t.setAttribute("relativeY",String(o));let x=p+5,d=t.parentElement;if(!d)return;let{width:b}=t.getBoundingClientRect(),{left:M}=d.getBoundingClientRect(),E=Number(g(e).left),N=b+E,W=E-b<0,w=N>document.body.clientWidth,X=(w||document.dir==="rtl")&&!W?b-s:0,Y=g(d).top-d.offsetTop,_=w?N-document.body.clientWidth+5:0,D=g(e).left-M+d.offsetLeft-X,q=D+b>=document.body.clientWidth;t.style.top=Number(g(e).top+x-Y)+"px",t.style.left=Number(D-(q?_:0))+"px"}function L(){let t=document.getElementsByClassName(f)[0];if(!t)return;let e=t.getAttribute("term-id")||"",n=document.getElementById(e);n&&v(t,n)}function T(t){return t?t.closest("table")||t.closest("code")||t.parentElement:null}function A(t){let e=document.getElementsByClassName(f)[0],n=t.getAttribute("id"),i=`${t.getAttribute("term-key")}_element`,c=t.closest(".wide-container"),s;if(c){let l=t.closest(".wide-content");if(!l)return;s=l.querySelector(`[id="${i}"]`)}else s=document.getElementById(i);if(e&&n===e.getAttribute("term-id")){m(e);return}let r=t.closest([h.CONTENT.replace(" ",""),u].join("."));e&&!r&&m(e),!(!t.matches(h.TITLE)||!s)&&(S(s,t),B(s,t),v(s,t),s.classList.toggle(u),P(s))}function m(t){t.classList.remove(u);let e=C(t),n=T(e);n&&(n.removeEventListener("scroll",L),a=!0)}function g(t){let e=t.getBoundingClientRect(),n=document.body,o=document.documentElement,i=window.pageYOffset||o.scrollTop||n.scrollTop,c=window.pageXOffset||o.scrollLeft||n.scrollLeft,s=o.clientTop||n.clientTop||0,p=o.clientLeft||n.clientLeft||0,r=e.top+i-s,l=e.left+c-p;return{top:Math.round(r),left:Math.round(l)}}function P(t){let e=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=e[0],o=e[e.length-1];n&&n.focus(),t.addEventListener("keydown",function(i){(i.key==="Tab"||i.keyCode===9)&&(i.shiftKey?document.activeElement===n&&(o.focus(),i.preventDefault()):document.activeElement===o&&(n.focus(),i.preventDefault()))})}function C(t){let e=t.getAttribute("term-id");if(!e)return null;if(t.closest(".wide-container")){let o=t.closest(".wide-content");return o?o.querySelector(`[id="${e}"]`):null}return document.getElementById(e)}typeof document!="undefined"&&(document.addEventListener("click",t=>{(y(t)||!I(t))&&A(y(t))}),document.addEventListener("keydown",t=>{var e;let n=document.getElementsByClassName(f)[0];t.key==="Enter"&&document.activeElement&&A(document.activeElement),t.key==="Escape"&&n&&(m(n),(e=C(n))==null||e.focus())}),window.addEventListener("resize",()=>{let t=document.getElementsByClassName(f)[0];if(!t)return;let e=t.getAttribute("term-id")||"",n=document.getElementById(e);if(!n){t.classList.toggle(u);return}v(t,n)}))})();})();
|
|
2
2
|
//# sourceMappingURL=_yfm-only.min.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/js/utils.ts", "../../src/js/term/utils.ts", "../../src/js/term/index.ts"],
|
|
4
|
-
"sourcesContent": ["export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionElement = document.getElementById(termKey + '_element');\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n return termId ? document.getElementById(termId) : null;\n}\n", "import {getEventTarget, isCustom} from '../utils';\n\nimport {\n closeDefinition,\n getTermByDefinition,\n openClass,\n openDefinition,\n openDefinitionClass,\n setDefinitionPosition,\n} from './utils';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (getEventTarget(event) || !isCustom(event)) {\n openDefinition(getEventTarget(event) as HTMLElement);\n }\n });\n\n document.addEventListener('keydown', (event) => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (event.key === 'Enter' && document.activeElement) {\n openDefinition(document.activeElement as HTMLElement);\n }\n\n if (event.key === 'Escape' && openedDefinition) {\n closeDefinition(openedDefinition);\n getTermByDefinition(openedDefinition)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n openedDefinition.classList.toggle(openClass);\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n });\n}\n"],
|
|
5
|
-
"mappings": "yBAAO,IAAMA,EAAkBC,GAAiB,CAC5C,IAAMC,EAAOD,EAAM,aAAa,EAChC,OAAO,MAAM,QAAQC,CAAI,GAAKA,EAAK,OAAS,EAAIA,EAAK,CAAC,EAAID,EAAM,MACpE,EAEaE,EAAYF,GAAiB,CACtC,IAAMG,EAASJ,EAAeC,CAAK,EACnC,MAAO,CAACG,GAAU,CAAEA,EAAuB,OAC/C,ECRaC,EAAW,CACpB,MAAO,uBACP,QAAS,oBACb,EACaC,EAAY,OACZC,EAAsBF,EAAS,QAAQ,QAAQ,MAAO,EAAE,EAAI,IAAMC,EAC3EE,EAAmB,GAEhB,SAASC,EAAgBC,EAAgCC,EAAgC,CAC5F,IAAMC,EAASD,EAAY,aAAa,IAAI,GAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,OAAO,EAAG,CAAC,EACvFD,GAAA,MAAAA,EAAmB,aAAa,UAAWE,CAAA,CAC/C,CAEO,SAASC,EACZH,EACAC,EACI,CACJ,IAAMG,EAAWH,EAAY,aAAa,WAAW,GAAK,SAC1DD,GAA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AA4B,SAAS,KAAK,YAF5B,EAGd,EACAM,EACFP,EAAUxB,CAAW,EAAE,KACvBsB,EACAF,EAAiB,WACjBQ,EAEEI,EAAoBD,EAAaV,GAAmB,SAAS,KAAK,YAExEtB,EAAkB,MAAM,IACpB,OAAOyB,EAAUxB,CAAW,EAAE,IAAMmB,EAAYU,CAAe,EAAI,KACvE9B,EAAkB,MAAM,KAAO,OAAOgC,GAAcC,EAAoBF,EAAY,EAAE,EAAI,IAC9F,CAEA,SAASd,GAAe,CACpB,IAAMiB,EAAmB,SAAS,uBAAuBrC,CAAmB,EAAE,CAAC,EAE/E,GAAI,CAACqC,EACD,OAEJ,IAAMhC,EAASgC,EAAiB,aAAa,SAAS,GAAK,GACrDjC,EAAc,SAAS,eAAeC,CAAM,EAE7CD,GAILI,EAAsB6B,EAAkBjC,CAAW,CACvD,CAEA,SAASY,EAAkBsB,EAA0B,CACjD,OAAKA,EAI2BA,EAAK,QAAQ,OAAO,GAAKA,EAAK,QAAQ,MAAM,GAE1CA,EAAK,cAL5B,IAMf,CAEO,SAASC,EAAe1C,EAAqB,CAChD,IAAMwC,EAAmB,SAAS,uBAAuBrC,CAAmB,EAAE,CAAC,EAEzEK,EAASR,EAAO,aAAa,IAAI,
|
|
6
|
-
"names": ["getEventTarget", "event", "path", "isCustom", "target", "Selector", "openClass", "openDefinitionClass", "isListenerNeeded", "setDefinitionId", "definitionElement", "termElement", "termId", "setDefinitonAriaAttributes", "ariaLive", "setDefinitionPosition", "termX", "termY", "termRight", "termLeft", "termWidth", "termHeight", "termParent", "termParentElement", "termParentRight", "termParentLeft", "closeDefinition", "termOnResize", "relativeX", "relativeY", "offsetTop", "definitionParent", "definitionWidth", "definitionParentLeft", "definitionLeftCoordinate", "getCoords", "definitionRightCoordinate", "definitionOutOfScreenOnLeft", "definitionOutOfScreenOnRight", "fitDefinitionDocument", "customHeaderTop", "shiftLeft", "offsetLeft", "isShiftLeftNeeded", "openedDefinition", "term", "openDefinition", "
|
|
4
|
+
"sourcesContent": ["export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionId = `${termKey}_element`;\n\n // Check if term is in modal window\n const isInModal = target.closest('.wide-container');\n\n let definitionElement: HTMLElement | null;\n\n if (isInModal) {\n // Find definition in modal window\n const modalContent = target.closest('.wide-content');\n if (!modalContent) {\n return;\n }\n definitionElement = modalContent.querySelector(`[id=\"${definitionId}\"]`) as HTMLElement;\n } else {\n // Find definition in normal document\n definitionElement = document.getElementById(definitionId);\n }\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n if (!termId) {\n return null;\n }\n\n // Check if definition is in modal window\n const isInModal = definition.closest('.wide-container');\n\n if (isInModal) {\n // Find term in modal window\n const modalContent = definition.closest('.wide-content');\n if (!modalContent) {\n return null;\n }\n return modalContent.querySelector(`[id=\"${termId}\"]`) as HTMLElement;\n }\n\n // Find term in normal document\n return document.getElementById(termId);\n}\n", "import {getEventTarget, isCustom} from '../utils';\n\nimport {\n closeDefinition,\n getTermByDefinition,\n openClass,\n openDefinition,\n openDefinitionClass,\n setDefinitionPosition,\n} from './utils';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (getEventTarget(event) || !isCustom(event)) {\n openDefinition(getEventTarget(event) as HTMLElement);\n }\n });\n\n document.addEventListener('keydown', (event) => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (event.key === 'Enter' && document.activeElement) {\n openDefinition(document.activeElement as HTMLElement);\n }\n\n if (event.key === 'Escape' && openedDefinition) {\n closeDefinition(openedDefinition);\n getTermByDefinition(openedDefinition)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const openedDefinition = document.getElementsByClassName(\n openDefinitionClass,\n )[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n openedDefinition.classList.toggle(openClass);\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n });\n}\n"],
|
|
5
|
+
"mappings": "yBAAO,IAAMA,EAAkBC,GAAiB,CAC5C,IAAMC,EAAOD,EAAM,aAAa,EAChC,OAAO,MAAM,QAAQC,CAAI,GAAKA,EAAK,OAAS,EAAIA,EAAK,CAAC,EAAID,EAAM,MACpE,EAEaE,EAAYF,GAAiB,CACtC,IAAMG,EAASJ,EAAeC,CAAK,EACnC,MAAO,CAACG,GAAU,CAAEA,EAAuB,OAC/C,ECRaC,EAAW,CACpB,MAAO,uBACP,QAAS,oBACb,EACaC,EAAY,OACZC,EAAsBF,EAAS,QAAQ,QAAQ,MAAO,EAAE,EAAI,IAAMC,EAC3EE,EAAmB,GAEhB,SAASC,EAAgBC,EAAgCC,EAAgC,CAC5F,IAAMC,EAASD,EAAY,aAAa,IAAI,GAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,OAAO,EAAG,CAAC,EACvFD,GAAA,MAAAA,EAAmB,aAAa,UAAWE,CAAA,CAC/C,CAEO,SAASC,EACZH,EACAC,EACI,CACJ,IAAMG,EAAWH,EAAY,aAAa,WAAW,GAAK,SAC1DD,GAAA,MAAAA,EAAmB,aAAa,YAAaI,CAAA,EAC7CJ,GAAA,MAAAA,EAAmB,aAAa,aAAc,MAAA,CAClD,CAEO,SAASK,EACZL,EACAC,EACI,CACJ,GAAM,CACF,EAAGK,EACH,EAAGC,EACH,MAAOC,EACP,KAAMC,EACN,MAAOC,EACP,OAAQC,CACZ,EAAIV,EAAY,sBAAsB,EAEh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CAEX,IAAMH,EAAeG,EAAW,QAAQ,eAAe,EACvD,OAAKH,EAGEA,EAAa,cAAc,QAAQrC,CAAM,IAAI,EAFzC,IAGf,CAGA,OAAO,SAAS,eAAeA,CAAM,CACzC,CCxPI,OAAO,UAAa,cACpB,SAAS,iBAAiB,QAAUX,GAAU,EACtCD,EAAeC,CAAK,GAAK,CAACE,EAASF,CAAK,IACxC6C,EAAe9C,EAAeC,CAAK,CAAgB,CAE3D,CAAC,EAED,SAAS,iBAAiB,UAAYA,GAAU,CAlBpD,IAAAoE,EAmBQ,IAAMzB,EAAmB,SAAS,uBAC9BrC,CACJ,EAAE,CAAC,EAECN,EAAM,MAAQ,SAAW,SAAS,eAClC6C,EAAe,SAAS,aAA4B,EAGpD7C,EAAM,MAAQ,UAAY2C,IAC1BlB,EAAgBkB,CAAgB,GAChCyB,EAAAhB,EAAoBT,CAAgB,IAApC,MAAAyB,EAAuC,MAAA,EAE/C,CAAC,EAED,OAAO,iBAAiB,SAAU,IAAM,CACpC,IAAMzB,EAAmB,SAAS,uBAC9BrC,CACJ,EAAE,CAAC,EAEH,GAAI,CAACqC,EACD,OAGJ,IAAMhC,EAASgC,EAAiB,aAAa,SAAS,GAAK,GACrDjC,EAAc,SAAS,eAAeC,CAAM,EAElD,GAAI,CAACD,EAAa,CACdiC,EAAiB,UAAU,OAAOtC,CAAS,EAC3C,MACJ,CAEAS,EAAsB6B,EAAkBjC,CAAW,CACvD,CAAC",
|
|
6
|
+
"names": ["getEventTarget", "event", "path", "isCustom", "target", "Selector", "openClass", "openDefinitionClass", "isListenerNeeded", "setDefinitionId", "definitionElement", "termElement", "termId", "setDefinitonAriaAttributes", "ariaLive", "setDefinitionPosition", "termX", "termY", "termRight", "termLeft", "termWidth", "termHeight", "termParent", "termParentElement", "termParentRight", "termParentLeft", "closeDefinition", "termOnResize", "relativeX", "relativeY", "offsetTop", "definitionParent", "definitionWidth", "definitionParentLeft", "definitionLeftCoordinate", "getCoords", "definitionRightCoordinate", "definitionOutOfScreenOnLeft", "definitionOutOfScreenOnRight", "fitDefinitionDocument", "customHeaderTop", "shiftLeft", "offsetLeft", "isShiftLeftNeeded", "openedDefinition", "term", "openDefinition", "definitionId", "isInModal", "modalContent", "isTargetDefinitionContent", "trapFocus", "definition", "getTermByDefinition", "elem", "box", "body", "docEl", "scrollTop", "scrollLeft", "clientTop", "clientLeft", "top", "left", "element", "focusableElements", "firstFocusableElement", "lastFocusableElement", "e", "_a"]
|
|
7
7
|
}
|
package/dist/js/base.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../node_modules/get-root-node-polyfill/index.js", "../../src/js/polyfill.js", "../../src/js/utils.ts", "../../src/js/code.ts", "../../src/js/anchor.ts", "../../src/js/inline-code/constant.ts", "../../src/js/term/utils.ts", "../../src/js/inline-code/utils.ts", "../../src/js/inline-code/index.ts"],
|
|
4
|
-
"sourcesContent": ["'use strict';\n\n// Node getRootNode(optional GetRootNodeOptions options);\n\n/**\n * Returns the context object\u2019s shadow-including root if options\u2019s composed is true.\n * Returns the context object\u2019s root otherwise.\n *\n * The root of an object is itself, if its parent is null, or else it is the root of its parent.\n *\n * The shadow-including root of an object is its root\u2019s host\u2019s shadow-including root,\n * if the object\u2019s root is a shadow root, and its root otherwise.\n *\n * https://dom.spec.whatwg.org/#dom-node-getrootnode\n *\n * @memberof Node.prototype\n * @param {!Object} [opt = {}] - Options.\n * @param {!boolean} [opt.composed] - See above description.\n * @returns {!Node} The root node.\n */\nfunction getRootNode(opt) {\n var composed = typeof opt === 'object' && Boolean(opt.composed);\n\n return composed ? getShadowIncludingRoot(this) : getRoot(this);\n}\n\nfunction getShadowIncludingRoot(node) {\n var root = getRoot(node);\n\n if (isShadowRoot(root)) {\n return getShadowIncludingRoot(root.host);\n }\n\n return root;\n}\n\nfunction getRoot(node) {\n if (node.parentNode != null) {\n return getRoot(node.parentNode);\n }\n\n return node;\n}\n\nfunction isShadowRoot(node) {\n return node.nodeName === '#document-fragment' && node.constructor.name === 'ShadowRoot';\n}\n\nif (typeof module === 'object' && module.exports) {\n module.exports = getRootNode;\n}\n", "import getRootNode from 'get-root-node-polyfill';\n\nif (typeof document !== 'undefined') {\n // matches polyfill for old edge\n (function (e) {\n const matches =\n e.matches ||\n e.matchesSelector ||\n e.webkitMatchesSelector ||\n e.mozMatchesSelector ||\n e.msMatchesSelector ||\n e.oMatchesSelector;\n\n if (matches) {\n e.matches = e.matchesSelector = matches;\n } else {\n e.matches = e.matchesSelector = function matches(selector) {\n const rootNode = e.getRootNode ? e.getRootNode() : getRootNode.call(e);\n const matches = rootNode.querySelectorAll(selector);\n const th = this;\n return Array.prototype.some.call(matches, (e) => {\n return e === th;\n });\n };\n }\n // eslint-disable-next-line no-undef\n })(Element.prototype);\n}\n", "export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst COPY_BUTTON_SELECTOR = '.yfm-clipboard-button';\nconst WRAP_BUTTON_SELECTOR = '.yfm-wrapping-button';\n\nfunction notifySuccess(svgButton: HTMLElement | null) {\n if (!svgButton) {\n return;\n }\n\n const id = svgButton.getAttribute('data-animation');\n\n // @ts-expect-error\n const icon = svgButton.getRootNode().getElementById(`visibileAnimation-${id}`);\n\n if (!icon) {\n return;\n }\n\n icon.beginElement();\n}\n\nfunction buttonCopyFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n // Get all text nodes and filter out line numbers\n const textContent = Array.from(code.childNodes)\n .filter((node) => {\n // Skip line number spans\n if (node instanceof HTMLElement && node.classList.contains('yfm-line-number')) {\n return false;\n }\n return true;\n })\n .map((node) => node.textContent)\n .join('');\n\n copyToClipboard(textContent.trim()).then(() => {\n notifySuccess(container.querySelector('.yfm-clipboard-icon'));\n\n setTimeout(() => target.blur(), 1500);\n });\n}\n\nfunction buttonWrapFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n code.classList.toggle('wrap');\n\n setTimeout(() => target.blur(), 500);\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (isCustom(event)) {\n return;\n }\n\n const target = getEventTarget(event) as HTMLElement;\n\n if (target.matches(COPY_BUTTON_SELECTOR)) {\n buttonCopyFn(target);\n } else if (target.matches(WRAP_BUTTON_SELECTOR)) {\n buttonWrapFn(target);\n }\n });\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst ANCHOR_BUTTON_SELECTOR = '.yfm-clipboard-anchor';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n if (isCustom(event) || !target.matches(ANCHOR_BUTTON_SELECTOR)) {\n return;\n }\n\n const href = target.getAttribute('data-href') || '';\n const link = new URL(href, window.location.href).toString();\n\n copyToClipboard(link);\n });\n}\n", "import type {Lang} from 'src/transform/typings';\n\nexport const INLINE_CODE = '.yfm-clipboard-inline-code';\n\nexport const INLINE_CODE_ID = 'tooltip_inline_clipboard_dialog';\n\nexport const INLINE_CODE_CLASS = 'yfm inline_code_tooltip';\n\nexport const OPEN_CLASS = 'open';\n\nexport const LANG_TOKEN: Record<Lang, string> = {\n ru: '\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u043E',\n en: 'Copied',\n ar: '\u062A\u0645 \u0627\u0644\u0646\u0633\u062E',\n cs: 'Zkop\u00EDrov\u00E1no',\n fr: 'Copi\u00E9',\n es: 'Copiado',\n he: '\u05D4\u05D5\u05E2\u05EA\u05E7',\n bg: '\u041A\u043E\u043F\u0438\u0440\u0430\u043D\u043E',\n et: 'Kopeeritud',\n el: '\u0391\u03BD\u03C4\u03B9\u03B3\u03C1\u03AC\u03C6\u03B7\u03BA\u03B5',\n pt: 'Copiado',\n zh: '\u5DF2\u590D\u5236',\n 'zh-tw': '\u5DF2\u8907\u88FD',\n kk: '\u041A\u04E9\u0448\u0456\u0440\u0456\u043B\u0434\u0456',\n tr: 'Kopyaland\u0131',\n uz: 'Nusxalandi',\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionElement = document.getElementById(termKey + '_element');\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n return termId ? document.getElementById(termId) : null;\n}\n", "import type {Lang} from 'src/transform/typings';\n\nimport {getCoords} from '../term/utils';\n\nimport {INLINE_CODE, INLINE_CODE_CLASS, INLINE_CODE_ID, LANG_TOKEN, OPEN_CLASS} from './constant';\n\nexport let timer: ReturnType<typeof setTimeout> | null = null;\n\nlet isListenerNeeded = true;\n\nexport function getTooltipElement(): HTMLElement | null {\n return document.getElementById(INLINE_CODE_ID);\n}\n\nfunction setTooltipAriaAttributes(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const ariaLive = targetElement.getAttribute('aria-live') || 'polite';\n tooltipElement?.setAttribute('aria-live', ariaLive);\n tooltipElement?.setAttribute('aria-modal', 'true');\n}\n\nfunction checkTimerAndClear() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n}\n\nfunction tooltipParentElement(target: HTMLElement | null) {\n if (!target) {\n return null;\n }\n\n const closestScrollableParent = target.closest('table') || target.closest('code');\n\n return closestScrollableParent || target.parentElement;\n}\n\nfunction tooltipOnResize() {\n const openedDefinition = getTooltipElement();\n\n if (!openedDefinition) {\n return;\n }\n const inlineId = openedDefinition.getAttribute('inline-id') || '';\n const targetElement = document.getElementById(inlineId);\n\n if (!targetElement) {\n return;\n }\n\n setTooltipPosition(openedDefinition, targetElement);\n}\n\nexport function setTooltipPosition(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const {\n x: inlineX,\n y: inlineY,\n right: inlineRight,\n left: inlineLeft,\n width: inlineWidth,\n height: inlineHeight,\n } = targetElement.getBoundingClientRect();\n\n const tooltipParent = tooltipParentElement(targetElement);\n\n if (!tooltipParent) {\n return;\n }\n\n const {right: tooltipParentRight, left: tooltipParentLeft} =\n tooltipParent.getBoundingClientRect();\n\n if ((tooltipParentRight < inlineLeft || tooltipParentLeft > inlineRight) && !isListenerNeeded) {\n closeTooltip(tooltipElement);\n return;\n }\n\n if (isListenerNeeded && tooltipParent) {\n tooltipParent.addEventListener('scroll', tooltipOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(tooltipElement.getAttribute('relativeX'));\n const relativeY = Number(tooltipElement.getAttribute('relativeY'));\n\n if (relativeX === inlineX && relativeY === inlineY) {\n return;\n }\n\n tooltipElement.setAttribute('relativeX', String(inlineX));\n tooltipElement.setAttribute('relativeY', String(inlineY));\n\n const offsetTop = inlineHeight + 5;\n const definitionParent = tooltipElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = tooltipElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(targetElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - inlineWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(targetElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n tooltipElement.style.top =\n Number(getCoords(targetElement).top + offsetTop - customHeaderTop) + 'px';\n tooltipElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nexport function getInlineCodeByTooltip(definition: HTMLElement) {\n const inlineId = definition.getAttribute('inline-id');\n\n return inlineId ? document.getElementById(inlineId) : null;\n}\n\nfunction closeTooltipFn(definition: HTMLElement) {\n definition.classList.remove(OPEN_CLASS);\n const inline = getInlineCodeByTooltip(definition);\n const inlineCodepParent = tooltipParentElement(inline);\n const tooltipParent = tooltipParentElement(definition);\n\n definition.removeAttribute('inline-id');\n\n if (!inlineCodepParent || !tooltipParent) {\n return;\n }\n\n tooltipParent.removeChild(definition);\n inlineCodepParent.removeEventListener('scroll', tooltipOnResize);\n isListenerNeeded = true;\n}\n\nfunction createTooltip() {\n let tooltip = getTooltipElement();\n\n if (!tooltip) {\n const pageContent = document.querySelector('.dc-doc-page__content') || document.body;\n const lang = document.documentElement.lang || 'en';\n const tooltipText = LANG_TOKEN[lang as Lang] ?? LANG_TOKEN.en;\n const host = document.createElement('div');\n\n host.innerHTML = `\n <div id=\"${INLINE_CODE_ID}\" class=\"${INLINE_CODE_CLASS}\"\n role=\"dialog\" aria-live=\"polite\" aria-modal=\"true\">\n ${tooltipText}\n </div>\n `;\n\n tooltip = host.firstElementChild as HTMLElement;\n pageContent.appendChild(tooltip);\n }\n\n return tooltip;\n}\n\nexport function openTooltip(target: HTMLElement) {\n const tooltip = createTooltip();\n\n if (!target.matches(INLINE_CODE) || !tooltip) {\n return;\n }\n\n tooltip.setAttribute('inline-id', target.getAttribute('id') || '');\n setTooltipAriaAttributes(tooltip, target);\n setTooltipPosition(tooltip, target);\n\n // In order not to get rid of the smooth appearance effect, I had to do this\n if (tooltip.classList.contains(OPEN_CLASS)) {\n tooltip.classList.remove(OPEN_CLASS);\n requestAnimationFrame(() => {\n tooltip.classList.add(OPEN_CLASS);\n });\n } else {\n tooltip.classList.add(OPEN_CLASS);\n }\n\n return tooltip;\n}\n\nexport function closeTooltip(target: HTMLElement) {\n checkTimerAndClear();\n closeTooltipFn(target);\n}\n\nexport function tooltipWorker(target: HTMLElement) {\n const definition = openTooltip(target);\n\n if (!definition) {\n return;\n }\n checkTimerAndClear();\n timer = setTimeout(() => {\n closeTooltip(definition);\n timer = null;\n }, 1000);\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from '../utils';\n\nimport {INLINE_CODE, OPEN_CLASS} from './constant';\nimport {\n closeTooltip,\n getInlineCodeByTooltip,\n getTooltipElement,\n setTooltipPosition,\n tooltipWorker,\n} from './utils';\n\nexport function inlineCopyFn(target: HTMLElement) {\n const innerText = target.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(target);\n });\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n const inline = target.matches(INLINE_CODE);\n\n if (isCustom(event) || !inline) {\n return;\n }\n\n inlineCopyFn(target);\n });\n\n document.addEventListener('keydown', (event) => {\n if (event.key === 'Enter' && document.activeElement) {\n const activeElement = document.activeElement as HTMLElement;\n const classInlineCode = INLINE_CODE.replace('.', '');\n\n if (!activeElement.classList.contains(classInlineCode)) {\n return;\n }\n\n const innerText = activeElement.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(activeElement);\n });\n }\n\n const inlineTooltip = getTooltipElement();\n\n if (event.key === 'Escape' && inlineTooltip) {\n closeTooltip(inlineTooltip);\n getInlineCodeByTooltip(inlineTooltip)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const inlineTooltip = getTooltipElement();\n if (!inlineTooltip) {\n return;\n }\n\n const inlineId = inlineTooltip.getAttribute('inline-id') || '';\n const inlineCodeElement = document.getElementById(inlineId);\n\n if (!inlineCodeElement) {\n inlineTooltip.classList.toggle(OPEN_CLASS);\n return;\n }\n\n setTooltipPosition(inlineTooltip, inlineCodeElement);\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAoBA,eAASA,aAAY,KAAK;AACxB,YAAI,WAAW,OAAO,QAAQ,YAAY,QAAQ,IAAI,QAAQ;AAE9D,eAAO,WAAW,uBAAuB,IAAI,IAAI,QAAQ,IAAI;AAAA,MAC/D;AAEA,eAAS,uBAAuB,MAAM;AACpC,YAAI,OAAO,QAAQ,IAAI;AAEvB,YAAI,aAAa,IAAI,GAAG;AACtB,iBAAO,uBAAuB,KAAK,IAAI;AAAA,QACzC;AAEA,eAAO;AAAA,MACT;AAEA,eAAS,QAAQ,MAAM;AACrB,YAAI,KAAK,cAAc,MAAM;AAC3B,iBAAO,QAAQ,KAAK,UAAU;AAAA,QAChC;AAEA,eAAO;AAAA,MACT;AAEA,eAAS,aAAa,MAAM;AAC1B,eAAO,KAAK,aAAa,wBAAwB,KAAK,YAAY,SAAS;AAAA,MAC7E;AAEA,UAAI,OAAO,WAAW,YAAY,OAAO,SAAS;AAChD,eAAO,UAAUA;AAAA,MACnB;AAAA;AAAA;;;AClDA,sCAAwB;AAExB,MAAI,OAAO,aAAa,aAAa;AAEjC,KAAC,SAAU,GAAG;AACV,YAAM,UACF,EAAE,WACF,EAAE,mBACF,EAAE,yBACF,EAAE,sBACF,EAAE,qBACF,EAAE;AAEN,UAAI,SAAS;AACT,UAAE,UAAU,EAAE,kBAAkB;AAAA,MACpC,OAAO;AACH,UAAE,UAAU,EAAE,kBAAkB,SAASC,SAAQ,UAAU;AACvD,gBAAM,WAAW,EAAE,cAAc,EAAE,YAAY,IAAI,8BAAAC,QAAY,K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Q,sBAAsB,GAAG;AAC5D;AAAA,MACJ;AAEA,YAAM,OAAO,OAAO,aAAa,WAAW,KAAK;AACjD,YAAM,OAAO,IAAI,IAAI,MAAM,OAAO,SAAS,IAAI,EAAE,SAAS;AAE1D,sBAAgB,IAAI;AAAA,IACxB,CAAC;AAAA,EACL;;;ACfO,MAAM,cAAc;AAEpB,MAAM,iBAAiB;AAEvB,MAAM,oBAAoB;AAE1B,MAAM,aAAa;AAEnB,MAAM,aAAmC;AAAA,IAC5C,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EACR;;;AC3BO,MAAM,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,SAAS;AAAA,EACb;AACO,MAAM,YAAY;AAClB,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,EAAE,IAAI,MAAM;
|
|
4
|
+
"sourcesContent": ["'use strict';\n\n// Node getRootNode(optional GetRootNodeOptions options);\n\n/**\n * Returns the context object\u2019s shadow-including root if options\u2019s composed is true.\n * Returns the context object\u2019s root otherwise.\n *\n * The root of an object is itself, if its parent is null, or else it is the root of its parent.\n *\n * The shadow-including root of an object is its root\u2019s host\u2019s shadow-including root,\n * if the object\u2019s root is a shadow root, and its root otherwise.\n *\n * https://dom.spec.whatwg.org/#dom-node-getrootnode\n *\n * @memberof Node.prototype\n * @param {!Object} [opt = {}] - Options.\n * @param {!boolean} [opt.composed] - See above description.\n * @returns {!Node} The root node.\n */\nfunction getRootNode(opt) {\n var composed = typeof opt === 'object' && Boolean(opt.composed);\n\n return composed ? getShadowIncludingRoot(this) : getRoot(this);\n}\n\nfunction getShadowIncludingRoot(node) {\n var root = getRoot(node);\n\n if (isShadowRoot(root)) {\n return getShadowIncludingRoot(root.host);\n }\n\n return root;\n}\n\nfunction getRoot(node) {\n if (node.parentNode != null) {\n return getRoot(node.parentNode);\n }\n\n return node;\n}\n\nfunction isShadowRoot(node) {\n return node.nodeName === '#document-fragment' && node.constructor.name === 'ShadowRoot';\n}\n\nif (typeof module === 'object' && module.exports) {\n module.exports = getRootNode;\n}\n", "import getRootNode from 'get-root-node-polyfill';\n\nif (typeof document !== 'undefined') {\n // matches polyfill for old edge\n (function (e) {\n const matches =\n e.matches ||\n e.matchesSelector ||\n e.webkitMatchesSelector ||\n e.mozMatchesSelector ||\n e.msMatchesSelector ||\n e.oMatchesSelector;\n\n if (matches) {\n e.matches = e.matchesSelector = matches;\n } else {\n e.matches = e.matchesSelector = function matches(selector) {\n const rootNode = e.getRootNode ? e.getRootNode() : getRootNode.call(e);\n const matches = rootNode.querySelectorAll(selector);\n const th = this;\n return Array.prototype.some.call(matches, (e) => {\n return e === th;\n });\n };\n }\n // eslint-disable-next-line no-undef\n })(Element.prototype);\n}\n", "export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst COPY_BUTTON_SELECTOR = '.yfm-clipboard-button';\nconst WRAP_BUTTON_SELECTOR = '.yfm-wrapping-button';\n\nfunction notifySuccess(svgButton: HTMLElement | null) {\n if (!svgButton) {\n return;\n }\n\n const id = svgButton.getAttribute('data-animation');\n\n // @ts-expect-error\n const icon = svgButton.getRootNode().getElementById(`visibileAnimation-${id}`);\n\n if (!icon) {\n return;\n }\n\n icon.beginElement();\n}\n\nfunction buttonCopyFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n // Get all text nodes and filter out line numbers\n const textContent = Array.from(code.childNodes)\n .filter((node) => {\n // Skip line number spans\n if (node instanceof HTMLElement && node.classList.contains('yfm-line-number')) {\n return false;\n }\n return true;\n })\n .map((node) => node.textContent)\n .join('');\n\n copyToClipboard(textContent.trim()).then(() => {\n notifySuccess(container.querySelector('.yfm-clipboard-icon'));\n\n setTimeout(() => target.blur(), 1500);\n });\n}\n\nfunction buttonWrapFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n code.classList.toggle('wrap');\n\n setTimeout(() => target.blur(), 500);\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (isCustom(event)) {\n return;\n }\n\n const target = getEventTarget(event) as HTMLElement;\n\n if (target.matches(COPY_BUTTON_SELECTOR)) {\n buttonCopyFn(target);\n } else if (target.matches(WRAP_BUTTON_SELECTOR)) {\n buttonWrapFn(target);\n }\n });\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst ANCHOR_BUTTON_SELECTOR = '.yfm-clipboard-anchor';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n if (isCustom(event) || !target.matches(ANCHOR_BUTTON_SELECTOR)) {\n return;\n }\n\n const href = target.getAttribute('data-href') || '';\n const link = new URL(href, window.location.href).toString();\n\n copyToClipboard(link);\n });\n}\n", "import type {Lang} from 'src/transform/typings';\n\nexport const INLINE_CODE = '.yfm-clipboard-inline-code';\n\nexport const INLINE_CODE_ID = 'tooltip_inline_clipboard_dialog';\n\nexport const INLINE_CODE_CLASS = 'yfm inline_code_tooltip';\n\nexport const OPEN_CLASS = 'open';\n\nexport const LANG_TOKEN: Record<Lang, string> = {\n ru: '\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u043E',\n en: 'Copied',\n ar: '\u062A\u0645 \u0627\u0644\u0646\u0633\u062E',\n cs: 'Zkop\u00EDrov\u00E1no',\n fr: 'Copi\u00E9',\n es: 'Copiado',\n he: '\u05D4\u05D5\u05E2\u05EA\u05E7',\n bg: '\u041A\u043E\u043F\u0438\u0440\u0430\u043D\u043E',\n et: 'Kopeeritud',\n el: '\u0391\u03BD\u03C4\u03B9\u03B3\u03C1\u03AC\u03C6\u03B7\u03BA\u03B5',\n pt: 'Copiado',\n zh: '\u5DF2\u590D\u5236',\n 'zh-tw': '\u5DF2\u8907\u88FD',\n kk: '\u041A\u04E9\u0448\u0456\u0440\u0456\u043B\u0434\u0456',\n tr: 'Kopyaland\u0131',\n uz: 'Nusxalandi',\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionId = `${termKey}_element`;\n\n // Check if term is in modal window\n const isInModal = target.closest('.wide-container');\n\n let definitionElement: HTMLElement | null;\n\n if (isInModal) {\n // Find definition in modal window\n const modalContent = target.closest('.wide-content');\n if (!modalContent) {\n return;\n }\n definitionElement = modalContent.querySelector(`[id=\"${definitionId}\"]`) as HTMLElement;\n } else {\n // Find definition in normal document\n definitionElement = document.getElementById(definitionId);\n }\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n if (!termId) {\n return null;\n }\n\n // Check if definition is in modal window\n const isInModal = definition.closest('.wide-container');\n\n if (isInModal) {\n // Find term in modal window\n const modalContent = definition.closest('.wide-content');\n if (!modalContent) {\n return null;\n }\n return modalContent.querySelector(`[id=\"${termId}\"]`) as HTMLElement;\n }\n\n // Find term in normal document\n return document.getElementById(termId);\n}\n", "import type {Lang} from 'src/transform/typings';\n\nimport {getCoords} from '../term/utils';\n\nimport {INLINE_CODE, INLINE_CODE_CLASS, INLINE_CODE_ID, LANG_TOKEN, OPEN_CLASS} from './constant';\n\nexport let timer: ReturnType<typeof setTimeout> | null = null;\n\nlet isListenerNeeded = true;\n\nexport function getTooltipElement(): HTMLElement | null {\n return document.getElementById(INLINE_CODE_ID);\n}\n\nfunction setTooltipAriaAttributes(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const ariaLive = targetElement.getAttribute('aria-live') || 'polite';\n tooltipElement?.setAttribute('aria-live', ariaLive);\n tooltipElement?.setAttribute('aria-modal', 'true');\n}\n\nfunction checkTimerAndClear() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n}\n\nfunction tooltipParentElement(target: HTMLElement | null) {\n if (!target) {\n return null;\n }\n\n const closestScrollableParent = target.closest('table') || target.closest('code');\n\n return closestScrollableParent || target.parentElement;\n}\n\nfunction tooltipOnResize() {\n const openedDefinition = getTooltipElement();\n\n if (!openedDefinition) {\n return;\n }\n const inlineId = openedDefinition.getAttribute('inline-id') || '';\n const targetElement = document.getElementById(inlineId);\n\n if (!targetElement) {\n return;\n }\n\n setTooltipPosition(openedDefinition, targetElement);\n}\n\nexport function setTooltipPosition(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const {\n x: inlineX,\n y: inlineY,\n right: inlineRight,\n left: inlineLeft,\n width: inlineWidth,\n height: inlineHeight,\n } = targetElement.getBoundingClientRect();\n\n const tooltipParent = tooltipParentElement(targetElement);\n\n if (!tooltipParent) {\n return;\n }\n\n const {right: tooltipParentRight, left: tooltipParentLeft} =\n tooltipParent.getBoundingClientRect();\n\n if ((tooltipParentRight < inlineLeft || tooltipParentLeft > inlineRight) && !isListenerNeeded) {\n closeTooltip(tooltipElement);\n return;\n }\n\n if (isListenerNeeded && tooltipParent) {\n tooltipParent.addEventListener('scroll', tooltipOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(tooltipElement.getAttribute('relativeX'));\n const relativeY = Number(tooltipElement.getAttribute('relativeY'));\n\n if (relativeX === inlineX && relativeY === inlineY) {\n return;\n }\n\n tooltipElement.setAttribute('relativeX', String(inlineX));\n tooltipElement.setAttribute('relativeY', String(inlineY));\n\n const offsetTop = inlineHeight + 5;\n const definitionParent = tooltipElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = tooltipElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(targetElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - inlineWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(targetElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n tooltipElement.style.top =\n Number(getCoords(targetElement).top + offsetTop - customHeaderTop) + 'px';\n tooltipElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nexport function getInlineCodeByTooltip(definition: HTMLElement) {\n const inlineId = definition.getAttribute('inline-id');\n\n return inlineId ? document.getElementById(inlineId) : null;\n}\n\nfunction closeTooltipFn(definition: HTMLElement) {\n definition.classList.remove(OPEN_CLASS);\n const inline = getInlineCodeByTooltip(definition);\n const inlineCodepParent = tooltipParentElement(inline);\n const tooltipParent = tooltipParentElement(definition);\n\n definition.removeAttribute('inline-id');\n\n if (!inlineCodepParent || !tooltipParent) {\n return;\n }\n\n tooltipParent.removeChild(definition);\n inlineCodepParent.removeEventListener('scroll', tooltipOnResize);\n isListenerNeeded = true;\n}\n\nfunction createTooltip() {\n let tooltip = getTooltipElement();\n\n if (!tooltip) {\n const pageContent = document.querySelector('.dc-doc-page__content') || document.body;\n const lang = document.documentElement.lang || 'en';\n const tooltipText = LANG_TOKEN[lang as Lang] ?? LANG_TOKEN.en;\n const host = document.createElement('div');\n\n host.innerHTML = `\n <div id=\"${INLINE_CODE_ID}\" class=\"${INLINE_CODE_CLASS}\"\n role=\"dialog\" aria-live=\"polite\" aria-modal=\"true\">\n ${tooltipText}\n </div>\n `;\n\n tooltip = host.firstElementChild as HTMLElement;\n pageContent.appendChild(tooltip);\n }\n\n return tooltip;\n}\n\nexport function openTooltip(target: HTMLElement) {\n const tooltip = createTooltip();\n\n if (!target.matches(INLINE_CODE) || !tooltip) {\n return;\n }\n\n tooltip.setAttribute('inline-id', target.getAttribute('id') || '');\n setTooltipAriaAttributes(tooltip, target);\n setTooltipPosition(tooltip, target);\n\n // In order not to get rid of the smooth appearance effect, I had to do this\n if (tooltip.classList.contains(OPEN_CLASS)) {\n tooltip.classList.remove(OPEN_CLASS);\n requestAnimationFrame(() => {\n tooltip.classList.add(OPEN_CLASS);\n });\n } else {\n tooltip.classList.add(OPEN_CLASS);\n }\n\n return tooltip;\n}\n\nexport function closeTooltip(target: HTMLElement) {\n checkTimerAndClear();\n closeTooltipFn(target);\n}\n\nexport function tooltipWorker(target: HTMLElement) {\n const definition = openTooltip(target);\n\n if (!definition) {\n return;\n }\n checkTimerAndClear();\n timer = setTimeout(() => {\n closeTooltip(definition);\n timer = null;\n }, 1000);\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from '../utils';\n\nimport {INLINE_CODE, OPEN_CLASS} from './constant';\nimport {\n closeTooltip,\n getInlineCodeByTooltip,\n getTooltipElement,\n setTooltipPosition,\n tooltipWorker,\n} from './utils';\n\nexport function inlineCopyFn(target: HTMLElement) {\n const innerText = target.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(target);\n });\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n const inline = target.matches(INLINE_CODE);\n\n if (isCustom(event) || !inline) {\n return;\n }\n\n inlineCopyFn(target);\n });\n\n document.addEventListener('keydown', (event) => {\n if (event.key === 'Enter' && document.activeElement) {\n const activeElement = document.activeElement as HTMLElement;\n const classInlineCode = INLINE_CODE.replace('.', '');\n\n if (!activeElement.classList.contains(classInlineCode)) {\n return;\n }\n\n const innerText = activeElement.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(activeElement);\n });\n }\n\n const inlineTooltip = getTooltipElement();\n\n if (event.key === 'Escape' && inlineTooltip) {\n closeTooltip(inlineTooltip);\n getInlineCodeByTooltip(inlineTooltip)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const inlineTooltip = getTooltipElement();\n if (!inlineTooltip) {\n return;\n }\n\n const inlineId = inlineTooltip.getAttribute('inline-id') || '';\n const inlineCodeElement = document.getElementById(inlineId);\n\n if (!inlineCodeElement) {\n inlineTooltip.classList.toggle(OPEN_CLASS);\n return;\n }\n\n setTooltipPosition(inlineTooltip, inlineCodeElement);\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAoBA,eAASA,aAAY,KAAK;AACxB,YAAI,WAAW,OAAO,QAAQ,YAAY,QAAQ,IAAI,QAAQ;AAE9D,eAAO,WAAW,uBAAuB,IAAI,IAAI,QAAQ,IAAI;AAAA,MAC/D;AAEA,eAAS,uBAAuB,MAAM;AACpC,YAAI,OAAO,QAAQ,IAAI;AAEvB,YAAI,aAAa,IAAI,GAAG;AACtB,iBAAO,uBAAuB,KAAK,IAAI;AAAA,QACzC;AAEA,eAAO;AAAA,MACT;AAEA,eAAS,QAAQ,MAAM;AACrB,YAAI,KAAK,cAAc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AAK,CAAC,QAAQ;AAC5B;AAAA,MACJ;AAEA,mBAAa,MAAM;AAAA,IACvB,CAAC;AAED,aAAS,iBAAiB,WAAW,CAAC,UAAU;AApCpD;AAqCQ,UAAI,MAAM,QAAQ,WAAW,SAAS,eAAe;AACjD,cAAM,gBAAgB,SAAS;AAC/B,cAAM,kBAAkB,YAAY,QAAQ,KAAK,EAAE;AAEnD,YAAI,CAAC,cAAc,UAAU,SAAS,eAAe,GAAG;AACpD;AAAA,QACJ;AAEA,cAAM,YAAY,cAAc;AAEhC,YAAI,CAAC,WAAW;AACZ;AAAA,QACJ;AAEA,wBAAgB,SAAS,EAAE,KAAK,MAAM;AAClC,wBAAc,aAAa;AAAA,QAC/B,CAAC;AAAA,MACL;AAEA,YAAM,gBAAgB,kBAAkB;AAExC,UAAI,MAAM,QAAQ,YAAY,eAAe;AACzC,qBAAa,aAAa;AAC1B,qCAAuB,aAAa,MAApC,mBAAuC;AAAA,MAC3C;AAAA,IACJ,CAAC;AAED,WAAO,iBAAiB,UAAU,MAAM;AACpC,YAAM,gBAAgB,kBAAkB;AACxC,UAAI,CAAC,eAAe;AAChB;AAAA,MACJ;AAEA,YAAM,WAAW,cAAc,aAAa,WAAW,KAAK;AAC5D,YAAM,oBAAoB,SAAS,eAAe,QAAQ;AAE1D,UAAI,CAAC,mBAAmB;AACpB,sBAAc,UAAU,OAAO,UAAU;AACzC;AAAA,MACJ;AAEA,yBAAmB,eAAe,iBAAiB;AAAA,IACvD,CAAC;AAAA,EACL;",
|
|
6
6
|
"names": ["getRootNode", "matches", "getRootNode", "e"]
|
|
7
7
|
}
|
package/dist/js/base.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../node_modules/get-root-node-polyfill/index.js", "../../src/js/polyfill.js", "../../src/js/utils.ts", "../../src/js/code.ts", "../../src/js/anchor.ts", "../../src/js/inline-code/constant.ts", "../../src/js/term/utils.ts", "../../src/js/inline-code/utils.ts", "../../src/js/inline-code/index.ts"],
|
|
4
|
-
"sourcesContent": ["'use strict';\n\n// Node getRootNode(optional GetRootNodeOptions options);\n\n/**\n * Returns the context object\u2019s shadow-including root if options\u2019s composed is true.\n * Returns the context object\u2019s root otherwise.\n *\n * The root of an object is itself, if its parent is null, or else it is the root of its parent.\n *\n * The shadow-including root of an object is its root\u2019s host\u2019s shadow-including root,\n * if the object\u2019s root is a shadow root, and its root otherwise.\n *\n * https://dom.spec.whatwg.org/#dom-node-getrootnode\n *\n * @memberof Node.prototype\n * @param {!Object} [opt = {}] - Options.\n * @param {!boolean} [opt.composed] - See above description.\n * @returns {!Node} The root node.\n */\nfunction getRootNode(opt) {\n var composed = typeof opt === 'object' && Boolean(opt.composed);\n\n return composed ? getShadowIncludingRoot(this) : getRoot(this);\n}\n\nfunction getShadowIncludingRoot(node) {\n var root = getRoot(node);\n\n if (isShadowRoot(root)) {\n return getShadowIncludingRoot(root.host);\n }\n\n return root;\n}\n\nfunction getRoot(node) {\n if (node.parentNode != null) {\n return getRoot(node.parentNode);\n }\n\n return node;\n}\n\nfunction isShadowRoot(node) {\n return node.nodeName === '#document-fragment' && node.constructor.name === 'ShadowRoot';\n}\n\nif (typeof module === 'object' && module.exports) {\n module.exports = getRootNode;\n}\n", "import getRootNode from 'get-root-node-polyfill';\n\nif (typeof document !== 'undefined') {\n // matches polyfill for old edge\n (function (e) {\n const matches =\n e.matches ||\n e.matchesSelector ||\n e.webkitMatchesSelector ||\n e.mozMatchesSelector ||\n e.msMatchesSelector ||\n e.oMatchesSelector;\n\n if (matches) {\n e.matches = e.matchesSelector = matches;\n } else {\n e.matches = e.matchesSelector = function matches(selector) {\n const rootNode = e.getRootNode ? e.getRootNode() : getRootNode.call(e);\n const matches = rootNode.querySelectorAll(selector);\n const th = this;\n return Array.prototype.some.call(matches, (e) => {\n return e === th;\n });\n };\n }\n // eslint-disable-next-line no-undef\n })(Element.prototype);\n}\n", "export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst COPY_BUTTON_SELECTOR = '.yfm-clipboard-button';\nconst WRAP_BUTTON_SELECTOR = '.yfm-wrapping-button';\n\nfunction notifySuccess(svgButton: HTMLElement | null) {\n if (!svgButton) {\n return;\n }\n\n const id = svgButton.getAttribute('data-animation');\n\n // @ts-expect-error\n const icon = svgButton.getRootNode().getElementById(`visibileAnimation-${id}`);\n\n if (!icon) {\n return;\n }\n\n icon.beginElement();\n}\n\nfunction buttonCopyFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n // Get all text nodes and filter out line numbers\n const textContent = Array.from(code.childNodes)\n .filter((node) => {\n // Skip line number spans\n if (node instanceof HTMLElement && node.classList.contains('yfm-line-number')) {\n return false;\n }\n return true;\n })\n .map((node) => node.textContent)\n .join('');\n\n copyToClipboard(textContent.trim()).then(() => {\n notifySuccess(container.querySelector('.yfm-clipboard-icon'));\n\n setTimeout(() => target.blur(), 1500);\n });\n}\n\nfunction buttonWrapFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n code.classList.toggle('wrap');\n\n setTimeout(() => target.blur(), 500);\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (isCustom(event)) {\n return;\n }\n\n const target = getEventTarget(event) as HTMLElement;\n\n if (target.matches(COPY_BUTTON_SELECTOR)) {\n buttonCopyFn(target);\n } else if (target.matches(WRAP_BUTTON_SELECTOR)) {\n buttonWrapFn(target);\n }\n });\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst ANCHOR_BUTTON_SELECTOR = '.yfm-clipboard-anchor';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n if (isCustom(event) || !target.matches(ANCHOR_BUTTON_SELECTOR)) {\n return;\n }\n\n const href = target.getAttribute('data-href') || '';\n const link = new URL(href, window.location.href).toString();\n\n copyToClipboard(link);\n });\n}\n", "import type {Lang} from 'src/transform/typings';\n\nexport const INLINE_CODE = '.yfm-clipboard-inline-code';\n\nexport const INLINE_CODE_ID = 'tooltip_inline_clipboard_dialog';\n\nexport const INLINE_CODE_CLASS = 'yfm inline_code_tooltip';\n\nexport const OPEN_CLASS = 'open';\n\nexport const LANG_TOKEN: Record<Lang, string> = {\n ru: '\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u043E',\n en: 'Copied',\n ar: '\u062A\u0645 \u0627\u0644\u0646\u0633\u062E',\n cs: 'Zkop\u00EDrov\u00E1no',\n fr: 'Copi\u00E9',\n es: 'Copiado',\n he: '\u05D4\u05D5\u05E2\u05EA\u05E7',\n bg: '\u041A\u043E\u043F\u0438\u0440\u0430\u043D\u043E',\n et: 'Kopeeritud',\n el: '\u0391\u03BD\u03C4\u03B9\u03B3\u03C1\u03AC\u03C6\u03B7\u03BA\u03B5',\n pt: 'Copiado',\n zh: '\u5DF2\u590D\u5236',\n 'zh-tw': '\u5DF2\u8907\u88FD',\n kk: '\u041A\u04E9\u0448\u0456\u0440\u0456\u043B\u0434\u0456',\n tr: 'Kopyaland\u0131',\n uz: 'Nusxalandi',\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionElement = document.getElementById(termKey + '_element');\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n return termId ? document.getElementById(termId) : null;\n}\n", "import type {Lang} from 'src/transform/typings';\n\nimport {getCoords} from '../term/utils';\n\nimport {INLINE_CODE, INLINE_CODE_CLASS, INLINE_CODE_ID, LANG_TOKEN, OPEN_CLASS} from './constant';\n\nexport let timer: ReturnType<typeof setTimeout> | null = null;\n\nlet isListenerNeeded = true;\n\nexport function getTooltipElement(): HTMLElement | null {\n return document.getElementById(INLINE_CODE_ID);\n}\n\nfunction setTooltipAriaAttributes(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const ariaLive = targetElement.getAttribute('aria-live') || 'polite';\n tooltipElement?.setAttribute('aria-live', ariaLive);\n tooltipElement?.setAttribute('aria-modal', 'true');\n}\n\nfunction checkTimerAndClear() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n}\n\nfunction tooltipParentElement(target: HTMLElement | null) {\n if (!target) {\n return null;\n }\n\n const closestScrollableParent = target.closest('table') || target.closest('code');\n\n return closestScrollableParent || target.parentElement;\n}\n\nfunction tooltipOnResize() {\n const openedDefinition = getTooltipElement();\n\n if (!openedDefinition) {\n return;\n }\n const inlineId = openedDefinition.getAttribute('inline-id') || '';\n const targetElement = document.getElementById(inlineId);\n\n if (!targetElement) {\n return;\n }\n\n setTooltipPosition(openedDefinition, targetElement);\n}\n\nexport function setTooltipPosition(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const {\n x: inlineX,\n y: inlineY,\n right: inlineRight,\n left: inlineLeft,\n width: inlineWidth,\n height: inlineHeight,\n } = targetElement.getBoundingClientRect();\n\n const tooltipParent = tooltipParentElement(targetElement);\n\n if (!tooltipParent) {\n return;\n }\n\n const {right: tooltipParentRight, left: tooltipParentLeft} =\n tooltipParent.getBoundingClientRect();\n\n if ((tooltipParentRight < inlineLeft || tooltipParentLeft > inlineRight) && !isListenerNeeded) {\n closeTooltip(tooltipElement);\n return;\n }\n\n if (isListenerNeeded && tooltipParent) {\n tooltipParent.addEventListener('scroll', tooltipOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(tooltipElement.getAttribute('relativeX'));\n const relativeY = Number(tooltipElement.getAttribute('relativeY'));\n\n if (relativeX === inlineX && relativeY === inlineY) {\n return;\n }\n\n tooltipElement.setAttribute('relativeX', String(inlineX));\n tooltipElement.setAttribute('relativeY', String(inlineY));\n\n const offsetTop = inlineHeight + 5;\n const definitionParent = tooltipElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = tooltipElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(targetElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - inlineWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(targetElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n tooltipElement.style.top =\n Number(getCoords(targetElement).top + offsetTop - customHeaderTop) + 'px';\n tooltipElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nexport function getInlineCodeByTooltip(definition: HTMLElement) {\n const inlineId = definition.getAttribute('inline-id');\n\n return inlineId ? document.getElementById(inlineId) : null;\n}\n\nfunction closeTooltipFn(definition: HTMLElement) {\n definition.classList.remove(OPEN_CLASS);\n const inline = getInlineCodeByTooltip(definition);\n const inlineCodepParent = tooltipParentElement(inline);\n const tooltipParent = tooltipParentElement(definition);\n\n definition.removeAttribute('inline-id');\n\n if (!inlineCodepParent || !tooltipParent) {\n return;\n }\n\n tooltipParent.removeChild(definition);\n inlineCodepParent.removeEventListener('scroll', tooltipOnResize);\n isListenerNeeded = true;\n}\n\nfunction createTooltip() {\n let tooltip = getTooltipElement();\n\n if (!tooltip) {\n const pageContent = document.querySelector('.dc-doc-page__content') || document.body;\n const lang = document.documentElement.lang || 'en';\n const tooltipText = LANG_TOKEN[lang as Lang] ?? LANG_TOKEN.en;\n const host = document.createElement('div');\n\n host.innerHTML = `\n <div id=\"${INLINE_CODE_ID}\" class=\"${INLINE_CODE_CLASS}\"\n role=\"dialog\" aria-live=\"polite\" aria-modal=\"true\">\n ${tooltipText}\n </div>\n `;\n\n tooltip = host.firstElementChild as HTMLElement;\n pageContent.appendChild(tooltip);\n }\n\n return tooltip;\n}\n\nexport function openTooltip(target: HTMLElement) {\n const tooltip = createTooltip();\n\n if (!target.matches(INLINE_CODE) || !tooltip) {\n return;\n }\n\n tooltip.setAttribute('inline-id', target.getAttribute('id') || '');\n setTooltipAriaAttributes(tooltip, target);\n setTooltipPosition(tooltip, target);\n\n // In order not to get rid of the smooth appearance effect, I had to do this\n if (tooltip.classList.contains(OPEN_CLASS)) {\n tooltip.classList.remove(OPEN_CLASS);\n requestAnimationFrame(() => {\n tooltip.classList.add(OPEN_CLASS);\n });\n } else {\n tooltip.classList.add(OPEN_CLASS);\n }\n\n return tooltip;\n}\n\nexport function closeTooltip(target: HTMLElement) {\n checkTimerAndClear();\n closeTooltipFn(target);\n}\n\nexport function tooltipWorker(target: HTMLElement) {\n const definition = openTooltip(target);\n\n if (!definition) {\n return;\n }\n checkTimerAndClear();\n timer = setTimeout(() => {\n closeTooltip(definition);\n timer = null;\n }, 1000);\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from '../utils';\n\nimport {INLINE_CODE, OPEN_CLASS} from './constant';\nimport {\n closeTooltip,\n getInlineCodeByTooltip,\n getTooltipElement,\n setTooltipPosition,\n tooltipWorker,\n} from './utils';\n\nexport function inlineCopyFn(target: HTMLElement) {\n const innerText = target.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(target);\n });\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n const inline = target.matches(INLINE_CODE);\n\n if (isCustom(event) || !inline) {\n return;\n }\n\n inlineCopyFn(target);\n });\n\n document.addEventListener('keydown', (event) => {\n if (event.key === 'Enter' && document.activeElement) {\n const activeElement = document.activeElement as HTMLElement;\n const classInlineCode = INLINE_CODE.replace('.', '');\n\n if (!activeElement.classList.contains(classInlineCode)) {\n return;\n }\n\n const innerText = activeElement.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(activeElement);\n });\n }\n\n const inlineTooltip = getTooltipElement();\n\n if (event.key === 'Escape' && inlineTooltip) {\n closeTooltip(inlineTooltip);\n getInlineCodeByTooltip(inlineTooltip)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const inlineTooltip = getTooltipElement();\n if (!inlineTooltip) {\n return;\n }\n\n const inlineId = inlineTooltip.getAttribute('inline-id') || '';\n const inlineCodeElement = document.getElementById(inlineId);\n\n if (!inlineCodeElement) {\n inlineTooltip.classList.toggle(OPEN_CLASS);\n return;\n }\n\n setTooltipPosition(inlineTooltip, inlineCodeElement);\n });\n}\n"],
|
|
5
|
-
"mappings": "giBAAAA,EAAAC,EAAA,CAAA,+CAAAC,EAAAC,EAAA,CAAA,aAoBA,SAASC,EAAYC,EAAK,CACxB,IAAIC,EAAW,OAAOD,GAAQ,UAAY,EAAQA,EAAI,SAEtD,OAAOC,EAAWC,EAAuB,IAAI,EAAIC,EAAQ,IAAI,CAC/D,CAEA,SAASD,EAAuBE,EAAM,CACpC,IAAIC,EAAOF,EAAQC,CAAI,EAEvB,OAAIE,EAAaD,CAAI,EACZH,EAAuBG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G,EAAO,QAAQI,CAAoB,EACnCM,EAAaV,CAAM,EACZA,EAAO,QAAQK,CAAoB,GAC1CU,EAAaf,CAAM,CAE3B,CAAC,ECvEL,IAAMgB,EAAyB,wBAE3B,OAAO,UAAa,aACpB,SAAS,iBAAiB,QAAUnB,GAAU,CAC1C,IAAMG,EAASJ,EAAeC,CAAK,EAEnC,GAAIE,EAASF,CAAK,GAAK,CAACG,EAAO,QAAQgB,CAAsB,EACzD,OAGJ,IAAMC,EAAOjB,EAAO,aAAa,WAAW,GAAK,GAC3CkB,EAAO,IAAI,IAAID,EAAM,OAAO,SAAS,IAAI,EAAE,SAAS,EAE1DhB,EAAgBiB,CAAI,CACxB,CAAC,ECdE,IAAMC,EAAc,6BAEdC,EAAiB,kCAEjBC,EAAoB,0BAEpBC,EAAa,OAEbC,EAAmC,CAC5C,GAAI,qEACJ,GAAI,SACJ,GAAI,8CACJ,GAAI,oBACJ,GAAI,WACJ,GAAI,UACJ,GAAI,iCACJ,GAAI,mDACJ,GAAI,aACJ,GAAI,qEACJ,GAAI,UACJ,GAAI,qBACJ,QAAS,qBACT,GAAI,yDACJ,GAAI,kBACJ,GAAI,YACR,EC3BaC,EAAW,CACpB,MAAO,uBACP,QAAS,oBACb,EACaC,EAAY,OACZC,GAAsBF,EAAS,QAAQ,QAAQ,MAAO,EAAE,EAAI,IAAMC,
|
|
4
|
+
"sourcesContent": ["'use strict';\n\n// Node getRootNode(optional GetRootNodeOptions options);\n\n/**\n * Returns the context object\u2019s shadow-including root if options\u2019s composed is true.\n * Returns the context object\u2019s root otherwise.\n *\n * The root of an object is itself, if its parent is null, or else it is the root of its parent.\n *\n * The shadow-including root of an object is its root\u2019s host\u2019s shadow-including root,\n * if the object\u2019s root is a shadow root, and its root otherwise.\n *\n * https://dom.spec.whatwg.org/#dom-node-getrootnode\n *\n * @memberof Node.prototype\n * @param {!Object} [opt = {}] - Options.\n * @param {!boolean} [opt.composed] - See above description.\n * @returns {!Node} The root node.\n */\nfunction getRootNode(opt) {\n var composed = typeof opt === 'object' && Boolean(opt.composed);\n\n return composed ? getShadowIncludingRoot(this) : getRoot(this);\n}\n\nfunction getShadowIncludingRoot(node) {\n var root = getRoot(node);\n\n if (isShadowRoot(root)) {\n return getShadowIncludingRoot(root.host);\n }\n\n return root;\n}\n\nfunction getRoot(node) {\n if (node.parentNode != null) {\n return getRoot(node.parentNode);\n }\n\n return node;\n}\n\nfunction isShadowRoot(node) {\n return node.nodeName === '#document-fragment' && node.constructor.name === 'ShadowRoot';\n}\n\nif (typeof module === 'object' && module.exports) {\n module.exports = getRootNode;\n}\n", "import getRootNode from 'get-root-node-polyfill';\n\nif (typeof document !== 'undefined') {\n // matches polyfill for old edge\n (function (e) {\n const matches =\n e.matches ||\n e.matchesSelector ||\n e.webkitMatchesSelector ||\n e.mozMatchesSelector ||\n e.msMatchesSelector ||\n e.oMatchesSelector;\n\n if (matches) {\n e.matches = e.matchesSelector = matches;\n } else {\n e.matches = e.matchesSelector = function matches(selector) {\n const rootNode = e.getRootNode ? e.getRootNode() : getRootNode.call(e);\n const matches = rootNode.querySelectorAll(selector);\n const th = this;\n return Array.prototype.some.call(matches, (e) => {\n return e === th;\n });\n };\n }\n // eslint-disable-next-line no-undef\n })(Element.prototype);\n}\n", "export const getEventTarget = (event: Event) => {\n const path = event.composedPath();\n return Array.isArray(path) && path.length > 0 ? path[0] : event.target;\n};\n\nexport const isCustom = (event: Event) => {\n const target = getEventTarget(event);\n return !target || !(target as HTMLElement).matches;\n};\n\nexport const copyToClipboard = async (text: string) => {\n if (!text) {\n return;\n }\n\n if (navigator.clipboard && typeof navigator.clipboard.writeText) {\n return navigator.clipboard.writeText(text);\n }\n\n const textarea = document.createElement('textarea');\n textarea.setAttribute('style', 'position: absolute; left: 1000%');\n textarea.textContent = text;\n document.body.append(textarea);\n\n textarea.select();\n document.execCommand('copy');\n\n document.body.removeChild(textarea);\n};\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst COPY_BUTTON_SELECTOR = '.yfm-clipboard-button';\nconst WRAP_BUTTON_SELECTOR = '.yfm-wrapping-button';\n\nfunction notifySuccess(svgButton: HTMLElement | null) {\n if (!svgButton) {\n return;\n }\n\n const id = svgButton.getAttribute('data-animation');\n\n // @ts-expect-error\n const icon = svgButton.getRootNode().getElementById(`visibileAnimation-${id}`);\n\n if (!icon) {\n return;\n }\n\n icon.beginElement();\n}\n\nfunction buttonCopyFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n // Get all text nodes and filter out line numbers\n const textContent = Array.from(code.childNodes)\n .filter((node) => {\n // Skip line number spans\n if (node instanceof HTMLElement && node.classList.contains('yfm-line-number')) {\n return false;\n }\n return true;\n })\n .map((node) => node.textContent)\n .join('');\n\n copyToClipboard(textContent.trim()).then(() => {\n notifySuccess(container.querySelector('.yfm-clipboard-icon'));\n\n setTimeout(() => target.blur(), 1500);\n });\n}\n\nfunction buttonWrapFn(target: HTMLElement) {\n const container = target.parentNode?.parentNode;\n const code = container?.querySelector<HTMLElement>('pre code');\n if (!container || !code) {\n return;\n }\n\n code.classList.toggle('wrap');\n\n setTimeout(() => target.blur(), 500);\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n if (isCustom(event)) {\n return;\n }\n\n const target = getEventTarget(event) as HTMLElement;\n\n if (target.matches(COPY_BUTTON_SELECTOR)) {\n buttonCopyFn(target);\n } else if (target.matches(WRAP_BUTTON_SELECTOR)) {\n buttonWrapFn(target);\n }\n });\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from './utils';\n\nconst ANCHOR_BUTTON_SELECTOR = '.yfm-clipboard-anchor';\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n if (isCustom(event) || !target.matches(ANCHOR_BUTTON_SELECTOR)) {\n return;\n }\n\n const href = target.getAttribute('data-href') || '';\n const link = new URL(href, window.location.href).toString();\n\n copyToClipboard(link);\n });\n}\n", "import type {Lang} from 'src/transform/typings';\n\nexport const INLINE_CODE = '.yfm-clipboard-inline-code';\n\nexport const INLINE_CODE_ID = 'tooltip_inline_clipboard_dialog';\n\nexport const INLINE_CODE_CLASS = 'yfm inline_code_tooltip';\n\nexport const OPEN_CLASS = 'open';\n\nexport const LANG_TOKEN: Record<Lang, string> = {\n ru: '\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u043E',\n en: 'Copied',\n ar: '\u062A\u0645 \u0627\u0644\u0646\u0633\u062E',\n cs: 'Zkop\u00EDrov\u00E1no',\n fr: 'Copi\u00E9',\n es: 'Copiado',\n he: '\u05D4\u05D5\u05E2\u05EA\u05E7',\n bg: '\u041A\u043E\u043F\u0438\u0440\u0430\u043D\u043E',\n et: 'Kopeeritud',\n el: '\u0391\u03BD\u03C4\u03B9\u03B3\u03C1\u03AC\u03C6\u03B7\u03BA\u03B5',\n pt: 'Copiado',\n zh: '\u5DF2\u590D\u5236',\n 'zh-tw': '\u5DF2\u8907\u88FD',\n kk: '\u041A\u04E9\u0448\u0456\u0440\u0456\u043B\u0434\u0456',\n tr: 'Kopyaland\u0131',\n uz: 'Nusxalandi',\n};\n", "export const Selector = {\n TITLE: '.yfm .yfm-term_title',\n CONTENT: '.yfm .yfm-term_dfn',\n};\nexport const openClass = 'open';\nexport const openDefinitionClass = Selector.CONTENT.replace(/\\./g, '') + ' ' + openClass;\nlet isListenerNeeded = true;\n\nexport function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {\n const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);\n definitionElement?.setAttribute('term-id', termId);\n}\n\nexport function setDefinitonAriaAttributes(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const ariaLive = termElement.getAttribute('aria-live') || 'polite';\n definitionElement?.setAttribute('aria-live', ariaLive);\n definitionElement?.setAttribute('aria-modal', 'true');\n}\n\nexport function setDefinitionPosition(\n definitionElement: HTMLElement,\n termElement: HTMLElement,\n): void {\n const {\n x: termX,\n y: termY,\n right: termRight,\n left: termLeft,\n width: termWidth,\n height: termHeight,\n } = termElement.getBoundingClientRect();\n\n const termParent = termParentElement(termElement);\n\n if (!termParent) {\n return;\n }\n\n const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();\n\n if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {\n closeDefinition(definitionElement);\n return;\n }\n\n if (isListenerNeeded && termParent) {\n termParent.addEventListener('scroll', termOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(definitionElement.getAttribute('relativeX'));\n const relativeY = Number(definitionElement.getAttribute('relativeY'));\n\n if (relativeX === termX && relativeY === termY) {\n return;\n }\n\n definitionElement.setAttribute('relativeX', String(termX));\n definitionElement.setAttribute('relativeY', String(termY));\n\n const offsetTop = termHeight + 5;\n const definitionParent = definitionElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = definitionElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(termElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(termElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n definitionElement.style.top =\n Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';\n definitionElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nfunction termOnResize() {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n if (!openedDefinition) {\n return;\n }\n const termId = openedDefinition.getAttribute('term-id') || '';\n const termElement = document.getElementById(termId);\n\n if (!termElement) {\n return;\n }\n\n setDefinitionPosition(openedDefinition, termElement);\n}\n\nfunction termParentElement(term: HTMLElement | null) {\n if (!term) {\n return null;\n }\n\n const closestScrollableParent = term.closest('table') || term.closest('code');\n\n return closestScrollableParent || term.parentElement;\n}\n\nexport function openDefinition(target: HTMLElement) {\n const openedDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;\n\n const termId = target.getAttribute('id');\n const termKey = target.getAttribute('term-key');\n const definitionId = `${termKey}_element`;\n\n // Check if term is in modal window\n const isInModal = target.closest('.wide-container');\n\n let definitionElement: HTMLElement | null;\n\n if (isInModal) {\n // Find definition in modal window\n const modalContent = target.closest('.wide-content');\n if (!modalContent) {\n return;\n }\n definitionElement = modalContent.querySelector(`[id=\"${definitionId}\"]`) as HTMLElement;\n } else {\n // Find definition in normal document\n definitionElement = document.getElementById(definitionId);\n }\n\n const isSameTerm = openedDefinition && termId === openedDefinition.getAttribute('term-id');\n if (isSameTerm) {\n closeDefinition(openedDefinition);\n return;\n }\n\n const isTargetDefinitionContent = target.closest(\n [Selector.CONTENT.replace(' ', ''), openClass].join('.'),\n );\n\n if (openedDefinition && !isTargetDefinitionContent) {\n closeDefinition(openedDefinition);\n }\n\n if (!target.matches(Selector.TITLE) || !definitionElement) {\n return;\n }\n\n setDefinitionId(definitionElement, target);\n setDefinitonAriaAttributes(definitionElement, target);\n setDefinitionPosition(definitionElement, target);\n\n definitionElement.classList.toggle(openClass);\n\n trapFocus(definitionElement);\n}\n\nexport function closeDefinition(definition: HTMLElement) {\n definition.classList.remove(openClass);\n const term = getTermByDefinition(definition);\n const termParent = termParentElement(term);\n\n if (!termParent) {\n return;\n }\n\n termParent.removeEventListener('scroll', termOnResize);\n isListenerNeeded = true;\n}\n\nexport function getCoords(elem: HTMLElement) {\n const box = elem.getBoundingClientRect();\n\n const body = document.body;\n const docEl = document.documentElement;\n\n const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;\n const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;\n\n const clientTop = docEl.clientTop || body.clientTop || 0;\n const clientLeft = docEl.clientLeft || body.clientLeft || 0;\n\n const top = box.top + scrollTop - clientTop;\n const left = box.left + scrollLeft - clientLeft;\n\n return {top: Math.round(top), left: Math.round(left)};\n}\n\nexport function trapFocus(element: HTMLElement) {\n const focusableElements = element.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstFocusableElement = focusableElements[0] as HTMLElement;\n const lastFocusableElement = focusableElements[focusableElements.length - 1] as HTMLElement;\n\n if (firstFocusableElement) {\n firstFocusableElement.focus();\n }\n\n element.addEventListener('keydown', function (e) {\n const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n if (!isTabPressed) {\n return;\n }\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n });\n}\n\nexport function getTermByDefinition(definition: HTMLElement) {\n const termId = definition.getAttribute('term-id');\n\n if (!termId) {\n return null;\n }\n\n // Check if definition is in modal window\n const isInModal = definition.closest('.wide-container');\n\n if (isInModal) {\n // Find term in modal window\n const modalContent = definition.closest('.wide-content');\n if (!modalContent) {\n return null;\n }\n return modalContent.querySelector(`[id=\"${termId}\"]`) as HTMLElement;\n }\n\n // Find term in normal document\n return document.getElementById(termId);\n}\n", "import type {Lang} from 'src/transform/typings';\n\nimport {getCoords} from '../term/utils';\n\nimport {INLINE_CODE, INLINE_CODE_CLASS, INLINE_CODE_ID, LANG_TOKEN, OPEN_CLASS} from './constant';\n\nexport let timer: ReturnType<typeof setTimeout> | null = null;\n\nlet isListenerNeeded = true;\n\nexport function getTooltipElement(): HTMLElement | null {\n return document.getElementById(INLINE_CODE_ID);\n}\n\nfunction setTooltipAriaAttributes(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const ariaLive = targetElement.getAttribute('aria-live') || 'polite';\n tooltipElement?.setAttribute('aria-live', ariaLive);\n tooltipElement?.setAttribute('aria-modal', 'true');\n}\n\nfunction checkTimerAndClear() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n}\n\nfunction tooltipParentElement(target: HTMLElement | null) {\n if (!target) {\n return null;\n }\n\n const closestScrollableParent = target.closest('table') || target.closest('code');\n\n return closestScrollableParent || target.parentElement;\n}\n\nfunction tooltipOnResize() {\n const openedDefinition = getTooltipElement();\n\n if (!openedDefinition) {\n return;\n }\n const inlineId = openedDefinition.getAttribute('inline-id') || '';\n const targetElement = document.getElementById(inlineId);\n\n if (!targetElement) {\n return;\n }\n\n setTooltipPosition(openedDefinition, targetElement);\n}\n\nexport function setTooltipPosition(tooltipElement: HTMLElement, targetElement: HTMLElement): void {\n const {\n x: inlineX,\n y: inlineY,\n right: inlineRight,\n left: inlineLeft,\n width: inlineWidth,\n height: inlineHeight,\n } = targetElement.getBoundingClientRect();\n\n const tooltipParent = tooltipParentElement(targetElement);\n\n if (!tooltipParent) {\n return;\n }\n\n const {right: tooltipParentRight, left: tooltipParentLeft} =\n tooltipParent.getBoundingClientRect();\n\n if ((tooltipParentRight < inlineLeft || tooltipParentLeft > inlineRight) && !isListenerNeeded) {\n closeTooltip(tooltipElement);\n return;\n }\n\n if (isListenerNeeded && tooltipParent) {\n tooltipParent.addEventListener('scroll', tooltipOnResize);\n isListenerNeeded = false;\n }\n\n const relativeX = Number(tooltipElement.getAttribute('relativeX'));\n const relativeY = Number(tooltipElement.getAttribute('relativeY'));\n\n if (relativeX === inlineX && relativeY === inlineY) {\n return;\n }\n\n tooltipElement.setAttribute('relativeX', String(inlineX));\n tooltipElement.setAttribute('relativeY', String(inlineY));\n\n const offsetTop = inlineHeight + 5;\n const definitionParent = tooltipElement.parentElement;\n\n if (!definitionParent) {\n return;\n }\n\n const {width: definitionWidth} = tooltipElement.getBoundingClientRect();\n const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();\n\n // If definition not fit document change base alignment\n const definitionLeftCoordinate = Number(getCoords(targetElement).left);\n const definitionRightCoordinate = definitionWidth + definitionLeftCoordinate;\n\n const definitionOutOfScreenOnLeft = definitionLeftCoordinate - definitionWidth < 0;\n const definitionOutOfScreenOnRight = definitionRightCoordinate > document.body.clientWidth;\n\n const isAlignSwapped = definitionOutOfScreenOnRight || document.dir === 'rtl';\n const fitDefinitionDocument =\n isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - inlineWidth : 0;\n const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;\n const offsetRight = 5;\n const shiftLeft = definitionOutOfScreenOnRight\n ? definitionRightCoordinate - document.body.clientWidth + offsetRight\n : 0;\n const offsetLeft =\n getCoords(targetElement).left -\n definitionParentLeft +\n definitionParent.offsetLeft -\n fitDefinitionDocument;\n\n const isShiftLeftNeeded = offsetLeft + definitionWidth >= document.body.clientWidth;\n\n tooltipElement.style.top =\n Number(getCoords(targetElement).top + offsetTop - customHeaderTop) + 'px';\n tooltipElement.style.left = Number(offsetLeft - (isShiftLeftNeeded ? shiftLeft : 0)) + 'px';\n}\n\nexport function getInlineCodeByTooltip(definition: HTMLElement) {\n const inlineId = definition.getAttribute('inline-id');\n\n return inlineId ? document.getElementById(inlineId) : null;\n}\n\nfunction closeTooltipFn(definition: HTMLElement) {\n definition.classList.remove(OPEN_CLASS);\n const inline = getInlineCodeByTooltip(definition);\n const inlineCodepParent = tooltipParentElement(inline);\n const tooltipParent = tooltipParentElement(definition);\n\n definition.removeAttribute('inline-id');\n\n if (!inlineCodepParent || !tooltipParent) {\n return;\n }\n\n tooltipParent.removeChild(definition);\n inlineCodepParent.removeEventListener('scroll', tooltipOnResize);\n isListenerNeeded = true;\n}\n\nfunction createTooltip() {\n let tooltip = getTooltipElement();\n\n if (!tooltip) {\n const pageContent = document.querySelector('.dc-doc-page__content') || document.body;\n const lang = document.documentElement.lang || 'en';\n const tooltipText = LANG_TOKEN[lang as Lang] ?? LANG_TOKEN.en;\n const host = document.createElement('div');\n\n host.innerHTML = `\n <div id=\"${INLINE_CODE_ID}\" class=\"${INLINE_CODE_CLASS}\"\n role=\"dialog\" aria-live=\"polite\" aria-modal=\"true\">\n ${tooltipText}\n </div>\n `;\n\n tooltip = host.firstElementChild as HTMLElement;\n pageContent.appendChild(tooltip);\n }\n\n return tooltip;\n}\n\nexport function openTooltip(target: HTMLElement) {\n const tooltip = createTooltip();\n\n if (!target.matches(INLINE_CODE) || !tooltip) {\n return;\n }\n\n tooltip.setAttribute('inline-id', target.getAttribute('id') || '');\n setTooltipAriaAttributes(tooltip, target);\n setTooltipPosition(tooltip, target);\n\n // In order not to get rid of the smooth appearance effect, I had to do this\n if (tooltip.classList.contains(OPEN_CLASS)) {\n tooltip.classList.remove(OPEN_CLASS);\n requestAnimationFrame(() => {\n tooltip.classList.add(OPEN_CLASS);\n });\n } else {\n tooltip.classList.add(OPEN_CLASS);\n }\n\n return tooltip;\n}\n\nexport function closeTooltip(target: HTMLElement) {\n checkTimerAndClear();\n closeTooltipFn(target);\n}\n\nexport function tooltipWorker(target: HTMLElement) {\n const definition = openTooltip(target);\n\n if (!definition) {\n return;\n }\n checkTimerAndClear();\n timer = setTimeout(() => {\n closeTooltip(definition);\n timer = null;\n }, 1000);\n}\n", "import {copyToClipboard, getEventTarget, isCustom} from '../utils';\n\nimport {INLINE_CODE, OPEN_CLASS} from './constant';\nimport {\n closeTooltip,\n getInlineCodeByTooltip,\n getTooltipElement,\n setTooltipPosition,\n tooltipWorker,\n} from './utils';\n\nexport function inlineCopyFn(target: HTMLElement) {\n const innerText = target.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(target);\n });\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('click', (event) => {\n const target = getEventTarget(event) as HTMLElement;\n\n const inline = target.matches(INLINE_CODE);\n\n if (isCustom(event) || !inline) {\n return;\n }\n\n inlineCopyFn(target);\n });\n\n document.addEventListener('keydown', (event) => {\n if (event.key === 'Enter' && document.activeElement) {\n const activeElement = document.activeElement as HTMLElement;\n const classInlineCode = INLINE_CODE.replace('.', '');\n\n if (!activeElement.classList.contains(classInlineCode)) {\n return;\n }\n\n const innerText = activeElement.innerText;\n\n if (!innerText) {\n return;\n }\n\n copyToClipboard(innerText).then(() => {\n tooltipWorker(activeElement);\n });\n }\n\n const inlineTooltip = getTooltipElement();\n\n if (event.key === 'Escape' && inlineTooltip) {\n closeTooltip(inlineTooltip);\n getInlineCodeByTooltip(inlineTooltip)?.focus(); // Set focus back to open button after closing popup\n }\n });\n\n window.addEventListener('resize', () => {\n const inlineTooltip = getTooltipElement();\n if (!inlineTooltip) {\n return;\n }\n\n const inlineId = inlineTooltip.getAttribute('inline-id') || '';\n const inlineCodeElement = document.getElementById(inlineId);\n\n if (!inlineCodeElement) {\n inlineTooltip.classList.toggle(OPEN_CLASS);\n return;\n }\n\n setTooltipPosition(inlineTooltip, inlineCodeElement);\n });\n}\n"],
|
|
5
|
+
"mappings": "giBAAAA,EAAAC,EAAA,CAAA,+CAAAC,EAAAC,EAAA,CAAA,aAoBA,SAASC,EAAYC,EAAK,CACxB,IAAIC,EAAW,OAAOD,GAAQ,UAAY,EAAQA,EAAI,SAEtD,OAAOC,EAAWC,EAAuB,IAAI,EAAIC,EAAQ,IAAI,CAC/D,CAEA,SAASD,EAAuBE,EAAM,CACpC,IAAIC,EAAOF,EAAQC,CAAI,EAEvB,OAAIE,EAAaD,CAAI,EACZH,EAAuBG,EAAK,IAAI,EAGl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AazF,EAAqB,CAC9C,IAAM0F,EAAY1F,EAAO,UAEpB0F,GAILzF,EAAgByF,CAAS,EAAE,KAAK,IAAM,CAClCF,EAAcxF,CAAM,CACxB,CAAC,CACL,CAEI,OAAO,UAAa,cACpB,SAAS,iBAAiB,QAAUH,GAAU,CAC1C,IAAMG,EAASJ,EAAeC,CAAK,EAE7BkF,EAAS/E,EAAO,QAAQmB,CAAW,EAErCpB,EAASF,CAAK,GAAK,CAACkF,GAIxBU,GAAazF,CAAM,CACvB,CAAC,EAED,SAAS,iBAAiB,UAAYH,GAAU,CApCpD,IAAAc,EAqCQ,GAAId,EAAM,MAAQ,SAAW,SAAS,cAAe,CACjD,IAAM8F,EAAgB,SAAS,cACzBC,EAAkBzE,EAAY,QAAQ,IAAK,EAAE,EAEnD,GAAI,CAACwE,EAAc,UAAU,SAASC,CAAe,EACjD,OAGJ,IAAMF,EAAYC,EAAc,UAEhC,GAAI,CAACD,EACD,OAGJzF,EAAgByF,CAAS,EAAE,KAAK,IAAM,CAClCF,EAAcG,CAAa,CAC/B,CAAC,CACL,CAEA,IAAME,EAAgBrD,EAAkB,EAEpC3C,EAAM,MAAQ,UAAYgG,IAC1BjC,EAAaiC,CAAa,GAC1BlF,EAAAiE,EAAuBiB,CAAa,IAApC,MAAAlF,EAAuC,MAAA,EAE/C,CAAC,EAED,OAAO,iBAAiB,SAAU,IAAM,CACpC,IAAMkF,EAAgBrD,EAAkB,EACxC,GAAI,CAACqD,EACD,OAGJ,IAAM5C,EAAW4C,EAAc,aAAa,WAAW,GAAK,GACtDC,EAAoB,SAAS,eAAe7C,CAAQ,EAE1D,GAAI,CAAC6C,EAAmB,CACpBD,EAAc,UAAU,OAAOvE,CAAU,EACzC,MACJ,CAEA4B,EAAmB2C,EAAeC,CAAiB,CACvD,CAAC",
|
|
6
6
|
"names": ["require_get_root_node_polyfill", "__commonJS", "exports", "module", "getRootNode", "opt", "composed", "getShadowIncludingRoot", "getRoot", "node", "root", "isShadowRoot", "import_get_root_node_polyfill", "__toESM", "e", "matches", "selector", "th", "getEventTarget", "event", "path", "isCustom", "target", "copyToClipboard", "text", "textarea", "COPY_BUTTON_SELECTOR", "WRAP_BUTTON_SELECTOR", "notifySuccess", "svgButton", "id", "icon", "buttonCopyFn", "_a", "container", "code", "textContent", "buttonWrapFn", "ANCHOR_BUTTON_SELECTOR", "href", "link", "INLINE_CODE", "INLINE_CODE_ID", "INLINE_CODE_CLASS", "OPEN_CLASS", "LANG_TOKEN", "Selector", "openClass", "openDefinitionClass", "getCoords", "elem", "box", "body", "docEl", "scrollTop", "scrollLeft", "clientTop", "clientLeft", "top", "left", "timer", "isListenerNeeded", "getTooltipElement", "setTooltipAriaAttributes", "tooltipElement", "targetElement", "ariaLive", "checkTimerAndClear", "tooltipParentElement", "tooltipOnResize", "openedDefinition", "inlineId", "setTooltipPosition", "inlineX", "inlineY", "inlineRight", "inlineLeft", "inlineWidth", "inlineHeight", "tooltipParent", "tooltipParentRight", "tooltipParentLeft", "closeTooltip", "relativeX", "relativeY", "offsetTop", "definitionParent", "definitionWidth", "definitionParentLeft", "definitionLeftCoordinate", "definitionRightCoordinate", "definitionOutOfScreenOnLeft", "definitionOutOfScreenOnRight", "fitDefinitionDocument", "customHeaderTop", "shiftLeft", "offsetLeft", "isShiftLeftNeeded", "getInlineCodeByTooltip", "definition", "closeTooltipFn", "inline", "inlineCodepParent", "createTooltip", "tooltip", "pageContent", "lang", "tooltipText", "host", "openTooltip", "tooltipWorker", "inlineCopyFn", "innerText", "activeElement", "classInlineCode", "inlineTooltip", "inlineCodeElement"]
|
|
7
7
|
}
|