@pickaxeproject/react 0.0.72 → 1.0.1
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/README.md +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/Iframe/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/Img/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/P/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/common/TextModal.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/cjs/prose.css +1 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/Iframe/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/Img/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/P/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/common/TextModal.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/esm/prose.css +1 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
- package/dist/esm/src/index.d.ts +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),s=require("@tanstack/react-query"),i=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../common/Action.js"),n=require("../Img/index.js"),o=require("../common/Audio.js"),u=require("../common/Html/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),s=require("@tanstack/react-query"),i=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../common/Action.js"),n=require("../Img/index.js"),o=require("../common/Audio.js"),u=require("../common/Html/index.js"),c=require("../../../../../../common/api/utils.js"),l=require("../../../../../../common/error.js");exports.default=({node:d,href:f="",children:p})=>{const{accentColor:m,websiteMetadatas:h,linkPreviews:w,actions:j,setWebsiteMetadatas:x}=i.usePickaxeMarkdownContext(),[b,v]=r.useState("");r.useEffect((()=>{if(!f)return;const e=f.startsWith("http://")?`https://${f.slice(7)}`:f.startsWith("www.")?`https://${f}`:f;e!==b&&v(e)}),[f,b]),s.useQuery({queryKey:["website-metadata",b],queryFn:()=>{return t=b,e.__awaiter(void 0,void 0,void 0,(function*(){try{if("development"===process.env.NODE_ENV&&console.log("[getWebsiteMetadata]",t),!t||!t.startsWith("https")||!t.includes("."))return null;if(["/api/fn/result","/api/function_call_results","https://prod-pickaxe-assets.s3.amazonaws.com"].some((e=>t.includes(e))))return null;const e=(yield c.default.get(`/metadata?url=${encodeURIComponent(t)}`)).data;if(e.error)throw new Error(e.error||"Failed to fetch metadata");return e}catch(e){if("development"===process.env.NODE_ENV){const t=l.default(e);console.error("[getJobResult]",t)}return null}}));var t},enabled:"undefined"!=typeof window&&w&&Boolean(b)&&!h.some((e=>e.href===b))&&b.includes(".")&&!b.includes("https://prod-pickaxe-assets")&&!b.includes("https://pickaxeproject--v2"),retry:2,onSuccess:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t&&t.title&&(h.some((e=>e.href===t.href))||x((e=>[...e,t])))}))});const g=b.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(g&&(null==g?void 0:g[1]))return t.jsx("div",Object.assign({className:"pxe-markdown-youtube",style:{display:"flex",width:"100%",justifyContent:"center"}},{children:t.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${g[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(b.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/))return t.jsx(n.default,{src:b,alt:"string"==typeof p?p:"Markdown Image"});if(b.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/))return t.jsx(o.default,{url:b});return b.includes("action_generated_files")&&b.match(/\.html$/)?t.jsx(u.default,{url:b}):j&&b.includes("pickaxe")&&(b.includes("/api/fn/result")||b.includes("/api/function_call_results"))?t.jsx(a.default,{jobUrl:b}):t.jsx("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:m}},{children:p}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),s=require("react-syntax-highlighter"),a=require("../../hooks/usePickaxeMarkdownContext.js"),l=require("../../../PickaxeCopyButton.js");exports.default=t=>{var i,{node:c,children:o,className:n}=t,u=e.__rest(t,["node","children","className"]);const{syntaxTheme:d,accentColor:x}=a.usePickaxeMarkdownContext(),b=/language-(\w+)/.exec(n||"");return r.jsxs("div",Object.assign({className:"relative"},{children:[r.jsx("div",Object.assign({className:"absolute right-2 top-4 text-white"},{children:r.jsx(l.default,{color:x,text:null!==(i=null==o?void 0:o.toString())&&void 0!==i?i:"",iconClassName:"w-4 h-4"})})),r.jsx("div",Object.assign({className:"overflow-x-auto max-w-[600px] scrollbar scrollbar-thumb-black/50 scrollbar-thumb-rounded-full scrollbar-w-[4px] scrollbar-h-[4px] dark:scrollbar-thumb-black/60"},{children:r.jsx(s.Prism,Object.assign({},u,{PreTag:"div",language:b?b[1]:"js",style:d,showLineNumbers:!0},{children:String(o).replace(/\n$/,"")}))}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),s=require("react-syntax-highlighter"),a=require("../../hooks/usePickaxeMarkdownContext.js"),l=require("../../../PickaxeCopyButton.js");exports.default=t=>{var i,{node:c,children:o,className:n}=t,u=e.__rest(t,["node","children","className"]);const{syntaxTheme:d,accentColor:x}=a.usePickaxeMarkdownContext(),b=/language-(\w+)/.exec(n||"");return r.jsxs("div",Object.assign({className:"pxe-markdown-code relative"},{children:[r.jsx("div",Object.assign({className:"absolute right-2 top-4 text-white"},{children:r.jsx(l.default,{color:x,text:null!==(i=null==o?void 0:o.toString())&&void 0!==i?i:"",iconClassName:"w-4 h-4"})})),r.jsx("div",Object.assign({className:"overflow-x-auto max-w-[600px] scrollbar scrollbar-thumb-black/50 scrollbar-thumb-rounded-full scrollbar-w-[4px] scrollbar-h-[4px] dark:scrollbar-thumb-black/60"},{children:r.jsx(s.Prism,Object.assign({},u,{PreTag:"div",language:b?b[1]:"js",style:d,showLineNumbers:!0},{children:String(o).replace(/\n$/,"")}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime");exports.default=t=>{var{node:i,title:l="Random Iframe",children:s,style:a}=t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime");exports.default=t=>{var{node:i,title:l="Random Iframe",children:s,style:a}=t,d=e.__rest(t,["node","title","children","style"]);return r.jsx("iframe",Object.assign({title:l,style:Object.assign({borderRadius:"8px",width:"100%"},a),allowFullScreen:!0},d,{children:s}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),t=require("react"),s=require("../../hooks/usePickaxeMarkdownContext.js"),i=require("../../../../../../hooks/core/useHover.js"),r=require("framer-motion"),n=require("../../../../../../common/utils.js"),a=require("../../../../../Icons/download.svg.js"),l=require("../../../PickaxeCopyButton.js"),d=require("./ImgModal.js");exports.default=({node:c,src:p,alt:u})=>{const{accentColor:x}=s.usePickaxeMarkdownContext(),[b,h]=t.useState(!1),[g,j]=t.useState(!1),m=i.useHover(),{isHover:y}=m,v=e.__rest(m,["isHover"]);return o.jsxs("div",Object.assign({className:"pxe-markdown-image",style:{display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px",transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:y?"translateY(-5px)":"translateY(0)"}},v,{children:[g&&o.jsx(d.default,{src:p,isOpen:g,onChangeIsOpen:j}),b?o.jsx("p",Object.assign({style:{userSelect:"none",opacity:.5,fontStyle:"italic"}},{children:"[Image link is broken]"})):o.jsxs("div",Object.assign({style:{position:"relative"}},{children:[o.jsxs(r.motion.div,Object.assign({initial:"hidden",animate:y?"visible":"hidden",variants:{hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[o.jsx(r.motion.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:x,opacity:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:e=>{e.stopPropagation(),window.open(p,"_blank")}},{children:o.jsx(a.default,{width:24,height:24,style:{color:n.getContrastColor(x),flexShrink:0}})})),o.jsx(r.motion.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:x,opacity:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:e=>e.stopPropagation()},{children:o.jsx(l.default,{color:n.getContrastColor(x),iconClassName:"w-6 h-6",text:p||""})}))]})),o.jsx("img",{src:p,alt:u,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:y?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>h(!0),onClick:()=>j(!0)})]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../common/Action.js");exports.default=({node:i,children:n})=>{const{actions:r}=t.usePickaxeMarkdownContext(),l="string"==typeof n&&n.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(l&&(null==l?void 0:l[1]))return e.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:"center"}},{children:e.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${l[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(r&&"string"==typeof n&&n.includes("pickaxe")&&(n.includes("/api/fn/result")||n.includes("/api/function_call_results"))){const t=n.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),i=n.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e.jsxs("div",Object.assign({
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../common/Action.js");exports.default=({node:i,children:n})=>{const{actions:r}=t.usePickaxeMarkdownContext(),l="string"==typeof n&&n.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(l&&(null==l?void 0:l[1]))return e.jsx("div",Object.assign({className:"pxe-markdown-youtube",style:{display:"flex",width:"100%",justifyContent:"center"}},{children:e.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${l[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(r&&"string"==typeof n&&n.includes("pickaxe")&&(n.includes("/api/fn/result")||n.includes("/api/function_call_results"))){const t=n.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),i=n.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx("p",{children:t}),e.jsx(s.default,{jobUrl:(null==i?void 0:i[0])||""})]}))}return e.jsx("p",{children:n})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./Modal/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../Renderer.js"),t=require("./Modal/index.js"),l=require("./Modal/Body.js"),a=require("./Modal/CloseButton.js");exports.default=({value:i,isOpen:x,onChangeIsOpen:n})=>{const{colors:o}=s.usePickaxeContext();return e.jsx(t.default,Object.assign({isOpen:x,onChange:n},{children:e.jsxs(l.default,Object.assign({className:"relative flex flex-col px-8 pt-[26px] pb-8 w-full min-[767px]:max-w-[600px] max-[767px]:border-0",style:{backgroundColor:o.primary,color:o.text,borderColor:o.text+"4D"},avoidOverflow:!0},{children:[e.jsx("div",Object.assign({className:"flex items-start justify-end gap-4"},{children:e.jsx(a.default,{})})),e.jsx("div",Object.assign({className:"mt-6 flex flex-col items-center"},{children:e.jsx("div",Object.assign({className:"flex w-full max-w-[550px] flex-col items-center text-center"},{children:e.jsx(r.PickaxeMarkdownRenderer,{value:i})}))}))]}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),s=require("./hooks/usePickaxeMarkdownContext.js"),i=require("react-markdown"),l=require("remark-gfm"),t=require("remark-math"),d=require("rehype-katex"),a=require("rehype-raw"),o=require("./Custom/A/index.js"),c=require("./Custom/P/index.js"),u=require("./Custom/Img/index.js"),h=require("./Custom/Iframe/index.js"),x=require("./Custom/Code/index.js"),m=require("./Custom/common/LinkPreview.js"),p=require("./Custom/common/TextModal.js"),j=require("../../../../common/cn.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=f(i),b=f(l),k=f(t),q=f(d),y=f(a);exports.PickaxeMarkdownRenderer=({className:i,style:l,value:t,recursion:d=!1,children:a,maxChar:f,multiLineBreaks:C})=>{const{theme:D,accentColor:v,websiteMetadatas:O}=s.usePickaxeMarkdownContext(),[w,P]=n.useState(!1),M=n.useRef(null),_=n.useMemo((()=>{if(!t)return"";let e=t;if(e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),C&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),f&&e.length>f){const r=/(https?:\/\/[^\s)]+)/g,n=[];let s;for(;null!==(s=r.exec(e));)n.push({start:s.index,end:s.index+s[0].length});let i=f;for(const e of n)if(f>e.start&&f<e.end){i=e.end+1;break}e=e.slice(0,i)}return e}),[t,f,C]),B={h1:({node:e,children:n})=>r.jsx("h1",{children:n}),h2:({node:e,children:n})=>r.jsx("h2",{children:n}),h3:({node:e,children:n})=>r.jsx("h3",{children:n}),h4:({node:e,children:n})=>r.jsx("h4",{children:n}),h5:({node:e,children:n})=>r.jsx("h5",{children:n}),p:c.default,a:o.default,ol:({node:e,children:n})=>r.jsx("ol",{children:n}),ul:({node:e,children:n})=>r.jsx("ul",{children:n}),li:({node:e,children:n})=>r.jsx("li",{children:n}),table:({children:e})=>r.jsx("div",Object.assign({className:"pxe-markdown-table"},{children:r.jsx("table",{children:e})})),th:({node:e,children:n})=>r.jsx("th",{children:n}),tr:({node:e,children:n})=>r.jsx("tr",Object.assign({style:{border:"dark"===D?"1px solid #30363D":"1px solid #D0D7DE"}},{children:n})),td:({node:e,children:n})=>r.jsx("td",{children:n}),code:x.default,blockquote:({node:e,children:n})=>r.jsx("blockquote",Object.assign({style:{borderLeft:"dark"===D?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===D?"#8B8B8B":"#656D76"}},{children:n})),img:u.default,iframe:h.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===D?"1px solid #30363D":"1px solid #D0D7DE"}}),span:n=>{var{node:s,children:i}=n,l=e.__rest(n,["node","children"]);return"intro-msg-expand-btn"===l.className?r.jsx("span",Object.assign({},l,{style:{display:"inline",fontWeight:500,color:v,cursor:"pointer"},onClick:()=>P(!0)},{children:i})):r.jsx("span",Object.assign({},l,{children:i}))},br:()=>r.jsx("br",{})};return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:M,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},l)},{children:[w&&r.jsx(p.default,{value:_,isOpen:w,onChangeIsOpen:P}),r.jsx(g.default,Object.assign({className:j.default("pxe-prose",i),components:B,remarkPlugins:[b.default,k.default],rehypePlugins:[q.default,y.default]},{children:`${_}${!d&&O.length>0?"\n\n---":""}${"number"==typeof f&&_.length>=f?'<span class="intro-msg-expand-btn">...</span>':""}`})),!d&&O.length>0&&r.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:O.map(((e,n)=>r.jsx(m.default,{data:e},n)))})),a]}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pxe-prose p{font-weight:350}.pxe-prose>p{margin-bottom:.75rem}.pxe-prose a{font-weight:600;text-decoration:underline;text-underline-offset:.2rem}.pxe-prose iframe{margin-bottom:1.5rem}.pxe-prose blockquote{margin-bottom:2.5rem;padding-bottom:.25rem;padding-left:1rem;padding-top:.25rem}.pxe-prose hr{margin-bottom:1.5rem}.pxe-prose .pxe-markdown-code,.pxe-prose .pxe-markdown-image,.pxe-prose .pxe-markdown-youtube{margin-bottom:2.5rem}.pxe-prose ol{list-style-type:decimal}.pxe-prose ol,.pxe-prose ul{list-style-position:inside;margin-bottom:1.5rem;padding-left:1rem}.pxe-prose ul{list-style-type:disc}.pxe-prose li{margin:10px}.pxe-prose li>p{display:inline}.pxe-prose .pxe-markdown-table{margin-bottom:2.5rem;overflow:auto;position:relative}.pxe-prose table{font-size:.875rem;line-height:1.24rem;table-layout:fixed}.pxe-prose th{font-weight:600;text-align:left}.pxe-prose td,.pxe-prose th{padding:.75em 1em}.pxe-prose h1{font-size:2.25rem;line-height:2.5rem;margin-bottom:1.5rem}.pxe-prose h2{font-size:1.875rem;line-height:2.25rem;margin-bottom:1.5rem}.pxe-prose h3{font-size:1.5rem;line-height:2rem;margin-bottom:1.5rem}.pxe-prose h4{font-size:1.25rem}.pxe-prose h4,.pxe-prose h5{line-height:1.75rem;margin-bottom:1rem}.pxe-prose h5{font-size:1.125rem}.pxe-prose h2:not(:first-child),.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose h5:not(:first-child),.pxe-prose>p:not(:first-child) .pxe-markdown-image,.pxe-prose>p:not(:first-child) .pxe-markdown-youtube,.pxe-prose>pre:not(:first-child){margin-top:2.5rem}
|
|
@@ -6,8 +6,9 @@ export interface PickaxeMarkdownRendererProps {
|
|
|
6
6
|
recursion?: boolean;
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
maxChar?: number;
|
|
9
|
+
multiLineBreaks?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export type Node = {
|
|
11
12
|
node?: any;
|
|
12
13
|
};
|
|
13
|
-
export declare const PickaxeMarkdownRenderer: ({ className, style, value, recursion, children: _children, maxChar, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const PickaxeMarkdownRenderer: ({ className, style, value, recursion, children: _children, maxChar, multiLineBreaks, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/cjs/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{useState as r,useEffect as o}from"react";import{useQuery as i}from"@tanstack/react-query";import{usePickaxeMarkdownContext as
|
|
1
|
+
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{useState as r,useEffect as o}from"react";import{useQuery as i}from"@tanstack/react-query";import{usePickaxeMarkdownContext as s}from"../../hooks/usePickaxeMarkdownContext.js";import n from"../common/Action.js";import a from"../Img/index.js";import c from"../common/Audio.js";import l from"../common/Html/index.js";import m from"../../../../../../common/api/utils.js";import u from"../../../../../../common/error.js";const p=({node:p,href:d="",children:f})=>{const{accentColor:h,websiteMetadatas:w,linkPreviews:b,actions:g,setWebsiteMetadatas:j}=s(),[v,y]=r("");o((()=>{if(!d)return;const e=d.startsWith("http://")?`https://${d.slice(7)}`:d.startsWith("www.")?`https://${d}`:d;e!==v&&y(e)}),[d,v]),i({queryKey:["website-metadata",v],queryFn:()=>{return t=v,e(void 0,void 0,void 0,(function*(){try{if("development"===process.env.NODE_ENV&&console.log("[getWebsiteMetadata]",t),!t||!t.startsWith("https")||!t.includes("."))return null;if(["/api/fn/result","/api/function_call_results","https://prod-pickaxe-assets.s3.amazonaws.com"].some((e=>t.includes(e))))return null;const e=(yield m.get(`/metadata?url=${encodeURIComponent(t)}`)).data;if(e.error)throw new Error(e.error||"Failed to fetch metadata");return e}catch(e){if("development"===process.env.NODE_ENV){const t=u(e);console.error("[getJobResult]",t)}return null}}));var t},enabled:"undefined"!=typeof window&&b&&Boolean(v)&&!w.some((e=>e.href===v))&&v.includes(".")&&!v.includes("https://prod-pickaxe-assets")&&!v.includes("https://pickaxeproject--v2"),retry:2,onSuccess:t=>e(void 0,void 0,void 0,(function*(){t&&t.title&&(w.some((e=>e.href===t.href))||j((e=>[...e,t])))}))});const x=v.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(x&&(null==x?void 0:x[1]))return t("div",Object.assign({className:"pxe-markdown-youtube",style:{display:"flex",width:"100%",justifyContent:"center"}},{children:t("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${x[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(v.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/))return t(a,{src:v,alt:"string"==typeof f?f:"Markdown Image"});if(v.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/))return t(c,{url:v});return v.includes("action_generated_files")&&v.match(/\.html$/)?t(l,{url:v}):g&&v.includes("pickaxe")&&(v.includes("/api/fn/result")||v.includes("/api/function_call_results"))?t(n,{jobUrl:v}):t("a",Object.assign({href:v,target:"_blank",rel:"noopener noreferrer",style:{color:h}},{children:f}))};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as r,jsx as a}from"react/jsx-runtime";import{Prism as l}from"react-syntax-highlighter";import{usePickaxeMarkdownContext as
|
|
1
|
+
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as r,jsx as a}from"react/jsx-runtime";import{Prism as l}from"react-syntax-highlighter";import{usePickaxeMarkdownContext as o}from"../../hooks/usePickaxeMarkdownContext.js";import t from"../../../PickaxeCopyButton.js";const s=s=>{var c,{node:i,children:n,className:m}=s,d=e(s,["node","children","className"]);const{syntaxTheme:h,accentColor:b}=o(),u=/language-(\w+)/.exec(m||"");return r("div",Object.assign({className:"pxe-markdown-code relative"},{children:[a("div",Object.assign({className:"absolute right-2 top-4 text-white"},{children:a(t,{color:b,text:null!==(c=null==n?void 0:n.toString())&&void 0!==c?c:"",iconClassName:"w-4 h-4"})})),a("div",Object.assign({className:"overflow-x-auto max-w-[600px] scrollbar scrollbar-thumb-black/50 scrollbar-thumb-rounded-full scrollbar-w-[4px] scrollbar-h-[4px] dark:scrollbar-thumb-black/60"},{children:a(l,Object.assign({},d,{PreTag:"div",language:u?u[1]:"js",style:h,showLineNumbers:!0},{children:String(n).replace(/\n$/,"")}))}))]}))};export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";const r=r=>{var{node:i,title:l="Random Iframe",children:
|
|
1
|
+
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";const r=r=>{var{node:i,title:l="Random Iframe",children:s,style:a}=r,n=e(r,["node","title","children","style"]);return t("iframe",Object.assign({title:l,style:Object.assign({borderRadius:"8px",width:"100%"},a),allowFullScreen:!0},n,{children:s}))};export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../../../../../_virtual/_tslib.js";import{jsxs as e,jsx as i}from"react/jsx-runtime";import{useState as t}from"react";import{usePickaxeMarkdownContext as r}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as n}from"../../../../../../hooks/core/useHover.js";import{motion as s}from"framer-motion";import{getContrastColor as a}from"../../../../../../common/utils.js";import l from"../../../../../Icons/download.svg.js";import p from"../../../PickaxeCopyButton.js";import c from"./ImgModal.js";const d=({node:d,src:m,alt:
|
|
1
|
+
import{__rest as o}from"../../../../../../_virtual/_tslib.js";import{jsxs as e,jsx as i}from"react/jsx-runtime";import{useState as t}from"react";import{usePickaxeMarkdownContext as r}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as n}from"../../../../../../hooks/core/useHover.js";import{motion as s}from"framer-motion";import{getContrastColor as a}from"../../../../../../common/utils.js";import l from"../../../../../Icons/download.svg.js";import p from"../../../PickaxeCopyButton.js";import c from"./ImgModal.js";const d=({node:d,src:m,alt:x})=>{const{accentColor:b}=r(),[h,g]=t(!1),[u,y]=t(!1),f=n(),{isHover:w}=f,k=o(f,["isHover"]);return e("div",Object.assign({className:"pxe-markdown-image",style:{display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px",transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:w?"translateY(-5px)":"translateY(0)"}},k,{children:[u&&i(c,{src:m,isOpen:u,onChangeIsOpen:y}),h?i("p",Object.assign({style:{userSelect:"none",opacity:.5,fontStyle:"italic"}},{children:"[Image link is broken]"})):e("div",Object.assign({style:{position:"relative"}},{children:[e(s.div,Object.assign({initial:"hidden",animate:w?"visible":"hidden",variants:{hidden:{opacity:0,y:-10,pointerEvents:"none"},visible:{opacity:1,y:0,pointerEvents:"auto"}},style:{position:"absolute",display:"flex",gap:"0.4rem",top:"10px",right:"10px",color:"#FFF"}},{children:[i(s.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:b,opacity:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:o=>{o.stopPropagation(),window.open(m,"_blank")}},{children:i(l,{width:24,height:24,style:{color:a(b),flexShrink:0}})})),i(s.button,Object.assign({style:{outline:"none",padding:"0.5rem 0.65rem",borderRadius:"4px",boxShadow:"0px 4px 6px rgba(0, 0, 0, 0.1)",transition:"background-color 0.2s ease",backgroundColor:b,opacity:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:o=>o.stopPropagation()},{children:i(p,{color:a(b),iconClassName:"w-6 h-6",text:m||""})}))]})),i("img",{src:m,alt:x,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:w?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>g(!0),onClick:()=>y(!0)})]}))]}))};export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{usePickaxeMarkdownContext as i}from"../../hooks/usePickaxeMarkdownContext.js";import n from"../common/Action.js";const s=({node:s,children:l})=>{const{actions:r}=i(),o="string"==typeof l&&l.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(o&&(null==o?void 0:o[1]))return e("div",Object.assign({className:"pxe-markdown-youtube",style:{display:"flex",width:"100%",justifyContent:"center"}},{children:e("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${o[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(r&&"string"==typeof l&&l.includes("pickaxe")&&(l.includes("/api/fn/result")||l.includes("/api/function_call_results"))){const i=l.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),s=l.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return t("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e("p",{children:i}),e(n,{jobUrl:(null==s?void 0:s[0])||""})]}))}return e("p",{children:l})};export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{usePickaxeContext as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{usePickaxeContext as r}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{PickaxeMarkdownRenderer as t}from"../../Renderer.js";import s from"./Modal/index.js";import l from"./Modal/Body.js";import a from"./Modal/CloseButton.js";const i=({value:i,isOpen:n,onChangeIsOpen:c})=>{const{colors:m}=r();return e(s,Object.assign({isOpen:n,onChange:c},{children:o(l,Object.assign({className:"relative flex flex-col px-8 pt-[26px] pb-8 w-full min-[767px]:max-w-[600px] max-[767px]:border-0",style:{backgroundColor:m.primary,color:m.text,borderColor:m.text+"4D"},avoidOverflow:!0},{children:[e("div",Object.assign({className:"flex items-start justify-end gap-4"},{children:e(a,{})})),e("div",Object.assign({className:"mt-6 flex flex-col items-center"},{children:e("div",Object.assign({className:"flex w-full max-w-[550px] flex-col items-center text-center"},{children:e(t,{value:i})}))}))]}))}))};export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as o,useRef as i,useMemo as t}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import s from"react-markdown";import d from"remark-gfm";import a from"remark-math";import m from"rehype-katex";import c from"rehype-raw";import h from"./Custom/A/index.js";import p from"./Custom/P/index.js";import f from"./Custom/Img/index.js";import g from"./Custom/Iframe/index.js";import u from"./Custom/Code/index.js";import x from"./Custom/common/LinkPreview.js";import b from"./Custom/common/TextModal.js";import k from"../../../../common/cn.js";const j=({className:j,style:y,value:C,recursion:D=!1,children:O,maxChar:v,multiLineBreaks:w})=>{const{theme:B,accentColor:N,websiteMetadatas:P}=l(),[T,E]=o(!1),I=i(null),L=t((()=>{if(!C)return"";let e=C;if(e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),w&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),v&&e.length>v){const r=/(https?:\/\/[^\s)]+)/g,n=[];let o;for(;null!==(o=r.exec(e));)n.push({start:o.index,end:o.index+o[0].length});let i=v;for(const e of n)if(v>e.start&&v<e.end){i=e.end+1;break}e=e.slice(0,i)}return e}),[C,v,w]),M={h1:({node:e,children:r})=>n("h1",{children:r}),h2:({node:e,children:r})=>n("h2",{children:r}),h3:({node:e,children:r})=>n("h3",{children:r}),h4:({node:e,children:r})=>n("h4",{children:r}),h5:({node:e,children:r})=>n("h5",{children:r}),p:p,a:h,ol:({node:e,children:r})=>n("ol",{children:r}),ul:({node:e,children:r})=>n("ul",{children:r}),li:({node:e,children:r})=>n("li",{children:r}),table:({children:e})=>n("div",Object.assign({className:"pxe-markdown-table"},{children:n("table",{children:e})})),th:({node:e,children:r})=>n("th",{children:r}),tr:({node:e,children:r})=>n("tr",Object.assign({style:{border:"dark"===B?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>n("td",{children:r}),code:u,blockquote:({node:e,children:r})=>n("blockquote",Object.assign({style:{borderLeft:"dark"===B?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===B?"#8B8B8B":"#656D76"}},{children:r})),img:f,iframe:g,hr:()=>n("hr",{style:{border:0,borderTop:"dark"===B?"1px solid #30363D":"1px solid #D0D7DE"}}),span:r=>{var{node:o,children:i}=r,t=e(r,["node","children"]);return"intro-msg-expand-btn"===t.className?n("span",Object.assign({},t,{style:{display:"inline",fontWeight:500,color:N,cursor:"pointer"},onClick:()=>E(!0)},{children:i})):n("span",Object.assign({},t,{children:i}))},br:()=>n("br",{})};return r("div",Object.assign({className:"pxe-markdown",ref:I,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},y)},{children:[T&&n(b,{value:L,isOpen:T,onChangeIsOpen:E}),n(s,Object.assign({className:k("pxe-prose",j),components:M,remarkPlugins:[d,a],rehypePlugins:[m,c]},{children:`${L}${!D&&P.length>0?"\n\n---":""}${"number"==typeof v&&L.length>=v?'<span class="intro-msg-expand-btn">...</span>':""}`})),!D&&P.length>0&&n("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:P.map(((e,r)=>n(x,{data:e},r)))})),O]}))};export{j as PickaxeMarkdownRenderer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pxe-prose p{font-weight:350}.pxe-prose>p{margin-bottom:.75rem}.pxe-prose a{font-weight:600;text-decoration:underline;text-underline-offset:.2rem}.pxe-prose iframe{margin-bottom:1.5rem}.pxe-prose blockquote{margin-bottom:2.5rem;padding-bottom:.25rem;padding-left:1rem;padding-top:.25rem}.pxe-prose hr{margin-bottom:1.5rem}.pxe-prose .pxe-markdown-code,.pxe-prose .pxe-markdown-image,.pxe-prose .pxe-markdown-youtube{margin-bottom:2.5rem}.pxe-prose ol{list-style-type:decimal}.pxe-prose ol,.pxe-prose ul{list-style-position:inside;margin-bottom:1.5rem;padding-left:1rem}.pxe-prose ul{list-style-type:disc}.pxe-prose li{margin:10px}.pxe-prose li>p{display:inline}.pxe-prose .pxe-markdown-table{margin-bottom:2.5rem;overflow:auto;position:relative}.pxe-prose table{font-size:.875rem;line-height:1.24rem;table-layout:fixed}.pxe-prose th{font-weight:600;text-align:left}.pxe-prose td,.pxe-prose th{padding:.75em 1em}.pxe-prose h1{font-size:2.25rem;line-height:2.5rem;margin-bottom:1.5rem}.pxe-prose h2{font-size:1.875rem;line-height:2.25rem;margin-bottom:1.5rem}.pxe-prose h3{font-size:1.5rem;line-height:2rem;margin-bottom:1.5rem}.pxe-prose h4{font-size:1.25rem}.pxe-prose h4,.pxe-prose h5{line-height:1.75rem;margin-bottom:1rem}.pxe-prose h5{font-size:1.125rem}.pxe-prose h2:not(:first-child),.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose h5:not(:first-child),.pxe-prose>p:not(:first-child) .pxe-markdown-image,.pxe-prose>p:not(:first-child) .pxe-markdown-youtube,.pxe-prose>pre:not(:first-child){margin-top:2.5rem}
|
|
@@ -6,8 +6,9 @@ export interface PickaxeMarkdownRendererProps {
|
|
|
6
6
|
recursion?: boolean;
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
maxChar?: number;
|
|
9
|
+
multiLineBreaks?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export type Node = {
|
|
11
12
|
node?: any;
|
|
12
13
|
};
|
|
13
|
-
export declare const PickaxeMarkdownRenderer: ({ className, style, value, recursion, children: _children, maxChar, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const PickaxeMarkdownRenderer: ({ className, style, value, recursion, children: _children, maxChar, multiLineBreaks, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/src/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pickaxeproject/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Client utility library for Pickaxe",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"exports": {
|
|
11
11
|
"import": "./dist/esm/index.js",
|
|
12
|
-
"require": "./dist/cjs/index.js"
|
|
12
|
+
"require": "./dist/cjs/index.js",
|
|
13
|
+
"./prose.css": "./dist/esm/prose.css"
|
|
13
14
|
},
|
|
14
15
|
"main": "dist/cjs/index.js",
|
|
15
16
|
"module": "dist/esm/index.js",
|