@pickaxeproject/react 1.2.0 → 1.2.2
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/common/utils.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/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/common/Action.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/PickaxeSimpleButton.js +1 -1
- package/dist/cjs/prose.css +1 -1
- package/dist/cjs/src/common/utils.d.ts +0 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -2
- package/dist/cjs/src/components/Pickaxe/common/PickaxeSimpleButton.d.ts +1 -1
- package/dist/esm/common/utils.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/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/common/Action.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/PickaxeSimpleButton.js +1 -1
- package/dist/esm/prose.css +1 -1
- package/dist/esm/src/common/utils.d.ts +0 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -2
- package/dist/esm/src/components/Pickaxe/common/PickaxeSimpleButton.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/common/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.extractUrlsFromText=t=>{const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.extractUrlsFromText=t=>{const e=t.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(e))},exports.formatBytes=(t,e=2)=>{if(!+t)return"0 Bytes";const r=e<0?0:e,o=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,o)).toFixed(r))} ${["Bytes","KB","MB","PB","EB"][o]}`},exports.generateId=(t,e="",r="")=>{let o="";for(let e=0;e<t;e++){o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return e+o+r},exports.randomStr=(t,e=!1)=>{let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";e&&(r=r.replace(/[0-9]/g,""));let o="";for(let e=0;e<t;e++)o+=r.charAt(Math.floor(Math.random()*r.length));return o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../Addons/Document/hooks/useDocument.js"),i=require("date-fns"),l=require("../../common/PickaxeMarkdown/index.js"),r=require("../../common/PickaxeMarkdown/Renderer.js"),c=require("../../../Icons/message-square-notes.svg.js"),d=require("../../../Icons/visitor.svg.js"),u=require("../../common/PickaxeIcon.js"),m=require("../../common/PickaxeSimpleButton.js"),x=require("../../common/PickaxeCopyButton.js"),h=require("../../../../common/cn.js");exports.default=({item:p})=>{const{pickaxe:j,styles:f,colors:g,misc:v,translations:b,setChatId:k,setIsNewChat:y}=o.usePickaxeContext(),{setMessages:w}=t.useResponseContext(),{upsertDocuments:N}=a.useDocument(),q=n.useStyleFontSize(),O=s.useMemo((()=>i.format(p.createdAt,"hh:mm a MMM dd, yy")),[p]),C=s.useMemo((()=>p&&p.messages?p.messages.length:0),[p]),M=s.useMemo((()=>{var e,s,o,t;if("form"===p.type){return(null!==(e=p.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(t=null===(o=null===(s=p.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[p]),I=s.useMemo((()=>{var e,s,o,t;return"form"===p.type?null!==(e=p.questionResponse)&&void 0!==e?e:"":null!==(t=null===(o=null===(s=p.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[p]);return e.jsxs("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:g.primary,color:g.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(d.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[e.jsx("input",{id:`${p.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:M.length<280}),e.jsx("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:M}}),e.jsx("label",Object.assign({htmlFor:`${p.responseId}-input`,className:h.default(q.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:g.accent}},{children:(null==b?void 0:b["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${p.responseId}-input`,className:h.default(q.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:g.accent}},{children:(null==b?void 0:b["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:g.secondary,color:g.secondaryText}},{children:[v.isChatImage&&e.jsx(u.default,{src:null==j?void 0:j.chaticon,alt:`${null==j?void 0:j.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:g.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(l.PickaxeMarkdown,Object.assign({theme:f.theme,accentColor:g.accent,linkPreviews:!0,actions:!0},{children:e.jsx(r.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:I})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==j?void 0:j.enablechatresponses)&&e.jsxs(m.default,Object.assign({color:g.accent,onClick:()=>{return e=p.responseId,N([]),w([]),y(!1),void k(e);var e}},{children:[e.jsx(c.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:h.default(q.b3,"font-semibold")},{children:C+1}))]})),e.jsx(x.default,{color:g.accent,text:I})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:h.default(q.b3,"font-semibold uppercase opacity-30")},{children:O}))}))]}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../Addons/Document/hooks/useDocument.js"),l=require("date-fns"),i=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeMarkdown/Renderer.js"),d=require("../../../Icons/message-square-notes.svg.js"),u=require("../../../Icons/visitor.svg.js"),x=require("../../common/PickaxeIcon.js"),h=require("../../common/PickaxeSimpleButton.js"),m=require("../../common/PickaxeCopyButton.js"),p=require("../../Addons/Scroll/ScrollLockView.js"),j=require("../../../../common/cn.js");exports.default=()=>{var f;const{pickaxe:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../Addons/Document/hooks/useDocument.js"),l=require("date-fns"),i=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeMarkdown/Renderer.js"),d=require("../../../Icons/message-square-notes.svg.js"),u=require("../../../Icons/visitor.svg.js"),x=require("../../common/PickaxeIcon.js"),h=require("../../common/PickaxeSimpleButton.js"),m=require("../../common/PickaxeCopyButton.js"),p=require("../../Addons/Scroll/ScrollLockView.js"),j=require("../../../../common/cn.js");exports.default=()=>{var f;const{pickaxe:g,styles:b,colors:k,misc:v,translations:y,setChatId:w,setIsNewChat:q}=o.usePickaxeContext(),{response:N,setMessages:C}=t.useResponseContext(),{scrollTargetRef:O}=n.useScrollContext(),M=r.useStyleFontSize(),{upsertDocuments:I}=a.useDocument(),S=s.useMemo((()=>N?l.format(N.createdAt,"hh:mm a MMM dd, yy"):l.format(new Date,"hh:mm a MMM dd, yy")),[N]),P=s.useMemo((()=>{var e;if(!N)return"";return(null!==(e=N.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[N]);return N?e.jsxs("div",Object.assign({ref:O,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(u.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${N.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:P.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:P}}),e.jsx("label",Object.assign({htmlFor:`${N.responseId}-input`,className:j.default(M.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${N.responseId}-input`,className:j.default(M.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[v.isChatImage&&e.jsx(x.default,{src:null==g?void 0:g.chaticon,alt:`${null==g?void 0:g.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(i.PickaxeMarkdown,Object.assign({theme:b.theme,accentColor:k.accent,linkPreviews:!0,actions:!0},{children:e.jsx(c.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:N.questionResponse})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==g?void 0:g.enablechatresponses)&&e.jsxs(h.default,Object.assign({color:k.accent,onClick:()=>{return e=N.responseId,I([]),C([]),q(!1),void w(e);var e}},{children:[e.jsx(d.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:j.default(M.b3,"font-semibold")},{children:N.messages.length+1}))]})),e.jsx(m.default,{color:k.accent,text:null!==(f=N.questionResponse)&&void 0!==f?f:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:j.default(M.b3,"font-semibold uppercase opacity-30")},{children:S}))}))]}))]}))]})),e.jsx(p.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"),s=require("react-syntax-highlighter"),
|
|
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"),i=require("../../hooks/usePickaxeMarkdownContext.js"),t=require("../../../PickaxeCopyButton.js");exports.default=a=>{var n,{node:l,children:c,className:d}=a,o=e.__rest(a,["node","children","className"]);const{syntaxTheme:u}=i.usePickaxeMarkdownContext(),x=/language-(\w+)/.exec(d||"");return r.jsx("div",Object.assign({className:"pxe-markdown-code"},{children:r.jsxs("div",{children:[r.jsx("div",{children:r.jsx(t.default,{color:"#FFFFFF",text:null!==(n=null==c?void 0:c.toString())&&void 0!==n?n:"",iconClassName:"w-4 h-4 text-white"})}),r.jsx("div",{children:r.jsx(s.Prism,Object.assign({},o,{PreTag:"div",language:x?x[1]:"js",style:u,showLineNumbers:!0},{children:String(c).replace(/\n$/,"")}))})]})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),o=require("react/jsx-runtime"),t=require("react"),i=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../../../../../../hooks/core/useHover.js"),r=require("framer-motion"),n=require("../../../../../Icons/download.svg.js"),a=require("../../../../../Icons/copied-new.svg.js"),l=require("../../../../../Icons/copy-new.svg.js"),d=require("./ImgModal.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=c(require("copy-to-clipboard"));exports.default=({node:c,src:u,alt:x})=>{const{accentColor:h,accentTextColor:b,readOnly:g}=i.usePickaxeMarkdownContext(),[j,y]=t.useState(!1),[v,w]=t.useState(!1),[f,m]=t.useState(!1),k=s.useHover(),{isHover:O}=k,q=e.__rest(k,["isHover"]);return o.jsxs("div",Object.assign({className:"pxe-markdown-image",style:Object.assign({display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px"},!g&&{transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:O?"translateY(-5px)":"translateY(0)"})},!g&&Object.assign({},q),{children:[v&&o.jsx(d.default,{src:u,isOpen:v,onChangeIsOpen:w}),j?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:[!g&&o.jsxs(r.motion.div,Object.assign({initial:"hidden",animate:O||f?"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:h,opacity:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:e=>{e.stopPropagation(),window.open(u,"_blank")}},{children:o.jsx(n.default,{width:24,height:24,style:{color:b,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:h,opacity:f?1:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:o=>{o.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){try{m(!0),p.default(u||""),yield new Promise((e=>setTimeout(e,1500)))}finally{m(!1)}}))}},{children:f?o.jsx(a.default,{width:24,height:24,style:{color:b,flexShrink:0}}):o.jsx(l.default,{width:24,height:24,style:{color:b,flexShrink:0}})}))]})),o.jsx("img",Object.assign({src:u,alt:x,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:O?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>y(!0)},!g&&{onClick:()=>w(!0)}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),r=require("@tanstack/react-query"),o=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../../../../../../common/lotties/loader-black.js"),n=require("../../../../../../common/lotties/loader-white.js"),s=require("../../../../../../common/api/streamer.js"),d=require("../../../PickaxeLottie.js"),c=require("../../Renderer.js"),l=require("framer-motion"),u=require("../../../../../../common/api/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),r=require("@tanstack/react-query"),o=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../../../../../../common/lotties/loader-black.js"),n=require("../../../../../../common/lotties/loader-white.js"),s=require("../../../../../../common/api/streamer.js"),d=require("../../../PickaxeLottie.js"),c=require("../../Renderer.js"),l=require("framer-motion"),u=require("../../../../../../common/api/utils.js"),v=require("../../../../../../common/error.js");exports.default=({jobUrl:m})=>{var j,p,x,y;const{theme:f}=o.usePickaxeMarkdownContext(),[b,h]=i.useState(""),[g,k]=i.useState(""),q=i.useRef(null),w=r.useQuery({queryKey:[m],queryFn:()=>(t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!t||t.includes("undefined"))throw new Error("Invalid action job URL");const e=yield fetch(t);return yield e.json()}catch(e){const t=v.default(e);return"development"===process.env.NODE_ENV&&console.error("[getJobResult]",t),{success:!1,error:t}}})))(m),enabled:"undefined"!=typeof window,retry:10,onSuccess:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(k(""),!t.success)return;if("text"in t)return void h(t.text||"");if(!("fcid"in t)){const e=(yield s.streamer(Object.assign({formId:t.formId,responseId:t.responseId,data:t.encodedData},t.actionData&&{actionData:t.actionData}))).body;if(!e)return;let i=!0,r="";const o=e.getReader(),a=new TextDecoder;for(;i;){const{value:e,done:t}=yield o.read();i=!t;r+=a.decode(e),h(r)}return h(r),yield u.default.post("/fn/update",{id:t.jobId,data:Object.assign(Object.assign({},t),{text:r})}),void console.log("[Action] streaming done")}yield new Promise((e=>setTimeout(e,3e3))),w.refetch(),"development"===process.env.NODE_ENV&&console.log(`[Action] refetching <${m}>`)}catch(e){k(v.default(e))}}))}),O=i.useMemo((()=>{var e;return(null===(e=w.data)||void 0===e?void 0:e.actionId)||null}),[w.data]);return t.jsx("div",Object.assign({ref:q,className:"pxe-action"},!!O&&{"data-action-id":O},{children:t.jsx(l.AnimatePresence,{children:g||w.error||(null===(j=w.data)||void 0===j?void 0:j.error)?t.jsxs(l.motion.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:[t.jsx("blockquote",Object.assign({style:{lineHeight:"20px",borderLeft:"4px solid #FF0000",color:"#FF0000",paddingLeft:"1rem",marginBottom:"1rem"}},{children:g||(null===(p=w.data)||void 0===p?void 0:p.error)||"Failed to process, please try again."})),(null===(x=w.data)||void 0===x?void 0:x.traceback)&&t.jsxs(t.Fragment,{children:[t.jsxs("p",Object.assign({style:{color:"#FF0000"}},{children:["Traceback:"," "]})),t.jsx(c.PickaxeMarkdownRenderer,{value:`\`\`\`js\n${null===(y=w.data)||void 0===y?void 0:y.traceback}\n\`\`\``,recursion:!0})]})]})):b?t.jsx(l.motion.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:t.jsx(c.PickaxeMarkdownRenderer,{value:b,recursion:!0})})):t.jsx(l.motion.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:t.jsx(d.PickaxeLottie,{id:"dark"===f?"loader-white":"loader-black",getJson:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return"dark"===f?n.loaderWhite:a.loaderBlack})),autoplay:!0,loop:!0,style:{cursor:"default",pointerEvents:"none",width:"100%",maxWidth:"150px",height:"150px"}})}))})}))};
|
|
@@ -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"),s=require("react-markdown"),i=require("remark-gfm"),l=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"),p=require("./Custom/common/LinkPreview.js"),m=require("../../../../common/cn.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=j(s),g=j(i),b=j(l),k=j(d),q=j(a);exports.PickaxeMarkdownRenderer=({className:s,style:i,value:l,recursion:d=!1,children:a,maxLines:j,multiLineBreaks:w,onExpandClick:y})=>{const{theme:v,accentColor:C,websiteMetadatas:D}=t.usePickaxeMarkdownContext(),[O,M]=n.useState({width:0,height:0}),[P,S]=n.useState(null),$=n.useRef(null),E=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)+"$")),w&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,w]);n.useEffect((()=>{if(!j)return void S(null);if(!$.current||!E||P)return;const e=$.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=j*r;if(!(O.height>n))return;const t=Math.floor(O.width/8),s=Math.floor(t*j);S(E.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[E,j,O,P]);const _={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"===v?"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"===v?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===v?"#8B8B8B":"#656D76"}},{children:n})),img:u.default,iframe:h.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===v?"1px solid #30363D":"1px solid #D0D7DE"}}),span:n=>{var{node:t,children:s}=n,i=e.__rest(n,["node","children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:C,marginLeft:".25rem",userSelect:"none"},y&&{cursor:"pointer"})},y&&{onClick:y},{children:s})):r.jsx("span",Object.assign({},i,{children:s}))},br:()=>r.jsx("br",{})};n.useEffect((()=>{if(!$.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;M({width:e,height:n})}}));return e.observe($.current),()=>{e.disconnect()}}),[]);const B=P||E,L=!d&&D.length>0?"\n\n---":"";return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:$,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},i)},{children:[r.jsx(f.default,Object.assign({className:m.default("pxe-prose",s),components:_,remarkPlugins:[g.default,b.default],rehypePlugins:[k.default,q.default]},{children:`${B}${L}`})),!d&&D.length>0&&r.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:D.map(((e,n)=>r.jsx(p.default,{data:e},n)))})),a]}))};
|
|
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("react-markdown"),i=require("remark-gfm"),l=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"),p=require("./Custom/common/LinkPreview.js"),m=require("../../../../common/cn.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=j(s),g=j(i),b=j(l),k=j(d),q=j(a);exports.PickaxeMarkdownRenderer=({className:s,style:i,value:l,recursion:d=!1,children:a,maxLines:j,multiLineBreaks:w,onExpandClick:y})=>{const{theme:v,accentColor:C,websiteMetadatas:D}=t.usePickaxeMarkdownContext(),[O,M]=n.useState({width:0,height:0}),[P,S]=n.useState(null),$=n.useRef(null),E=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)+"$")),w&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,w]);n.useEffect((()=>{if(!j)return void S(null);if(!$.current||!E||P)return;const e=$.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=j*r;if(!(O.height>n))return;const t=Math.floor(O.width/8),s=Math.floor(t*j);S(E.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[E,j,O,P]);const _={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"===v?"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"===v?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===v?"#8B8B8B":"#656D76"}},{children:n})),img:u.default,iframe:h.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===v?"1px solid #30363D":"1px solid #D0D7DE"}}),span:n=>{var{node:t,children:s}=n,i=e.__rest(n,["node","children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:C,marginLeft:".25rem",userSelect:"none"},y&&{cursor:"pointer"})},y&&{onClick:y},{children:s})):r.jsx("span",Object.assign({},i,{children:s}))},br:()=>r.jsx("br",{})};n.useEffect((()=>{if(!$.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;M({width:e,height:n})}}));return e.observe($.current),()=>{e.disconnect()}}),[]);const B=P||E,L=!d&&D.length>0?"\n\n---":"";return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:$,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},i)},{children:[r.jsx(f.default,Object.assign({className:m.default(!d&&"pxe-prose",s),components:_,remarkPlugins:[g.default,b.default],rehypePlugins:[k.default,q.default]},{children:`${B}${L}`})),!d&&D.length>0&&r.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:D.map(((e,n)=>r.jsx(p.default,{data:e},n)))})),a]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const t=o.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,accentColor:c="#228DD7",linkPreviews:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const t=o.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,accentColor:c="#228DD7",accentTextColor:l="#FFFFFF",linkPreviews:i=!1,actions:s=!1,readOnly:d=!1})=>{const[F,p]=o.useState(n),[C,u]=o.useState([]),[g,h]=o.useState(i),[m,b]=o.useState(s);return e.jsx(t.Provider,Object.assign({value:{theme:F,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"}},accentColor:c,accentTextColor:l,websiteMetadatas:C,linkPreviews:g,actions:m,readOnly:d,setTheme:p,setWebsiteMetadatas:u,setLinkPreviews:h,setActions:b}},{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("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("../../../common/cn.js");exports.default=({color:t,children:r,className:i,isForceColor:a,onClick:c})=>e.jsx("button",Object.assign({className:o.default("flex items-center gap-1 outline-none transition-opacity opacity-70 hover:opacity-100 duration-300 ease-in-out",i,a&&"opacity-100")},t&&{style:{color:t}},c&&{onClick:e=>{e.stopPropagation(),c()}},{children:r}));
|
package/dist/cjs/prose.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){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-image,.pxe-prose .pxe-markdown-youtube{margin-bottom:
|
|
1
|
+
.pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){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-image,.pxe-prose .pxe-markdown-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.pxe-prose .pxe-markdown-code{margin-bottom:1.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){margin-top:2.5rem}.pxe-prose>pre:not(:first-child){margin-top:1rem}.pxe-prose .pxe-markdown-code{display:flex;flex-direction:column}.pxe-prose .pxe-markdown-code>div:first-child{background-color:#1d1f21;border-radius:.3em;display:flex;flex-direction:column;max-width:min-content;padding-top:1em;position:relative}.pxe-prose .pxe-markdown-code>div:first-child>div:first-child{display:flex;justify-content:flex-end;padding:0 1em}.pxe-prose .pxe-markdown-code>div:first-child>div:last-child{overflow:auto}.pxe-prose .pxe-action[data-action-id]:not(:nth-child(2)){margin-top:1rem}.pxe-prose>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-youtube{margin-top:0}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const generateId: (length: number, prefix?: string, suffix?: string) => string;
|
|
2
2
|
export declare const randomStr: (len: number, charOnly?: boolean) => string;
|
|
3
3
|
export declare const extractUrlsFromText: (text: string) => string[];
|
|
4
|
-
export declare const getContrastColor: (hex: string) => "#FFFFFF" | "#000000";
|
|
5
4
|
export declare const formatBytes: (bytes: number, decimals?: number) => string;
|
package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ export declare const usePickaxeMarkdownContext: () => {
|
|
|
3
3
|
theme: import("..").PickaxeMarkdownTheme;
|
|
4
4
|
syntaxTheme: Record<string, import("react").CSSProperties>;
|
|
5
5
|
accentColor: string;
|
|
6
|
+
accentTextColor: string;
|
|
6
7
|
websiteMetadatas: import("..").WebsiteMetadata[];
|
|
7
8
|
linkPreviews: boolean;
|
|
8
9
|
actions: boolean;
|
|
9
10
|
readOnly: boolean;
|
|
10
11
|
setTheme: import("../../../../../types/common").SetState<import("..").PickaxeMarkdownTheme>;
|
|
11
|
-
setAccentColor: import("../../../../../types/common").SetState<string>;
|
|
12
12
|
setWebsiteMetadatas: import("../../../../../types/common").SetState<import("..").WebsiteMetadata[]>;
|
|
13
13
|
setLinkPreviews: import("../../../../../types/common").SetState<boolean>;
|
|
14
14
|
setActions: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -11,12 +11,12 @@ type PickaxeMarkdownContextType = {
|
|
|
11
11
|
theme: PickaxeMarkdownTheme;
|
|
12
12
|
syntaxTheme: Record<string, CSSProperties>;
|
|
13
13
|
accentColor: string;
|
|
14
|
+
accentTextColor: string;
|
|
14
15
|
websiteMetadatas: WebsiteMetadata[];
|
|
15
16
|
linkPreviews: boolean;
|
|
16
17
|
actions: boolean;
|
|
17
18
|
readOnly: boolean;
|
|
18
19
|
setTheme: SetState<PickaxeMarkdownTheme>;
|
|
19
|
-
setAccentColor: SetState<string>;
|
|
20
20
|
setWebsiteMetadatas: SetState<WebsiteMetadata[]>;
|
|
21
21
|
setLinkPreviews: SetState<boolean>;
|
|
22
22
|
setActions: SetState<boolean>;
|
|
@@ -26,10 +26,11 @@ export interface PickaxeMarkdownProps {
|
|
|
26
26
|
theme?: PickaxeMarkdownTheme;
|
|
27
27
|
syntaxTheme?: Record<string, CSSProperties>;
|
|
28
28
|
accentColor?: string;
|
|
29
|
+
accentTextColor?: string;
|
|
29
30
|
linkPreviews?: boolean;
|
|
30
31
|
actions?: boolean;
|
|
31
32
|
readOnly?: boolean;
|
|
32
33
|
}
|
|
33
34
|
export declare const PickaxeMarkdownContext: import("react").Context<PickaxeMarkdownContextType>;
|
|
34
|
-
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor
|
|
35
|
+
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor, accentTextColor, linkPreviews: _linkPreviews, actions: _actions, readOnly, }: PickaxeMarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
36
|
export default PickaxeMarkdown;
|
package/dist/esm/common/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=(t,r="",e="")=>{let
|
|
1
|
+
const t=(t,r="",e="")=>{let o="";for(let r=0;r<t;r++){o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return r+o+e},r=(t,r=!1)=>{let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";r&&(e=e.replace(/[0-9]/g,""));let o="";for(let r=0;r<t;r++)o+=e.charAt(Math.floor(Math.random()*e.length));return o},e=t=>{const r=t.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(r))},o=(t,r=2)=>{if(!+t)return"0 Bytes";const e=r<0?0:r,o=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,o)).toFixed(e))} ${["Bytes","KB","MB","PB","EB"][o]}`};export{e as extractUrlsFromText,o as formatBytes,t as generateId,r as randomStr};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as r}from"../../Addons/Document/hooks/useDocument.js";import{format as a}from"date-fns";import{PickaxeMarkdown as l}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as c}from"../../common/PickaxeMarkdown/Renderer.js";import m from"../../../Icons/message-square-notes.svg.js";import d from"../../../Icons/visitor.svg.js";import p from"../../common/PickaxeIcon.js";import h from"../../common/PickaxeSimpleButton.js";import u from"../../common/PickaxeCopyButton.js";import f from"../../../../common/cn.js";const g=({item:g})=>{const{pickaxe:x,styles:v,colors:b,misc:j,translations:k,setChatId:y,setIsNewChat:w}=t(),{setMessages:N}=n(),{upsertDocuments:O}=r(),C=i(),I=o((()=>a(g.createdAt,"hh:mm a MMM dd, yy")),[g]),M=o((()=>g&&g.messages?g.messages.length:0),[g]),P=o((()=>{var e,s,o,t;if("form"===g.type){return(null!==(e=g.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(t=null===(o=null===(s=g.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[g]),$=o((()=>{var e,s,o,t;return"form"===g.type?null!==(e=g.questionResponse)&&void 0!==e?e:"":null!==(t=null===(o=null===(s=g.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[g]);return e("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:b.primary,color:b.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(d,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${g.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:P.length<280}),s("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:P}}),s("label",Object.assign({htmlFor:`${g.responseId}-input`,className:f(C.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:b.accent}},{children:(null==k?void 0:k["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${g.responseId}-input`,className:f(C.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:b.accent}},{children:(null==k?void 0:k["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:b.secondary,color:b.secondaryText}},{children:[j.isChatImage&&s(p,{src:null==x?void 0:x.chaticon,alt:`${null==x?void 0:x.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:b.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(l,Object.assign({theme:v.theme,accentColor:b.accent,linkPreviews:!0,actions:!0},{children:s(c,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:$})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==x?void 0:x.enablechatresponses)&&e(h,Object.assign({color:b.accent,onClick:()=>{return e=g.responseId,O([]),N([]),w(!1),void y(e);var e}},{children:[s(m,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:f(C.b3,"font-semibold")},{children:M+1}))]})),s(u,{color:b.accent,text:$})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:f(C.b3,"font-semibold uppercase opacity-30")},{children:I}))}))]}))]}))]}))]}))};export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useScrollContext as r}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{format as c}from"date-fns";import{PickaxeMarkdown as a}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as m}from"../../common/PickaxeMarkdown/Renderer.js";import d from"../../../Icons/message-square-notes.svg.js";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../common/PickaxeSimpleButton.js";import u from"../../common/PickaxeCopyButton.js";import x from"../../Addons/Scroll/ScrollLockView.js";import g from"../../../../common/cn.js";const b=()=>{var b;const{pickaxe:v,styles:j,colors:k,misc:y,translations:w,setChatId:N,setIsNewChat:O}=t(),{response:C}=n(),{scrollTargetRef:
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useScrollContext as r}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{format as c}from"date-fns";import{PickaxeMarkdown as a}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as m}from"../../common/PickaxeMarkdown/Renderer.js";import d from"../../../Icons/message-square-notes.svg.js";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../common/PickaxeSimpleButton.js";import u from"../../common/PickaxeCopyButton.js";import x from"../../Addons/Scroll/ScrollLockView.js";import g from"../../../../common/cn.js";const b=()=>{var b;const{pickaxe:v,styles:j,colors:k,misc:y,translations:w,setChatId:N,setIsNewChat:O}=t(),{response:C,setMessages:I}=n(),{scrollTargetRef:S}=r(),D=i(),{upsertDocuments:M}=l(),P=o((()=>c(C?C.createdAt:new Date,"hh:mm a MMM dd, yy")),[C]),$=o((()=>{var e;if(!C)return"";return(null!==(e=C.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[C]);return C?e("div",Object.assign({ref:S,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(p,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${C.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:$.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:$}}),s("label",Object.assign({htmlFor:`${C.responseId}-input`,className:g(D.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${C.responseId}-input`,className:g(D.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[y.isChatImage&&s(h,{src:null==v?void 0:v.chaticon,alt:`${null==v?void 0:v.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(a,Object.assign({theme:j.theme,accentColor:k.accent,linkPreviews:!0,actions:!0},{children:s(m,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:C.questionResponse})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==v?void 0:v.enablechatresponses)&&e(f,Object.assign({color:k.accent,onClick:()=>{return e=C.responseId,M([]),I([]),O(!1),void N(e);var e}},{children:[s(d,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:g(D.b3,"font-semibold")},{children:C.messages.length+1}))]})),s(u,{color:k.accent,text:null!==(b=C.questionResponse)&&void 0!==b?b:""})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:g(D.b3,"font-semibold uppercase opacity-30")},{children:P}))}))]}))]}))]})),s(x,{className:"w-full"})]})):null};export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as r,jsxs as
|
|
1
|
+
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Prism as t}from"react-syntax-highlighter";import{usePickaxeMarkdownContext as n}from"../../hooks/usePickaxeMarkdownContext.js";import o from"../../../PickaxeCopyButton.js";const a=a=>{var s,{node:l,children:c,className:d}=a,m=e(a,["node","children","className"]);const{syntaxTheme:h}=n(),g=/language-(\w+)/.exec(d||"");return r("div",Object.assign({className:"pxe-markdown-code"},{children:i("div",{children:[r("div",{children:r(o,{color:"#FFFFFF",text:null!==(s=null==c?void 0:c.toString())&&void 0!==s?s:"",iconClassName:"w-4 h-4 text-white"})}),r("div",{children:r(t,Object.assign({},m,{PreTag:"div",language:g?g[1]:"js",style:h,showLineNumbers:!0},{children:String(c).replace(/\n$/,"")}))})]})}))};export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../../../../../_virtual/_tslib.js";import{jsxs as
|
|
1
|
+
import{__rest as o,__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useState as r}from"react";import{usePickaxeMarkdownContext as n}from"../../hooks/usePickaxeMarkdownContext.js";import{useHover as s}from"../../../../../../hooks/core/useHover.js";import{motion as a}from"framer-motion";import l from"../../../../../Icons/download.svg.js";import c from"../../../../../Icons/copied-new.svg.js";import p from"../../../../../Icons/copy-new.svg.js";import d from"./ImgModal.js";import m from"copy-to-clipboard";const b=({node:b,src:h,alt:g})=>{const{accentColor:x,accentTextColor:y,readOnly:f}=n(),[u,v]=r(!1),[w,j]=r(!1),[k,O]=r(!1),C=s(),{isHover:S}=C,I=o(C,["isHover"]);return i("div",Object.assign({className:"pxe-markdown-image",style:Object.assign({display:"flex",width:"100%",justifyContent:"center",overflow:"hidden",borderRadius:"8px"},!f&&{transition:"transform 0.3s ease, box-shadow 0.3s ease",transform:S?"translateY(-5px)":"translateY(0)"})},!f&&Object.assign({},I),{children:[w&&t(d,{src:h,isOpen:w,onChangeIsOpen:j}),u?t("p",Object.assign({style:{userSelect:"none",opacity:.5,fontStyle:"italic"}},{children:"[Image link is broken]"})):i("div",Object.assign({style:{position:"relative"}},{children:[!f&&i(a.div,Object.assign({initial:"hidden",animate:S||k?"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:[t(a.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:o=>{o.stopPropagation(),window.open(h,"_blank")}},{children:t(l,{width:24,height:24,style:{color:y,flexShrink:0}})})),t(a.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:k?1:.6},whileTap:{scale:.95},whileHover:{opacity:1},onClick:o=>{o.stopPropagation(),e(void 0,void 0,void 0,(function*(){try{O(!0),m(h||""),yield new Promise((o=>setTimeout(o,1500)))}finally{O(!1)}}))}},{children:t(k?c:p,{width:24,height:24,style:{color:y,flexShrink:0}})}))]})),t("img",Object.assign({src:h,alt:g,style:{borderRadius:"8px",width:"100%",transition:"box-shadow 0.3s ease",boxShadow:S?"inset 0px 4px 10px rgba(0, 0, 0, 0.5)":"none"},onError:()=>v(!0)},!f&&{onClick:()=>j(!0)}))]}))]}))};export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n}from"react";import{useQuery as
|
|
1
|
+
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n,useMemo as a}from"react";import{useQuery as d}from"@tanstack/react-query";import{usePickaxeMarkdownContext as c}from"../../hooks/usePickaxeMarkdownContext.js";import{loaderBlack as s}from"../../../../../../common/lotties/loader-black.js";import{loaderWhite as l}from"../../../../../../common/lotties/loader-white.js";import{streamer as m}from"../../../../../../common/api/streamer.js";import{PickaxeLottie as u}from"../../../PickaxeLottie.js";import{PickaxeMarkdownRenderer as p}from"../../Renderer.js";import{AnimatePresence as f,motion as v}from"framer-motion";import y from"../../../../../../common/api/utils.js";import j from"../../../../../../common/error.js";const b=({jobUrl:b})=>{var h,g,x,k;const{theme:O}=c(),[w,F]=r(""),[D,I]=r(""),E=n(null),N=d({queryKey:[b],queryFn:()=>(o=>e(void 0,void 0,void 0,(function*(){try{if(!o||o.includes("undefined"))throw new Error("Invalid action job URL");const e=yield fetch(o);return yield e.json()}catch(e){const o=j(e);return"development"===process.env.NODE_ENV&&console.error("[getJobResult]",o),{success:!1,error:o}}})))(b),enabled:"undefined"!=typeof window,retry:10,onSuccess:o=>e(void 0,void 0,void 0,(function*(){try{if(I(""),!o.success)return;if("text"in o)return void F(o.text||"");if(!("fcid"in o)){const e=(yield m(Object.assign({formId:o.formId,responseId:o.responseId,data:o.encodedData},o.actionData&&{actionData:o.actionData}))).body;if(!e)return;let t=!0,i="";const r=e.getReader(),n=new TextDecoder;for(;t;){const{value:e,done:o}=yield r.read();t=!o;i+=n.decode(e),F(i)}return F(i),yield y.post("/fn/update",{id:o.jobId,data:Object.assign(Object.assign({},o),{text:i})}),void console.log("[Action] streaming done")}yield new Promise((e=>setTimeout(e,3e3))),N.refetch(),"development"===process.env.NODE_ENV&&console.log(`[Action] refetching <${b}>`)}catch(e){I(j(e))}}))}),q=a((()=>{var e;return(null===(e=N.data)||void 0===e?void 0:e.actionId)||null}),[N.data]);return o("div",Object.assign({ref:E,className:"pxe-action"},!!q&&{"data-action-id":q},{children:o(f,{children:D||N.error||(null===(h=N.data)||void 0===h?void 0:h.error)?t(v.div,Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:[o("blockquote",Object.assign({style:{lineHeight:"20px",borderLeft:"4px solid #FF0000",color:"#FF0000",paddingLeft:"1rem",marginBottom:"1rem"}},{children:D||(null===(g=N.data)||void 0===g?void 0:g.error)||"Failed to process, please try again."})),(null===(x=N.data)||void 0===x?void 0:x.traceback)&&t(i,{children:[t("p",Object.assign({style:{color:"#FF0000"}},{children:["Traceback:"," "]})),o(p,{value:`\`\`\`js\n${null===(k=N.data)||void 0===k?void 0:k.traceback}\n\`\`\``,recursion:!0})]})]})):o(v.div,w?Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:o(p,{value:w,recursion:!0})}):Object.assign({initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}},{children:o(u,{id:"dark"===O?"loader-white":"loader-black",getJson:()=>e(void 0,void 0,void 0,(function*(){return"dark"===O?l:s})),autoplay:!0,loop:!0,style:{cursor:"default",pointerEvents:"none",width:"100%",maxWidth:"150px",height:"150px"}})}))})}))};export{b 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 i,useRef as t,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import d from"react-markdown";import c from"remark-gfm";import a from"remark-math";import m from"rehype-katex";import h from"rehype-raw";import p from"./Custom/A/index.js";import u from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import x from"./Custom/common/LinkPreview.js";import k from"../../../../common/cn.js";const j=({className:j,style:w,value:y,recursion:D=!1,children:C,maxLines:v,multiLineBreaks:O,onExpandClick:$})=>{const{theme:S,accentColor:B,websiteMetadatas:L}=l(),[N,P]=i({width:0,height:0}),[E,M]=i(null),I=t(null),T=o((()=>{if(!y)return"";let e=y.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)+"$")),O&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[y,O]);s((()=>{if(!v)return void M(null);if(!I.current||!T||E)return;const e=I.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=v*r;if(!(N.height>n))return;const i=Math.floor(N.width/8),t=Math.floor(i*v);M(T.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[T,v,N,E]);const q={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:u,a:p,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"===S?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>n("td",{children:r}),code:b,blockquote:({node:e,children:r})=>n("blockquote",Object.assign({style:{borderLeft:"dark"===S?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===S?"#8B8B8B":"#656D76"}},{children:r})),img:g,iframe:f,hr:()=>n("hr",{style:{border:0,borderTop:"dark"===S?"1px solid #30363D":"1px solid #D0D7DE"}}),span:r=>{var{node:i,children:t}=r,o=e(r,["node","children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:B,marginLeft:".25rem",userSelect:"none"},$&&{cursor:"pointer"})},$&&{onClick:$},{children:t})):n("span",Object.assign({},o,{children:t}))},br:()=>n("br",{})};s((()=>{if(!I.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;P({width:e,height:n})}}));return e.observe(I.current),()=>{e.disconnect()}}),[]);const R=E||T,W=!D&&L.length>0?"\n\n---":"";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"},w)},{children:[n(d,Object.assign({className:k("pxe-prose",j),components:q,remarkPlugins:[c,a],rehypePlugins:[m,h]},{children:`${R}${W}`})),!D&&L.length>0&&n("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:L.map(((e,r)=>n(x,{data:e},r)))})),C]}))};export{j as PickaxeMarkdownRenderer};
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as t,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import d from"react-markdown";import c from"remark-gfm";import a from"remark-math";import m from"rehype-katex";import h from"rehype-raw";import p from"./Custom/A/index.js";import u from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import x from"./Custom/common/LinkPreview.js";import k from"../../../../common/cn.js";const j=({className:j,style:w,value:y,recursion:D=!1,children:C,maxLines:v,multiLineBreaks:O,onExpandClick:$})=>{const{theme:S,accentColor:B,websiteMetadatas:L}=l(),[N,P]=i({width:0,height:0}),[E,M]=i(null),I=t(null),T=o((()=>{if(!y)return"";let e=y.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)+"$")),O&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[y,O]);s((()=>{if(!v)return void M(null);if(!I.current||!T||E)return;const e=I.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=v*r;if(!(N.height>n))return;const i=Math.floor(N.width/8),t=Math.floor(i*v);M(T.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[T,v,N,E]);const q={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:u,a:p,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"===S?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>n("td",{children:r}),code:b,blockquote:({node:e,children:r})=>n("blockquote",Object.assign({style:{borderLeft:"dark"===S?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===S?"#8B8B8B":"#656D76"}},{children:r})),img:g,iframe:f,hr:()=>n("hr",{style:{border:0,borderTop:"dark"===S?"1px solid #30363D":"1px solid #D0D7DE"}}),span:r=>{var{node:i,children:t}=r,o=e(r,["node","children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:B,marginLeft:".25rem",userSelect:"none"},$&&{cursor:"pointer"})},$&&{onClick:$},{children:t})):n("span",Object.assign({},o,{children:t}))},br:()=>n("br",{})};s((()=>{if(!I.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;P({width:e,height:n})}}));return e.observe(I.current),()=>{e.disconnect()}}),[]);const R=E||T,W=!D&&L.length>0?"\n\n---":"";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"},w)},{children:[n(d,Object.assign({className:k(!D&&"pxe-prose",j),components:q,remarkPlugins:[c,a],rehypePlugins:[m,h]},{children:`${R}${W}`})),!D&&L.length>0&&n("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:L.map(((e,r)=>n(x,{data:e},r)))})),C]}))};export{j 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:a,accentColor:c="#228DD7",linkPreviews:
|
|
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:c="#228DD7",accentTextColor:l="#FFFFFF",linkPreviews:i=!1,actions:s=!1,readOnly:d=!1})=>{const[F,p]=r(n),[C,m]=r([]),[g,h]=r(i),[u,b]=r(s);return o(t.Provider,Object.assign({value:{theme:F,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"}},accentColor:c,accentTextColor:l,websiteMetadatas:C,linkPreviews:g,actions:u,readOnly:d,setTheme:p,setWebsiteMetadatas:m,setLinkPreviews:h,setActions:b}},{children:e}))};export{n as PickaxeMarkdown,t as PickaxeMarkdownContext,n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import t from"../../../common/cn.js";const e=({color:e,children:i,className:c,isForceColor:n,onClick:a})=>o("button",Object.assign({className:t("flex items-center gap-1 outline-none transition-opacity opacity-70 hover:opacity-100 duration-300 ease-in-out",c,n&&"opacity-100")},e&&{style:{color:e}},a&&{onClick:o=>{o.stopPropagation(),a()}},{children:i}));export{e as default};
|
package/dist/esm/prose.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){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-image,.pxe-prose .pxe-markdown-youtube{margin-bottom:
|
|
1
|
+
.pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){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-image,.pxe-prose .pxe-markdown-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.pxe-prose .pxe-markdown-code{margin-bottom:1.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){margin-top:2.5rem}.pxe-prose>pre:not(:first-child){margin-top:1rem}.pxe-prose .pxe-markdown-code{display:flex;flex-direction:column}.pxe-prose .pxe-markdown-code>div:first-child{background-color:#1d1f21;border-radius:.3em;display:flex;flex-direction:column;max-width:min-content;padding-top:1em;position:relative}.pxe-prose .pxe-markdown-code>div:first-child>div:first-child{display:flex;justify-content:flex-end;padding:0 1em}.pxe-prose .pxe-markdown-code>div:first-child>div:last-child{overflow:auto}.pxe-prose .pxe-action[data-action-id]:not(:nth-child(2)){margin-top:1rem}.pxe-prose>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-youtube{margin-top:0}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const generateId: (length: number, prefix?: string, suffix?: string) => string;
|
|
2
2
|
export declare const randomStr: (len: number, charOnly?: boolean) => string;
|
|
3
3
|
export declare const extractUrlsFromText: (text: string) => string[];
|
|
4
|
-
export declare const getContrastColor: (hex: string) => "#FFFFFF" | "#000000";
|
|
5
4
|
export declare const formatBytes: (bytes: number, decimals?: number) => string;
|
package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ export declare const usePickaxeMarkdownContext: () => {
|
|
|
3
3
|
theme: import("..").PickaxeMarkdownTheme;
|
|
4
4
|
syntaxTheme: Record<string, import("react").CSSProperties>;
|
|
5
5
|
accentColor: string;
|
|
6
|
+
accentTextColor: string;
|
|
6
7
|
websiteMetadatas: import("..").WebsiteMetadata[];
|
|
7
8
|
linkPreviews: boolean;
|
|
8
9
|
actions: boolean;
|
|
9
10
|
readOnly: boolean;
|
|
10
11
|
setTheme: import("../../../../../types/common").SetState<import("..").PickaxeMarkdownTheme>;
|
|
11
|
-
setAccentColor: import("../../../../../types/common").SetState<string>;
|
|
12
12
|
setWebsiteMetadatas: import("../../../../../types/common").SetState<import("..").WebsiteMetadata[]>;
|
|
13
13
|
setLinkPreviews: import("../../../../../types/common").SetState<boolean>;
|
|
14
14
|
setActions: import("../../../../../types/common").SetState<boolean>;
|
|
@@ -11,12 +11,12 @@ type PickaxeMarkdownContextType = {
|
|
|
11
11
|
theme: PickaxeMarkdownTheme;
|
|
12
12
|
syntaxTheme: Record<string, CSSProperties>;
|
|
13
13
|
accentColor: string;
|
|
14
|
+
accentTextColor: string;
|
|
14
15
|
websiteMetadatas: WebsiteMetadata[];
|
|
15
16
|
linkPreviews: boolean;
|
|
16
17
|
actions: boolean;
|
|
17
18
|
readOnly: boolean;
|
|
18
19
|
setTheme: SetState<PickaxeMarkdownTheme>;
|
|
19
|
-
setAccentColor: SetState<string>;
|
|
20
20
|
setWebsiteMetadatas: SetState<WebsiteMetadata[]>;
|
|
21
21
|
setLinkPreviews: SetState<boolean>;
|
|
22
22
|
setActions: SetState<boolean>;
|
|
@@ -26,10 +26,11 @@ export interface PickaxeMarkdownProps {
|
|
|
26
26
|
theme?: PickaxeMarkdownTheme;
|
|
27
27
|
syntaxTheme?: Record<string, CSSProperties>;
|
|
28
28
|
accentColor?: string;
|
|
29
|
+
accentTextColor?: string;
|
|
29
30
|
linkPreviews?: boolean;
|
|
30
31
|
actions?: boolean;
|
|
31
32
|
readOnly?: boolean;
|
|
32
33
|
}
|
|
33
34
|
export declare const PickaxeMarkdownContext: import("react").Context<PickaxeMarkdownContextType>;
|
|
34
|
-
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor
|
|
35
|
+
export declare const PickaxeMarkdown: ({ children, theme: _theme, syntaxTheme, accentColor, accentTextColor, linkPreviews: _linkPreviews, actions: _actions, readOnly, }: PickaxeMarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
36
|
export default PickaxeMarkdown;
|