@happeouikit/content-renderer 3.4.4 → 3.4.5
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 +2 -2
- 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,u){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],u);return a=a.trim(),a}),t.subParser("makeMarkdown.pre",function(r,u){var a=r.getAttribute("prenum");return"<pre>"+u.preList[a]+"</pre>"}),t.subParser("makeMarkdown.strikethrough",function(r,u){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],u);a+="~~"}return a}),t.subParser("makeMarkdown.strong",function(r,u){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],u);a+="**"}return a}),t.subParser("makeMarkdown.table",function(r,u){var a="",d=[[],[]],o=r.querySelectorAll("thead>tr>th"),f=r.querySelectorAll("tbody>tr"),c,h;for(c=0;c<o.length;++c){var T=t.subParser("makeMarkdown.tableCell")(o[c],u),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(h=0;h<o.length;++h){var w=" ";typeof l[h]<"u"&&(w=t.subParser("makeMarkdown.tableCell")(l[h],u)),d[E].push(w)}}var S=3;for(c=0;c<d.length;++c)for(h=0;h<d[c].length;++h){var P=d[c][h].length;P>S&&(S=P)}for(c=0;c<d.length;++c){for(h=0;h<d[c].length;++h)c===1?d[c][h].slice(-1)===":"?d[c][h]=t.helper.padEnd(d[c][h].slice(-1),S-1,"-")+":":d[c][h]=t.helper.padEnd(d[c][h],S,"-"):d[c][h]=t.helper.padEnd(d[c][h],S);a+="| "+d[c].join(" | ")+` |
|
|
136
136
|
`}return a.trim()}),t.subParser("makeMarkdown.tableCell",function(r,u){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],u,!0);return a.trim()}),t.subParser("makeMarkdown.txt",function(r){var u=r.nodeValue;return u=u.replace(/ +/g," "),u=u.replace(/¨NBSP;/g," "),u=t.helper.unescapeHTMLEntities(u),u=u.replace(/([*_~|`])/g,"\\$1"),u=u.replace(/^(\s*)>/g,"\\$1>"),u=u.replace(/^#/gm,"\\#"),u=u.replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3"),u=u.replace(/^( {0,3}\d+)\./gm,"$1\\."),u=u.replace(/^( {0,3})([+-])/gm,"$1\\$2"),u=u.replace(/]([\s]*)\(/g,"\\]$1\\("),u=u.replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:"),u});var N=this;e.exports?e.exports=t:N.showdown=t}).call(Oe)})(Xt);var Jn=Xt.exports;const Ne=Vr(Jn),at=/@(\d*|channel|editors):\((.*?)\)/,Jt=["channel","editors"],ei=new RegExp(at,"i"),ri=new RegExp(at,"gi");let ue;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,n)=>`<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("]","")}">${n}</span>`},mention:{type:"lang",regex:ri,replace:e=>{const n=e.match(ei),i=n&&n.length>1&&n[1],t=n&&n.length>2&&n[2];return Jt.find(s=>s.toLowerCase()===String(i).toLowerCase())?`<a class="mention extraMention" data-user-id="${i}">@${t}</a>`:`<a class="mention" data-user-id="${i}">@${t}</a>`}},userMentioTag:{type:"lang",regex:/<user-mentio[^>]*>(.+?)<\/user-mentio>/gi,replace:e=>{const n=e.match(/<user-mentio[^>]*>(.+?)<\/user-mentio>/),i=e.match(/data-user-id=["']([^"]+)["']/),t=n&&n.length>1&&n[1];return`<a class="mention" data-user-id="${i&&i.length>1&&i[1]}">${t}</a>`}}};function ti(){return ue||(Ne.extension("color",Dr.color),Ne.extension("mention",Dr.mention),Ne.extension("usermentiotag",Dr.userMentioTag),ue=new Ne.Converter({extensions:["color","mention","usermentiotag"]}),ue.setOption("strikethrough",!0),ue.setOption("tables",!0),ue.setOption("openLinksInNewWindow",!0),ue.setOption("disableForced4SpacesIndentedSublists",!0),ue)}const ai=ti(),ni=new RegExp(at,"gi"),ii=new RegExp(/<user-mentio[^>]*data-user-id=["']([^"]+)["'][^>]*>(?:@|(?:@))(.+?)<\/user-mentio>/,"gi"),Tt=(e,n,i)=>Jt.find(t=>t.toLowerCase()===String(n).toLowerCase())?`<a class="mention extraMention" data-user-id="${n}">@${i}</a>`:`<a class="mention" data-user-id="${n}">@${i}</a>`,ui=(e="")=>e.replace(ni,Tt).replace(ii,Tt),si=(e="")=>zr(e,{whiteList:Gn,css:{whiteList:{...zr.getDefaultCSSWhiteList(),"vertical-align":!0}},stripIgnoreTag:!0}).replace(/ /g," ").replace(/\u2060/g,""),di=(e="")=>{const n=/#(?:[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(n,i=>`${i}<span class="color-block" style="background-color: ${i};"></span>`)},oi=(e="")=>{try{return Rn(e,{target:"_blank",ignoreTags:["pre","code","script","style"],render:({tagName:n,attributes:i,content:t})=>{let s=t;if(s.length>85){const g=s.slice(0,40),m=s.slice(-40);s=`${g}[...]${m}`}const p=Object.keys(i).reduce((g,m)=>{const b=i[m];return`${g} ${m}="${b}"`});return`<${n} ${p}>${s}</${n}>`},validate:{url(n){return/^(http|ftp)s?:\/\//.test(n)}}})}catch{return e}},ci=(e="",n="html")=>{let i=st.shortToUnicode(e);return i=st.fixEmojioneBug(i),n==="markdown"?i=ai.makeHtml(i):i=ui(i),i=Yt(i),i=pi(i),i=oi(i),i},li=()=>{const e="ibmMonoOnDemand";if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.appendChild(document.createTextNode(`@import url(${Kn});`)),document.head.appendChild(n)}},At=(e="")=>e.replace(/[^\u0000-\u007E]/g,""),fi=(e="")=>{const n=/<pre\b[^>]*>\s*<code\b[^>]*>([\s\S]*?)<\/code>\s*<\/pre>/g;return e.replace(n,s=>s.replace(/<\/p>\s*<p>/g,`
|
|
137
|
-
`).replace(/<p>/g,"").replace(/<\/p>/g,"")).replace(n,s=>zr(s,{whiteList:{pre:[],code:[]}}))},pi=e=>e.replace(/<(?![a-zA-Z\/!])/g,"<"),hi=(e,n,i)=>{try{let t;try{t=decodeURIComponent(n)}catch{t=n}const s=t.replace("#",""),p=e.querySelector(`[id="${s}"]`);p&&setTimeout(()=>{window.scrollTo({top:p.getBoundingClientRect().top-i,behavior:"smooth"}),p.classList.add("highlight"),setTimeout(()=>{p.classList.remove("highlight")},5e3)},500)}catch{}},gi=/^x[a-f0-9]{7}$/,ea=/^([\w-]*)\+(x[a-f0-9]{7})$/,mi=()=>`x${bi().substring(0,7)}`,ra=e=>{const n=e.match(ea);return n?n[2]:e};function bi(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}const vi=e=>` ${e}`.replace(/[^a-zA-Z0-9]+(.)/g,(n,i)=>i.toUpperCase()),wi=(e="")=>e.replace(/[^a-zA-Z0-9]/gi,""),ta=e=>{let n=(e==null?void 0:e.trim())||"";return n=vi(n),n=wi(n),n=n.trim(),n||"empty"},aa=e=>`:~:text=${encodeURIComponent(e.textContent)}`,na=e=>{const n=e.id,i=e.textContent;return n?`${n}:~:headerText=${ta(i)}`:!n&&(i!=null&&i.length)?aa(e):""},yi=({content:e,type:n,widgetType:i="post",createAnchors:t,useHashAutoscroll:s,hashAutoscrollTopMargin:p=0,forceDefaultLinkTarget:g,inheritBrandingStyles:m=!1,addColorBlocks:b=!1,replaceLinkDomains:D=[],onSaveToClipboard:C})=>{const v=ae.useRef(null),y=ae.useRef(!1),[q,L]=ae.useState([]),j=ae.useCallback(()=>{const{hash:z}=window.location;if(v.current&&z){const I=ra(z.substring(1));hi(v.current,`#${I}`,p)}},[p]);ae.useEffect(()=>(j(),document.addEventListener("hashchange",j),()=>{document.removeEventListener("hashchange",j)}),[]),ae.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"})}},I=()=>{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")||(li(),Er([...Qn,...Zn],"highlightjs")),Er.ready("highlightjs",()=>{window.hljs.configure({languages:Xn,useBr:!0}),a.forEach(d=>{const o=d.innerText,f=document.createElement(Yn),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,h=new URL(c),{hostname:T}=h;if(T!==a||h.pathname==="/")return;if(d===""){const k=`${h.pathname}${h.search}${h.hash}`;f.href=k}else f.href=c.replace(a,d)}catch{}})})};requestAnimationFrame(()=>{z(),I(),N(),r(),s&&j()}),y.current=!0},[v,t,g,s,D,j]),ae.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:u=""}=r;(u||"").length>0&&(r.id=r.id||At((u||"").toLowerCase().replace(/\s/g,"-")))}),L(r=>[...r,...N])},I=()=>{if(!v.current)return;v.current.querySelectorAll("td, th").forEach(r=>{var a;const u=r.style.backgroundColor;if(u){const[d,o,f]=((a=u.match(/[.?\d]+/g))==null?void 0:a.map(T=>parseInt(T,10)))??[0,0,0],h=.2126*d+.7152*o+.0722*f>186?"light":"dark";r.style.colorScheme!==h&&r.style.setProperty("color-scheme",h)}else r.style.colorScheme&&r.style.removeProperty("color-scheme")})};z(),I()},[t,e]);const O=ae.useMemo(()=>{const z=n&&typeof n=="string"?n.toLowerCase():"html";let I=z==="text"?`<p>${e}</p>`:ci(e,z);return b&&(I=di(I)),I=fi(I),si(I)},[e,n,b]);return fe.jsxs(fe.Fragment,{children:[fe.jsx(ki,{className:`content-renderer ${i==="page"?"fr-view pages-text":""}`,ref:v,widgetType:i,createAnchors:t,hashAutoscrollTopMargin:s&&p,dangerouslySetInnerHTML:{__html:O},inheritBrandingStyles:m}),q.map(z=>{let I=z.textContent?At(z.textContent):"",N=!1;if(z.tagName!==Et){N=!0;const r=na(z);I=`${window.location.href.split("#")[0]}#${r}`}return ia.createPortal(fe.jsx(_i,{className:"content-copy-btn",children:fe.jsx(ua.CopyToClipboardButton,{icon:N?fe.jsx(oa,{}):void 0,colorScheme:"blank",clipboardCopyLabel:"Copy heading link",clipboardContent:I,onSaveToClipboard:C,hideSuccessTooltip:!!C})}),z)})]})},_i=ye.div`
|
|
137
|
+
`).replace(/<p>/g,"").replace(/<\/p>/g,"")).replace(n,s=>zr(s,{whiteList:{pre:[],code:[]}}))},pi=e=>e.replace(/<(?![a-zA-Z\/!])/g,"<"),hi=(e,n,i)=>{try{let t;try{t=decodeURIComponent(n)}catch{t=n}const s=t.replace("#",""),p=e.querySelector(`[id="${s}"]`);p&&setTimeout(()=>{window.scrollTo({top:p.getBoundingClientRect().top-i,behavior:"smooth"}),p.classList.add("highlight"),setTimeout(()=>{p.classList.remove("highlight")},5e3)},500)}catch{}},gi=/^x[a-f0-9]{7}$/,ea=/^([\w-]*)\+(x[a-f0-9]{7})$/,mi=()=>`x${bi().substring(0,7)}`,ra=e=>{const n=e.match(ea);return n?n[2]:e};function bi(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}const vi=e=>` ${e}`.replace(/[^a-zA-Z0-9]+(.)/g,(n,i)=>i.toUpperCase()),wi=(e="")=>e.replace(/[^a-zA-Z0-9]/gi,""),ta=e=>{let n=(e==null?void 0:e.trim())||"";return n=vi(n),n=wi(n),n=n.trim(),n||"empty"},aa=e=>`:~:text=${encodeURIComponent(e.textContent)}`,na=e=>{const n=e.id,i=e.textContent;return n?`${n}:~:headerText=${ta(i)}`:!n&&(i!=null&&i.length)?aa(e):""},yi=({content:e,type:n,widgetType:i="post",createAnchors:t,useHashAutoscroll:s,hashAutoscrollTopMargin:p=0,forceDefaultLinkTarget:g,inheritBrandingStyles:m=!1,addColorBlocks:b=!1,replaceLinkDomains:D=[],onSaveToClipboard:C})=>{const v=ae.useRef(null),y=ae.useRef(!1),[q,L]=ae.useState([]),j=ae.useCallback(()=>{const{hash:z}=window.location;if(v.current&&z){const I=ra(z.substring(1));hi(v.current,`#${I}`,p)}},[p]);ae.useEffect(()=>(s&&(j(),document.addEventListener("hashchange",j)),()=>{document.removeEventListener("hashchange",j)}),[s]),ae.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"})}},I=()=>{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")||(li(),Er([...Qn,...Zn],"highlightjs")),Er.ready("highlightjs",()=>{window.hljs.configure({languages:Xn,useBr:!0}),a.forEach(d=>{const o=d.innerText,f=document.createElement(Yn),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,h=new URL(c),{hostname:T}=h;if(T!==a||h.pathname==="/")return;if(d===""){const k=`${h.pathname}${h.search}${h.hash}`;f.href=k}else f.href=c.replace(a,d)}catch{}})})};requestAnimationFrame(()=>{z(),I(),N(),r(),s&&j()}),y.current=!0},[v,t,g,s,D,j]),ae.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:u=""}=r;(u||"").length>0&&(r.id=r.id||At((u||"").toLowerCase().replace(/\s/g,"-")))}),L(r=>[...r,...N])},I=()=>{if(!v.current)return;v.current.querySelectorAll("td, th").forEach(r=>{var a;const u=r.style.backgroundColor;if(u){const[d,o,f]=((a=u.match(/[.?\d]+/g))==null?void 0:a.map(T=>parseInt(T,10)))??[0,0,0],h=.2126*d+.7152*o+.0722*f>186?"light":"dark";r.style.colorScheme!==h&&r.style.setProperty("color-scheme",h)}else r.style.colorScheme&&r.style.removeProperty("color-scheme")})};z(),I()},[t,e]);const O=ae.useMemo(()=>{const z=n&&typeof n=="string"?n.toLowerCase():"html";let I=z==="text"?`<p>${e}</p>`:ci(e,z);return b&&(I=di(I)),I=fi(I),si(I)},[e,n,b]);return fe.jsxs(fe.Fragment,{children:[fe.jsx(ki,{className:`content-renderer ${i==="page"?"fr-view pages-text":""}`,ref:v,widgetType:i,createAnchors:t,hashAutoscrollTopMargin:s&&p,dangerouslySetInnerHTML:{__html:O},inheritBrandingStyles:m}),q.map(z=>{let I=z.textContent?At(z.textContent):"",N=!1;if(z.tagName!==Et){N=!0;const r=na(z);I=`${window.location.href.split("#")[0]}#${r}`}return ia.createPortal(fe.jsx(_i,{className:"content-copy-btn",children:fe.jsx(ua.CopyToClipboardButton,{icon:N?fe.jsx(oa,{}):void 0,colorScheme:"blank",clipboardCopyLabel:"Copy heading link",clipboardContent:I,onSaveToClipboard:C,hideSuccessTooltip:!!C})}),z)})]})},_i=ye.div`
|
|
138
138
|
position: absolute;
|
|
139
139
|
display: inline-block;
|
|
140
140
|
margin-inline-start: var(--space-sm);
|