PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.8.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.8.1
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
ablocks / assets / library / prism / prism-line-highlight.js

prism-line-highlight.js in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.8.1, at assets/library/prism/prism-line-highlight.js

2 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // https://github.com/PrismJS/prism/blob/master/plugins/line-highlight/prism-line-highlight.js
2 !function(){if("undefined"!=typeof Prism&&"undefined"!=typeof document&&document.querySelector){var e,t="line-numbers",i="linkable-line-numbers",n=/\n(?!$)/g,r=function(){if(void 0===e){var t=document.createElement("div");t.style.fontSize="13px",t.style.lineHeight="1.5",t.style.padding="0",t.style.border="0",t.innerHTML="&nbsp;<br />&nbsp;",document.body.appendChild(t),e=38===t.offsetHeight,document.body.removeChild(t)}return e},o=!0;Prism.plugins.lineHighlight={highlightLines:function(e,s,c){var h=(s="string"==typeof s?s:e.getAttribute("data-line")||"").replace(/\s+/g,"").split(",").filter(Boolean),d=+e.getAttribute("data-line-offset")||0,f=(r()?parseInt:parseFloat)(getComputedStyle(e).lineHeight),p=Prism.util.isActive(e,t),g=e.querySelector("code"),m=p?e:g||e,v=[],y=g.textContent.match(n),b=y?y.length+1:1,A=g&&m!=g?function(e,t){var i=getComputedStyle(e),n=getComputedStyle(t);function r(e){return+e.substr(0,e.length-2)}return t.offsetTop+r(n.borderTopWidth)+r(n.paddingTop)-r(i.paddingTop)}(e,g):0;h.forEach((function(t){var i=t.split("-"),n=+i[0],r=+i[1]||n;if(!((r=Math.min(b+d,r))<n)){var o=e.querySelector('.line-highlight[data-range="'+t+'"]')||document.createElement("div");if(v.push((function(){o.setAttribute("aria-hidden","true"),o.setAttribute("data-range",t),o.className=(c||"")+" line-highlight"})),p&&Prism.plugins.lineNumbers){var s=Prism.plugins.lineNumbers.getLine(e,n),l=Prism.plugins.lineNumbers.getLine(e,r);if(s){var a=s.offsetTop+A+"px";v.push((function(){o.style.top=a}))}if(l){var u=l.offsetTop-s.offsetTop+l.offsetHeight+"px";v.push((function(){o.style.height=u}))}}else v.push((function(){o.setAttribute("data-start",String(n)),r>n&&o.setAttribute("data-end",String(r)),o.style.top=(n-d-1)*f+A+"px",o.textContent=new Array(r-n+2).join(" \n")}));v.push((function(){o.style.width=e.scrollWidth+"px"})),v.push((function(){m.appendChild(o)}))}}));var P=e.id;if(p&&Prism.util.isActive(e,i)&&P){a(e,i)||v.push((function(){e.classList.add(i)}));var E=parseInt(e.getAttribute("data-start")||"1");l(".line-numbers-rows > span",e).forEach((function(e,t){var i=t+E;e.onclick=function(){var e=P+"."+i;o=!1,location.hash=e,setTimeout((function(){o=!0}),1)}}))}return function(){v.forEach(u)}}};var s=0;Prism.hooks.add("before-sanity-check",(function(e){var t=e.element.parentElement;if(c(t)){var i=0;l(".line-highlight",t).forEach((function(e){i+=e.textContent.length,e.parentNode.removeChild(e)})),i&&/^(?: \n)+$/.test(e.code.slice(-i))&&(e.code=e.code.slice(0,-i))}})),Prism.hooks.add("complete",(function e(i){var n=i.element.parentElement;if(c(n)){clearTimeout(s);var r=Prism.plugins.lineNumbers,o=i.plugins&&i.plugins.lineNumbers;if(a(n,t)&&r&&!o)Prism.hooks.add("line-numbers",e);else Prism.plugins.lineHighlight.highlightLines(n)(),s=setTimeout(h,1)}})),window.addEventListener("hashchange",h),window.addEventListener("resize",(function(){l("pre").filter(c).map((function(e){return Prism.plugins.lineHighlight.highlightLines(e)})).forEach(u)}))}function l(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function a(e,t){return e.classList.contains(t)}function u(e){e()}function c(e){return!(!e||!/pre/i.test(e.nodeName))&&(!!e.hasAttribute("data-line")||!(!e.id||!Prism.util.isActive(e,i)))}function h(){var e=location.hash.slice(1);l(".temporary.line-highlight").forEach((function(e){e.parentNode.removeChild(e)}));var t=(e.match(/\.([\d,-]+)$/)||[,""])[1];if(t&&!document.getElementById(e)){var i=e.slice(0,e.lastIndexOf(".")),n=document.getElementById(i);if(n)n.hasAttribute("data-line")||n.setAttribute("data-line",""),Prism.plugins.lineHighlight.highlightLines(n,t,"temporary ")(),o&&document.querySelector(".temporary.line-highlight").scrollIntoView()}}}();