@diplodoc/transform
Version:
A simple transformer of text in YFM (Yandex Flavored Markdown) to HTML
3 lines (2 loc) • 5.85 kB
JavaScript
;(()=>{(()=>{var I=Object.create,L=Object.defineProperty,B=Object.getOwnPropertyDescriptor,O=Object.getOwnPropertyNames,j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty,M=(t,e)=>function(){return e||(0,t[O(t)[0]])((e={exports:{}}).exports,e),e.exports},q=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of O(e))!k.call(t,o)&&o!==n&&L(t,o,{get:()=>e[o],enumerable:!(i=B(e,o))||i.enumerable});return t},D=(t,e,n)=>(n=t!=null?I(j(t)):{},q(e||!t||!t.__esModule?L(n,"default",{value:t,enumerable:!0}):n,t)),W=(t,e,n)=>new Promise((i,o)=>{var l=s=>{try{c(n.next(s))}catch(a){o(a)}},r=s=>{try{c(n.throw(s))}catch(a){o(a)}},c=s=>s.done?i(s.value):Promise.resolve(s.value).then(l,r);c((n=n.apply(t,e)).next())}),X=M({"node_modules/get-root-node-polyfill/index.js"(t,e){"use strict";function n(r){var c=typeof r=="object"&&!!r.composed;return c?i(this):o(this)}function i(r){var c=o(r);return l(c)?i(c.host):c}function o(r){return r.parentNode!=null?o(r.parentNode):r}function l(r){return r.nodeName==="#document-fragment"&&r.constructor.name==="ShadowRoot"}typeof e=="object"&&e.exports&&(e.exports=n)}}),Y=D(X());typeof document!="undefined"&&function(t){let e=t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector;e?t.matches=t.matchesSelector=e:t.matches=t.matchesSelector=function(i){let l=(t.getRootNode?t.getRootNode():Y.default.call(t)).querySelectorAll(i),r=this;return Array.prototype.some.call(l,c=>c===r)}}(Element.prototype);var p=t=>{let e=t.composedPath();return Array.isArray(e)&&e.length>0?e[0]:t.target},g=t=>{let e=p(t);return!e||!e.matches},m=t=>W(void 0,null,function*(){if(!t)return;if(navigator.clipboard&&typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(t);let e=document.createElement("textarea");e.setAttribute("style","position: absolute; left: 1000%"),e.textContent=t,document.body.append(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}),F=".yfm-clipboard-button";function H(t){if(!t)return;let e=t.getAttribute("data-animation"),n=t.getRootNode().getElementById(`visibileAnimation-${e}`);n&&n.beginElement()}function z(t){let e=t.parentNode;if(!e)return;let n=e.querySelector("pre code");if(!n)return;let i=Array.from(n.childNodes).filter(o=>!(o instanceof HTMLElement&&o.classList.contains("yfm-line-number"))).map(o=>o.textContent).join("");m(i).then(()=>{H(e.querySelector(".yfm-clipboard-icon"))})}typeof document!="undefined"&&document.addEventListener("click",t=>{let e=p(t),n=e.matches(F);g(t)||!n||z(e)});var U=".yfm-clipboard-anchor";typeof document!="undefined"&&document.addEventListener("click",t=>{let e=p(t);if(g(t)||!e.matches(U))return;let n=e.getAttribute("data-href")||"",i=new URL(n,window.location.href).toString();m(i)});var J=".yfm-clipboard-inline-code",u="open",$={TITLE:".yfm .yfm-term_title",CONTENT:".yfm .yfm-term_dfn"},G="open",ut=$.CONTENT.replace(/\./g,"")+" "+G;function y(t){let e=t.getBoundingClientRect(),n=document.body,i=document.documentElement,o=window.pageYOffset||i.scrollTop||n.scrollTop,l=window.pageXOffset||i.scrollLeft||n.scrollLeft,r=i.clientTop||n.clientTop||0,c=i.clientLeft||n.clientLeft||0,s=e.top+o-r,a=e.left+l-c;return{top:Math.round(s),left:Math.round(a)}}var f=null,h=!0;function v(){return document.querySelector(".yfm-inline-code-tooltip")}function K(t,e){let n=e.getAttribute("aria-live")||"polite";t==null||t.setAttribute("aria-live",n),t==null||t.setAttribute("aria-modal","true")}function S(){f&&(clearTimeout(f),f=null)}function A(t){return t?t.closest("table")||t.closest("code")||t.parentElement:null}function N(){let t=v();if(!t)return;let e=t.getAttribute("inline-id")||"",n=document.getElementById(e);n&&_(t,n)}function _(t,e){let{x:n,y:i,right:o,left:l,width:r,height:c}=e.getBoundingClientRect(),s=A(e);if(!s)return;let{right:a,left:tt}=s.getBoundingClientRect();if((a<l||tt>o)&&!h){T(t);return}h&&s&&(s.addEventListener("scroll",N),h=!1);let et=Number(t.getAttribute("relativeX")),nt=Number(t.getAttribute("relativeY"));if(et===n&&nt===i)return;t.setAttribute("relativeX",String(n)),t.setAttribute("relativeY",String(i));let ot=c+5,d=t.parentElement;if(!d)return;let{width:b}=t.getBoundingClientRect(),{left:it}=d.getBoundingClientRect(),E=Number(y(e).left),P=b+E,rt=E-b<0,R=P>document.body.clientWidth,ct=(R||document.dir==="rtl")&&!rt?b-r:0,st=y(d).top-d.offsetTop,lt=R?P-document.body.clientWidth+5:0,x=y(e).left-it+d.offsetLeft-ct,at=x+b>=document.body.clientWidth;t.style.top=Number(y(e).top+ot-st)+"px",t.style.left=Number(x-(at?lt:0))+"px"}function C(t){let e=t.getAttribute("inline-id");return e?document.getElementById(e):null}function Q(t){t.classList.remove(u);let e=C(t),n=A(e);t.removeAttribute("inline-id"),n&&(n.removeEventListener("scroll",N),h=!0)}function V(t){let e=document.getElementById("tooltip_inline_clipboard_dialog");if(!(!t.matches(".yfm-clipboard-inline-code")||!e))return e.setAttribute("inline-id",t.getAttribute("id")||""),K(e,t),_(e,t),e.classList.contains(u)?(e.classList.remove(u),requestAnimationFrame(()=>{e.classList.add(u)})):e.classList.add(u),e}function T(t){S(),Q(t)}function w(t){let e=V(t);e&&(S(),f=setTimeout(()=>{T(e),f=null},1e3))}function Z(t){let e=t.innerText;e&&m(e).then(()=>{w(t)})}typeof document!="undefined"&&(document.addEventListener("click",t=>{let e=p(t),n=e.matches(J);g(t)||!n||Z(e)}),document.addEventListener("keydown",t=>{var e;if(t.key==="Enter"&&document.activeElement){let i=document.activeElement,o=i.innerText;if(!o)return;m(o).then(()=>{w(i)})}let n=v();t.key==="Escape"&&n&&(T(n),(e=C(n))==null||e.focus())}),window.addEventListener("resize",()=>{let t=v();if(!t)return;let e=t.getAttribute("inline-id")||"",n=document.getElementById(e);if(!n){t.classList.toggle(u);return}_(t,n)}))})();})();
//# sourceMappingURL=base.min.js.map