@donotdev/templates 0.0.4 → 0.0.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.
@@ -1,27 +1,9 @@
1
- import type { ComponentType } from 'react';
2
1
  export interface MarkdownViewerProps {
3
- /** Pre-parsed HTML (from getStaticProps) */
4
- html?: string;
5
- /** Raw markdown content (parses on client) */
2
+ /** Raw markdown content */
6
3
  content?: string;
7
4
  /** Additional CSS classes */
8
5
  className?: string;
9
6
  }
10
- /**
11
- * MarkdownViewer - Renders markdown content using framework components
12
- *
13
- * Features:
14
- * - Accepts pre-parsed HTML (Next.js SSR) or raw markdown (client-side)
15
- * - Code blocks use framework Code component (Shiki syntax highlighting)
16
- * - Links use framework Link component (internal) or <a> (external)
17
- * - Framework prose typography
18
- * - Theme-aware styling
19
- * - 100% Lighthouse compliant
20
- *
21
- * @version 0.0.1
22
- * @since 0.0.1
23
- * @author AMBROISE PARK Consulting
24
- */
25
- export declare const MarkdownViewer: ComponentType<MarkdownViewerProps>;
7
+ export declare const MarkdownViewer: import("react").NamedExoticComponent<MarkdownViewerProps>;
26
8
  export default MarkdownViewer;
27
9
  //# sourceMappingURL=MarkdownViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownViewer.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownViewer.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,mBAAmB,CA2V7D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"MarkdownViewer.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownViewer.tsx"],"names":[],"mappings":"AAyBA,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqED,eAAO,MAAM,cAAc,2DAA2B,CAAC;AACvD,eAAe,cAAc,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r}from"react/jsx-runtime";import{marked as M}from"marked";import{useMemo as g}from"react";import{Code as x,cn as b}from"@donotdev/components";import{isClient as v}from"@donotdev/core";import{Link as T}from"@donotdev/ui";const B=({html:d,content:l,className:p})=>{const m=g(()=>{if(d)return d;if(!l||!v())return"";try{const i=M.parse(l);return typeof i=="string"?i:i.toString()}catch{return""}},[d,l]),c=g(()=>{if(!m)return null;const f=new DOMParser().parseFromString(m,"text/html").body,h=s=>{if(s.nodeType===Node.TEXT_NODE)return s.textContent;if(s.nodeType!==Node.ELEMENT_NODE)return null;const o=s,y=o.tagName.toLowerCase(),e=Array.from(o.childNodes).map(h).filter(Boolean);switch(y){case"pre":{const t=o.querySelector("code");if(!t)return null;const a=t.textContent||"",u=t.className.replace("language-","")||"text";return r(x,{language:u,children:a},Math.random())}case"a":{const t=o.getAttribute("href")||"",a=o.textContent||"";return t.startsWith("http")||t.startsWith("//")?r("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:n=>{n.currentTarget.style.textDecoration="underline"},onMouseLeave:n=>{n.currentTarget.style.textDecoration="none"},children:a},Math.random()):r(T,{path:t,style:{color:"var(--primary)",textDecoration:"none"},onMouseEnter:n=>{n.currentTarget.style.textDecoration="underline"},onMouseLeave:n=>{n.currentTarget.style.textDecoration="none"},children:a},Math.random())}case"h1":return r("h1",{style:{fontSize:"var(--font-size-3xl)",fontWeight:700,marginTop:"2rem",marginBottom:"1rem"},children:e},Math.random());case"h2":return r("h2",{style:{fontSize:"var(--font-size-2xl)",fontWeight:700,marginTop:"1.5rem",marginBottom:"0.75rem"},children:e},Math.random());case"h3":return r("h3",{style:{fontSize:"var(--font-size-xl)",fontWeight:600,marginTop:"1rem",marginBottom:"0.5rem"},children:e},Math.random());case"h4":return r("h4",{style:{fontSize:"var(--font-size-lg)",fontWeight:600,marginTop:"0.75rem",marginBottom:"0.5rem"},children:e},Math.random());case"p":return r("p",{style:{marginBottom:"1rem",lineHeight:1.6},children:e},Math.random());case"ul":return r("ul",{style:{listStyleType:"disc",listStylePosition:"inside",marginBottom:"1rem",display:"grid",gap:"var(--gap-sm)"},children:e},Math.random());case"ol":return r("ol",{style:{listStyleType:"decimal",listStylePosition:"inside",marginBottom:"1rem",display:"grid",gap:"var(--gap-sm)"},children:e},Math.random());case"li":return r("li",{children:e},Math.random());case"blockquote":return r("blockquote",{style:{borderLeft:"4px solid var(--primary)",paddingLeft:"1rem",fontStyle:"italic",marginTop:"1rem",marginBottom:"1rem"},children:e},Math.random());case"code":return r("code",{style:{backgroundColor:"var(--muted)",paddingLeft:"0.375rem",paddingRight:"0.375rem",paddingTop:"0.125rem",paddingBottom:"0.125rem",borderRadius:"var(--radius-lg)",fontSize:"var(--font-size-sm)",fontFamily:"monospace"},children:o.textContent},Math.random());case"strong":case"b":return r("strong",{children:e},Math.random());case"em":case"i":return r("em",{children:e},Math.random());case"img":{const t=o.getAttribute("src")||"",a=o.getAttribute("alt")||"";return r("img",{src:t,alt:a,className:"dndev-w-full",style:{maxWidth:"100%",height:"auto",marginTop:"1rem",marginBottom:"1rem",borderRadius:"var(--radius-lg)"},loading:"lazy"},Math.random())}case"table":return r("div",{className:"dndev-overflow-x-hidden",style:{marginTop:"1rem",marginBottom:"1rem"},children:r("table",{style:{minWidth:"100%",borderCollapse:"collapse",border:"1px solid var(--border)"},children:e})},Math.random());case"thead":return r("thead",{children:e},Math.random());case"tbody":return r("tbody",{children:e},Math.random());case"tr":return r("tr",{style:{borderBottom:"1px solid var(--border)"},children:e},Math.random());case"th":return r("th",{style:{border:"1px solid var(--border)",padding:"0.5rem 1rem",textAlign:"left",fontWeight:600,backgroundColor:"var(--muted)"},children:e},Math.random());case"td":return r("td",{style:{border:"1px solid var(--border)",padding:"0.5rem 1rem"},children:e},Math.random());case"hr":return r("hr",{style:{marginTop:"2rem",marginBottom:"2rem",borderColor:"var(--border)"}},Math.random());default:return r("div",{children:e},Math.random())}};return Array.from(f.childNodes).map(h).filter(Boolean)},[m]);return c?r("div",{className:b(p),style:{maxWidth:"none"},children:c}):null};var D=B;export{B as MarkdownViewer,D as default};
1
+ "use client";import{jsx as s}from"react/jsx-runtime";import{memo as p,useMemo as h}from"react";import{marked as x}from"marked";import g,{domToReact as k,Element as a}from"html-react-parser";import{Code as w,cn as b}from"@donotdev/components";import{Link as E}from"@donotdev/ui";function m(n){let o="";for(const r of n.children)r.type==="text"?o+=r.data:r instanceof a&&(o+=m(r));return o}const M=({content:n,className:o})=>{const r=h(()=>{if(!n)return null;const d=x.parse(n,{async:!1,gfm:!0,breaks:!0});return g(d,{replace(i){if(!(i instanceof a))return;const{name:c,attribs:u,children:f}=i;if(c==="pre"){const e=f.find(t=>t instanceof a&&t.name==="code");if(e){const t=/language-(\w+)/.exec(e.attribs?.class||"")?.[1]||"text";return s(w,{language:t,children:m(e).replace(/\n$/,"")})}}if(c==="a"){const e=u?.href||"",t=e.startsWith("http")||e.startsWith("//"),l=k(f);return t?s("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:l}):s(E,{path:e,children:l})}}})},[n]);return r?s("div",{className:b("prose",o),children:r}):null},j=p(M);var B=j;export{j as MarkdownViewer,B as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/templates",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -45,19 +45,20 @@
45
45
  "type-check": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@donotdev/adv-comps": "0.0.4",
49
- "@donotdev/components": "0.0.4",
50
- "@donotdev/core": "0.0.4",
51
- "@donotdev/crud": "0.0.4",
52
- "@donotdev/ui": "0.0.4",
48
+ "@donotdev/adv-comps": "0.0.5",
49
+ "@donotdev/components": "0.0.5",
50
+ "@donotdev/core": "0.0.5",
51
+ "@donotdev/crud": "0.0.5",
52
+ "@donotdev/ui": "0.0.5",
53
53
  "@hookform/resolvers": "^5.2.2",
54
+ "html-react-parser": "^5.2.11",
54
55
  "marked": "^17.0.1",
55
- "react-hook-form": "^7.68.0"
56
+ "react-hook-form": "^7.71.0"
56
57
  },
57
58
  "peerDependencies": {
58
- "@donotdev/auth": "0.0.4",
59
- "@donotdev/billing": "0.0.4",
60
- "@donotdev/oauth": "0.0.4",
59
+ "@donotdev/auth": "0.0.5",
60
+ "@donotdev/billing": "0.0.5",
61
+ "@donotdev/oauth": "0.0.5",
61
62
  "lucide-react": "^0.562.0",
62
63
  "react": "^19.2.3",
63
64
  "react-dom": "^19.2.3",