diff options
author | moisseev <moiseev@mezonplus.ru> | 2020-07-15 16:21:00 +0300 |
---|---|---|
committer | moisseev <moiseev@mezonplus.ru> | 2020-07-15 16:21:00 +0300 |
commit | 46479b4d2c0488926bce09efc1b3d215bf090608 (patch) | |
tree | 3df4b73906870ceef4fb455a092d53e3f865cca4 /interface | |
parent | f688e88f182a0bceb99ce203c2d9933855cbedc3 (diff) | |
download | rspamd-46479b4d2c0488926bce09efc1b3d215bf090608.tar.gz rspamd-46479b4d2c0488926bce09efc1b3d215bf090608.zip |
[Minor] Fix line count calculation
Diffstat (limited to 'interface')
-rw-r--r-- | interface/js/lib/linenumbers.min.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/interface/js/lib/linenumbers.min.js b/interface/js/lib/linenumbers.min.js index 1b8312009..850f6d065 100644 --- a/interface/js/lib/linenumbers.min.js +++ b/interface/js/lib/linenumbers.min.js @@ -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 |