@happeouikit/content-renderer 3.2.27 → 3.2.28
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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1 -0
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
|
|
135
135
|
`}return d}),t.subParser("makeMarkdown.paragraph",function(r,n){var a="";if(r.hasChildNodes())for(var d=r.childNodes,o=d.length,f=0;f<o;++f)a+=t.subParser("makeMarkdown.node")(d[f],n);return a=a.trim(),a}),t.subParser("makeMarkdown.pre",function(r,n){var a=r.getAttribute("prenum");return"<pre>"+n.preList[a]+"</pre>"}),t.subParser("makeMarkdown.strikethrough",function(r,n){var a="";if(r.hasChildNodes()){a+="~~";for(var d=r.childNodes,o=d.length,f=0;f<o;++f)a+=t.subParser("makeMarkdown.node")(d[f],n);a+="~~"}return a}),t.subParser("makeMarkdown.strong",function(r,n){var a="";if(r.hasChildNodes()){a+="**";for(var d=r.childNodes,o=d.length,f=0;f<o;++f)a+=t.subParser("makeMarkdown.node")(d[f],n);a+="**"}return a}),t.subParser("makeMarkdown.table",function(r,n){var a="",d=[[],[]],o=r.querySelectorAll("thead>tr>th"),f=r.querySelectorAll("tbody>tr"),c,p;for(c=0;c<o.length;++c){var T=t.subParser("makeMarkdown.tableCell")(o[c],n),k="---";if(o[c].hasAttribute("style")){var _=o[c].getAttribute("style").toLowerCase().replace(/\s/g,"");switch(_){case"text-align:left;":k=":---";break;case"text-align:right;":k="---:";break;case"text-align:center;":k=":---:";break}}d[0][c]=T.trim(),d[1][c]=k}for(c=0;c<f.length;++c){var E=d.push([])-1,l=f[c].getElementsByTagName("td");for(p=0;p<o.length;++p){var w=" ";typeof l[p]<"u"&&(w=t.subParser("makeMarkdown.tableCell")(l[p],n)),d[E].push(w)}}var S=3;for(c=0;c<d.length;++c)for(p=0;p<d[c].length;++p){var P=d[c][p].length;P>S&&(S=P)}for(c=0;c<d.length;++c){for(p=0;p<d[c].length;++p)c===1?d[c][p].slice(-1)===":"?d[c][p]=t.helper.padEnd(d[c][p].slice(-1),S-1,"-")+":":d[c][p]=t.helper.padEnd(d[c][p],S,"-"):d[c][p]=t.helper.padEnd(d[c][p],S);a+="| "+d[c].join(" | ")+` |
|
|
136
136
|
`}return a.trim()}),t.subParser("makeMarkdown.tableCell",function(r,n){var a="";if(!r.hasChildNodes())return"";for(var d=r.childNodes,o=d.length,f=0;f<o;++f)a+=t.subParser("makeMarkdown.node")(d[f],n,!0);return a.trim()}),t.subParser("makeMarkdown.txt",function(r){var n=r.nodeValue;return n=n.replace(/ +/g," "),n=n.replace(/¨NBSP;/g," "),n=t.helper.unescapeHTMLEntities(n),n=n.replace(/([*_~|`])/g,"\\$1"),n=n.replace(/^(\s*)>/g,"\\$1>"),n=n.replace(/^#/gm,"\\#"),n=n.replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3"),n=n.replace(/^( {0,3}\d+)\./gm,"$1\\."),n=n.replace(/^( {0,3})([+-])/gm,"$1\\$2"),n=n.replace(/]([\s]*)\(/g,"\\]$1\\("),n=n.replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:"),n});var N=this;e.exports?e.exports=t:N.showdown=t}).call(xe)})(Xt);var Kn=Xt.exports;const Ne=Vr(Kn),at=/@(\d*|channel|editors):\((.*?)\)/,Jt=["channel","editors"],Qn=new RegExp(at,"i"),Zn=new RegExp(at,"gi");let ie;const Dr={color:{type:"lang",regex:/\((.*?)\)\[(rgb\((?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]), ?)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]), ?)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]))\))\]/gi,replace:(e,i)=>`<span style="color:${e.match(/\[(rgb\((?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]), ?)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]), ?)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5]))\))\]/gi)[0].replace("[","").replace("]","")}">${i}</span>`},mention:{type:"lang",regex:Zn,replace:e=>{const i=e.match(Qn),u=i&&i.length>1&&i[1],t=i&&i.length>2&&i[2];return Jt.find(s=>s.toLowerCase()===String(u).toLowerCase())?`<a class="mention extraMention" data-user-id="${u}">@${t}</a>`:`<a class="mention" data-user-id="${u}">@${t}</a>`}},userMentioTag:{type:"lang",regex:/<user-mentio[^>]*>(.+?)<\/user-mentio>/gi,replace:e=>{const i=e.match(/<user-mentio[^>]*>(.+?)<\/user-mentio>/),u=e.match(/data-user-id=["']([^"]+)["']/),t=i&&i.length>1&&i[1];return`<a class="mention" data-user-id="${u&&u.length>1&&u[1]}">${t}</a>`}}};function Yn(){return ie||(Ne.extension("color",Dr.color),Ne.extension("mention",Dr.mention),Ne.extension("usermentiotag",Dr.userMentioTag),ie=new Ne.Converter({extensions:["color","mention","usermentiotag"]}),ie.setOption("strikethrough",!0),ie.setOption("tables",!0),ie.setOption("openLinksInNewWindow",!0),ie.setOption("disableForced4SpacesIndentedSublists",!0),ie)}const Xn=Yn(),Jn=new RegExp(at,"gi"),ei=new RegExp(/<user-mentio[^>]*data-user-id=["']([^"]+)["'][^>]*>(?:@|(?:@))(.+?)<\/user-mentio>/,"gi"),Tt=(e,i,u)=>Jt.find(t=>t.toLowerCase()===String(i).toLowerCase())?`<a class="mention extraMention" data-user-id="${i}">@${u}</a>`:`<a class="mention" data-user-id="${i}">@${u}</a>`,ri=(e="")=>e.replace(Jn,Tt).replace(ei,Tt),ti=(e="")=>zr(e,{whiteList:Un,css:{whiteList:{...zr.getDefaultCSSWhiteList(),"vertical-align":!0}},stripIgnoreTag:!0}).replace(/ /g," ").replace(/\u2060/g,""),ai=(e="")=>{const i=/#(?:[0-9a-fA-F]{3}){1,2}|\brgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)|\brgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d*(?:\.\d+)?\s*\)/gi;return e.replace(i,u=>`${u}<span class="color-block" style="background-color: ${u};"></span>`)},ni=(e="")=>{try{return Sn(e,{target:"_blank",ignoreTags:["pre","code","script","style"],render:({tagName:i,attributes:u,content:t})=>{let s=t;if(s.length>85){const g=s.slice(0,40),m=s.slice(-40);s=`${g}[...]${m}`}const h=Object.keys(u).reduce((g,m)=>{const b=u[m];return`${g} ${m}="${b}"`});return`<${i} ${h}>${s}</${i}>`},validate:{url(i){return/^(http|ftp)s?:\/\//.test(i)}}})}catch{return e}},ii=(e="",i="html")=>{let u=st.shortToUnicode(e);return u=st.fixEmojioneBug(u),i==="markdown"?u=Xn.makeHtml(u):u=ri(u),u=Yt(u),u=di(u),u=ni(u),u},ui=()=>{const e="ibmMonoOnDemand";if(!document.getElementById(e)){const i=document.createElement("style");i.id=e,i.appendChild(document.createTextNode(`@import url(${Vn});`)),document.head.appendChild(i)}},At=(e="")=>e.replace(/[^\u0000-\u007E]/g,""),si=(e="")=>{const i=/<pre\b[^>]*>\s*<code\b[^>]*>([\s\S]*?)<\/code>\s*<\/pre>/g;return e.replace(i,s=>s.replace(/<\/p>\s*<p>/g,`
|
|
137
|
-
`).replace(/<p>/g,"").replace(/<\/p>/g,"")).replace(i,s=>zr(s,{whiteList:{pre:[],code:[]}}))},di=e=>e.replace(/<(?![a-zA-Z\/!])/g,"<"),oi=({content:e,type:i,widgetType:u="post",createAnchors:t,useHashAutoscroll:s,hashAutoscrollTopMargin:h=0,forceDefaultLinkTarget:g,inheritBrandingStyles:m=!1,addColorBlocks:b=!1,replaceLinkDomains:D=[],onSaveToClipboard:C})=>{const v=ue.useRef(null),y=ue.useRef(!1),[q,L]=ue.useState([]),I=ue.useCallback(()=>{var z;try{const{hash:j}=window.location;if(v.current&&j){const N=(z=v.current)==null?void 0:z.querySelector(j);N&&setTimeout(()=>{window.scrollTo({top:N.getBoundingClientRect().top-h,behavior:"smooth"}),N.classList.add("highlight"),setTimeout(()=>{N.classList.remove("highlight")},5e3)},500)}}catch{}},[h]);ue.useLayoutEffect(()=>{if(!v.current||y.current)return;const z=()=>{if(!v.current||!g)return;const a=v.current.querySelectorAll("a")||[];if(a.length>0){const d=window.origin;a.forEach(o=>{const{href:f}=o;f.startsWith(d)?delete o.target:o.target="_blank"})}},j=()=>{v.current&&(v.current.querySelectorAll("a")||[]).forEach(a=>{const{href:d}=a;d.startsWith("mailto:")&&(a.target="_blank")})},N=()=>{if(!v.current)return;const a=v.current.querySelectorAll(Et);a.length>0&&(Er.isDefined("highlightjs")||(ui(),Er([...Fn,...$n],"highlightjs")),Er.ready("highlightjs",()=>{window.hljs.configure({languages:Wn,useBr:!0}),a.forEach(d=>{const o=d.innerText,f=document.createElement(Gn),c=Yt(o);f.textContent=c,d.innerHTML="",d.appendChild(f),window.hljs.highlightBlock(d)}),L(d=>[...d,...a])}))},r=()=>{D.length!==0&&D.forEach(({domainToReplace:a,domainToReplaceWith:d})=>{if(!v.current)return;const o=v.current.querySelectorAll("a")||[];o.length>0&&o.forEach(f=>{try{const{href:c}=f,p=new URL(c),{hostname:T}=p;if(T!==a||p.pathname==="/")return;if(d===""){const k=`${p.pathname}${p.search}${p.hash}`;f.href=k}else f.href=c.replace(a,d)}catch{}})})};requestAnimationFrame(()=>{z(),j(),N(),r(),s&&I()}),y.current=!0},[v,t,g,s,D,I]),ue.useLayoutEffect(()=>{const z=()=>{if(!v.current||!t)return;const N=v.current.querySelectorAll("h1, h2, h3, h4, h5, h6")||[];N.length>0&&N.forEach(r=>{const{textContent:n=""}=r;(n||"").length>0&&(r.id=r.id||At((n||"").toLowerCase().replace(/\s/g,"-")))}),L(r=>[...r,...N])},j=()=>{if(!v.current)return;v.current.querySelectorAll("td, th").forEach(r=>{var a;const n=r.style.backgroundColor;if(n){const[d,o,f]=((a=n.match(/[.?\d]+/g))==null?void 0:a.map(T=>parseInt(T,10)))??[0,0,0],p=.2126*d+.7152*o+.0722*f>186?"light":"dark";r.style.colorScheme!==p&&r.style.setProperty("color-scheme",p)}else r.style.colorScheme&&r.style.removeProperty("color-scheme")})};z(),j()},[t,e]);const x=ue.useMemo(()=>{const z=i&&typeof i=="string"?i.toLowerCase():"html";let j=z==="text"?`<p>${e}</p>`:ii(e,z);return b&&(j=ai(j)),j=si(j),ti(j)},[e,i,b]);return fe.jsxs(fe.Fragment,{children:[fe.jsx(li,{className:`content-renderer ${u==="page"?"fr-view pages-text":""}`,ref:v,widgetType:u,createAnchors:t,hashAutoscrollTopMargin:s&&h,dangerouslySetInnerHTML:{__html:x},inheritBrandingStyles:m}),q.map(z=>{let j=z.textContent?At(z.textContent):"",N=!1;return z.tagName!==Et&&(N=!0,j=`${window.location.href.split("#")[0]}#${z.id}`),ea.createPortal(fe.jsx(ci,{className:"content-copy-btn",children:fe.jsx(ra.CopyToClipboardButton,{icon:N?fe.jsx(na,{}):void 0,colorScheme:"blank",clipboardContent:j,onSaveToClipboard:C,hideSuccessTooltip:!!C})}),z)})]})},ci=ye.div`
|
|
137
|
+
`).replace(/<p>/g,"").replace(/<\/p>/g,"")).replace(i,s=>zr(s,{whiteList:{pre:[],code:[]}}))},di=e=>e.replace(/<(?![a-zA-Z\/!])/g,"<"),oi=({content:e,type:i,widgetType:u="post",createAnchors:t,useHashAutoscroll:s,hashAutoscrollTopMargin:h=0,forceDefaultLinkTarget:g,inheritBrandingStyles:m=!1,addColorBlocks:b=!1,replaceLinkDomains:D=[],onSaveToClipboard:C})=>{const v=ue.useRef(null),y=ue.useRef(!1),[q,L]=ue.useState([]),I=ue.useCallback(()=>{var z;try{const{hash:j}=window.location;if(v.current&&j){const N=(z=v.current)==null?void 0:z.querySelector(j);N&&setTimeout(()=>{window.scrollTo({top:N.getBoundingClientRect().top-h,behavior:"smooth"}),N.classList.add("highlight"),setTimeout(()=>{N.classList.remove("highlight")},5e3)},500)}}catch{}},[h]);ue.useLayoutEffect(()=>{if(!v.current||y.current)return;const z=()=>{if(!v.current||!g)return;const a=v.current.querySelectorAll("a")||[];if(a.length>0){const d=window.origin;a.forEach(o=>{const{href:f}=o;f.startsWith(d)?delete o.target:o.target="_blank"})}},j=()=>{v.current&&(v.current.querySelectorAll("a")||[]).forEach(a=>{const{href:d}=a;d.startsWith("mailto:")&&(a.target="_blank")})},N=()=>{if(!v.current)return;const a=v.current.querySelectorAll(Et);a.length>0&&(Er.isDefined("highlightjs")||(ui(),Er([...Fn,...$n],"highlightjs")),Er.ready("highlightjs",()=>{window.hljs.configure({languages:Wn,useBr:!0}),a.forEach(d=>{const o=d.innerText,f=document.createElement(Gn),c=Yt(o);f.textContent=c,d.innerHTML="",d.appendChild(f),window.hljs.highlightBlock(d)}),L(d=>[...d,...a])}))},r=()=>{D.length!==0&&D.forEach(({domainToReplace:a,domainToReplaceWith:d})=>{if(!v.current)return;const o=v.current.querySelectorAll("a")||[];o.length>0&&o.forEach(f=>{try{const{href:c}=f,p=new URL(c),{hostname:T}=p;if(T!==a||p.pathname==="/")return;if(d===""){const k=`${p.pathname}${p.search}${p.hash}`;f.href=k}else f.href=c.replace(a,d)}catch{}})})};requestAnimationFrame(()=>{z(),j(),N(),r(),s&&I()}),y.current=!0},[v,t,g,s,D,I]),ue.useLayoutEffect(()=>{const z=()=>{if(!v.current||!t)return;const N=v.current.querySelectorAll("h1, h2, h3, h4, h5, h6")||[];N.length>0&&N.forEach(r=>{const{textContent:n=""}=r;(n||"").length>0&&(r.id=r.id||At((n||"").toLowerCase().replace(/\s/g,"-")))}),L(r=>[...r,...N])},j=()=>{if(!v.current)return;v.current.querySelectorAll("td, th").forEach(r=>{var a;const n=r.style.backgroundColor;if(n){const[d,o,f]=((a=n.match(/[.?\d]+/g))==null?void 0:a.map(T=>parseInt(T,10)))??[0,0,0],p=.2126*d+.7152*o+.0722*f>186?"light":"dark";r.style.colorScheme!==p&&r.style.setProperty("color-scheme",p)}else r.style.colorScheme&&r.style.removeProperty("color-scheme")})};z(),j()},[t,e]);const x=ue.useMemo(()=>{const z=i&&typeof i=="string"?i.toLowerCase():"html";let j=z==="text"?`<p>${e}</p>`:ii(e,z);return b&&(j=ai(j)),j=si(j),ti(j)},[e,i,b]);return fe.jsxs(fe.Fragment,{children:[fe.jsx(li,{className:`content-renderer ${u==="page"?"fr-view pages-text":""}`,ref:v,widgetType:u,createAnchors:t,hashAutoscrollTopMargin:s&&h,dangerouslySetInnerHTML:{__html:x},inheritBrandingStyles:m}),q.map(z=>{let j=z.textContent?At(z.textContent):"",N=!1;return z.tagName!==Et&&(N=!0,j=`${window.location.href.split("#")[0]}#${z.id}`),ea.createPortal(fe.jsx(ci,{className:"content-copy-btn",children:fe.jsx(ra.CopyToClipboardButton,{icon:N?fe.jsx(na,{}):void 0,colorScheme:"blank",clipboardCopyLabel:"Copy heading link",clipboardContent:j,onSaveToClipboard:C,hideSuccessTooltip:!!C})}),z)})]})},ci=ye.div`
|
|
138
138
|
position: absolute;
|
|
139
139
|
display: inline-block;
|
|
140
140
|
margin-inline-start: var(--space-sm);
|