@primeui-devkit/react-markdown 0.1.0-rc.4 → 0.1.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MarkdownDocument as e}from"@comark/react";import t,{componentMap as n,sanitizeOptions as r,sanitizeTree as i}from"@primeui-devkit/markdown-core/plugins/sanitize";import{jsx as a}from"react/jsx-runtime";function o(e){let t=[],n=``,r=0,i=``;for(let a of e){if(i)a===i&&(i=``);else if(a===`"`||a===`'`)i=a;else if(a===`(`)r++;else if(a===`)`)r=Math.max(0,r-1);else if(a===`;`&&r===0){t.push(n),n=``;continue}n+=a}return[...t,n]}function s(e){if(typeof e!=`string`)return e;let t=[];for(let n of o(e)){let e=n.indexOf(`:`),r=n.slice(0,e).trim(),i=n.slice(e+1).trim();e<1||!r||!i||t.push([r.startsWith(`--`)?r:r.toLowerCase().replace(/^-ms-/,`ms-`).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),i])}return Object.fromEntries(t)}function c(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`string`?JSON.stringify(s(t)):e}catch{return e}}function l(e){let t={...e};typeof e.style==`string`&&(t.style=s(e.style)),`:style`in e&&(t[`:style`]=c(e[`:style`]));for(let n of[`class`,`className`]){let r=e[n];Array.isArray(r)&&(t[n]=r.filter(Boolean).join(` `))}return t}function u(e){if(!Array.isArray(e)||typeof e[0]!=`string`)return e;let[t,n,...r]=e;return[t,l(n??{}),...r.map(u)]}function d(e){return{...e,nodes:(e.nodes??[]).map(u)}}const f=(...e)=>e.filter(Boolean).join(` `)||void 0;function p(e=[],n){let i=r(n);return i===!1?e:[...e,t(i)]}function m({sanitize:t,tree:o,components:s,className:c,...l}){let u=r(t),p=u===!1?o:i(o,u);return/* @__PURE__ */ a(e,{...l,value:d(p),components:n(s),className:f(`markdown-content prose`,c)})}function h(e={}){let{name:t,components:n,className:r,sanitize:i}=e;function o({components:e,className:t,sanitize:o=i,...s}){return/* @__PURE__ */ a(m,{...s,sanitize:o,components:{...n,...e},className:f(r,t)})}return o.displayName=t??`MarkdownRenderer`,o}export{s as a,p as i,h as n,f as r,m as t};
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{i as e,t}from"./chunks/render-
|
|
1
|
+
"use client";import{i as e,t}from"./chunks/render-CcsM4C3Y.js";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{parseMarkdown as i}from"@primeui-devkit/markdown-core";import{Suspense as a,use as o,useDeferredValue as s,useEffect as c,useMemo as l,useState as u}from"react";function d({tree:e,comarkKey:r,...i}){let[a,o]=u(null),s=e.meta?.key||r;return c(()=>{let t=globalThis.comarkContext;if(!s||!t)return;let n=t.get(s,e).listen(o);return()=>n(!0)},[s]),/* @__PURE__ */ n(t,{...i,tree:a??e})}function f({parsing:e,...t}){return/* @__PURE__ */ n(d,{...t,tree:o(e)})}function p({children:t,markdown:r=``,options:o={},plugins:c=[],sanitize:u,...d}){let p=t?String(t):r,m=l(()=>i(p,{...o,plugins:e(c,u)}),[p]),h=s(m);return/* @__PURE__ */ n(a,{fallback:null,children:/* @__PURE__ */ n(f,{...d,sanitize:u,parsing:h})})}function m({code:e=``}){let[t,i]=u(!1);async function a(){e&&(await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3))}return/* @__PURE__ */ n(`button`,{type:`button`,className:`prose-pre-copy`,title:t?`Copied`:`Copy Code`,onClick:a,children:t?/* @__PURE__ */ n(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:/* @__PURE__ */ n(`path`,{d:`M20 6 9 17l-5-5`})}):/* @__PURE__ */ r(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[/* @__PURE__ */ n(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),/* @__PURE__ */ n(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})})}export{p as MarkdownClient,d as MarkdownLive,m as ProseCopyButton};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MarkdownProps, SanitizeSetting } from './render-
|
|
2
|
-
export { MarkdownRenderer, MarkdownRendererOptions, MarkdownRendererProps, defineMarkdownRenderer } from './render-
|
|
1
|
+
import { MarkdownProps, SanitizeSetting } from './render-CwaofC8t.js';
|
|
2
|
+
export { MarkdownRenderer, MarkdownRendererOptions, MarkdownRendererProps, defineMarkdownRenderer } from './render-CwaofC8t.js';
|
|
3
3
|
import { MarkdownParseOptions, MarkdownPlugin } from '@primeui-devkit/markdown-core';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { JSX, ComponentType, ReactNode } from 'react';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./chunks/render-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./chunks/render-CcsM4C3Y.js";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{parseMarkdown as s}from"@primeui-devkit/markdown-core";import{MarkdownClient as c,MarkdownClient as l,MarkdownLive as u,ProseCopyButton as d}from"@primeui-devkit/react-markdown/client";import{createElement as f}from"react";function p(e={}){let{name:n,plugins:o=[],components:c,className:u,sanitize:d,...f}=e;async function p({children:e,markdown:n=``,options:p,plugins:m=[],components:h,className:g,sanitize:_=d,streaming:v=!1,...y}){let b=e?String(e):n,x={...y,components:{...c,...h},className:r(u,g),sanitize:_},S={...f,...p},C=[...o,...m];if(v)return/* @__PURE__ */ a(l,{...x,markdown:b,options:S,plugins:C,streaming:!0});let w=await s(b,{...S,plugins:t(C,_)});return/* @__PURE__ */ a(i,{...x,tree:w})}return Object.defineProperty(p,"name",{value:n??`Markdown`}),p}const m=/* @__PURE__ */ p({name:`Markdown`});function h(t,{class:n,className:r,style:i,...a}){return{...a,className:[t,r??n].filter(Boolean).join(` `),...i===void 0?{}:{style:e(i)}}}function g(e,t){return function({children:n,...r}){return f(e,h(t,r),n)}}function _(e,t){return function({id:n,children:r,...i}){return n?f(e,{...h(t,i),id:n},/* @__PURE__ */ o(`a`,{href:`#${n}`,className:`prose-heading-link`,children:[/* @__PURE__ */ a(`span`,{className:`prose-heading-anchor`,children:`#`}),r]})):f(e,h(t,i),r)}}const v=/* @__PURE__ */ _(`h1`,`prose-h1`),y=/* @__PURE__ */ _(`h2`,`prose-h2`),b=/* @__PURE__ */ _(`h3`,`prose-h3`),x=/* @__PURE__ */ _(`h4`,`prose-h4`),S=/* @__PURE__ */ _(`h5`,`prose-h5`),C=/* @__PURE__ */ _(`h6`,`prose-h6`),w=/* @__PURE__ */ g(`a`,`prose-a`),T=/* @__PURE__ */ g(`img`,`prose-img`);function E({code:e=``,filename:t,class:n,className:r,children:i}){let s=r??n,c=t?.replace(`:line-numbers`,``)||null,l=t?.includes(`:line-numbers`);return/* @__PURE__ */ o(`div`,{className:`prose-pre`,children:[c&&/* @__PURE__ */ a(`div`,{className:`prose-pre-filename`,children:/* @__PURE__ */ a(`span`,{children:c})}),/* @__PURE__ */ a(`div`,{className:`prose-pre-actions`,children:/* @__PURE__ */ a(d,{code:e})}),/* @__PURE__ */ a(`pre`,{className:[s,l?`prose-pre-line-numbers`:``].filter(Boolean).join(` `)||void 0,children:i})]})}function D({children:e}){return/* @__PURE__ */ a(`div`,{className:`prose-table-scroll`,children:/* @__PURE__ */ a(`table`,{className:`prose-table`,children:e})})}const O=/* @__PURE__ */ g(`p`,`prose-p`),k=/* @__PURE__ */ g(`blockquote`,`prose-blockquote`),A=/* @__PURE__ */ g(`code`,`prose-code`),j=/* @__PURE__ */ g(`em`,`prose-em`),M=/* @__PURE__ */ g(`strong`,`prose-strong`),N=/* @__PURE__ */ g(`li`,`prose-li`),P=/* @__PURE__ */ g(`ol`,`prose-ol`),F=/* @__PURE__ */ g(`ul`,`prose-ul`),I=/* @__PURE__ */ g(`tbody`,`prose-tbody`),L=/* @__PURE__ */ g(`td`,`prose-td`),R=/* @__PURE__ */ g(`th`,`prose-th`),z=/* @__PURE__ */ g(`thead`,`prose-thead`),B=/* @__PURE__ */ g(`tr`,`prose-tr`),V=/* @__PURE__ */ g(`hr`,`prose-hr`),H={ProseA:w,ProseBlockquote:k,ProseCode:A,ProseEm:j,ProseH1:v,ProseH2:y,ProseH3:b,ProseH4:x,ProseH5:S,ProseH6:C,ProseHr:V,ProseImg:T,ProseLi:N,ProseOl:P,ProseP:O,ProsePre:E,ProseStrong:M,ProseTable:D,ProseTbody:I,ProseTd:L,ProseTh:R,ProseThead:z,ProseTr:B,ProseUl:F};export{m as Markdown,c as MarkdownClient,u as MarkdownLive,i as MarkdownRenderer,w as ProseA,k as ProseBlockquote,A as ProseCode,j as ProseEm,v as ProseH1,y as ProseH2,b as ProseH3,x as ProseH4,S as ProseH5,C as ProseH6,V as ProseHr,T as ProseImg,N as ProseLi,P as ProseOl,O as ProseP,E as ProsePre,M as ProseStrong,D as ProseTable,I as ProseTbody,L as ProseTd,R as ProseTh,z as ProseThead,B as ProseTr,F as ProseUl,p as defineMarkdownComponent,n as defineMarkdownRenderer,H as proseComponents};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarkdownDocument } from '@comark/react';
|
|
2
2
|
import { MarkdownParseOptions, MarkdownPlugin } from '@primeui-devkit/markdown-core';
|
|
3
3
|
import { SanitizeOptions } from '@primeui-devkit/markdown-core/plugins/sanitize';
|
|
4
4
|
import { ComponentProps, ReactNode, JSX, ComponentType, FunctionComponent } from 'react';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type DocumentProps = ComponentProps<typeof MarkdownDocument>;
|
|
7
|
+
type ComarkRendererProps = Omit<DocumentProps, 'value'> & {
|
|
8
|
+
/** The parsed tree to render, or a bare `{ nodes }`. */
|
|
9
|
+
tree: NonNullable<DocumentProps['value']>;
|
|
10
|
+
};
|
|
7
11
|
/** The option every renderer shares: on unless `false`, or the sanitizer's options. */
|
|
8
12
|
type SanitizeSetting = boolean | SanitizeOptions;
|
|
9
13
|
type MarkdownRendererProps = ComarkRendererProps & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primeui-devkit/react-markdown",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.5",
|
|
4
4
|
"author": "PrimeTek Informatics",
|
|
5
5
|
"description": "React renderer for the PrimeUI DevKit markdown AST, plus the Prose* component set. The rendering backend is an internal implementation detail.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"README.md"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@comark/react": "
|
|
51
|
-
"@primeui-devkit/markdown-core": "0.1.0-rc.
|
|
50
|
+
"@comark/react": "0.7.0",
|
|
51
|
+
"@primeui-devkit/markdown-core": "0.1.0-rc.5"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": "^19.0.0"
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"react-dom": "^19.0.0",
|
|
63
63
|
"typescript": "~6.0.0",
|
|
64
64
|
"vitest": "4.1.11",
|
|
65
|
+
"@primeui-devkit/test-config": "0.1.0-rc.2",
|
|
65
66
|
"@primeui-devkit/bundle": "0.1.0-rc.2",
|
|
66
67
|
"@primeui-devkit/cli": "0.1.0-rc.2",
|
|
67
|
-
"@primeui-devkit/ts-config": "0.1.0-rc.2"
|
|
68
|
-
"@primeui-devkit/test-config": "0.1.0-rc.2"
|
|
68
|
+
"@primeui-devkit/ts-config": "0.1.0-rc.2"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=22.18.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ComarkRenderer as e}from"@comark/react";import t,{componentMap as n,sanitizeOptions as r,sanitizeTree as i}from"@primeui-devkit/markdown-core/plugins/sanitize";import{jsx as a}from"react/jsx-runtime";function o(e){let t=[],n=``,r=0,i=``;for(let a of e){if(i)a===i&&(i=``);else if(a===`"`||a===`'`)i=a;else if(a===`(`)r++;else if(a===`)`)r=Math.max(0,r-1);else if(a===`;`&&r===0){t.push(n),n=``;continue}n+=a}return[...t,n]}function s(e){if(typeof e!=`string`)return e;let t=[];for(let n of o(e)){let e=n.indexOf(`:`),r=n.slice(0,e).trim(),i=n.slice(e+1).trim();e<1||!r||!i||t.push([r.startsWith(`--`)?r:r.toLowerCase().replace(/^-ms-/,`ms-`).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),i])}return Object.fromEntries(t)}function c(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`string`?JSON.stringify(s(t)):e}catch{return e}}function l(e){let t={...e};typeof e.style==`string`&&(t.style=s(e.style)),`:style`in e&&(t[`:style`]=c(e[`:style`]));for(let n of[`class`,`className`]){let r=e[n];Array.isArray(r)&&(t[n]=r.filter(Boolean).join(` `))}return t}function u(e){if(!Array.isArray(e)||typeof e[0]!=`string`)return e;let[t,n,...r]=e;return[t,l(n??{}),...r.map(u)]}function d(e){return{...e,nodes:(e.nodes??[]).map(u)}}const f=(...e)=>e.filter(Boolean).join(` `)||void 0;function p(e=[],n){let i=r(n);return i===!1?e:[...e,t(i)]}function m({sanitize:t,tree:o,components:s,className:c,...l}){let u=r(t),p=u===!1?o:i(o,u);return/* @__PURE__ */ a(e,{...l,tree:d(p),components:n(s),className:f(`markdown-content prose`,c)})}function h(e={}){let{name:t,components:n,className:r,sanitize:i}=e;function o({components:e,className:t,sanitize:o=i,...s}){return/* @__PURE__ */ a(m,{...s,sanitize:o,components:{...n,...e},className:f(r,t)})}return o.displayName=t??`MarkdownRenderer`,o}export{s as a,p as i,h as n,f as r,m as t};
|