]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix line count calculation
authormoisseev <moiseev@mezonplus.ru>
Wed, 15 Jul 2020 13:21:00 +0000 (16:21 +0300)
committermoisseev <moiseev@mezonplus.ru>
Wed, 15 Jul 2020 13:21:00 +0000 (16:21 +0300)
interface/js/lib/linenumbers.min.js

index 1b831200925c71adbe5000fe6c397b32ba864db8..850f6d0659ef1da10e51151389a4896639424e74 100644 (file)
@@ -1,5 +1,6 @@
 /*!
  * CodeJar 3.1.0 helper: lineNumbers (https://github.com/antonmedv/codejar)
  * Copyright (c) 2020, Anton Medvedev, MIT
+ * Added line count fix (https://github.com/antonmedv/codejar/pull/26/commits/245e213622ef60574ae76d9b7969b43249c592f5)
  */
-function withLineNumbers(e,t={}){const o=Object.assign({class:"codejar-linenumbers",wrapClass:"codejar-wrap",width:"35px",backgroundColor:"rgba(128, 128, 128, 0.15)",color:""},t);let l;return function(t){e(t),l||(l=init(t,o));const n=(t.textContent||"").replace(/\n+$/,"\n").split("\n").length+1;let s="";for(let e=1;e<n;e++)s+=`${e}\n`;l.innerText=s}}function init(e,t){const o=getComputedStyle(e),l=document.createElement("div");l.className=t.wrapClass,l.style.position="relative";const n=document.createElement("div");return n.className=t.class,l.appendChild(n),n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.bottom="0px",n.style.width=t.width,n.style.overflow="hidden",n.style.backgroundColor=t.backgroundColor,n.style.color=t.color||o.color,n.style.setProperty("mix-blend-mode","difference"),n.style.fontFamily=o.fontFamily,n.style.fontSize=o.fontSize,n.style.lineHeight=o.lineHeight,n.style.paddingTop=o.paddingTop,n.style.paddingLeft=o.paddingLeft,n.style.borderTopLeftRadius=o.borderTopLeftRadius,n.style.borderBottomLeftRadius=o.borderBottomLeftRadius,e.style.paddingLeft=`calc(${t.width} + ${n.style.paddingLeft})`,e.style.whiteSpace="pre",e.parentNode.insertBefore(l,e),l.appendChild(e),n}
\ No newline at end of file
+function withLineNumbers(e,t={}){const o=Object.assign({class:"codejar-linenumbers",wrapClass:"codejar-wrap",width:"35px",backgroundColor:"rgba(128, 128, 128, 0.15)",color:""},t);let n;return function(t){e(t),n||(n=init(t,o));const l=t.textContent||"",s=l.split(/\r\n|\r|\n/).length+(l.endsWith("\r")||l.endsWith("\n")?0:1);let i="";for(let e=1;e<s;e++)i+=`${e}\n`;n.innerText=i}}function init(e,t){const o=getComputedStyle(e),n=document.createElement("div");n.className=t.wrapClass,n.style.position="relative";const l=document.createElement("div");return l.className=t.class,n.appendChild(l),l.style.position="absolute",l.style.top="0px",l.style.left="0px",l.style.bottom="0px",l.style.width=t.width,l.style.overflow="hidden",l.style.backgroundColor=t.backgroundColor,l.style.color=t.color||o.color,l.style.setProperty("mix-blend-mode","difference"),l.style.fontFamily=o.fontFamily,l.style.fontSize=o.fontSize,l.style.lineHeight=o.lineHeight,l.style.paddingTop=o.paddingTop,l.style.paddingLeft=o.paddingLeft,l.style.borderTopLeftRadius=o.borderTopLeftRadius,l.style.borderBottomLeftRadius=o.borderBottomLeftRadius,e.style.paddingLeft=`calc(${t.width} + ${l.style.paddingLeft})`,e.style.whiteSpace="pre",e.parentNode.insertBefore(n,e),n.appendChild(e),l}
\ No newline at end of file