@pickaxeproject/react 2.3.2 → 2.4.0
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/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +3 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +7 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +4 -0
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +3 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +7 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),t=require("../../../../hooks/pickaxe/useDimensionContext.js"),i=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../../../hooks/pickaxe/useConversation.js"),r=require("../../common/PickaxeIcon.js"),c=require("../../../Core/ErrorAlert.js"),d=require("../../../Core/Skeleton.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeHead.js"),m=require("../../common/PickaxeCompactHead.js"),f=require("../../common/PickaxeUpgradeCard.js"),j=require("./Message.js"),h=require("../../common/PickaxeBranding.js"),p=require("../../../../common/cn.js");exports.default=({hideInfo:g,isInputFocused:v})=>{var w;const N=n.useConversation(),b=o.useStyleFontSize(),{pickaxe:k,colors:y,misc:C,isNewChat:O,isRtl:q,isEmbed:S,setChatId:P}=a.usePickaxeContext(),{scrollContainerRef:I}=i.useScrollContext(),{messages:L,status:E,limitData:M,error:A}=l.useResponseContext(),{height:H}=t.useDimensionContext(),R=s.useMemo((()=>!!N.data&&!(N.data.messages.length<=1)),[N.data]),z=s.useMemo((()=>!g&&N.isSuccess&&O&&!R),[g,N.isSuccess,O,R]),D=s.useMemo((()=>{var e,s;return!!L.length&&!(null!==(s=null===(e=null==L?void 0:L[L.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[L]);return e.jsx("div",Object.assign({ref:I,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${H}px - 74px)`}},{children:e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(z||!S)&&!C.isWhiteLabel&&e.jsx(h.default,{className:p.default("absolute top-4 right-4",!z&&!S&&"top-2"),animateHover:!0}),e.jsx(x.default,{className:p.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",z&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>P("")}),S&&!N.isLoading&&e.jsx(m.default,{className:p.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!z&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>P("")}),e.jsx("div",Object.assign({className:p.default("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",S&&!N.isLoading&&!z&&"mt-0")},{children:N.isLoading&&!(null==k?void 0:k.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[O&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(d.default,{className:"w-[72px] h-[72px]"}),e.jsx(d.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(d.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(d.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(d.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):N.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:p.default(b.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):N.data?e.jsxs("div",Object.assign({className:"flex flex-col w-full"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[N.data.messages.map(((s,a)=>e.jsx(j.default,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),L.map(((s,a)=>e.jsx(j.default,{index:N.data.messages.length+a,message:s},a))),"fetching"===E||D?e.jsx("div",Object.assign({className:p.default("flex w-full",q?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:"flex flex-col"},{children:e.jsxs("div",Object.assign({className:p.default("flex gap-x-3",q&&"flex-row-reverse")},{children:["NONE"!==(null==k?void 0:k.chaticon)&&e.jsx(r.default,{src:null!==(w=null==k?void 0:k.chaticon)&&void 0!==w?w:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==k?void 0:k.formid}.png`,alt:`${null==k?void 0:k.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:y.text}),e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e.jsx("div",{className:p.default("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:y.secondaryText}},a)))}))]}))}))})):M?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(f.default,{})})):A?e.jsx("div",Object.assign({className:p.default("flex items-center gap-x-3",q?"justify-end":"justify-start")},{children:e.jsx(c.default,{error:A})})):null]})),e.jsx(u.default,{className:"w-full"})]})):null}))]}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),s=require("./utils/custom-plugins.js"),i=require("react-markdown"),o=require("remark-gfm"),a=require("remark-math"),l=require("rehype-katex"),u=require("rehype-raw"),c=require("./Components/A/index.js"),d=require("./Components/P/index.js"),p=require("./Components/Img/index.js"),m=require("./Components/Iframe/index.js"),h=require("./Components/Code/index.js"),g=require("./Components/Headings/index.js"),f=require("./Components/List/index.js"),x=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),j=require("./Components/Action/index.js"),q=require("../../../../common/cn.js");function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=C(i),w=C(o),y=C(a),v=C(l),A=C(u);exports.PickaxeMarkdownRenderer=({className:i,style:o,children:a,value:l,maxLines:u,multiLineBreaks:C,recursion:O,onExpandClick:H})=>{const{accentColor:P,rtl:S,disableHtml:M,disableJs:$,disableCss:T}=t.usePickaxeMarkdownContext(),[_,E]=n.useState({width:0,height:0}),[I,L]=n.useState(null),B=n.useRef(null),N=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),C&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,C]);n.useEffect((()=>{if(!u)return void L(null);if(!B.current||!N||I)return;const e=B.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=u*r;if(!(_.height>n))return;const t=Math.floor(_.width/8),s=Math.floor(t*u);L(N.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[N,u,_,I]);const R={h1:g.H1,h2:g.H2,h3:g.H3,h4:g.H4,h5:g.H5,p:d.P,a:c.A,img:p.Img,iframe:m.Iframe,code:h.Code,ol:f.Ol,ul:f.Ul,li:f.Li,table:x.Table,th:x.Th,tr:x.Tr,td:x.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:n=>{var{children:t}=n,s=e.__rest(n,["children"]);return"pxe-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:P,marginLeft:".25rem",userSelect:"none"},H&&{cursor:"pointer"})},H&&{onClick:H},{children:t})):r.jsx("span",Object.assign({},s,{children:t}))},ActionCaption:j.ActionCaption,ActionFinished:j.ActionFinished,ActionError:j.ActionError};n.useEffect((()=>{if(!B.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;E({width:e,height:n})}}));return e.observe(B.current),()=>{e.disconnect()}}),[]);const z=I||N;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:B,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},o)},S&&{dir:"rtl"},{children:[r.jsx(k.default,Object.assign({className:q.default(!O&&"pxe-prose",i),components:R,remarkPlugins:[w.default,[y.default,{singleDollarTextMath:!1}]],rehypePlugins:[v.default,...M?[]:[A.default],[s.rehypeSanitize,{disableJs:$,disableCss:T}],s.rehypePickaxeAction]},{children:z})),a]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react/jsx-runtime"),e=require("react");const t=e.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,accentColor:c="#228DD7",accentTextColor:l="#FFFFFF",actions:i=!1,readOnly:s=!1,rtl:d=!1})=>{const[
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react/jsx-runtime"),e=require("react");const t=e.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,accentColor:c="#228DD7",accentTextColor:l="#FFFFFF",actions:i=!1,readOnly:s=!1,rtl:d=!1,disableHtml:C=!1,disableJs:F=!1,disableCss:p=!1})=>{const[u,m]=e.useState(n),[b,g]=e.useState({}),[h,x]=e.useState(i);return o.jsx(t.Provider,Object.assign({value:{theme:u,accentColor:c,accentTextColor:l,actionState:b,actions:h,readOnly:s,rtl:d,disableHtml:C,disableJs:F,disableCss:p,setTheme:m,setActionState:g,setActions:x,syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}}},{children:r}))};exports.PickaxeMarkdown=r,exports.PickaxeMarkdownContext=t,exports.default=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"];exports.rehypePickaxeAction=()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"];exports.rehypePickaxeAction=()=>r=>(e.visit(r,"element",(e=>{const i=e.tagName;if(t.includes(i)){const t=i.split("-");e.tagName=t.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e.visit(r,"element",((t,r,o)=>{if("p"===t.tagName){const s=t.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===s.length){const t=s[0];if("element"===t.type&&i.includes(t.tagName)&&o&&"children"in o&&o.children&&void 0!==r)return o.children.splice(r,1,t),[e.SKIP,r]}}})),r),exports.rehypeSanitize=(t={})=>i=>{e.visit(i,"element",((i,r,o)=>{if(t.disableJs){if("script"===i.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[e.SKIP,r];if(i.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{i.properties[e]&&delete i.properties[e]})),i.properties.href&&"string"==typeof i.properties.href&&i.properties.href.toLowerCase().startsWith("javascript:")&&delete i.properties.href}}if(t.disableCss&&"style"===i.tagName&&o&&"number"==typeof r)return o.children.splice(r,1),[e.SKIP,r]}))};
|
package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare const usePickaxeMarkdownContext: () => {
|
|
|
8
8
|
actions: boolean;
|
|
9
9
|
readOnly: boolean;
|
|
10
10
|
rtl: boolean;
|
|
11
|
+
disableHtml: boolean;
|
|
12
|
+
disableJs: boolean;
|
|
13
|
+
disableCss: boolean;
|
|
11
14
|
setTheme: import("../../../../../types/common").SetState<import("..").PickaxeMarkdownTheme>;
|
|
12
15
|
setActionState: import("../../../../../types/common").SetState<Record<string, import("..").ActionState>>;
|
|
13
16
|
setActions: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -21,6 +21,9 @@ type PickaxeMarkdownContextType = {
|
|
|
21
21
|
actions: boolean;
|
|
22
22
|
readOnly: boolean;
|
|
23
23
|
rtl: boolean;
|
|
24
|
+
disableHtml: boolean;
|
|
25
|
+
disableJs: boolean;
|
|
26
|
+
disableCss: boolean;
|
|
24
27
|
setTheme: SetState<PickaxeMarkdownTheme>;
|
|
25
28
|
setActionState: SetState<Record<string, ActionState>>;
|
|
26
29
|
setActions: SetState<boolean>;
|
|
@@ -34,7 +37,10 @@ export interface PickaxeMarkdownProps {
|
|
|
34
37
|
actions?: boolean;
|
|
35
38
|
readOnly?: boolean;
|
|
36
39
|
rtl?: boolean;
|
|
40
|
+
disableHtml?: boolean;
|
|
41
|
+
disableJs?: boolean;
|
|
42
|
+
disableCss?: boolean;
|
|
37
43
|
}
|
|
38
44
|
export declare const PickaxeMarkdownContext: import("react").Context<PickaxeMarkdownContextType>;
|
|
39
|
-
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor, accentTextColor, actions: _actions, readOnly, rtl, }: PickaxeMarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor, accentTextColor, actions: _actions, readOnly, rtl, disableHtml, disableJs, disableCss, }: PickaxeMarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
46
|
export default PickaxeMarkdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import
|
|
1
|
+
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import f from"../../Addons/Scroll/ScrollLockView.js";import p from"../../common/PickaxeHead.js";import x from"../../common/PickaxeCompactHead.js";import u from"../../common/PickaxeUpgradeCard.js";import h from"./Message.js";import g from"../../common/PickaxeBranding.js";import j from"../../../../common/cn.js";const w=({hideInfo:w,isInputFocused:v})=>{var N;const b=r(),k=n(),{pickaxe:y,colors:C,misc:O,isNewChat:S,isRtl:I,isEmbed:P,setChatId:L}=o(),{scrollContainerRef:E}=l(),{messages:A,status:H,limitData:R,error:$}=t(),{height:z}=i(),D=a((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),F=a((()=>!w&&b.isSuccess&&S&&!D),[w,b.isSuccess,S,D]),B=a((()=>{var e,s;return!!A.length&&!(null!==(s=null===(e=null==A?void 0:A[A.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[A]);return e("div",Object.assign({ref:E,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${z}px - 74px)`}},{children:s("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(F||!P)&&!O.isWhiteLabel&&e(g,{className:j("absolute top-4 right-4",!F&&!P&&"top-2"),animateHover:!0}),e(p,{className:j("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",F&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>L("")}),P&&!b.isLoading&&e(x,{className:j("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!F&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>L("")}),e("div",Object.assign({className:j("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",P&&!b.isLoading&&!F&&"mt-0")},{children:b.isLoading&&!(null==y?void 0:y.enablechatresponses)?s("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[S&&s("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e(d,{className:"w-[72px] h-[72px]"}),e(d,{className:"h-[20px] mt-6 w-full"}),e(d,{className:"h-[20px] mt-2 w-full"}),e(d,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e(d,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e(d,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e(d,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):b.isError?e("div",Object.assign({className:"flex w-full justify-center"},{children:s("p",Object.assign({className:j(k.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):b.data?s("div",Object.assign({className:"flex flex-col w-full"},{children:[s("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[b.data.messages.map(((s,a)=>e(h,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),A.map(((s,a)=>e(h,{index:b.data.messages.length+a,message:s},a))),"fetching"===H||B?e("div",Object.assign({className:j("flex w-full",I?"justify-end":"justify-start")},{children:e("div",Object.assign({className:"flex flex-col"},{children:s("div",Object.assign({className:j("flex gap-x-3",I&&"flex-row-reverse")},{children:["NONE"!==(null==y?void 0:y.chaticon)&&e(c,{src:null!==(N=null==y?void 0:y.chaticon)&&void 0!==N?N:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e("div",{className:j("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:C.secondaryText}},a)))}))]}))}))})):R?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e(u,{})})):$?e("div",Object.assign({className:j("flex items-center gap-x-3",I?"justify-end":"justify-start")},{children:e(m,{error:$})})):null]})),e(f,{className:"w-full"})]})):null}))]}))}))};export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as t,useRef as o,useMemo as
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as t,useRef as o,useMemo as s,useEffect as i}from"react";import{usePickaxeMarkdownContext as m}from"./hooks/usePickaxeMarkdownContext.js";import{rehypeSanitize as a,rehypePickaxeAction as l}from"./utils/custom-plugins.js";import p from"react-markdown";import c from"remark-gfm";import d from"remark-math";import h from"rehype-katex";import f from"rehype-raw";import{A as u}from"./Components/A/index.js";import{P as g}from"./Components/P/index.js";import{Img as x}from"./Components/Img/index.js";import{Iframe as b}from"./Components/Iframe/index.js";import{Code as j}from"./Components/Code/index.js";import{H1 as C,H2 as k,H3 as w,H4 as v,H5 as y}from"./Components/Headings/index.js";import{Ol as O,Ul as $,Li as S}from"./Components/List/index.js";import{Table as A,Th as L,Tr as M,Td as N}from"./Components/Table/index.js";import{Hr as P,Br as H,Blockquote as I}from"./Components/Others/index.js";import{ActionCaption as T,ActionFinished as B,ActionError as E}from"./Components/Action/index.js";import J from"../../../../common/cn.js";const R=({className:R,style:W,children:_,value:q,maxLines:z,multiLineBreaks:D,recursion:F,onExpandClick:G})=>{const{accentColor:K,rtl:Q,disableHtml:U,disableJs:V,disableCss:X}=m(),[Y,Z]=t({width:0,height:0}),[ee,re]=t(null),ne=o(null),te=s((()=>{if(!q)return"";let e=q.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),D&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[q,D]);i((()=>{if(!z)return void re(null);if(!ne.current||!te||ee)return;const e=ne.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=z*r;if(!(Y.height>n))return;const t=Math.floor(Y.width/8),o=Math.floor(t*z);re(te.slice(0,o)+'<span class="pxe-expand-btn">...</span>')}),[te,z,Y,ee]);const oe={h1:C,h2:k,h3:w,h4:v,h5:y,p:g,a:u,img:x,iframe:b,code:j,ol:O,ul:$,li:S,table:A,th:L,tr:M,td:N,hr:P,br:H,blockquote:I,span:r=>{var{children:t}=r,o=e(r,["children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:K,marginLeft:".25rem",userSelect:"none"},G&&{cursor:"pointer"})},G&&{onClick:G},{children:t})):n("span",Object.assign({},o,{children:t}))},ActionCaption:T,ActionFinished:B,ActionError:E};i((()=>{if(!ne.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;Z({width:e,height:n})}}));return e.observe(ne.current),()=>{e.disconnect()}}),[]);const se=ee||te;return r("div",Object.assign({className:"pxe-markdown",ref:ne,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},W)},Q&&{dir:"rtl"},{children:[n(p,Object.assign({className:J(!F&&"pxe-prose",R),components:oe,remarkPlugins:[c,[d,{singleDollarTextMath:!1}]],rehypePlugins:[h,...U?[]:[f],[a,{disableJs:V,disableCss:X}],l]},{children:se})),_]}))};export{R as PickaxeMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o}from"react/jsx-runtime";import{createContext as e,useState as r}from"react";const t=e({}),n=({children:e,theme:n="light",syntaxTheme:
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{createContext as e,useState as r}from"react";const t=e({}),n=({children:e,theme:n="light",syntaxTheme:a,accentColor:l="#228DD7",accentTextColor:c="#FFFFFF",actions:i=!1,readOnly:s=!1,rtl:d=!1,disableHtml:F=!1,disableJs:C=!1,disableCss:m=!1})=>{const[p,g]=r(n),[h,b]=r({}),[u,y]=r(i);return o(t.Provider,Object.assign({value:{theme:p,accentColor:l,accentTextColor:c,actionState:h,actions:u,readOnly:s,rtl:d,disableHtml:F,disableJs:C,disableCss:m,setTheme:g,setActionState:b,setActions:y,syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}}},{children:e}))};export{n as PickaxeMarkdown,t as PickaxeMarkdownContext,n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{visit as e,SKIP as t}from"unist-util-visit";const
|
|
1
|
+
import{visit as e,SKIP as t}from"unist-util-visit";const r=["action-caption","action-finished","action-error"],i=["ActionCaption","ActionFinished","ActionError"],o=()=>o=>(e(o,"element",(e=>{const t=e.tagName;if(r.includes(t)){const r=t.split("-");e.tagName=r.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(""),e.properties=e.properties||{}}})),e(o,"element",((e,r,o)=>{if("p"===e.tagName){const n=e.children.filter((e=>"text"===e.type?""!==e.value.trim():"element"===e.type));if(1===n.length){const e=n[0];if("element"===e.type&&i.includes(e.tagName)&&o&&"children"in o&&o.children&&void 0!==r)return o.children.splice(r,1,e),[t,r]}}})),o),n=(r={})=>i=>{e(i,"element",((e,i,o)=>{if(r.disableJs){if("script"===e.tagName&&o&&"number"==typeof i)return o.children.splice(i,1),[t,i];if(e.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((t=>{e.properties[t]&&delete e.properties[t]})),e.properties.href&&"string"==typeof e.properties.href&&e.properties.href.toLowerCase().startsWith("javascript:")&&delete e.properties.href}}if(r.disableCss&&"style"===e.tagName&&o&&"number"==typeof i)return o.children.splice(i,1),[t,i]}))};export{o as rehypePickaxeAction,n as rehypeSanitize};
|
package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare const usePickaxeMarkdownContext: () => {
|
|
|
8
8
|
actions: boolean;
|
|
9
9
|
readOnly: boolean;
|
|
10
10
|
rtl: boolean;
|
|
11
|
+
disableHtml: boolean;
|
|
12
|
+
disableJs: boolean;
|
|
13
|
+
disableCss: boolean;
|
|
11
14
|
setTheme: import("../../../../../types/common").SetState<import("..").PickaxeMarkdownTheme>;
|
|
12
15
|
setActionState: import("../../../../../types/common").SetState<Record<string, import("..").ActionState>>;
|
|
13
16
|
setActions: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -21,6 +21,9 @@ type PickaxeMarkdownContextType = {
|
|
|
21
21
|
actions: boolean;
|
|
22
22
|
readOnly: boolean;
|
|
23
23
|
rtl: boolean;
|
|
24
|
+
disableHtml: boolean;
|
|
25
|
+
disableJs: boolean;
|
|
26
|
+
disableCss: boolean;
|
|
24
27
|
setTheme: SetState<PickaxeMarkdownTheme>;
|
|
25
28
|
setActionState: SetState<Record<string, ActionState>>;
|
|
26
29
|
setActions: SetState<boolean>;
|
|
@@ -34,7 +37,10 @@ export interface PickaxeMarkdownProps {
|
|
|
34
37
|
actions?: boolean;
|
|
35
38
|
readOnly?: boolean;
|
|
36
39
|
rtl?: boolean;
|
|
40
|
+
disableHtml?: boolean;
|
|
41
|
+
disableJs?: boolean;
|
|
42
|
+
disableCss?: boolean;
|
|
37
43
|
}
|
|
38
44
|
export declare const PickaxeMarkdownContext: import("react").Context<PickaxeMarkdownContextType>;
|
|
39
|
-
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor, accentTextColor, actions: _actions, readOnly, rtl, }: PickaxeMarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor, accentTextColor, actions: _actions, readOnly, rtl, disableHtml, disableJs, disableCss, }: PickaxeMarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
46
|
export default PickaxeMarkdown;
|