@create-markdown/react 2.0.0 → 2.0.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/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var S=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var U=(o,e)=>{for(var t in e)S(o,t,{get:e[t],enumerable:!0})},N=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let k of M(e))!L.call(o,k)&&k!==t&&S(o,k,{get:()=>e[k],enumerable:!(i=D(e,k))||i.enumerable});return o};var q=o=>N(S({},"__esModule",{value:!0}),o);var W={};U(W,{BlockElement:()=>b,BlockRenderer:()=>w,InlineContent:()=>g,VERSION:()=>Q,blockquote:()=>r.blockquote,bold:()=>r.bold,bulletList:()=>r.bulletList,callout:()=>r.callout,checkList:()=>r.checkList,checkListItem:()=>r.checkListItem,code:()=>r.code,codeBlock:()=>r.codeBlock,divider:()=>r.divider,h1:()=>r.h1,h2:()=>r.h2,h3:()=>r.h3,h4:()=>r.h4,h5:()=>r.h5,h6:()=>r.h6,heading:()=>r.heading,image:()=>r.image,italic:()=>r.italic,link:()=>r.link,numberedList:()=>r.numberedList,paragraph:()=>r.paragraph,text:()=>r.text,useBlockEditor:()=>P,useDocument:()=>T,useMarkdown:()=>E});module.exports=q(W);var n=require("react/jsx-runtime");function w({blocks:o,className:e,customRenderers:t}){return(0,n.jsx)("div",{className:e,children:o.map(i=>(0,n.jsx)(b,{block:i,customRenderers:t},i.id))})}function b({block:o,customRenderers:e}){let t=e?.[o.type];if(t)return(0,n.jsx)(t,{block:o});switch(o.type){case"paragraph":return(0,n.jsx)(H,{block:o});case"heading":return(0,n.jsx)(A,{block:o});case"bulletList":return(0,n.jsx)($,{block:o,customRenderers:e});case"numberedList":return(0,n.jsx)(z,{block:o,customRenderers:e});case"checkList":return(0,n.jsx)(F,{block:o});case"codeBlock":return(0,n.jsx)(J,{block:o});case"blockquote":return(0,n.jsx)(V,{block:o});case"table":return(0,n.jsx)(X,{block:o});case"image":return(0,n.jsx)(j,{block:o});case"divider":return(0,n.jsx)(G,{});case"callout":return(0,n.jsx)(K,{block:o});default:return null}}function g({spans:o}){return(0,n.jsx)(n.Fragment,{children:o.map((e,t)=>(0,n.jsx)(O,{span:e},t))})}function O({span:o}){let e=o.text,t=o.styles;return t.code&&(e=(0,n.jsx)("code",{children:e})),t.highlight&&(e=(0,n.jsx)("mark",{children:e})),t.strikethrough&&(e=(0,n.jsx)("del",{children:e})),t.underline&&(e=(0,n.jsx)("u",{children:e})),t.italic&&(e=(0,n.jsx)("em",{children:e})),t.bold&&(e=(0,n.jsx)("strong",{children:e})),t.link&&(e=(0,n.jsx)("a",{href:t.link.url,title:t.link.title,children:e})),(0,n.jsx)(n.Fragment,{children:e})}function H({block:o}){return(0,n.jsx)("p",{children:(0,n.jsx)(g,{spans:o.content})})}function A({block:o}){let e=`h${o.props.level}`;return(0,n.jsx)(e,{children:(0,n.jsx)(g,{spans:o.content})})}function $({block:o,customRenderers:e}){return(0,n.jsx)("ul",{children:o.children.map(t=>(0,n.jsxs)("li",{children:[(0,n.jsx)(g,{spans:t.content}),t.children.length>0&&(0,n.jsx)(b,{block:t,customRenderers:e})]},t.id))})}function z({block:o,customRenderers:e}){return(0,n.jsx)("ol",{children:o.children.map(t=>(0,n.jsxs)("li",{children:[(0,n.jsx)(g,{spans:t.content}),t.children.length>0&&(0,n.jsx)(b,{block:t,customRenderers:e})]},t.id))})}function F({block:o}){return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem"},children:[(0,n.jsx)("input",{type:"checkbox",checked:o.props.checked,readOnly:!0,style:{marginTop:"0.25rem"}}),(0,n.jsx)("span",{style:{textDecoration:o.props.checked?"line-through":"none"},children:(0,n.jsx)(g,{spans:o.content})})]})}function J({block:o}){let e=o.content.map(i=>i.text).join(""),t=o.props.language;return(0,n.jsx)("pre",{children:(0,n.jsx)("code",{className:t?`language-${t}`:void 0,children:e})})}function V({block:o}){return(0,n.jsx)("blockquote",{children:(0,n.jsx)(g,{spans:o.content})})}function X({block:o}){let{headers:e,rows:t,alignments:i}=o.props,k=p=>i?.[p]??void 0;return(0,n.jsxs)("table",{children:[e.length>0&&(0,n.jsx)("thead",{children:(0,n.jsx)("tr",{children:e.map((p,B)=>(0,n.jsx)("th",{style:{textAlign:k(B)},children:p},B))})}),(0,n.jsx)("tbody",{children:t.map((p,B)=>(0,n.jsx)("tr",{children:p.map((l,m)=>(0,n.jsx)("td",{style:{textAlign:k(m)},children:l},m))},B))})]})}function j({block:o}){return(0,n.jsxs)("figure",{children:[(0,n.jsx)("img",{src:o.props.url,alt:o.props.alt??"",title:o.props.title,width:o.props.width,height:o.props.height}),o.props.alt&&(0,n.jsx)("figcaption",{children:o.props.alt})]})}function G(){return(0,n.jsx)("hr",{})}function K({block:o}){let e=o.props.type,t={padding:"1rem",borderRadius:"0.25rem",borderLeft:"4px solid",marginBottom:"1rem"},i={info:{borderColor:"#3b82f6",backgroundColor:"#eff6ff"},warning:{borderColor:"#f59e0b",backgroundColor:"#fffbeb"},tip:{borderColor:"#10b981",backgroundColor:"#ecfdf5"},danger:{borderColor:"#ef4444",backgroundColor:"#fef2f2"},note:{borderColor:"#6b7280",backgroundColor:"#f9fafb"}},k=i[e]??i.note;return(0,n.jsxs)("div",{style:{...t,borderLeftColor:k.borderColor,backgroundColor:k.backgroundColor},role:"alert",children:[(0,n.jsx)("strong",{style:{textTransform:"capitalize",display:"block",marginBottom:"0.5rem"},children:e}),(0,n.jsx)(g,{spans:o.content})]})}var a=require("react"),c=require("@create-markdown/core");function T(o=[],e){let[t,i]=(0,a.useState)(()=>(0,c.createDocument)(o,e)),k=(0,a.useCallback)((d,u)=>{i(s=>(0,c.insertBlock)(s,d,u))},[]),p=(0,a.useCallback)(d=>{i(u=>(0,c.appendBlock)(u,d))},[]),B=(0,a.useCallback)(d=>{i(u=>(0,c.removeBlock)(u,d))},[]),l=(0,a.useCallback)((d,u)=>{i(s=>(0,c.updateBlock)(s,d,u))},[]),m=(0,a.useCallback)((d,u)=>{i(s=>(0,c.moveBlock)(s,d,u))},[]),f=(0,a.useCallback)(d=>(0,c.findBlock)(t,d),[t]),R=(0,a.useCallback)(d=>(0,c.getBlockIndex)(t,d),[t]),h=(0,a.useCallback)(()=>{i(d=>(0,c.clearBlocks)(d))},[]),C=(0,a.useCallback)(d=>{i(u=>(0,c.setBlocks)(u,d))},[]),x=(0,a.useCallback)(()=>(0,c.blocksToMarkdown)(t.blocks),[t]),y=(0,a.useCallback)(d=>{let u=(0,c.markdownToBlocks)(d);i(s=>(0,c.setBlocks)(s,u))},[]),v=(0,a.useCallback)(d=>{i(u=>(0,c.updateMeta)(u,d))},[]);return{document:t,blocks:t.blocks,insertBlock:k,appendBlock:p,removeBlock:B,updateBlock:l,moveBlock:m,findBlock:f,getBlockIndex:R,clearBlocks:h,setBlocks:C,setDocument:i,toMarkdown:x,fromMarkdown:y,updateMeta:v}}function E(o=""){let[e,t]=(0,a.useState)(o),i=(0,a.useMemo)(()=>(0,c.markdownToBlocks)(e),[e]),k=(0,a.useCallback)(B=>{t(B)},[]),p=(0,a.useCallback)(B=>{let l=(0,c.blocksToMarkdown)(B);t(l)},[]);return{markdown:e,blocks:i,setMarkdown:k,setBlocks:p}}function P(o){let{document:e,blocks:t,removeBlock:i,updateBlock:k,moveBlock:p,insertBlock:B}=o,[l,m]=(0,a.useState)(null),f=(0,a.useMemo)(()=>l?(0,c.findBlock)(e,l):void 0,[e,l]),R=(0,a.useCallback)(s=>{m(s)},[]),h=(0,a.useCallback)(()=>{if(!l){t.length>0&&m(t[0].id);return}let s=(0,c.getBlockIndex)(e,l);s<t.length-1&&m(t[s+1].id)},[e,t,l]),C=(0,a.useCallback)(()=>{if(!l){t.length>0&&m(t[t.length-1].id);return}let s=(0,c.getBlockIndex)(e,l);s>0&&m(t[s-1].id)},[e,t,l]),x=(0,a.useCallback)(()=>{if(!l)return;let s=(0,c.getBlockIndex)(e,l);i(l),t.length>1?s<t.length-1?m(t[s+1].id):s>0&&m(t[s-1].id):m(null)},[e,t,l,i]),y=(0,a.useCallback)(s=>{l&&k(l,{content:s})},[l,k]),v=(0,a.useCallback)(()=>{if(!l||!f)return;let s=(0,c.getBlockIndex)(e,l),I={...f,id:Math.random().toString(36).substring(2,9)};B(I,s+1),m(I.id)},[e,l,f,B]),d=(0,a.useCallback)(()=>{if(!l)return;let s=(0,c.getBlockIndex)(e,l);s>0&&p(l,s-1)},[e,l,p]),u=(0,a.useCallback)(()=>{if(!l)return;let s=(0,c.getBlockIndex)(e,l);s<t.length-1&&p(l,s+1)},[e,t,l,p]);return{selectedBlockId:l,selectedBlock:f,selectBlock:R,selectNext:h,selectPrevious:C,deleteSelected:x,updateSelectedContent:y,duplicateSelected:v,moveSelectedUp:d,moveSelectedDown:u}}var r=require("@create-markdown/core"),Q="2.0.0";0&&(module.exports={BlockElement,BlockRenderer,InlineContent,VERSION,blockquote,bold,bulletList,callout,checkList,checkListItem,code,codeBlock,divider,h1,h2,h3,h4,h5,h6,heading,image,italic,link,numberedList,paragraph,text,useBlockEditor,useDocument,useMarkdown});
1
+ "use strict";var S=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var U=(o,e)=>{for(var t in e)S(o,t,{get:e[t],enumerable:!0})},N=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let k of M(e))!L.call(o,k)&&k!==t&&S(o,k,{get:()=>e[k],enumerable:!(i=D(e,k))||i.enumerable});return o};var q=o=>N(S({},"__esModule",{value:!0}),o);var W={};U(W,{BlockElement:()=>b,BlockRenderer:()=>w,InlineContent:()=>g,VERSION:()=>Q,blockquote:()=>r.blockquote,bold:()=>r.bold,bulletList:()=>r.bulletList,callout:()=>r.callout,checkList:()=>r.checkList,checkListItem:()=>r.checkListItem,code:()=>r.code,codeBlock:()=>r.codeBlock,divider:()=>r.divider,h1:()=>r.h1,h2:()=>r.h2,h3:()=>r.h3,h4:()=>r.h4,h5:()=>r.h5,h6:()=>r.h6,heading:()=>r.heading,image:()=>r.image,italic:()=>r.italic,link:()=>r.link,numberedList:()=>r.numberedList,paragraph:()=>r.paragraph,text:()=>r.text,useBlockEditor:()=>P,useDocument:()=>T,useMarkdown:()=>E});module.exports=q(W);var n=require("react/jsx-runtime");function w({blocks:o,className:e,customRenderers:t}){return(0,n.jsx)("div",{className:e,children:o.map(i=>(0,n.jsx)(b,{block:i,customRenderers:t},i.id))})}function b({block:o,customRenderers:e}){let t=e?.[o.type];if(t)return(0,n.jsx)(t,{block:o});switch(o.type){case"paragraph":return(0,n.jsx)(H,{block:o});case"heading":return(0,n.jsx)(A,{block:o});case"bulletList":return(0,n.jsx)($,{block:o,customRenderers:e});case"numberedList":return(0,n.jsx)(z,{block:o,customRenderers:e});case"checkList":return(0,n.jsx)(F,{block:o});case"codeBlock":return(0,n.jsx)(J,{block:o});case"blockquote":return(0,n.jsx)(V,{block:o});case"table":return(0,n.jsx)(X,{block:o});case"image":return(0,n.jsx)(j,{block:o});case"divider":return(0,n.jsx)(G,{});case"callout":return(0,n.jsx)(K,{block:o});default:return null}}function g({spans:o}){return(0,n.jsx)(n.Fragment,{children:o.map((e,t)=>(0,n.jsx)(O,{span:e},t))})}function O({span:o}){let e=o.text,t=o.styles;return t.code&&(e=(0,n.jsx)("code",{children:e})),t.highlight&&(e=(0,n.jsx)("mark",{children:e})),t.strikethrough&&(e=(0,n.jsx)("del",{children:e})),t.underline&&(e=(0,n.jsx)("u",{children:e})),t.italic&&(e=(0,n.jsx)("em",{children:e})),t.bold&&(e=(0,n.jsx)("strong",{children:e})),t.link&&(e=(0,n.jsx)("a",{href:t.link.url,title:t.link.title,children:e})),(0,n.jsx)(n.Fragment,{children:e})}function H({block:o}){return(0,n.jsx)("p",{children:(0,n.jsx)(g,{spans:o.content})})}function A({block:o}){let e=`h${o.props.level}`;return(0,n.jsx)(e,{children:(0,n.jsx)(g,{spans:o.content})})}function $({block:o,customRenderers:e}){return(0,n.jsx)("ul",{children:o.children.map(t=>(0,n.jsxs)("li",{children:[(0,n.jsx)(g,{spans:t.content}),t.children.length>0&&(0,n.jsx)(b,{block:t,customRenderers:e})]},t.id))})}function z({block:o,customRenderers:e}){return(0,n.jsx)("ol",{children:o.children.map(t=>(0,n.jsxs)("li",{children:[(0,n.jsx)(g,{spans:t.content}),t.children.length>0&&(0,n.jsx)(b,{block:t,customRenderers:e})]},t.id))})}function F({block:o}){return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem"},children:[(0,n.jsx)("input",{type:"checkbox",checked:o.props.checked,readOnly:!0,style:{marginTop:"0.25rem"}}),(0,n.jsx)("span",{style:{textDecoration:o.props.checked?"line-through":"none"},children:(0,n.jsx)(g,{spans:o.content})})]})}function J({block:o}){let e=o.content.map(i=>i.text).join(""),t=o.props.language;return(0,n.jsx)("pre",{children:(0,n.jsx)("code",{className:t?`language-${t}`:void 0,children:e})})}function V({block:o}){return(0,n.jsx)("blockquote",{children:(0,n.jsx)(g,{spans:o.content})})}function X({block:o}){let{headers:e,rows:t,alignments:i}=o.props,k=p=>i?.[p]??void 0;return(0,n.jsxs)("table",{children:[e.length>0&&(0,n.jsx)("thead",{children:(0,n.jsx)("tr",{children:e.map((p,B)=>(0,n.jsx)("th",{style:{textAlign:k(B)},children:p},B))})}),(0,n.jsx)("tbody",{children:t.map((p,B)=>(0,n.jsx)("tr",{children:p.map((l,m)=>(0,n.jsx)("td",{style:{textAlign:k(m)},children:l},m))},B))})]})}function j({block:o}){return(0,n.jsxs)("figure",{children:[(0,n.jsx)("img",{src:o.props.url,alt:o.props.alt??"",title:o.props.title,width:o.props.width,height:o.props.height}),o.props.alt&&(0,n.jsx)("figcaption",{children:o.props.alt})]})}function G(){return(0,n.jsx)("hr",{})}function K({block:o}){let e=o.props.type,t={padding:"1rem",borderRadius:"0.25rem",borderLeft:"4px solid",marginBottom:"1rem"},i={info:{borderColor:"#3b82f6",backgroundColor:"#eff6ff"},warning:{borderColor:"#f59e0b",backgroundColor:"#fffbeb"},tip:{borderColor:"#10b981",backgroundColor:"#ecfdf5"},danger:{borderColor:"#ef4444",backgroundColor:"#fef2f2"},note:{borderColor:"#6b7280",backgroundColor:"#f9fafb"}},k=i[e]??i.note;return(0,n.jsxs)("div",{style:{...t,borderLeftColor:k.borderColor,backgroundColor:k.backgroundColor},role:"alert",children:[(0,n.jsx)("strong",{style:{textTransform:"capitalize",display:"block",marginBottom:"0.5rem"},children:e}),(0,n.jsx)(g,{spans:o.content})]})}var a=require("react"),c=require("@create-markdown/core");function T(o=[],e){let[t,i]=(0,a.useState)(()=>(0,c.createDocument)(o,e)),k=(0,a.useCallback)((d,u)=>{i(s=>(0,c.insertBlock)(s,d,u))},[]),p=(0,a.useCallback)(d=>{i(u=>(0,c.appendBlock)(u,d))},[]),B=(0,a.useCallback)(d=>{i(u=>(0,c.removeBlock)(u,d))},[]),l=(0,a.useCallback)((d,u)=>{i(s=>(0,c.updateBlock)(s,d,u))},[]),m=(0,a.useCallback)((d,u)=>{i(s=>(0,c.moveBlock)(s,d,u))},[]),f=(0,a.useCallback)(d=>(0,c.findBlock)(t,d),[t]),R=(0,a.useCallback)(d=>(0,c.getBlockIndex)(t,d),[t]),h=(0,a.useCallback)(()=>{i(d=>(0,c.clearBlocks)(d))},[]),C=(0,a.useCallback)(d=>{i(u=>(0,c.setBlocks)(u,d))},[]),x=(0,a.useCallback)(()=>(0,c.blocksToMarkdown)(t.blocks),[t]),y=(0,a.useCallback)(d=>{let u=(0,c.markdownToBlocks)(d);i(s=>(0,c.setBlocks)(s,u))},[]),v=(0,a.useCallback)(d=>{i(u=>(0,c.updateMeta)(u,d))},[]);return{document:t,blocks:t.blocks,insertBlock:k,appendBlock:p,removeBlock:B,updateBlock:l,moveBlock:m,findBlock:f,getBlockIndex:R,clearBlocks:h,setBlocks:C,setDocument:i,toMarkdown:x,fromMarkdown:y,updateMeta:v}}function E(o=""){let[e,t]=(0,a.useState)(o),i=(0,a.useMemo)(()=>(0,c.markdownToBlocks)(e),[e]),k=(0,a.useCallback)(B=>{t(B)},[]),p=(0,a.useCallback)(B=>{let l=(0,c.blocksToMarkdown)(B);t(l)},[]);return{markdown:e,blocks:i,setMarkdown:k,setBlocks:p}}function P(o){let{document:e,blocks:t,removeBlock:i,updateBlock:k,moveBlock:p,insertBlock:B}=o,[l,m]=(0,a.useState)(null),f=(0,a.useMemo)(()=>l?(0,c.findBlock)(e,l):void 0,[e,l]),R=(0,a.useCallback)(s=>{m(s)},[]),h=(0,a.useCallback)(()=>{if(!l){t.length>0&&m(t[0].id);return}let s=(0,c.getBlockIndex)(e,l);s<t.length-1&&m(t[s+1].id)},[e,t,l]),C=(0,a.useCallback)(()=>{if(!l){t.length>0&&m(t[t.length-1].id);return}let s=(0,c.getBlockIndex)(e,l);s>0&&m(t[s-1].id)},[e,t,l]),x=(0,a.useCallback)(()=>{if(!l)return;let s=(0,c.getBlockIndex)(e,l);i(l),t.length>1?s<t.length-1?m(t[s+1].id):s>0&&m(t[s-1].id):m(null)},[e,t,l,i]),y=(0,a.useCallback)(s=>{l&&k(l,{content:s})},[l,k]),v=(0,a.useCallback)(()=>{if(!l||!f)return;let s=(0,c.getBlockIndex)(e,l),I={...f,id:Math.random().toString(36).substring(2,9)};B(I,s+1),m(I.id)},[e,l,f,B]),d=(0,a.useCallback)(()=>{if(!l)return;let s=(0,c.getBlockIndex)(e,l);s>0&&p(l,s-1)},[e,l,p]),u=(0,a.useCallback)(()=>{if(!l)return;let s=(0,c.getBlockIndex)(e,l);s<t.length-1&&p(l,s+1)},[e,t,l,p]);return{selectedBlockId:l,selectedBlock:f,selectBlock:R,selectNext:h,selectPrevious:C,deleteSelected:x,updateSelectedContent:y,duplicateSelected:v,moveSelectedUp:d,moveSelectedDown:u}}var r=require("@create-markdown/core"),Q="2.0.2";0&&(module.exports={BlockElement,BlockRenderer,InlineContent,VERSION,blockquote,bold,bulletList,callout,checkList,checkListItem,code,codeBlock,divider,h1,h2,h3,h4,h5,h6,heading,image,italic,link,numberedList,paragraph,text,useBlockEditor,useDocument,useMarkdown});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/block-renderer.tsx","../src/hooks.ts"],"sourcesContent":["/**\n * @create-markdown/react\n * React components and hooks for @create-markdown\n */\n\n// Components\nexport {\n BlockRenderer,\n BlockElement,\n InlineContent,\n} from './block-renderer';\n\nexport type {\n BlockRendererProps,\n BlockRenderers,\n SingleBlockProps,\n} from './block-renderer';\n\n// Hooks\nexport {\n useDocument,\n useMarkdown,\n useBlockEditor,\n} from './hooks';\n\nexport type {\n UseDocumentReturn,\n UseMarkdownReturn,\n UseBlockEditorReturn,\n} from './hooks';\n\n// Re-export types that are commonly needed with React components\nexport type {\n Block,\n BlockType,\n Document,\n TextSpan,\n InlineStyle,\n} from '@create-markdown/core';\n\n// Re-export block factories for convenience\nexport {\n paragraph,\n heading,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n bulletList,\n numberedList,\n checkListItem,\n checkList,\n codeBlock,\n blockquote,\n divider,\n image,\n callout,\n text,\n bold,\n italic,\n code,\n link,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Package Info\n// ============================================================================\n\n/**\n * Package version\n */\nexport const VERSION = '2.0.0';\n","/**\n * @create-markdown/react - Block Renderer\n * Render blocks as React elements\n */\n\nimport React from 'react';\nimport type {\n Block,\n TextSpan,\n HeadingBlock,\n CodeBlockBlock,\n ImageBlock,\n TableBlock,\n CalloutBlock,\n CheckListBlock,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BlockRendererProps {\n /** Blocks to render */\n blocks: Block[];\n /** Custom class name for the container */\n className?: string;\n /** Custom renderers for specific block types */\n customRenderers?: Partial<BlockRenderers>;\n}\n\nexport interface BlockRenderers {\n paragraph: React.ComponentType<{ block: Block }>;\n heading: React.ComponentType<{ block: HeadingBlock }>;\n bulletList: React.ComponentType<{ block: Block }>;\n numberedList: React.ComponentType<{ block: Block }>;\n checkList: React.ComponentType<{ block: CheckListBlock }>;\n codeBlock: React.ComponentType<{ block: CodeBlockBlock }>;\n blockquote: React.ComponentType<{ block: Block }>;\n table: React.ComponentType<{ block: TableBlock }>;\n image: React.ComponentType<{ block: ImageBlock }>;\n divider: React.ComponentType<{ block: Block }>;\n callout: React.ComponentType<{ block: CalloutBlock }>;\n}\n\nexport interface SingleBlockProps {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * Renders: array of blocks as React elements\n */\nexport function BlockRenderer({\n blocks,\n className,\n customRenderers,\n}: BlockRendererProps): React.ReactElement {\n return (\n <div className={className}>\n {blocks.map((block) => (\n <BlockElement\n key={block.id}\n block={block}\n customRenderers={customRenderers}\n />\n ))}\n </div>\n );\n}\n\n/**\n * Renders: single block\n */\nexport function BlockElement({\n block,\n customRenderers,\n}: SingleBlockProps): React.ReactElement | null {\n // Check for custom renderer first\n const CustomRenderer = customRenderers?.[block.type as keyof BlockRenderers];\n if (CustomRenderer) {\n return <CustomRenderer block={block as never} />;\n }\n\n // Use default renderers\n switch (block.type) {\n case 'paragraph':\n return <ParagraphRenderer block={block} />;\n\n case 'heading':\n return <HeadingRenderer block={block as HeadingBlock} />;\n\n case 'bulletList':\n return <BulletListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'numberedList':\n return <NumberedListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'checkList':\n return <CheckListRenderer block={block as CheckListBlock} />;\n\n case 'codeBlock':\n return <CodeBlockRenderer block={block as CodeBlockBlock} />;\n\n case 'blockquote':\n return <BlockquoteRenderer block={block} />;\n\n case 'table':\n return <TableRenderer block={block as TableBlock} />;\n\n case 'image':\n return <ImageRenderer block={block as ImageBlock} />;\n\n case 'divider':\n return <DividerRenderer />;\n\n case 'callout':\n return <CalloutRenderer block={block as CalloutBlock} />;\n\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Inline Content Renderer\n// ============================================================================\n\ninterface InlineContentProps {\n spans: TextSpan[];\n}\n\n/**\n * Renders: inline content (text spans with styles)\n */\nexport function InlineContent({ spans }: InlineContentProps): React.ReactElement {\n return (\n <>\n {spans.map((span, index) => (\n <SpanElement key={index} span={span} />\n ))}\n </>\n );\n}\n\ninterface SpanProps {\n span: TextSpan;\n}\n\n/**\n * Renders: single text span with styles\n */\nfunction SpanElement({ span }: SpanProps): React.ReactElement {\n let content: React.ReactNode = span.text;\n const styles = span.styles;\n\n // Apply styles from innermost to outermost\n if (styles.code) {\n content = <code>{content}</code>;\n }\n\n if (styles.highlight) {\n content = <mark>{content}</mark>;\n }\n\n if (styles.strikethrough) {\n content = <del>{content}</del>;\n }\n\n if (styles.underline) {\n content = <u>{content}</u>;\n }\n\n if (styles.italic) {\n content = <em>{content}</em>;\n }\n\n if (styles.bold) {\n content = <strong>{content}</strong>;\n }\n\n if (styles.link) {\n content = (\n <a href={styles.link.url} title={styles.link.title}>\n {content}\n </a>\n );\n }\n\n return <>{content}</>;\n}\n\n// ============================================================================\n// Block Renderers\n// ============================================================================\n\n/**\n * Renders: paragraph block\n */\nfunction ParagraphRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <p>\n <InlineContent spans={block.content} />\n </p>\n );\n}\n\n/**\n * Renders: heading block\n */\nfunction HeadingRenderer({ block }: { block: HeadingBlock }): React.ReactElement {\n const Tag = `h${block.props.level}` as keyof React.JSX.IntrinsicElements;\n\n return (\n <Tag>\n <InlineContent spans={block.content} />\n </Tag>\n );\n}\n\n/**\n * Renders: bullet list block\n */\nfunction BulletListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ul>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Renders: numbered list block\n */\nfunction NumberedListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ol>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ol>\n );\n}\n\n/**\n * Renders: checklist block\n */\nfunction CheckListRenderer({ block }: { block: CheckListBlock }): React.ReactElement {\n return (\n <div style={{ display: 'flex', alignItems: 'flex-start', gap: '0.5rem' }}>\n <input\n type=\"checkbox\"\n checked={block.props.checked}\n readOnly\n style={{ marginTop: '0.25rem' }}\n />\n <span style={{ textDecoration: block.props.checked ? 'line-through' : 'none' }}>\n <InlineContent spans={block.content} />\n </span>\n </div>\n );\n}\n\n/**\n * Renders: code block block\n */\nfunction CodeBlockRenderer({ block }: { block: CodeBlockBlock }): React.ReactElement {\n const code = block.content.map((span) => span.text).join('');\n const language = block.props.language;\n\n return (\n <pre>\n <code className={language ? `language-${language}` : undefined}>\n {code}\n </code>\n </pre>\n );\n}\n\n/**\n * Renders: blockquote block\n */\nfunction BlockquoteRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <blockquote>\n <InlineContent spans={block.content} />\n </blockquote>\n );\n}\n\n/**\n * Renders: table block\n */\nfunction TableRenderer({ block }: { block: TableBlock }): React.ReactElement {\n const { headers, rows, alignments } = block.props;\n\n const getAlignment = (index: number): React.CSSProperties['textAlign'] => {\n return alignments?.[index] ?? undefined;\n };\n\n return (\n <table>\n {headers.length > 0 && (\n <thead>\n <tr>\n {headers.map((header, i) => (\n <th key={i} style={{ textAlign: getAlignment(i) }}>\n {header}\n </th>\n ))}\n </tr>\n </thead>\n )}\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <td key={cellIndex} style={{ textAlign: getAlignment(cellIndex) }}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\n/**\n * Renders: image block\n */\nfunction ImageRenderer({ block }: { block: ImageBlock }): React.ReactElement {\n return (\n <figure>\n <img\n src={block.props.url}\n alt={block.props.alt ?? ''}\n title={block.props.title}\n width={block.props.width}\n height={block.props.height}\n />\n {block.props.alt && <figcaption>{block.props.alt}</figcaption>}\n </figure>\n );\n}\n\n/**\n * Renders: divider block\n */\nfunction DividerRenderer(): React.ReactElement {\n return <hr />;\n}\n\n/**\n * Renders: callout block\n */\nfunction CalloutRenderer({ block }: { block: CalloutBlock }): React.ReactElement {\n const calloutType = block.props.type;\n\n const styles: React.CSSProperties = {\n padding: '1rem',\n borderRadius: '0.25rem',\n borderLeft: '4px solid',\n marginBottom: '1rem',\n };\n\n // Color based on callout type\n const colors: Record<string, { borderColor: string; backgroundColor: string }> = {\n info: { borderColor: '#3b82f6', backgroundColor: '#eff6ff' },\n warning: { borderColor: '#f59e0b', backgroundColor: '#fffbeb' },\n tip: { borderColor: '#10b981', backgroundColor: '#ecfdf5' },\n danger: { borderColor: '#ef4444', backgroundColor: '#fef2f2' },\n note: { borderColor: '#6b7280', backgroundColor: '#f9fafb' },\n };\n\n const colorStyle = colors[calloutType] ?? colors.note;\n\n return (\n <div\n style={{\n ...styles,\n borderLeftColor: colorStyle.borderColor,\n backgroundColor: colorStyle.backgroundColor,\n }}\n role=\"alert\"\n >\n <strong style={{ textTransform: 'capitalize', display: 'block', marginBottom: '0.5rem' }}>\n {calloutType}\n </strong>\n <InlineContent spans={block.content} />\n </div>\n );\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport default BlockRenderer;\n","/**\n * @create-markdown/react - Hooks\n * State management hooks for document manipulation\n */\n\nimport { useState, useCallback, useMemo } from 'react';\nimport type { Block, Document, DocumentOptions, TextSpan } from '@create-markdown/core';\nimport {\n createDocument,\n insertBlock,\n appendBlock,\n removeBlock,\n updateBlock,\n moveBlock,\n findBlock,\n getBlockIndex,\n clearBlocks,\n setBlocks,\n updateMeta,\n markdownToBlocks,\n blocksToMarkdown,\n} from '@create-markdown/core';\n\n// ============================================================================\n// useDocument Hook\n// ============================================================================\n\nexport interface UseDocumentReturn {\n /** Current document state */\n document: Document;\n /** Blocks in the document */\n blocks: Block[];\n \n // Block operations\n /** Insert: block at a specific index */\n insertBlock: (block: Block, index?: number) => void;\n /** Append: block to the end */\n appendBlock: (block: Block) => void;\n /** Remove: block by ID */\n removeBlock: (blockId: string) => void;\n /** Update: block by ID */\n updateBlock: (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => void;\n /** Move: block to a new index */\n moveBlock: (blockId: string, newIndex: number) => void;\n /** Find: block by ID */\n findBlock: (blockId: string) => Block | undefined;\n /** Get: index of a block */\n getBlockIndex: (blockId: string) => number;\n \n // Bulk operations\n /** Clear: all blocks */\n clearBlocks: () => void;\n /** Replace: entire document with new blocks */\n setBlocks: (blocks: Block[]) => void;\n /** Set: entire document */\n setDocument: (doc: Document) => void;\n \n // Markdown operations\n /** Get: document as markdown */\n toMarkdown: () => string;\n /** Load: markdown into the document */\n fromMarkdown: (markdown: string) => void;\n \n // Metadata operations\n /** Update: document metadata */\n updateMeta: (meta: Partial<Document['meta']>) => void;\n}\n\n/**\n * Hook for managing: document with blocks\n * \n * @example\n * ```tsx\n * function Editor() {\n * const { blocks, appendBlock, toMarkdown } = useDocument();\n * \n * const addParagraph = () => {\n * appendBlock(paragraph('New paragraph'));\n * };\n * \n * return (\n * <div>\n * <BlockRenderer blocks={blocks} />\n * <button onClick={addParagraph}>Add Paragraph</button>\n * <button onClick={() => console.log(toMarkdown())}>Export</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useDocument(\n initialBlocks: Block[] = [],\n options?: DocumentOptions\n): UseDocumentReturn {\n const [document, setDocument] = useState<Document>(() =>\n createDocument(initialBlocks, options)\n );\n \n const insert = useCallback((block: Block, index?: number) => {\n setDocument((doc) => insertBlock(doc, block, index));\n }, []);\n \n const append = useCallback((block: Block) => {\n setDocument((doc) => appendBlock(doc, block));\n }, []);\n \n const remove = useCallback((blockId: string) => {\n setDocument((doc) => removeBlock(doc, blockId));\n }, []);\n \n const update = useCallback(\n (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => {\n setDocument((doc) => updateBlock(doc, blockId, updates));\n },\n []\n );\n \n const move = useCallback((blockId: string, newIndex: number) => {\n setDocument((doc) => moveBlock(doc, blockId, newIndex));\n }, []);\n \n const find = useCallback(\n (blockId: string) => findBlock(document, blockId),\n [document]\n );\n \n const getIndex = useCallback(\n (blockId: string) => getBlockIndex(document, blockId),\n [document]\n );\n \n const clear = useCallback(() => {\n setDocument((doc) => clearBlocks(doc));\n }, []);\n \n const set = useCallback((blocks: Block[]) => {\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const toMd = useCallback(() => blocksToMarkdown(document.blocks), [document]);\n \n const fromMd = useCallback((markdown: string) => {\n const blocks = markdownToBlocks(markdown);\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const meta = useCallback((newMeta: Partial<Document['meta']>) => {\n setDocument((doc) => updateMeta(doc, newMeta));\n }, []);\n \n return {\n document,\n blocks: document.blocks,\n insertBlock: insert,\n appendBlock: append,\n removeBlock: remove,\n updateBlock: update,\n moveBlock: move,\n findBlock: find,\n getBlockIndex: getIndex,\n clearBlocks: clear,\n setBlocks: set,\n setDocument,\n toMarkdown: toMd,\n fromMarkdown: fromMd,\n updateMeta: meta,\n };\n}\n\n// ============================================================================\n// useMarkdown Hook\n// ============================================================================\n\nexport interface UseMarkdownReturn {\n /** Current markdown string */\n markdown: string;\n /** Parsed blocks */\n blocks: Block[];\n /** Update: markdown content */\n setMarkdown: (markdown: string) => void;\n /** Update: blocks (will update markdown too) */\n setBlocks: (blocks: Block[]) => void;\n}\n\n/**\n * Hook for bidirectional: markdown/blocks state\n * \n * @example\n * ```tsx\n * function MarkdownEditor() {\n * const { markdown, blocks, setMarkdown } = useMarkdown('# Hello');\n * \n * return (\n * <div>\n * <textarea\n * value={markdown}\n * onChange={(e) => setMarkdown(e.target.value)}\n * />\n * <BlockRenderer blocks={blocks} />\n * </div>\n * );\n * }\n * ```\n */\nexport function useMarkdown(initialMarkdown: string = ''): UseMarkdownReturn {\n const [markdown, setMarkdownState] = useState(initialMarkdown);\n \n const blocks = useMemo(() => markdownToBlocks(markdown), [markdown]);\n \n const setMarkdown = useCallback((newMarkdown: string) => {\n setMarkdownState(newMarkdown);\n }, []);\n \n const setBlocksFromBlocks = useCallback((newBlocks: Block[]) => {\n const newMarkdown = blocksToMarkdown(newBlocks);\n setMarkdownState(newMarkdown);\n }, []);\n \n return {\n markdown,\n blocks,\n setMarkdown,\n setBlocks: setBlocksFromBlocks,\n };\n}\n\n// ============================================================================\n// useBlockEditor Hook\n// ============================================================================\n\nexport interface UseBlockEditorReturn {\n /** Current selected block ID */\n selectedBlockId: string | null;\n /** Current selected block */\n selectedBlock: Block | undefined;\n /** Select: block by ID */\n selectBlock: (blockId: string | null) => void;\n /** Select: next block */\n selectNext: () => void;\n /** Select: previous block */\n selectPrevious: () => void;\n /** Delete: selected block */\n deleteSelected: () => void;\n /** Update: selected block's content */\n updateSelectedContent: (content: TextSpan[]) => void;\n /** Duplicate: selected block */\n duplicateSelected: () => void;\n /** Move: selected block up */\n moveSelectedUp: () => void;\n /** Move: selected block down */\n moveSelectedDown: () => void;\n}\n\n/**\n * Hook for: block selection and editing operations\n * \n * @example\n * ```tsx\n * function Editor() {\n * const doc = useDocument();\n * const editor = useBlockEditor(doc);\n * \n * return (\n * <div>\n * {doc.blocks.map((block) => (\n * <div\n * key={block.id}\n * onClick={() => editor.selectBlock(block.id)}\n * style={{\n * border: editor.selectedBlockId === block.id ? '2px solid blue' : 'none'\n * }}\n * >\n * <BlockElement block={block} />\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useBlockEditor(\n documentHook: UseDocumentReturn\n): UseBlockEditorReturn {\n const { document, blocks, removeBlock, updateBlock, moveBlock, insertBlock } =\n documentHook;\n \n const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null);\n \n const selectedBlock = useMemo(\n () => (selectedBlockId ? findBlock(document, selectedBlockId) : undefined),\n [document, selectedBlockId]\n );\n \n const selectBlock = useCallback((blockId: string | null) => {\n setSelectedBlockId(blockId);\n }, []);\n \n const selectNext = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[0].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const selectPrevious = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[blocks.length - 1].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const deleteSelected = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n removeBlock(selectedBlockId);\n \n // Select next block or previous if at end\n if (blocks.length > 1) {\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n } else if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n } else {\n setSelectedBlockId(null);\n }\n }, [document, blocks, selectedBlockId, removeBlock]);\n \n const updateSelectedContent = useCallback(\n (content: TextSpan[]) => {\n if (!selectedBlockId) return;\n updateBlock(selectedBlockId, { content });\n },\n [selectedBlockId, updateBlock]\n );\n \n const duplicateSelected = useCallback(() => {\n if (!selectedBlockId || !selectedBlock) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n const clonedBlock: Block = {\n ...selectedBlock,\n id: Math.random().toString(36).substring(2, 9),\n };\n \n insertBlock(clonedBlock, currentIndex + 1);\n setSelectedBlockId(clonedBlock.id);\n }, [document, selectedBlockId, selectedBlock, insertBlock]);\n \n const moveSelectedUp = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n moveBlock(selectedBlockId, currentIndex - 1);\n }\n }, [document, selectedBlockId, moveBlock]);\n \n const moveSelectedDown = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n moveBlock(selectedBlockId, currentIndex + 1);\n }\n }, [document, blocks, selectedBlockId, moveBlock]);\n \n return {\n selectedBlockId,\n selectedBlock,\n selectBlock,\n selectNext,\n selectPrevious,\n deleteSelected,\n updateSelectedContent,\n duplicateSelected,\n moveSelectedUp,\n moveSelectedDown,\n };\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,kBAAAC,EAAA,kBAAAC,EAAA,YAAAC,EAAA,2cAAAC,EAAA,gBAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAT,GCgEgB,IAAAU,EAAA,6BART,SAASC,EAAc,CAC1B,OAAAC,EACA,UAAAC,EACA,gBAAAC,CACJ,EAA2C,CACvC,SACI,OAAC,OAAI,UAAWD,EACX,SAAAD,EAAO,IAAKG,MACT,OAACC,EAAA,CAEG,MAAOD,EACP,gBAAiBD,GAFZC,EAAM,EAGf,CACH,EACL,CAER,CAKO,SAASC,EAAa,CACzB,MAAAD,EACA,gBAAAD,CACJ,EAAgD,CAE5C,IAAMG,EAAiBH,IAAkBC,EAAM,IAA4B,EAC3E,GAAIE,EACA,SAAO,OAACA,EAAA,CAAe,MAAOF,EAAgB,EAIlD,OAAQA,EAAM,KAAM,CAChB,IAAK,YACD,SAAO,OAACG,EAAA,CAAkB,MAAOH,EAAO,EAE5C,IAAK,UACD,SAAO,OAACI,EAAA,CAAgB,MAAOJ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AQmB,EAAiBF,CAAS,CAAC,EAEjD,MAAO,CACL,gBAAAE,EACA,cAAAE,EACA,YAAAC,EACA,WAAAC,EACA,eAAAE,EACA,eAAAC,EACA,sBAAAC,EACA,kBAAAE,EACA,eAAAE,EACA,iBAAAC,CACF,CACF,CFjWA,IAAAC,EAuBO,iCASMC,EAAU","names":["index_exports","__export","BlockElement","BlockRenderer","InlineContent","VERSION","useBlockEditor","useDocument","useMarkdown","__toCommonJS","import_jsx_runtime","BlockRenderer","blocks","className","customRenderers","block","BlockElement","CustomRenderer","ParagraphRenderer","HeadingRenderer","BulletListRenderer","NumberedListRenderer","CheckListRenderer","CodeBlockRenderer","BlockquoteRenderer","TableRenderer","ImageRenderer","DividerRenderer","CalloutRenderer","InlineContent","spans","span","index","SpanElement","content","styles","Tag","child","code","language","headers","rows","alignments","getAlignment","header","i","row","rowIndex","cell","cellIndex","calloutType","colors","colorStyle","import_react","import_core","useDocument","initialBlocks","options","document","setDocument","insert","block","index","doc","append","remove","blockId","update","updates","move","newIndex","find","getIndex","clear","set","blocks","toMd","fromMd","markdown","meta","newMeta","useMarkdown","initialMarkdown","setMarkdownState","setMarkdown","newMarkdown","setBlocksFromBlocks","newBlocks","useBlockEditor","documentHook","removeBlock","updateBlock","moveBlock","insertBlock","selectedBlockId","setSelectedBlockId","selectedBlock","selectBlock","selectNext","currentIndex","selectPrevious","deleteSelected","updateSelectedContent","content","duplicateSelected","clonedBlock","moveSelectedUp","moveSelectedDown","import_core","VERSION"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/block-renderer.tsx","../src/hooks.ts"],"sourcesContent":["/**\n * @create-markdown/react\n * React components and hooks for @create-markdown\n */\n\n// Components\nexport {\n BlockRenderer,\n BlockElement,\n InlineContent,\n} from './block-renderer';\n\nexport type {\n BlockRendererProps,\n BlockRenderers,\n SingleBlockProps,\n} from './block-renderer';\n\n// Hooks\nexport {\n useDocument,\n useMarkdown,\n useBlockEditor,\n} from './hooks';\n\nexport type {\n UseDocumentReturn,\n UseMarkdownReturn,\n UseBlockEditorReturn,\n} from './hooks';\n\n// Re-export types that are commonly needed with React components\nexport type {\n Block,\n BlockType,\n Document,\n TextSpan,\n InlineStyle,\n} from '@create-markdown/core';\n\n// Re-export block factories for convenience\nexport {\n paragraph,\n heading,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n bulletList,\n numberedList,\n checkListItem,\n checkList,\n codeBlock,\n blockquote,\n divider,\n image,\n callout,\n text,\n bold,\n italic,\n code,\n link,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Package Info\n// ============================================================================\n\n/**\n * Package version\n */\nexport const VERSION = '2.0.2';\n","/**\n * @create-markdown/react - Block Renderer\n * Render blocks as React elements\n */\n\nimport React from 'react';\nimport type {\n Block,\n TextSpan,\n HeadingBlock,\n CodeBlockBlock,\n ImageBlock,\n TableBlock,\n CalloutBlock,\n CheckListBlock,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BlockRendererProps {\n /** Blocks to render */\n blocks: Block[];\n /** Custom class name for the container */\n className?: string;\n /** Custom renderers for specific block types */\n customRenderers?: Partial<BlockRenderers>;\n}\n\nexport interface BlockRenderers {\n paragraph: React.ComponentType<{ block: Block }>;\n heading: React.ComponentType<{ block: HeadingBlock }>;\n bulletList: React.ComponentType<{ block: Block }>;\n numberedList: React.ComponentType<{ block: Block }>;\n checkList: React.ComponentType<{ block: CheckListBlock }>;\n codeBlock: React.ComponentType<{ block: CodeBlockBlock }>;\n blockquote: React.ComponentType<{ block: Block }>;\n table: React.ComponentType<{ block: TableBlock }>;\n image: React.ComponentType<{ block: ImageBlock }>;\n divider: React.ComponentType<{ block: Block }>;\n callout: React.ComponentType<{ block: CalloutBlock }>;\n}\n\nexport interface SingleBlockProps {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * Renders: array of blocks as React elements\n */\nexport function BlockRenderer({\n blocks,\n className,\n customRenderers,\n}: BlockRendererProps): React.ReactElement {\n return (\n <div className={className}>\n {blocks.map((block) => (\n <BlockElement\n key={block.id}\n block={block}\n customRenderers={customRenderers}\n />\n ))}\n </div>\n );\n}\n\n/**\n * Renders: single block\n */\nexport function BlockElement({\n block,\n customRenderers,\n}: SingleBlockProps): React.ReactElement | null {\n // Check for custom renderer first\n const CustomRenderer = customRenderers?.[block.type as keyof BlockRenderers];\n if (CustomRenderer) {\n return <CustomRenderer block={block as never} />;\n }\n\n // Use default renderers\n switch (block.type) {\n case 'paragraph':\n return <ParagraphRenderer block={block} />;\n\n case 'heading':\n return <HeadingRenderer block={block as HeadingBlock} />;\n\n case 'bulletList':\n return <BulletListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'numberedList':\n return <NumberedListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'checkList':\n return <CheckListRenderer block={block as CheckListBlock} />;\n\n case 'codeBlock':\n return <CodeBlockRenderer block={block as CodeBlockBlock} />;\n\n case 'blockquote':\n return <BlockquoteRenderer block={block} />;\n\n case 'table':\n return <TableRenderer block={block as TableBlock} />;\n\n case 'image':\n return <ImageRenderer block={block as ImageBlock} />;\n\n case 'divider':\n return <DividerRenderer />;\n\n case 'callout':\n return <CalloutRenderer block={block as CalloutBlock} />;\n\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Inline Content Renderer\n// ============================================================================\n\ninterface InlineContentProps {\n spans: TextSpan[];\n}\n\n/**\n * Renders: inline content (text spans with styles)\n */\nexport function InlineContent({ spans }: InlineContentProps): React.ReactElement {\n return (\n <>\n {spans.map((span, index) => (\n <SpanElement key={index} span={span} />\n ))}\n </>\n );\n}\n\ninterface SpanProps {\n span: TextSpan;\n}\n\n/**\n * Renders: single text span with styles\n */\nfunction SpanElement({ span }: SpanProps): React.ReactElement {\n let content: React.ReactNode = span.text;\n const styles = span.styles;\n\n // Apply styles from innermost to outermost\n if (styles.code) {\n content = <code>{content}</code>;\n }\n\n if (styles.highlight) {\n content = <mark>{content}</mark>;\n }\n\n if (styles.strikethrough) {\n content = <del>{content}</del>;\n }\n\n if (styles.underline) {\n content = <u>{content}</u>;\n }\n\n if (styles.italic) {\n content = <em>{content}</em>;\n }\n\n if (styles.bold) {\n content = <strong>{content}</strong>;\n }\n\n if (styles.link) {\n content = (\n <a href={styles.link.url} title={styles.link.title}>\n {content}\n </a>\n );\n }\n\n return <>{content}</>;\n}\n\n// ============================================================================\n// Block Renderers\n// ============================================================================\n\n/**\n * Renders: paragraph block\n */\nfunction ParagraphRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <p>\n <InlineContent spans={block.content} />\n </p>\n );\n}\n\n/**\n * Renders: heading block\n */\nfunction HeadingRenderer({ block }: { block: HeadingBlock }): React.ReactElement {\n const Tag = `h${block.props.level}` as keyof React.JSX.IntrinsicElements;\n\n return (\n <Tag>\n <InlineContent spans={block.content} />\n </Tag>\n );\n}\n\n/**\n * Renders: bullet list block\n */\nfunction BulletListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ul>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Renders: numbered list block\n */\nfunction NumberedListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ol>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ol>\n );\n}\n\n/**\n * Renders: checklist block\n */\nfunction CheckListRenderer({ block }: { block: CheckListBlock }): React.ReactElement {\n return (\n <div style={{ display: 'flex', alignItems: 'flex-start', gap: '0.5rem' }}>\n <input\n type=\"checkbox\"\n checked={block.props.checked}\n readOnly\n style={{ marginTop: '0.25rem' }}\n />\n <span style={{ textDecoration: block.props.checked ? 'line-through' : 'none' }}>\n <InlineContent spans={block.content} />\n </span>\n </div>\n );\n}\n\n/**\n * Renders: code block block\n */\nfunction CodeBlockRenderer({ block }: { block: CodeBlockBlock }): React.ReactElement {\n const code = block.content.map((span) => span.text).join('');\n const language = block.props.language;\n\n return (\n <pre>\n <code className={language ? `language-${language}` : undefined}>\n {code}\n </code>\n </pre>\n );\n}\n\n/**\n * Renders: blockquote block\n */\nfunction BlockquoteRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <blockquote>\n <InlineContent spans={block.content} />\n </blockquote>\n );\n}\n\n/**\n * Renders: table block\n */\nfunction TableRenderer({ block }: { block: TableBlock }): React.ReactElement {\n const { headers, rows, alignments } = block.props;\n\n const getAlignment = (index: number): React.CSSProperties['textAlign'] => {\n return alignments?.[index] ?? undefined;\n };\n\n return (\n <table>\n {headers.length > 0 && (\n <thead>\n <tr>\n {headers.map((header, i) => (\n <th key={i} style={{ textAlign: getAlignment(i) }}>\n {header}\n </th>\n ))}\n </tr>\n </thead>\n )}\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <td key={cellIndex} style={{ textAlign: getAlignment(cellIndex) }}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\n/**\n * Renders: image block\n */\nfunction ImageRenderer({ block }: { block: ImageBlock }): React.ReactElement {\n return (\n <figure>\n <img\n src={block.props.url}\n alt={block.props.alt ?? ''}\n title={block.props.title}\n width={block.props.width}\n height={block.props.height}\n />\n {block.props.alt && <figcaption>{block.props.alt}</figcaption>}\n </figure>\n );\n}\n\n/**\n * Renders: divider block\n */\nfunction DividerRenderer(): React.ReactElement {\n return <hr />;\n}\n\n/**\n * Renders: callout block\n */\nfunction CalloutRenderer({ block }: { block: CalloutBlock }): React.ReactElement {\n const calloutType = block.props.type;\n\n const styles: React.CSSProperties = {\n padding: '1rem',\n borderRadius: '0.25rem',\n borderLeft: '4px solid',\n marginBottom: '1rem',\n };\n\n // Color based on callout type\n const colors: Record<string, { borderColor: string; backgroundColor: string }> = {\n info: { borderColor: '#3b82f6', backgroundColor: '#eff6ff' },\n warning: { borderColor: '#f59e0b', backgroundColor: '#fffbeb' },\n tip: { borderColor: '#10b981', backgroundColor: '#ecfdf5' },\n danger: { borderColor: '#ef4444', backgroundColor: '#fef2f2' },\n note: { borderColor: '#6b7280', backgroundColor: '#f9fafb' },\n };\n\n const colorStyle = colors[calloutType] ?? colors.note;\n\n return (\n <div\n style={{\n ...styles,\n borderLeftColor: colorStyle.borderColor,\n backgroundColor: colorStyle.backgroundColor,\n }}\n role=\"alert\"\n >\n <strong style={{ textTransform: 'capitalize', display: 'block', marginBottom: '0.5rem' }}>\n {calloutType}\n </strong>\n <InlineContent spans={block.content} />\n </div>\n );\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport default BlockRenderer;\n","/**\n * @create-markdown/react - Hooks\n * State management hooks for document manipulation\n */\n\nimport { useState, useCallback, useMemo } from 'react';\nimport type { Block, Document, DocumentOptions, TextSpan } from '@create-markdown/core';\nimport {\n createDocument,\n insertBlock,\n appendBlock,\n removeBlock,\n updateBlock,\n moveBlock,\n findBlock,\n getBlockIndex,\n clearBlocks,\n setBlocks,\n updateMeta,\n markdownToBlocks,\n blocksToMarkdown,\n} from '@create-markdown/core';\n\n// ============================================================================\n// useDocument Hook\n// ============================================================================\n\nexport interface UseDocumentReturn {\n /** Current document state */\n document: Document;\n /** Blocks in the document */\n blocks: Block[];\n \n // Block operations\n /** Insert: block at a specific index */\n insertBlock: (block: Block, index?: number) => void;\n /** Append: block to the end */\n appendBlock: (block: Block) => void;\n /** Remove: block by ID */\n removeBlock: (blockId: string) => void;\n /** Update: block by ID */\n updateBlock: (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => void;\n /** Move: block to a new index */\n moveBlock: (blockId: string, newIndex: number) => void;\n /** Find: block by ID */\n findBlock: (blockId: string) => Block | undefined;\n /** Get: index of a block */\n getBlockIndex: (blockId: string) => number;\n \n // Bulk operations\n /** Clear: all blocks */\n clearBlocks: () => void;\n /** Replace: entire document with new blocks */\n setBlocks: (blocks: Block[]) => void;\n /** Set: entire document */\n setDocument: (doc: Document) => void;\n \n // Markdown operations\n /** Get: document as markdown */\n toMarkdown: () => string;\n /** Load: markdown into the document */\n fromMarkdown: (markdown: string) => void;\n \n // Metadata operations\n /** Update: document metadata */\n updateMeta: (meta: Partial<Document['meta']>) => void;\n}\n\n/**\n * Hook for managing: document with blocks\n * \n * @example\n * ```tsx\n * function Editor() {\n * const { blocks, appendBlock, toMarkdown } = useDocument();\n * \n * const addParagraph = () => {\n * appendBlock(paragraph('New paragraph'));\n * };\n * \n * return (\n * <div>\n * <BlockRenderer blocks={blocks} />\n * <button onClick={addParagraph}>Add Paragraph</button>\n * <button onClick={() => console.log(toMarkdown())}>Export</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useDocument(\n initialBlocks: Block[] = [],\n options?: DocumentOptions\n): UseDocumentReturn {\n const [document, setDocument] = useState<Document>(() =>\n createDocument(initialBlocks, options)\n );\n \n const insert = useCallback((block: Block, index?: number) => {\n setDocument((doc) => insertBlock(doc, block, index));\n }, []);\n \n const append = useCallback((block: Block) => {\n setDocument((doc) => appendBlock(doc, block));\n }, []);\n \n const remove = useCallback((blockId: string) => {\n setDocument((doc) => removeBlock(doc, blockId));\n }, []);\n \n const update = useCallback(\n (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => {\n setDocument((doc) => updateBlock(doc, blockId, updates));\n },\n []\n );\n \n const move = useCallback((blockId: string, newIndex: number) => {\n setDocument((doc) => moveBlock(doc, blockId, newIndex));\n }, []);\n \n const find = useCallback(\n (blockId: string) => findBlock(document, blockId),\n [document]\n );\n \n const getIndex = useCallback(\n (blockId: string) => getBlockIndex(document, blockId),\n [document]\n );\n \n const clear = useCallback(() => {\n setDocument((doc) => clearBlocks(doc));\n }, []);\n \n const set = useCallback((blocks: Block[]) => {\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const toMd = useCallback(() => blocksToMarkdown(document.blocks), [document]);\n \n const fromMd = useCallback((markdown: string) => {\n const blocks = markdownToBlocks(markdown);\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const meta = useCallback((newMeta: Partial<Document['meta']>) => {\n setDocument((doc) => updateMeta(doc, newMeta));\n }, []);\n \n return {\n document,\n blocks: document.blocks,\n insertBlock: insert,\n appendBlock: append,\n removeBlock: remove,\n updateBlock: update,\n moveBlock: move,\n findBlock: find,\n getBlockIndex: getIndex,\n clearBlocks: clear,\n setBlocks: set,\n setDocument,\n toMarkdown: toMd,\n fromMarkdown: fromMd,\n updateMeta: meta,\n };\n}\n\n// ============================================================================\n// useMarkdown Hook\n// ============================================================================\n\nexport interface UseMarkdownReturn {\n /** Current markdown string */\n markdown: string;\n /** Parsed blocks */\n blocks: Block[];\n /** Update: markdown content */\n setMarkdown: (markdown: string) => void;\n /** Update: blocks (will update markdown too) */\n setBlocks: (blocks: Block[]) => void;\n}\n\n/**\n * Hook for bidirectional: markdown/blocks state\n * \n * @example\n * ```tsx\n * function MarkdownEditor() {\n * const { markdown, blocks, setMarkdown } = useMarkdown('# Hello');\n * \n * return (\n * <div>\n * <textarea\n * value={markdown}\n * onChange={(e) => setMarkdown(e.target.value)}\n * />\n * <BlockRenderer blocks={blocks} />\n * </div>\n * );\n * }\n * ```\n */\nexport function useMarkdown(initialMarkdown: string = ''): UseMarkdownReturn {\n const [markdown, setMarkdownState] = useState(initialMarkdown);\n \n const blocks = useMemo(() => markdownToBlocks(markdown), [markdown]);\n \n const setMarkdown = useCallback((newMarkdown: string) => {\n setMarkdownState(newMarkdown);\n }, []);\n \n const setBlocksFromBlocks = useCallback((newBlocks: Block[]) => {\n const newMarkdown = blocksToMarkdown(newBlocks);\n setMarkdownState(newMarkdown);\n }, []);\n \n return {\n markdown,\n blocks,\n setMarkdown,\n setBlocks: setBlocksFromBlocks,\n };\n}\n\n// ============================================================================\n// useBlockEditor Hook\n// ============================================================================\n\nexport interface UseBlockEditorReturn {\n /** Current selected block ID */\n selectedBlockId: string | null;\n /** Current selected block */\n selectedBlock: Block | undefined;\n /** Select: block by ID */\n selectBlock: (blockId: string | null) => void;\n /** Select: next block */\n selectNext: () => void;\n /** Select: previous block */\n selectPrevious: () => void;\n /** Delete: selected block */\n deleteSelected: () => void;\n /** Update: selected block's content */\n updateSelectedContent: (content: TextSpan[]) => void;\n /** Duplicate: selected block */\n duplicateSelected: () => void;\n /** Move: selected block up */\n moveSelectedUp: () => void;\n /** Move: selected block down */\n moveSelectedDown: () => void;\n}\n\n/**\n * Hook for: block selection and editing operations\n * \n * @example\n * ```tsx\n * function Editor() {\n * const doc = useDocument();\n * const editor = useBlockEditor(doc);\n * \n * return (\n * <div>\n * {doc.blocks.map((block) => (\n * <div\n * key={block.id}\n * onClick={() => editor.selectBlock(block.id)}\n * style={{\n * border: editor.selectedBlockId === block.id ? '2px solid blue' : 'none'\n * }}\n * >\n * <BlockElement block={block} />\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useBlockEditor(\n documentHook: UseDocumentReturn\n): UseBlockEditorReturn {\n const { document, blocks, removeBlock, updateBlock, moveBlock, insertBlock } =\n documentHook;\n \n const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null);\n \n const selectedBlock = useMemo(\n () => (selectedBlockId ? findBlock(document, selectedBlockId) : undefined),\n [document, selectedBlockId]\n );\n \n const selectBlock = useCallback((blockId: string | null) => {\n setSelectedBlockId(blockId);\n }, []);\n \n const selectNext = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[0].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const selectPrevious = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[blocks.length - 1].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const deleteSelected = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n removeBlock(selectedBlockId);\n \n // Select next block or previous if at end\n if (blocks.length > 1) {\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n } else if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n } else {\n setSelectedBlockId(null);\n }\n }, [document, blocks, selectedBlockId, removeBlock]);\n \n const updateSelectedContent = useCallback(\n (content: TextSpan[]) => {\n if (!selectedBlockId) return;\n updateBlock(selectedBlockId, { content });\n },\n [selectedBlockId, updateBlock]\n );\n \n const duplicateSelected = useCallback(() => {\n if (!selectedBlockId || !selectedBlock) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n const clonedBlock: Block = {\n ...selectedBlock,\n id: Math.random().toString(36).substring(2, 9),\n };\n \n insertBlock(clonedBlock, currentIndex + 1);\n setSelectedBlockId(clonedBlock.id);\n }, [document, selectedBlockId, selectedBlock, insertBlock]);\n \n const moveSelectedUp = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n moveBlock(selectedBlockId, currentIndex - 1);\n }\n }, [document, selectedBlockId, moveBlock]);\n \n const moveSelectedDown = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n moveBlock(selectedBlockId, currentIndex + 1);\n }\n }, [document, blocks, selectedBlockId, moveBlock]);\n \n return {\n selectedBlockId,\n selectedBlock,\n selectBlock,\n selectNext,\n selectPrevious,\n deleteSelected,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ACA,CAACT,EAAiBH,CAAW,CAC/B,EAEMa,KAAoB,eAAY,IAAM,CAC1C,GAAI,CAACV,GAAmB,CAACE,EAAe,OAExC,IAAMG,KAAe,iBAAczC,EAAUoC,CAAe,EACtDW,EAAqB,CACzB,GAAGT,EACH,GAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,EAAG,CAAC,CAC/C,EAEAH,EAAYY,EAAaN,EAAe,CAAC,EACzCJ,EAAmBU,EAAY,EAAE,CACnC,EAAG,CAAC/C,EAAUoC,EAAiBE,EAAeH,CAAW,CAAC,EAEpDa,KAAiB,eAAY,IAAM,CACvC,GAAI,CAACZ,EAAiB,OAEtB,IAAMK,KAAe,iBAAczC,EAAUoC,CAAe,EACxDK,EAAe,GACjBP,EAAUE,EAAiBK,EAAe,CAAC,CAE/C,EAAG,CAACzC,EAAUoC,EAAiBF,CAAS,CAAC,EAEnCe,KAAmB,eAAY,IAAM,CACzC,GAAI,CAACb,EAAiB,OAEtB,IAAMK,KAAe,iBAAczC,EAAUoC,CAAe,EACxDK,EAAexB,EAAO,OAAS,GACjCiB,EAAUE,EAAiBK,EAAe,CAAC,CAE/C,EAAG,CAACzC,EAAUiB,EAAQmB,EAAiBF,CAAS,CAAC,EAEjD,MAAO,CACL,gBAAAE,EACA,cAAAE,EACA,YAAAC,EACA,WAAAC,EACA,eAAAE,EACA,eAAAC,EACA,sBAAAC,EACA,kBAAAE,EACA,eAAAE,EACA,iBAAAC,CACF,CACF,CFjWA,IAAAC,EAuBO,iCASMC,EAAU","names":["index_exports","__export","BlockElement","BlockRenderer","InlineContent","VERSION","useBlockEditor","useDocument","useMarkdown","__toCommonJS","import_jsx_runtime","BlockRenderer","blocks","className","customRenderers","block","BlockElement","CustomRenderer","ParagraphRenderer","HeadingRenderer","BulletListRenderer","NumberedListRenderer","CheckListRenderer","CodeBlockRenderer","BlockquoteRenderer","TableRenderer","ImageRenderer","DividerRenderer","CalloutRenderer","InlineContent","spans","span","index","SpanElement","content","styles","Tag","child","code","language","headers","rows","alignments","getAlignment","header","i","row","rowIndex","cell","cellIndex","calloutType","colors","colorStyle","import_react","import_core","useDocument","initialBlocks","options","document","setDocument","insert","block","index","doc","append","remove","blockId","update","updates","move","newIndex","find","getIndex","clear","set","blocks","toMd","fromMd","markdown","meta","newMeta","useMarkdown","initialMarkdown","setMarkdownState","setMarkdown","newMarkdown","setBlocksFromBlocks","newBlocks","useBlockEditor","documentHook","removeBlock","updateBlock","moveBlock","insertBlock","selectedBlockId","setSelectedBlockId","selectedBlock","selectBlock","selectNext","currentIndex","selectPrevious","deleteSelected","updateSelectedContent","content","duplicateSelected","clonedBlock","moveSelectedUp","moveSelectedDown","import_core","VERSION"]}
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { paragraph, heading, h1, h2, h3, h4, h5, h6, bulletList, numberedList, c
11
11
  /**
12
12
  * Package version
13
13
  */
14
- export declare const VERSION = "2.0.0";
14
+ export declare const VERSION = "2.0.2";
15
15
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Fragment as w,jsx as n,jsxs as f}from"react/jsx-runtime";function L({blocks:o,className:t,customRenderers:e}){return n("div",{className:t,children:o.map(l=>n(b,{block:l,customRenderers:e},l.id))})}function b({block:o,customRenderers:t}){let e=t?.[o.type];if(e)return n(e,{block:o});switch(o.type){case"paragraph":return n(N,{block:o});case"heading":return n(q,{block:o});case"bulletList":return n(O,{block:o,customRenderers:t});case"numberedList":return n(H,{block:o,customRenderers:t});case"checkList":return n(A,{block:o});case"codeBlock":return n($,{block:o});case"blockquote":return n(z,{block:o});case"table":return n(F,{block:o});case"image":return n(J,{block:o});case"divider":return n(V,{});case"callout":return n(X,{block:o});default:return null}}function m({spans:o}){return n(w,{children:o.map((t,e)=>n(U,{span:t},e))})}function U({span:o}){let t=o.text,e=o.styles;return e.code&&(t=n("code",{children:t})),e.highlight&&(t=n("mark",{children:t})),e.strikethrough&&(t=n("del",{children:t})),e.underline&&(t=n("u",{children:t})),e.italic&&(t=n("em",{children:t})),e.bold&&(t=n("strong",{children:t})),e.link&&(t=n("a",{href:e.link.url,title:e.link.title,children:t})),n(w,{children:t})}function N({block:o}){return n("p",{children:n(m,{spans:o.content})})}function q({block:o}){let t=`h${o.props.level}`;return n(t,{children:n(m,{spans:o.content})})}function O({block:o,customRenderers:t}){return n("ul",{children:o.children.map(e=>f("li",{children:[n(m,{spans:e.content}),e.children.length>0&&n(b,{block:e,customRenderers:t})]},e.id))})}function H({block:o,customRenderers:t}){return n("ol",{children:o.children.map(e=>f("li",{children:[n(m,{spans:e.content}),e.children.length>0&&n(b,{block:e,customRenderers:t})]},e.id))})}function A({block:o}){return f("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem"},children:[n("input",{type:"checkbox",checked:o.props.checked,readOnly:!0,style:{marginTop:"0.25rem"}}),n("span",{style:{textDecoration:o.props.checked?"line-through":"none"},children:n(m,{spans:o.content})})]})}function $({block:o}){let t=o.content.map(l=>l.text).join(""),e=o.props.language;return n("pre",{children:n("code",{className:e?`language-${e}`:void 0,children:t})})}function z({block:o}){return n("blockquote",{children:n(m,{spans:o.content})})}function F({block:o}){let{headers:t,rows:e,alignments:l}=o.props,p=d=>l?.[d]??void 0;return f("table",{children:[t.length>0&&n("thead",{children:n("tr",{children:t.map((d,u)=>n("th",{style:{textAlign:p(u)},children:d},u))})}),n("tbody",{children:e.map((d,u)=>n("tr",{children:d.map((r,k)=>n("td",{style:{textAlign:p(k)},children:r},k))},u))})]})}function J({block:o}){return f("figure",{children:[n("img",{src:o.props.url,alt:o.props.alt??"",title:o.props.title,width:o.props.width,height:o.props.height}),o.props.alt&&n("figcaption",{children:o.props.alt})]})}function V(){return n("hr",{})}function X({block:o}){let t=o.props.type,e={padding:"1rem",borderRadius:"0.25rem",borderLeft:"4px solid",marginBottom:"1rem"},l={info:{borderColor:"#3b82f6",backgroundColor:"#eff6ff"},warning:{borderColor:"#f59e0b",backgroundColor:"#fffbeb"},tip:{borderColor:"#10b981",backgroundColor:"#ecfdf5"},danger:{borderColor:"#ef4444",backgroundColor:"#fef2f2"},note:{borderColor:"#6b7280",backgroundColor:"#f9fafb"}},p=l[t]??l.note;return f("div",{style:{...e,borderLeftColor:p.borderColor,backgroundColor:p.backgroundColor},role:"alert",children:[n("strong",{style:{textTransform:"capitalize",display:"block",marginBottom:"0.5rem"},children:t}),n(m,{spans:o.content})]})}import{useState as S,useCallback as a,useMemo as E}from"react";import{createDocument as j,insertBlock as G,appendBlock as K,removeBlock as Q,updateBlock as W,moveBlock as Y,findBlock as P,getBlockIndex as B,clearBlocks as Z,setBlocks as T,updateMeta as _,markdownToBlocks as D,blocksToMarkdown as M}from"@create-markdown/core";function ee(o=[],t){let[e,l]=S(()=>j(o,t)),p=a((s,i)=>{l(c=>G(c,s,i))},[]),d=a(s=>{l(i=>K(i,s))},[]),u=a(s=>{l(i=>Q(i,s))},[]),r=a((s,i)=>{l(c=>W(c,s,i))},[]),k=a((s,i)=>{l(c=>Y(c,s,i))},[]),g=a(s=>P(e,s),[e]),R=a(s=>B(e,s),[e]),h=a(()=>{l(s=>Z(s))},[]),C=a(s=>{l(i=>T(i,s))},[]),x=a(()=>M(e.blocks),[e]),y=a(s=>{let i=D(s);l(c=>T(c,i))},[]),v=a(s=>{l(i=>_(i,s))},[]);return{document:e,blocks:e.blocks,insertBlock:p,appendBlock:d,removeBlock:u,updateBlock:r,moveBlock:k,findBlock:g,getBlockIndex:R,clearBlocks:h,setBlocks:C,setDocument:l,toMarkdown:x,fromMarkdown:y,updateMeta:v}}function te(o=""){let[t,e]=S(o),l=E(()=>D(t),[t]),p=a(u=>{e(u)},[]),d=a(u=>{let r=M(u);e(r)},[]);return{markdown:t,blocks:l,setMarkdown:p,setBlocks:d}}function oe(o){let{document:t,blocks:e,removeBlock:l,updateBlock:p,moveBlock:d,insertBlock:u}=o,[r,k]=S(null),g=E(()=>r?P(t,r):void 0,[t,r]),R=a(c=>{k(c)},[]),h=a(()=>{if(!r){e.length>0&&k(e[0].id);return}let c=B(t,r);c<e.length-1&&k(e[c+1].id)},[t,e,r]),C=a(()=>{if(!r){e.length>0&&k(e[e.length-1].id);return}let c=B(t,r);c>0&&k(e[c-1].id)},[t,e,r]),x=a(()=>{if(!r)return;let c=B(t,r);l(r),e.length>1?c<e.length-1?k(e[c+1].id):c>0&&k(e[c-1].id):k(null)},[t,e,r,l]),y=a(c=>{r&&p(r,{content:c})},[r,p]),v=a(()=>{if(!r||!g)return;let c=B(t,r),I={...g,id:Math.random().toString(36).substring(2,9)};u(I,c+1),k(I.id)},[t,r,g,u]),s=a(()=>{if(!r)return;let c=B(t,r);c>0&&d(r,c-1)},[t,r,d]),i=a(()=>{if(!r)return;let c=B(t,r);c<e.length-1&&d(r,c+1)},[t,e,r,d]);return{selectedBlockId:r,selectedBlock:g,selectBlock:R,selectNext:h,selectPrevious:C,deleteSelected:x,updateSelectedContent:y,duplicateSelected:v,moveSelectedUp:s,moveSelectedDown:i}}import{paragraph as pe,heading as me,h1 as Be,h2 as ge,h3 as fe,h4 as be,h5 as Re,h6 as he,bulletList as Ce,numberedList as xe,checkListItem as ye,checkList as ve,codeBlock as Se,blockquote as Ie,divider as we,image as Te,callout as Ee,text as Pe,bold as De,italic as Me,code as Le,link as Ue}from"@create-markdown/core";var ae="2.0.0";export{b as BlockElement,L as BlockRenderer,m as InlineContent,ae as VERSION,Ie as blockquote,De as bold,Ce as bulletList,Ee as callout,ve as checkList,ye as checkListItem,Le as code,Se as codeBlock,we as divider,Be as h1,ge as h2,fe as h3,be as h4,Re as h5,he as h6,me as heading,Te as image,Me as italic,Ue as link,xe as numberedList,pe as paragraph,Pe as text,oe as useBlockEditor,ee as useDocument,te as useMarkdown};
1
+ import{Fragment as w,jsx as n,jsxs as f}from"react/jsx-runtime";function L({blocks:o,className:t,customRenderers:e}){return n("div",{className:t,children:o.map(l=>n(b,{block:l,customRenderers:e},l.id))})}function b({block:o,customRenderers:t}){let e=t?.[o.type];if(e)return n(e,{block:o});switch(o.type){case"paragraph":return n(N,{block:o});case"heading":return n(q,{block:o});case"bulletList":return n(O,{block:o,customRenderers:t});case"numberedList":return n(H,{block:o,customRenderers:t});case"checkList":return n(A,{block:o});case"codeBlock":return n($,{block:o});case"blockquote":return n(z,{block:o});case"table":return n(F,{block:o});case"image":return n(J,{block:o});case"divider":return n(V,{});case"callout":return n(X,{block:o});default:return null}}function m({spans:o}){return n(w,{children:o.map((t,e)=>n(U,{span:t},e))})}function U({span:o}){let t=o.text,e=o.styles;return e.code&&(t=n("code",{children:t})),e.highlight&&(t=n("mark",{children:t})),e.strikethrough&&(t=n("del",{children:t})),e.underline&&(t=n("u",{children:t})),e.italic&&(t=n("em",{children:t})),e.bold&&(t=n("strong",{children:t})),e.link&&(t=n("a",{href:e.link.url,title:e.link.title,children:t})),n(w,{children:t})}function N({block:o}){return n("p",{children:n(m,{spans:o.content})})}function q({block:o}){let t=`h${o.props.level}`;return n(t,{children:n(m,{spans:o.content})})}function O({block:o,customRenderers:t}){return n("ul",{children:o.children.map(e=>f("li",{children:[n(m,{spans:e.content}),e.children.length>0&&n(b,{block:e,customRenderers:t})]},e.id))})}function H({block:o,customRenderers:t}){return n("ol",{children:o.children.map(e=>f("li",{children:[n(m,{spans:e.content}),e.children.length>0&&n(b,{block:e,customRenderers:t})]},e.id))})}function A({block:o}){return f("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem"},children:[n("input",{type:"checkbox",checked:o.props.checked,readOnly:!0,style:{marginTop:"0.25rem"}}),n("span",{style:{textDecoration:o.props.checked?"line-through":"none"},children:n(m,{spans:o.content})})]})}function $({block:o}){let t=o.content.map(l=>l.text).join(""),e=o.props.language;return n("pre",{children:n("code",{className:e?`language-${e}`:void 0,children:t})})}function z({block:o}){return n("blockquote",{children:n(m,{spans:o.content})})}function F({block:o}){let{headers:t,rows:e,alignments:l}=o.props,p=d=>l?.[d]??void 0;return f("table",{children:[t.length>0&&n("thead",{children:n("tr",{children:t.map((d,u)=>n("th",{style:{textAlign:p(u)},children:d},u))})}),n("tbody",{children:e.map((d,u)=>n("tr",{children:d.map((r,k)=>n("td",{style:{textAlign:p(k)},children:r},k))},u))})]})}function J({block:o}){return f("figure",{children:[n("img",{src:o.props.url,alt:o.props.alt??"",title:o.props.title,width:o.props.width,height:o.props.height}),o.props.alt&&n("figcaption",{children:o.props.alt})]})}function V(){return n("hr",{})}function X({block:o}){let t=o.props.type,e={padding:"1rem",borderRadius:"0.25rem",borderLeft:"4px solid",marginBottom:"1rem"},l={info:{borderColor:"#3b82f6",backgroundColor:"#eff6ff"},warning:{borderColor:"#f59e0b",backgroundColor:"#fffbeb"},tip:{borderColor:"#10b981",backgroundColor:"#ecfdf5"},danger:{borderColor:"#ef4444",backgroundColor:"#fef2f2"},note:{borderColor:"#6b7280",backgroundColor:"#f9fafb"}},p=l[t]??l.note;return f("div",{style:{...e,borderLeftColor:p.borderColor,backgroundColor:p.backgroundColor},role:"alert",children:[n("strong",{style:{textTransform:"capitalize",display:"block",marginBottom:"0.5rem"},children:t}),n(m,{spans:o.content})]})}import{useState as S,useCallback as a,useMemo as E}from"react";import{createDocument as j,insertBlock as G,appendBlock as K,removeBlock as Q,updateBlock as W,moveBlock as Y,findBlock as P,getBlockIndex as B,clearBlocks as Z,setBlocks as T,updateMeta as _,markdownToBlocks as D,blocksToMarkdown as M}from"@create-markdown/core";function ee(o=[],t){let[e,l]=S(()=>j(o,t)),p=a((s,i)=>{l(c=>G(c,s,i))},[]),d=a(s=>{l(i=>K(i,s))},[]),u=a(s=>{l(i=>Q(i,s))},[]),r=a((s,i)=>{l(c=>W(c,s,i))},[]),k=a((s,i)=>{l(c=>Y(c,s,i))},[]),g=a(s=>P(e,s),[e]),R=a(s=>B(e,s),[e]),h=a(()=>{l(s=>Z(s))},[]),C=a(s=>{l(i=>T(i,s))},[]),x=a(()=>M(e.blocks),[e]),y=a(s=>{let i=D(s);l(c=>T(c,i))},[]),v=a(s=>{l(i=>_(i,s))},[]);return{document:e,blocks:e.blocks,insertBlock:p,appendBlock:d,removeBlock:u,updateBlock:r,moveBlock:k,findBlock:g,getBlockIndex:R,clearBlocks:h,setBlocks:C,setDocument:l,toMarkdown:x,fromMarkdown:y,updateMeta:v}}function te(o=""){let[t,e]=S(o),l=E(()=>D(t),[t]),p=a(u=>{e(u)},[]),d=a(u=>{let r=M(u);e(r)},[]);return{markdown:t,blocks:l,setMarkdown:p,setBlocks:d}}function oe(o){let{document:t,blocks:e,removeBlock:l,updateBlock:p,moveBlock:d,insertBlock:u}=o,[r,k]=S(null),g=E(()=>r?P(t,r):void 0,[t,r]),R=a(c=>{k(c)},[]),h=a(()=>{if(!r){e.length>0&&k(e[0].id);return}let c=B(t,r);c<e.length-1&&k(e[c+1].id)},[t,e,r]),C=a(()=>{if(!r){e.length>0&&k(e[e.length-1].id);return}let c=B(t,r);c>0&&k(e[c-1].id)},[t,e,r]),x=a(()=>{if(!r)return;let c=B(t,r);l(r),e.length>1?c<e.length-1?k(e[c+1].id):c>0&&k(e[c-1].id):k(null)},[t,e,r,l]),y=a(c=>{r&&p(r,{content:c})},[r,p]),v=a(()=>{if(!r||!g)return;let c=B(t,r),I={...g,id:Math.random().toString(36).substring(2,9)};u(I,c+1),k(I.id)},[t,r,g,u]),s=a(()=>{if(!r)return;let c=B(t,r);c>0&&d(r,c-1)},[t,r,d]),i=a(()=>{if(!r)return;let c=B(t,r);c<e.length-1&&d(r,c+1)},[t,e,r,d]);return{selectedBlockId:r,selectedBlock:g,selectBlock:R,selectNext:h,selectPrevious:C,deleteSelected:x,updateSelectedContent:y,duplicateSelected:v,moveSelectedUp:s,moveSelectedDown:i}}import{paragraph as pe,heading as me,h1 as Be,h2 as ge,h3 as fe,h4 as be,h5 as Re,h6 as he,bulletList as Ce,numberedList as xe,checkListItem as ye,checkList as ve,codeBlock as Se,blockquote as Ie,divider as we,image as Te,callout as Ee,text as Pe,bold as De,italic as Me,code as Le,link as Ue}from"@create-markdown/core";var ae="2.0.2";export{b as BlockElement,L as BlockRenderer,m as InlineContent,ae as VERSION,Ie as blockquote,De as bold,Ce as bulletList,Ee as callout,ve as checkList,ye as checkListItem,Le as code,Se as codeBlock,we as divider,Be as h1,ge as h2,fe as h3,be as h4,Re as h5,he as h6,me as heading,Te as image,Me as italic,Ue as link,xe as numberedList,pe as paragraph,Pe as text,oe as useBlockEditor,ee as useDocument,te as useMarkdown};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/block-renderer.tsx","../src/hooks.ts","../src/index.ts"],"sourcesContent":["/**\n * @create-markdown/react - Block Renderer\n * Render blocks as React elements\n */\n\nimport React from 'react';\nimport type {\n Block,\n TextSpan,\n HeadingBlock,\n CodeBlockBlock,\n ImageBlock,\n TableBlock,\n CalloutBlock,\n CheckListBlock,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BlockRendererProps {\n /** Blocks to render */\n blocks: Block[];\n /** Custom class name for the container */\n className?: string;\n /** Custom renderers for specific block types */\n customRenderers?: Partial<BlockRenderers>;\n}\n\nexport interface BlockRenderers {\n paragraph: React.ComponentType<{ block: Block }>;\n heading: React.ComponentType<{ block: HeadingBlock }>;\n bulletList: React.ComponentType<{ block: Block }>;\n numberedList: React.ComponentType<{ block: Block }>;\n checkList: React.ComponentType<{ block: CheckListBlock }>;\n codeBlock: React.ComponentType<{ block: CodeBlockBlock }>;\n blockquote: React.ComponentType<{ block: Block }>;\n table: React.ComponentType<{ block: TableBlock }>;\n image: React.ComponentType<{ block: ImageBlock }>;\n divider: React.ComponentType<{ block: Block }>;\n callout: React.ComponentType<{ block: CalloutBlock }>;\n}\n\nexport interface SingleBlockProps {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * Renders: array of blocks as React elements\n */\nexport function BlockRenderer({\n blocks,\n className,\n customRenderers,\n}: BlockRendererProps): React.ReactElement {\n return (\n <div className={className}>\n {blocks.map((block) => (\n <BlockElement\n key={block.id}\n block={block}\n customRenderers={customRenderers}\n />\n ))}\n </div>\n );\n}\n\n/**\n * Renders: single block\n */\nexport function BlockElement({\n block,\n customRenderers,\n}: SingleBlockProps): React.ReactElement | null {\n // Check for custom renderer first\n const CustomRenderer = customRenderers?.[block.type as keyof BlockRenderers];\n if (CustomRenderer) {\n return <CustomRenderer block={block as never} />;\n }\n\n // Use default renderers\n switch (block.type) {\n case 'paragraph':\n return <ParagraphRenderer block={block} />;\n\n case 'heading':\n return <HeadingRenderer block={block as HeadingBlock} />;\n\n case 'bulletList':\n return <BulletListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'numberedList':\n return <NumberedListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'checkList':\n return <CheckListRenderer block={block as CheckListBlock} />;\n\n case 'codeBlock':\n return <CodeBlockRenderer block={block as CodeBlockBlock} />;\n\n case 'blockquote':\n return <BlockquoteRenderer block={block} />;\n\n case 'table':\n return <TableRenderer block={block as TableBlock} />;\n\n case 'image':\n return <ImageRenderer block={block as ImageBlock} />;\n\n case 'divider':\n return <DividerRenderer />;\n\n case 'callout':\n return <CalloutRenderer block={block as CalloutBlock} />;\n\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Inline Content Renderer\n// ============================================================================\n\ninterface InlineContentProps {\n spans: TextSpan[];\n}\n\n/**\n * Renders: inline content (text spans with styles)\n */\nexport function InlineContent({ spans }: InlineContentProps): React.ReactElement {\n return (\n <>\n {spans.map((span, index) => (\n <SpanElement key={index} span={span} />\n ))}\n </>\n );\n}\n\ninterface SpanProps {\n span: TextSpan;\n}\n\n/**\n * Renders: single text span with styles\n */\nfunction SpanElement({ span }: SpanProps): React.ReactElement {\n let content: React.ReactNode = span.text;\n const styles = span.styles;\n\n // Apply styles from innermost to outermost\n if (styles.code) {\n content = <code>{content}</code>;\n }\n\n if (styles.highlight) {\n content = <mark>{content}</mark>;\n }\n\n if (styles.strikethrough) {\n content = <del>{content}</del>;\n }\n\n if (styles.underline) {\n content = <u>{content}</u>;\n }\n\n if (styles.italic) {\n content = <em>{content}</em>;\n }\n\n if (styles.bold) {\n content = <strong>{content}</strong>;\n }\n\n if (styles.link) {\n content = (\n <a href={styles.link.url} title={styles.link.title}>\n {content}\n </a>\n );\n }\n\n return <>{content}</>;\n}\n\n// ============================================================================\n// Block Renderers\n// ============================================================================\n\n/**\n * Renders: paragraph block\n */\nfunction ParagraphRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <p>\n <InlineContent spans={block.content} />\n </p>\n );\n}\n\n/**\n * Renders: heading block\n */\nfunction HeadingRenderer({ block }: { block: HeadingBlock }): React.ReactElement {\n const Tag = `h${block.props.level}` as keyof React.JSX.IntrinsicElements;\n\n return (\n <Tag>\n <InlineContent spans={block.content} />\n </Tag>\n );\n}\n\n/**\n * Renders: bullet list block\n */\nfunction BulletListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ul>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Renders: numbered list block\n */\nfunction NumberedListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ol>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ol>\n );\n}\n\n/**\n * Renders: checklist block\n */\nfunction CheckListRenderer({ block }: { block: CheckListBlock }): React.ReactElement {\n return (\n <div style={{ display: 'flex', alignItems: 'flex-start', gap: '0.5rem' }}>\n <input\n type=\"checkbox\"\n checked={block.props.checked}\n readOnly\n style={{ marginTop: '0.25rem' }}\n />\n <span style={{ textDecoration: block.props.checked ? 'line-through' : 'none' }}>\n <InlineContent spans={block.content} />\n </span>\n </div>\n );\n}\n\n/**\n * Renders: code block block\n */\nfunction CodeBlockRenderer({ block }: { block: CodeBlockBlock }): React.ReactElement {\n const code = block.content.map((span) => span.text).join('');\n const language = block.props.language;\n\n return (\n <pre>\n <code className={language ? `language-${language}` : undefined}>\n {code}\n </code>\n </pre>\n );\n}\n\n/**\n * Renders: blockquote block\n */\nfunction BlockquoteRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <blockquote>\n <InlineContent spans={block.content} />\n </blockquote>\n );\n}\n\n/**\n * Renders: table block\n */\nfunction TableRenderer({ block }: { block: TableBlock }): React.ReactElement {\n const { headers, rows, alignments } = block.props;\n\n const getAlignment = (index: number): React.CSSProperties['textAlign'] => {\n return alignments?.[index] ?? undefined;\n };\n\n return (\n <table>\n {headers.length > 0 && (\n <thead>\n <tr>\n {headers.map((header, i) => (\n <th key={i} style={{ textAlign: getAlignment(i) }}>\n {header}\n </th>\n ))}\n </tr>\n </thead>\n )}\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <td key={cellIndex} style={{ textAlign: getAlignment(cellIndex) }}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\n/**\n * Renders: image block\n */\nfunction ImageRenderer({ block }: { block: ImageBlock }): React.ReactElement {\n return (\n <figure>\n <img\n src={block.props.url}\n alt={block.props.alt ?? ''}\n title={block.props.title}\n width={block.props.width}\n height={block.props.height}\n />\n {block.props.alt && <figcaption>{block.props.alt}</figcaption>}\n </figure>\n );\n}\n\n/**\n * Renders: divider block\n */\nfunction DividerRenderer(): React.ReactElement {\n return <hr />;\n}\n\n/**\n * Renders: callout block\n */\nfunction CalloutRenderer({ block }: { block: CalloutBlock }): React.ReactElement {\n const calloutType = block.props.type;\n\n const styles: React.CSSProperties = {\n padding: '1rem',\n borderRadius: '0.25rem',\n borderLeft: '4px solid',\n marginBottom: '1rem',\n };\n\n // Color based on callout type\n const colors: Record<string, { borderColor: string; backgroundColor: string }> = {\n info: { borderColor: '#3b82f6', backgroundColor: '#eff6ff' },\n warning: { borderColor: '#f59e0b', backgroundColor: '#fffbeb' },\n tip: { borderColor: '#10b981', backgroundColor: '#ecfdf5' },\n danger: { borderColor: '#ef4444', backgroundColor: '#fef2f2' },\n note: { borderColor: '#6b7280', backgroundColor: '#f9fafb' },\n };\n\n const colorStyle = colors[calloutType] ?? colors.note;\n\n return (\n <div\n style={{\n ...styles,\n borderLeftColor: colorStyle.borderColor,\n backgroundColor: colorStyle.backgroundColor,\n }}\n role=\"alert\"\n >\n <strong style={{ textTransform: 'capitalize', display: 'block', marginBottom: '0.5rem' }}>\n {calloutType}\n </strong>\n <InlineContent spans={block.content} />\n </div>\n );\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport default BlockRenderer;\n","/**\n * @create-markdown/react - Hooks\n * State management hooks for document manipulation\n */\n\nimport { useState, useCallback, useMemo } from 'react';\nimport type { Block, Document, DocumentOptions, TextSpan } from '@create-markdown/core';\nimport {\n createDocument,\n insertBlock,\n appendBlock,\n removeBlock,\n updateBlock,\n moveBlock,\n findBlock,\n getBlockIndex,\n clearBlocks,\n setBlocks,\n updateMeta,\n markdownToBlocks,\n blocksToMarkdown,\n} from '@create-markdown/core';\n\n// ============================================================================\n// useDocument Hook\n// ============================================================================\n\nexport interface UseDocumentReturn {\n /** Current document state */\n document: Document;\n /** Blocks in the document */\n blocks: Block[];\n \n // Block operations\n /** Insert: block at a specific index */\n insertBlock: (block: Block, index?: number) => void;\n /** Append: block to the end */\n appendBlock: (block: Block) => void;\n /** Remove: block by ID */\n removeBlock: (blockId: string) => void;\n /** Update: block by ID */\n updateBlock: (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => void;\n /** Move: block to a new index */\n moveBlock: (blockId: string, newIndex: number) => void;\n /** Find: block by ID */\n findBlock: (blockId: string) => Block | undefined;\n /** Get: index of a block */\n getBlockIndex: (blockId: string) => number;\n \n // Bulk operations\n /** Clear: all blocks */\n clearBlocks: () => void;\n /** Replace: entire document with new blocks */\n setBlocks: (blocks: Block[]) => void;\n /** Set: entire document */\n setDocument: (doc: Document) => void;\n \n // Markdown operations\n /** Get: document as markdown */\n toMarkdown: () => string;\n /** Load: markdown into the document */\n fromMarkdown: (markdown: string) => void;\n \n // Metadata operations\n /** Update: document metadata */\n updateMeta: (meta: Partial<Document['meta']>) => void;\n}\n\n/**\n * Hook for managing: document with blocks\n * \n * @example\n * ```tsx\n * function Editor() {\n * const { blocks, appendBlock, toMarkdown } = useDocument();\n * \n * const addParagraph = () => {\n * appendBlock(paragraph('New paragraph'));\n * };\n * \n * return (\n * <div>\n * <BlockRenderer blocks={blocks} />\n * <button onClick={addParagraph}>Add Paragraph</button>\n * <button onClick={() => console.log(toMarkdown())}>Export</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useDocument(\n initialBlocks: Block[] = [],\n options?: DocumentOptions\n): UseDocumentReturn {\n const [document, setDocument] = useState<Document>(() =>\n createDocument(initialBlocks, options)\n );\n \n const insert = useCallback((block: Block, index?: number) => {\n setDocument((doc) => insertBlock(doc, block, index));\n }, []);\n \n const append = useCallback((block: Block) => {\n setDocument((doc) => appendBlock(doc, block));\n }, []);\n \n const remove = useCallback((blockId: string) => {\n setDocument((doc) => removeBlock(doc, blockId));\n }, []);\n \n const update = useCallback(\n (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => {\n setDocument((doc) => updateBlock(doc, blockId, updates));\n },\n []\n );\n \n const move = useCallback((blockId: string, newIndex: number) => {\n setDocument((doc) => moveBlock(doc, blockId, newIndex));\n }, []);\n \n const find = useCallback(\n (blockId: string) => findBlock(document, blockId),\n [document]\n );\n \n const getIndex = useCallback(\n (blockId: string) => getBlockIndex(document, blockId),\n [document]\n );\n \n const clear = useCallback(() => {\n setDocument((doc) => clearBlocks(doc));\n }, []);\n \n const set = useCallback((blocks: Block[]) => {\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const toMd = useCallback(() => blocksToMarkdown(document.blocks), [document]);\n \n const fromMd = useCallback((markdown: string) => {\n const blocks = markdownToBlocks(markdown);\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const meta = useCallback((newMeta: Partial<Document['meta']>) => {\n setDocument((doc) => updateMeta(doc, newMeta));\n }, []);\n \n return {\n document,\n blocks: document.blocks,\n insertBlock: insert,\n appendBlock: append,\n removeBlock: remove,\n updateBlock: update,\n moveBlock: move,\n findBlock: find,\n getBlockIndex: getIndex,\n clearBlocks: clear,\n setBlocks: set,\n setDocument,\n toMarkdown: toMd,\n fromMarkdown: fromMd,\n updateMeta: meta,\n };\n}\n\n// ============================================================================\n// useMarkdown Hook\n// ============================================================================\n\nexport interface UseMarkdownReturn {\n /** Current markdown string */\n markdown: string;\n /** Parsed blocks */\n blocks: Block[];\n /** Update: markdown content */\n setMarkdown: (markdown: string) => void;\n /** Update: blocks (will update markdown too) */\n setBlocks: (blocks: Block[]) => void;\n}\n\n/**\n * Hook for bidirectional: markdown/blocks state\n * \n * @example\n * ```tsx\n * function MarkdownEditor() {\n * const { markdown, blocks, setMarkdown } = useMarkdown('# Hello');\n * \n * return (\n * <div>\n * <textarea\n * value={markdown}\n * onChange={(e) => setMarkdown(e.target.value)}\n * />\n * <BlockRenderer blocks={blocks} />\n * </div>\n * );\n * }\n * ```\n */\nexport function useMarkdown(initialMarkdown: string = ''): UseMarkdownReturn {\n const [markdown, setMarkdownState] = useState(initialMarkdown);\n \n const blocks = useMemo(() => markdownToBlocks(markdown), [markdown]);\n \n const setMarkdown = useCallback((newMarkdown: string) => {\n setMarkdownState(newMarkdown);\n }, []);\n \n const setBlocksFromBlocks = useCallback((newBlocks: Block[]) => {\n const newMarkdown = blocksToMarkdown(newBlocks);\n setMarkdownState(newMarkdown);\n }, []);\n \n return {\n markdown,\n blocks,\n setMarkdown,\n setBlocks: setBlocksFromBlocks,\n };\n}\n\n// ============================================================================\n// useBlockEditor Hook\n// ============================================================================\n\nexport interface UseBlockEditorReturn {\n /** Current selected block ID */\n selectedBlockId: string | null;\n /** Current selected block */\n selectedBlock: Block | undefined;\n /** Select: block by ID */\n selectBlock: (blockId: string | null) => void;\n /** Select: next block */\n selectNext: () => void;\n /** Select: previous block */\n selectPrevious: () => void;\n /** Delete: selected block */\n deleteSelected: () => void;\n /** Update: selected block's content */\n updateSelectedContent: (content: TextSpan[]) => void;\n /** Duplicate: selected block */\n duplicateSelected: () => void;\n /** Move: selected block up */\n moveSelectedUp: () => void;\n /** Move: selected block down */\n moveSelectedDown: () => void;\n}\n\n/**\n * Hook for: block selection and editing operations\n * \n * @example\n * ```tsx\n * function Editor() {\n * const doc = useDocument();\n * const editor = useBlockEditor(doc);\n * \n * return (\n * <div>\n * {doc.blocks.map((block) => (\n * <div\n * key={block.id}\n * onClick={() => editor.selectBlock(block.id)}\n * style={{\n * border: editor.selectedBlockId === block.id ? '2px solid blue' : 'none'\n * }}\n * >\n * <BlockElement block={block} />\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useBlockEditor(\n documentHook: UseDocumentReturn\n): UseBlockEditorReturn {\n const { document, blocks, removeBlock, updateBlock, moveBlock, insertBlock } =\n documentHook;\n \n const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null);\n \n const selectedBlock = useMemo(\n () => (selectedBlockId ? findBlock(document, selectedBlockId) : undefined),\n [document, selectedBlockId]\n );\n \n const selectBlock = useCallback((blockId: string | null) => {\n setSelectedBlockId(blockId);\n }, []);\n \n const selectNext = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[0].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const selectPrevious = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[blocks.length - 1].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const deleteSelected = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n removeBlock(selectedBlockId);\n \n // Select next block or previous if at end\n if (blocks.length > 1) {\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n } else if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n } else {\n setSelectedBlockId(null);\n }\n }, [document, blocks, selectedBlockId, removeBlock]);\n \n const updateSelectedContent = useCallback(\n (content: TextSpan[]) => {\n if (!selectedBlockId) return;\n updateBlock(selectedBlockId, { content });\n },\n [selectedBlockId, updateBlock]\n );\n \n const duplicateSelected = useCallback(() => {\n if (!selectedBlockId || !selectedBlock) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n const clonedBlock: Block = {\n ...selectedBlock,\n id: Math.random().toString(36).substring(2, 9),\n };\n \n insertBlock(clonedBlock, currentIndex + 1);\n setSelectedBlockId(clonedBlock.id);\n }, [document, selectedBlockId, selectedBlock, insertBlock]);\n \n const moveSelectedUp = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n moveBlock(selectedBlockId, currentIndex - 1);\n }\n }, [document, selectedBlockId, moveBlock]);\n \n const moveSelectedDown = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n moveBlock(selectedBlockId, currentIndex + 1);\n }\n }, [document, blocks, selectedBlockId, moveBlock]);\n \n return {\n selectedBlockId,\n selectedBlock,\n selectBlock,\n selectNext,\n selectPrevious,\n deleteSelected,\n updateSelectedContent,\n duplicateSelected,\n moveSelectedUp,\n moveSelectedDown,\n };\n}\n","/**\n * @create-markdown/react\n * React components and hooks for @create-markdown\n */\n\n// Components\nexport {\n BlockRenderer,\n BlockElement,\n InlineContent,\n} from './block-renderer';\n\nexport type {\n BlockRendererProps,\n BlockRenderers,\n SingleBlockProps,\n} from './block-renderer';\n\n// Hooks\nexport {\n useDocument,\n useMarkdown,\n useBlockEditor,\n} from './hooks';\n\nexport type {\n UseDocumentReturn,\n UseMarkdownReturn,\n UseBlockEditorReturn,\n} from './hooks';\n\n// Re-export types that are commonly needed with React components\nexport type {\n Block,\n BlockType,\n Document,\n TextSpan,\n InlineStyle,\n} from '@create-markdown/core';\n\n// Re-export block factories for convenience\nexport {\n paragraph,\n heading,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n bulletList,\n numberedList,\n checkListItem,\n checkList,\n codeBlock,\n blockquote,\n divider,\n image,\n callout,\n text,\n bold,\n italic,\n code,\n link,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Package Info\n// ============================================================================\n\n/**\n * Package version\n */\nexport const VERSION = '2.0.0';\n"],"mappings":"AAgEgB,OA4ER,YAAAA,EA5EQ,OAAAC,EA4KA,QAAAC,MA5KA,oBART,SAASC,EAAc,CAC1B,OAAAC,EACA,UAAAC,EACA,gBAAAC,CACJ,EAA2C,CACvC,OACIL,EAAC,OAAI,UAAWI,EACX,SAAAD,EAAO,IAAKG,GACTN,EAACO,EAAA,CAEG,MAAOD,EACP,gBAAiBD,GAFZC,EAAM,EAGf,CACH,EACL,CAER,CAKO,SAASC,EAAa,CACzB,MAAAD,EACA,gBAAAD,CACJ,EAAgD,CAE5C,IAAMG,EAAiBH,IAAkBC,EAAM,IAA4B,EAC3E,GAAIE,EACA,OAAOR,EAACQ,EAAA,CAAe,MAAOF,EAAgB,EAIlD,OAAQA,EAAM,KAAM,CAChB,IAAK,YACD,OAAON,EAACS,EAAA,CAAkB,MAAOH,EAAO,EAE5C,IAAK,UACD,OAAON,EAACU,EAAA,CAAgB,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AaN,EAAe,CAAC,EACzCJ,EAAmBU,EAAY,EAAE,CACnC,EAAG,CAAC3C,EAAUgC,EAAiBE,EAAejD,CAAW,CAAC,EAEpD2D,EAAiB9D,EAAY,IAAM,CACvC,GAAI,CAACkD,EAAiB,OAEtB,IAAMK,EAAe9C,EAAcS,EAAUgC,CAAe,EACxDK,EAAe,GACjBhD,EAAU2C,EAAiBK,EAAe,CAAC,CAE/C,EAAG,CAACrC,EAAUgC,EAAiB3C,CAAS,CAAC,EAEnCwD,EAAmB/D,EAAY,IAAM,CACzC,GAAI,CAACkD,EAAiB,OAEtB,IAAMK,EAAe9C,EAAcS,EAAUgC,CAAe,EACxDK,EAAepB,EAAO,OAAS,GACjC5B,EAAU2C,EAAiBK,EAAe,CAAC,CAE/C,EAAG,CAACrC,EAAUiB,EAAQe,EAAiB3C,CAAS,CAAC,EAEjD,MAAO,CACL,gBAAA2C,EACA,cAAAE,EACA,YAAAC,EACA,WAAAC,EACA,eAAAE,EACA,eAAAC,EACA,sBAAAC,EACA,kBAAAE,EACA,eAAAE,EACA,iBAAAC,CACF,CACF,CCjWA,OACE,aAAAC,GACA,WAAAC,GACA,MAAAC,GACA,MAAAC,GACA,MAAAC,GACA,MAAAC,GACA,MAAAC,GACA,MAAAC,GACA,cAAAC,GACA,gBAAAC,GACA,iBAAAC,GACA,aAAAC,GACA,aAAAC,GACA,cAAAC,GACA,WAAAC,GACA,SAAAC,GACA,WAAAC,GACA,QAAAC,GACA,QAAAC,GACA,UAAAC,GACA,QAAAC,GACA,QAAAC,OACK,wBASA,IAAMC,GAAU","names":["Fragment","jsx","jsxs","BlockRenderer","blocks","className","customRenderers","block","BlockElement","CustomRenderer","ParagraphRenderer","HeadingRenderer","BulletListRenderer","NumberedListRenderer","CheckListRenderer","CodeBlockRenderer","BlockquoteRenderer","TableRenderer","ImageRenderer","DividerRenderer","CalloutRenderer","InlineContent","spans","span","index","SpanElement","content","styles","Tag","child","code","language","headers","rows","alignments","getAlignment","header","i","row","rowIndex","cell","cellIndex","calloutType","colors","colorStyle","useState","useCallback","useMemo","createDocument","insertBlock","appendBlock","removeBlock","updateBlock","moveBlock","findBlock","getBlockIndex","clearBlocks","setBlocks","updateMeta","markdownToBlocks","blocksToMarkdown","useDocument","initialBlocks","options","document","setDocument","insert","block","index","doc","append","remove","blockId","update","updates","move","newIndex","find","getIndex","clear","set","blocks","toMd","fromMd","markdown","meta","newMeta","useMarkdown","initialMarkdown","setMarkdownState","setMarkdown","newMarkdown","setBlocksFromBlocks","newBlocks","useBlockEditor","documentHook","selectedBlockId","setSelectedBlockId","selectedBlock","selectBlock","selectNext","currentIndex","selectPrevious","deleteSelected","updateSelectedContent","content","duplicateSelected","clonedBlock","moveSelectedUp","moveSelectedDown","paragraph","heading","h1","h2","h3","h4","h5","h6","bulletList","numberedList","checkListItem","checkList","codeBlock","blockquote","divider","image","callout","text","bold","italic","code","link","VERSION"]}
1
+ {"version":3,"sources":["../src/block-renderer.tsx","../src/hooks.ts","../src/index.ts"],"sourcesContent":["/**\n * @create-markdown/react - Block Renderer\n * Render blocks as React elements\n */\n\nimport React from 'react';\nimport type {\n Block,\n TextSpan,\n HeadingBlock,\n CodeBlockBlock,\n ImageBlock,\n TableBlock,\n CalloutBlock,\n CheckListBlock,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BlockRendererProps {\n /** Blocks to render */\n blocks: Block[];\n /** Custom class name for the container */\n className?: string;\n /** Custom renderers for specific block types */\n customRenderers?: Partial<BlockRenderers>;\n}\n\nexport interface BlockRenderers {\n paragraph: React.ComponentType<{ block: Block }>;\n heading: React.ComponentType<{ block: HeadingBlock }>;\n bulletList: React.ComponentType<{ block: Block }>;\n numberedList: React.ComponentType<{ block: Block }>;\n checkList: React.ComponentType<{ block: CheckListBlock }>;\n codeBlock: React.ComponentType<{ block: CodeBlockBlock }>;\n blockquote: React.ComponentType<{ block: Block }>;\n table: React.ComponentType<{ block: TableBlock }>;\n image: React.ComponentType<{ block: ImageBlock }>;\n divider: React.ComponentType<{ block: Block }>;\n callout: React.ComponentType<{ block: CalloutBlock }>;\n}\n\nexport interface SingleBlockProps {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\n/**\n * Renders: array of blocks as React elements\n */\nexport function BlockRenderer({\n blocks,\n className,\n customRenderers,\n}: BlockRendererProps): React.ReactElement {\n return (\n <div className={className}>\n {blocks.map((block) => (\n <BlockElement\n key={block.id}\n block={block}\n customRenderers={customRenderers}\n />\n ))}\n </div>\n );\n}\n\n/**\n * Renders: single block\n */\nexport function BlockElement({\n block,\n customRenderers,\n}: SingleBlockProps): React.ReactElement | null {\n // Check for custom renderer first\n const CustomRenderer = customRenderers?.[block.type as keyof BlockRenderers];\n if (CustomRenderer) {\n return <CustomRenderer block={block as never} />;\n }\n\n // Use default renderers\n switch (block.type) {\n case 'paragraph':\n return <ParagraphRenderer block={block} />;\n\n case 'heading':\n return <HeadingRenderer block={block as HeadingBlock} />;\n\n case 'bulletList':\n return <BulletListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'numberedList':\n return <NumberedListRenderer block={block} customRenderers={customRenderers} />;\n\n case 'checkList':\n return <CheckListRenderer block={block as CheckListBlock} />;\n\n case 'codeBlock':\n return <CodeBlockRenderer block={block as CodeBlockBlock} />;\n\n case 'blockquote':\n return <BlockquoteRenderer block={block} />;\n\n case 'table':\n return <TableRenderer block={block as TableBlock} />;\n\n case 'image':\n return <ImageRenderer block={block as ImageBlock} />;\n\n case 'divider':\n return <DividerRenderer />;\n\n case 'callout':\n return <CalloutRenderer block={block as CalloutBlock} />;\n\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Inline Content Renderer\n// ============================================================================\n\ninterface InlineContentProps {\n spans: TextSpan[];\n}\n\n/**\n * Renders: inline content (text spans with styles)\n */\nexport function InlineContent({ spans }: InlineContentProps): React.ReactElement {\n return (\n <>\n {spans.map((span, index) => (\n <SpanElement key={index} span={span} />\n ))}\n </>\n );\n}\n\ninterface SpanProps {\n span: TextSpan;\n}\n\n/**\n * Renders: single text span with styles\n */\nfunction SpanElement({ span }: SpanProps): React.ReactElement {\n let content: React.ReactNode = span.text;\n const styles = span.styles;\n\n // Apply styles from innermost to outermost\n if (styles.code) {\n content = <code>{content}</code>;\n }\n\n if (styles.highlight) {\n content = <mark>{content}</mark>;\n }\n\n if (styles.strikethrough) {\n content = <del>{content}</del>;\n }\n\n if (styles.underline) {\n content = <u>{content}</u>;\n }\n\n if (styles.italic) {\n content = <em>{content}</em>;\n }\n\n if (styles.bold) {\n content = <strong>{content}</strong>;\n }\n\n if (styles.link) {\n content = (\n <a href={styles.link.url} title={styles.link.title}>\n {content}\n </a>\n );\n }\n\n return <>{content}</>;\n}\n\n// ============================================================================\n// Block Renderers\n// ============================================================================\n\n/**\n * Renders: paragraph block\n */\nfunction ParagraphRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <p>\n <InlineContent spans={block.content} />\n </p>\n );\n}\n\n/**\n * Renders: heading block\n */\nfunction HeadingRenderer({ block }: { block: HeadingBlock }): React.ReactElement {\n const Tag = `h${block.props.level}` as keyof React.JSX.IntrinsicElements;\n\n return (\n <Tag>\n <InlineContent spans={block.content} />\n </Tag>\n );\n}\n\n/**\n * Renders: bullet list block\n */\nfunction BulletListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ul>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Renders: numbered list block\n */\nfunction NumberedListRenderer({\n block,\n customRenderers,\n}: {\n block: Block;\n customRenderers?: Partial<BlockRenderers>;\n}): React.ReactElement {\n return (\n <ol>\n {block.children.map((child) => (\n <li key={child.id}>\n <InlineContent spans={child.content} />\n {child.children.length > 0 && (\n <BlockElement block={child} customRenderers={customRenderers} />\n )}\n </li>\n ))}\n </ol>\n );\n}\n\n/**\n * Renders: checklist block\n */\nfunction CheckListRenderer({ block }: { block: CheckListBlock }): React.ReactElement {\n return (\n <div style={{ display: 'flex', alignItems: 'flex-start', gap: '0.5rem' }}>\n <input\n type=\"checkbox\"\n checked={block.props.checked}\n readOnly\n style={{ marginTop: '0.25rem' }}\n />\n <span style={{ textDecoration: block.props.checked ? 'line-through' : 'none' }}>\n <InlineContent spans={block.content} />\n </span>\n </div>\n );\n}\n\n/**\n * Renders: code block block\n */\nfunction CodeBlockRenderer({ block }: { block: CodeBlockBlock }): React.ReactElement {\n const code = block.content.map((span) => span.text).join('');\n const language = block.props.language;\n\n return (\n <pre>\n <code className={language ? `language-${language}` : undefined}>\n {code}\n </code>\n </pre>\n );\n}\n\n/**\n * Renders: blockquote block\n */\nfunction BlockquoteRenderer({ block }: { block: Block }): React.ReactElement {\n return (\n <blockquote>\n <InlineContent spans={block.content} />\n </blockquote>\n );\n}\n\n/**\n * Renders: table block\n */\nfunction TableRenderer({ block }: { block: TableBlock }): React.ReactElement {\n const { headers, rows, alignments } = block.props;\n\n const getAlignment = (index: number): React.CSSProperties['textAlign'] => {\n return alignments?.[index] ?? undefined;\n };\n\n return (\n <table>\n {headers.length > 0 && (\n <thead>\n <tr>\n {headers.map((header, i) => (\n <th key={i} style={{ textAlign: getAlignment(i) }}>\n {header}\n </th>\n ))}\n </tr>\n </thead>\n )}\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <td key={cellIndex} style={{ textAlign: getAlignment(cellIndex) }}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\n/**\n * Renders: image block\n */\nfunction ImageRenderer({ block }: { block: ImageBlock }): React.ReactElement {\n return (\n <figure>\n <img\n src={block.props.url}\n alt={block.props.alt ?? ''}\n title={block.props.title}\n width={block.props.width}\n height={block.props.height}\n />\n {block.props.alt && <figcaption>{block.props.alt}</figcaption>}\n </figure>\n );\n}\n\n/**\n * Renders: divider block\n */\nfunction DividerRenderer(): React.ReactElement {\n return <hr />;\n}\n\n/**\n * Renders: callout block\n */\nfunction CalloutRenderer({ block }: { block: CalloutBlock }): React.ReactElement {\n const calloutType = block.props.type;\n\n const styles: React.CSSProperties = {\n padding: '1rem',\n borderRadius: '0.25rem',\n borderLeft: '4px solid',\n marginBottom: '1rem',\n };\n\n // Color based on callout type\n const colors: Record<string, { borderColor: string; backgroundColor: string }> = {\n info: { borderColor: '#3b82f6', backgroundColor: '#eff6ff' },\n warning: { borderColor: '#f59e0b', backgroundColor: '#fffbeb' },\n tip: { borderColor: '#10b981', backgroundColor: '#ecfdf5' },\n danger: { borderColor: '#ef4444', backgroundColor: '#fef2f2' },\n note: { borderColor: '#6b7280', backgroundColor: '#f9fafb' },\n };\n\n const colorStyle = colors[calloutType] ?? colors.note;\n\n return (\n <div\n style={{\n ...styles,\n borderLeftColor: colorStyle.borderColor,\n backgroundColor: colorStyle.backgroundColor,\n }}\n role=\"alert\"\n >\n <strong style={{ textTransform: 'capitalize', display: 'block', marginBottom: '0.5rem' }}>\n {calloutType}\n </strong>\n <InlineContent spans={block.content} />\n </div>\n );\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport default BlockRenderer;\n","/**\n * @create-markdown/react - Hooks\n * State management hooks for document manipulation\n */\n\nimport { useState, useCallback, useMemo } from 'react';\nimport type { Block, Document, DocumentOptions, TextSpan } from '@create-markdown/core';\nimport {\n createDocument,\n insertBlock,\n appendBlock,\n removeBlock,\n updateBlock,\n moveBlock,\n findBlock,\n getBlockIndex,\n clearBlocks,\n setBlocks,\n updateMeta,\n markdownToBlocks,\n blocksToMarkdown,\n} from '@create-markdown/core';\n\n// ============================================================================\n// useDocument Hook\n// ============================================================================\n\nexport interface UseDocumentReturn {\n /** Current document state */\n document: Document;\n /** Blocks in the document */\n blocks: Block[];\n \n // Block operations\n /** Insert: block at a specific index */\n insertBlock: (block: Block, index?: number) => void;\n /** Append: block to the end */\n appendBlock: (block: Block) => void;\n /** Remove: block by ID */\n removeBlock: (blockId: string) => void;\n /** Update: block by ID */\n updateBlock: (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => void;\n /** Move: block to a new index */\n moveBlock: (blockId: string, newIndex: number) => void;\n /** Find: block by ID */\n findBlock: (blockId: string) => Block | undefined;\n /** Get: index of a block */\n getBlockIndex: (blockId: string) => number;\n \n // Bulk operations\n /** Clear: all blocks */\n clearBlocks: () => void;\n /** Replace: entire document with new blocks */\n setBlocks: (blocks: Block[]) => void;\n /** Set: entire document */\n setDocument: (doc: Document) => void;\n \n // Markdown operations\n /** Get: document as markdown */\n toMarkdown: () => string;\n /** Load: markdown into the document */\n fromMarkdown: (markdown: string) => void;\n \n // Metadata operations\n /** Update: document metadata */\n updateMeta: (meta: Partial<Document['meta']>) => void;\n}\n\n/**\n * Hook for managing: document with blocks\n * \n * @example\n * ```tsx\n * function Editor() {\n * const { blocks, appendBlock, toMarkdown } = useDocument();\n * \n * const addParagraph = () => {\n * appendBlock(paragraph('New paragraph'));\n * };\n * \n * return (\n * <div>\n * <BlockRenderer blocks={blocks} />\n * <button onClick={addParagraph}>Add Paragraph</button>\n * <button onClick={() => console.log(toMarkdown())}>Export</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useDocument(\n initialBlocks: Block[] = [],\n options?: DocumentOptions\n): UseDocumentReturn {\n const [document, setDocument] = useState<Document>(() =>\n createDocument(initialBlocks, options)\n );\n \n const insert = useCallback((block: Block, index?: number) => {\n setDocument((doc) => insertBlock(doc, block, index));\n }, []);\n \n const append = useCallback((block: Block) => {\n setDocument((doc) => appendBlock(doc, block));\n }, []);\n \n const remove = useCallback((blockId: string) => {\n setDocument((doc) => removeBlock(doc, blockId));\n }, []);\n \n const update = useCallback(\n (blockId: string, updates: Partial<Omit<Block, 'id' | 'type'>>) => {\n setDocument((doc) => updateBlock(doc, blockId, updates));\n },\n []\n );\n \n const move = useCallback((blockId: string, newIndex: number) => {\n setDocument((doc) => moveBlock(doc, blockId, newIndex));\n }, []);\n \n const find = useCallback(\n (blockId: string) => findBlock(document, blockId),\n [document]\n );\n \n const getIndex = useCallback(\n (blockId: string) => getBlockIndex(document, blockId),\n [document]\n );\n \n const clear = useCallback(() => {\n setDocument((doc) => clearBlocks(doc));\n }, []);\n \n const set = useCallback((blocks: Block[]) => {\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const toMd = useCallback(() => blocksToMarkdown(document.blocks), [document]);\n \n const fromMd = useCallback((markdown: string) => {\n const blocks = markdownToBlocks(markdown);\n setDocument((doc) => setBlocks(doc, blocks));\n }, []);\n \n const meta = useCallback((newMeta: Partial<Document['meta']>) => {\n setDocument((doc) => updateMeta(doc, newMeta));\n }, []);\n \n return {\n document,\n blocks: document.blocks,\n insertBlock: insert,\n appendBlock: append,\n removeBlock: remove,\n updateBlock: update,\n moveBlock: move,\n findBlock: find,\n getBlockIndex: getIndex,\n clearBlocks: clear,\n setBlocks: set,\n setDocument,\n toMarkdown: toMd,\n fromMarkdown: fromMd,\n updateMeta: meta,\n };\n}\n\n// ============================================================================\n// useMarkdown Hook\n// ============================================================================\n\nexport interface UseMarkdownReturn {\n /** Current markdown string */\n markdown: string;\n /** Parsed blocks */\n blocks: Block[];\n /** Update: markdown content */\n setMarkdown: (markdown: string) => void;\n /** Update: blocks (will update markdown too) */\n setBlocks: (blocks: Block[]) => void;\n}\n\n/**\n * Hook for bidirectional: markdown/blocks state\n * \n * @example\n * ```tsx\n * function MarkdownEditor() {\n * const { markdown, blocks, setMarkdown } = useMarkdown('# Hello');\n * \n * return (\n * <div>\n * <textarea\n * value={markdown}\n * onChange={(e) => setMarkdown(e.target.value)}\n * />\n * <BlockRenderer blocks={blocks} />\n * </div>\n * );\n * }\n * ```\n */\nexport function useMarkdown(initialMarkdown: string = ''): UseMarkdownReturn {\n const [markdown, setMarkdownState] = useState(initialMarkdown);\n \n const blocks = useMemo(() => markdownToBlocks(markdown), [markdown]);\n \n const setMarkdown = useCallback((newMarkdown: string) => {\n setMarkdownState(newMarkdown);\n }, []);\n \n const setBlocksFromBlocks = useCallback((newBlocks: Block[]) => {\n const newMarkdown = blocksToMarkdown(newBlocks);\n setMarkdownState(newMarkdown);\n }, []);\n \n return {\n markdown,\n blocks,\n setMarkdown,\n setBlocks: setBlocksFromBlocks,\n };\n}\n\n// ============================================================================\n// useBlockEditor Hook\n// ============================================================================\n\nexport interface UseBlockEditorReturn {\n /** Current selected block ID */\n selectedBlockId: string | null;\n /** Current selected block */\n selectedBlock: Block | undefined;\n /** Select: block by ID */\n selectBlock: (blockId: string | null) => void;\n /** Select: next block */\n selectNext: () => void;\n /** Select: previous block */\n selectPrevious: () => void;\n /** Delete: selected block */\n deleteSelected: () => void;\n /** Update: selected block's content */\n updateSelectedContent: (content: TextSpan[]) => void;\n /** Duplicate: selected block */\n duplicateSelected: () => void;\n /** Move: selected block up */\n moveSelectedUp: () => void;\n /** Move: selected block down */\n moveSelectedDown: () => void;\n}\n\n/**\n * Hook for: block selection and editing operations\n * \n * @example\n * ```tsx\n * function Editor() {\n * const doc = useDocument();\n * const editor = useBlockEditor(doc);\n * \n * return (\n * <div>\n * {doc.blocks.map((block) => (\n * <div\n * key={block.id}\n * onClick={() => editor.selectBlock(block.id)}\n * style={{\n * border: editor.selectedBlockId === block.id ? '2px solid blue' : 'none'\n * }}\n * >\n * <BlockElement block={block} />\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useBlockEditor(\n documentHook: UseDocumentReturn\n): UseBlockEditorReturn {\n const { document, blocks, removeBlock, updateBlock, moveBlock, insertBlock } =\n documentHook;\n \n const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null);\n \n const selectedBlock = useMemo(\n () => (selectedBlockId ? findBlock(document, selectedBlockId) : undefined),\n [document, selectedBlockId]\n );\n \n const selectBlock = useCallback((blockId: string | null) => {\n setSelectedBlockId(blockId);\n }, []);\n \n const selectNext = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[0].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const selectPrevious = useCallback(() => {\n if (!selectedBlockId) {\n if (blocks.length > 0) {\n setSelectedBlockId(blocks[blocks.length - 1].id);\n }\n return;\n }\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n }, [document, blocks, selectedBlockId]);\n \n const deleteSelected = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n removeBlock(selectedBlockId);\n \n // Select next block or previous if at end\n if (blocks.length > 1) {\n if (currentIndex < blocks.length - 1) {\n setSelectedBlockId(blocks[currentIndex + 1].id);\n } else if (currentIndex > 0) {\n setSelectedBlockId(blocks[currentIndex - 1].id);\n }\n } else {\n setSelectedBlockId(null);\n }\n }, [document, blocks, selectedBlockId, removeBlock]);\n \n const updateSelectedContent = useCallback(\n (content: TextSpan[]) => {\n if (!selectedBlockId) return;\n updateBlock(selectedBlockId, { content });\n },\n [selectedBlockId, updateBlock]\n );\n \n const duplicateSelected = useCallback(() => {\n if (!selectedBlockId || !selectedBlock) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n const clonedBlock: Block = {\n ...selectedBlock,\n id: Math.random().toString(36).substring(2, 9),\n };\n \n insertBlock(clonedBlock, currentIndex + 1);\n setSelectedBlockId(clonedBlock.id);\n }, [document, selectedBlockId, selectedBlock, insertBlock]);\n \n const moveSelectedUp = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex > 0) {\n moveBlock(selectedBlockId, currentIndex - 1);\n }\n }, [document, selectedBlockId, moveBlock]);\n \n const moveSelectedDown = useCallback(() => {\n if (!selectedBlockId) return;\n \n const currentIndex = getBlockIndex(document, selectedBlockId);\n if (currentIndex < blocks.length - 1) {\n moveBlock(selectedBlockId, currentIndex + 1);\n }\n }, [document, blocks, selectedBlockId, moveBlock]);\n \n return {\n selectedBlockId,\n selectedBlock,\n selectBlock,\n selectNext,\n selectPrevious,\n deleteSelected,\n updateSelectedContent,\n duplicateSelected,\n moveSelectedUp,\n moveSelectedDown,\n };\n}\n","/**\n * @create-markdown/react\n * React components and hooks for @create-markdown\n */\n\n// Components\nexport {\n BlockRenderer,\n BlockElement,\n InlineContent,\n} from './block-renderer';\n\nexport type {\n BlockRendererProps,\n BlockRenderers,\n SingleBlockProps,\n} from './block-renderer';\n\n// Hooks\nexport {\n useDocument,\n useMarkdown,\n useBlockEditor,\n} from './hooks';\n\nexport type {\n UseDocumentReturn,\n UseMarkdownReturn,\n UseBlockEditorReturn,\n} from './hooks';\n\n// Re-export types that are commonly needed with React components\nexport type {\n Block,\n BlockType,\n Document,\n TextSpan,\n InlineStyle,\n} from '@create-markdown/core';\n\n// Re-export block factories for convenience\nexport {\n paragraph,\n heading,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n bulletList,\n numberedList,\n checkListItem,\n checkList,\n codeBlock,\n blockquote,\n divider,\n image,\n callout,\n text,\n bold,\n italic,\n code,\n link,\n} from '@create-markdown/core';\n\n// ============================================================================\n// Package Info\n// ============================================================================\n\n/**\n * Package version\n */\nexport const VERSION = '2.0.2';\n"],"mappings":"AAgEgB,OA4ER,YAAAA,EA5EQ,OAAAC,EA4KA,QAAAC,MA5KA,oBART,SAASC,EAAc,CAC1B,OAAAC,EACA,UAAAC,EACA,gBAAAC,CACJ,EAA2C,CACvC,OACIL,EAAC,OAAI,UAAWI,EACX,SAAAD,EAAO,IAAKG,GACTN,EAACO,EAAA,CAEG,MAAOD,EACP,gBAAiBD,GAFZC,EAAM,EAGf,CACH,EACL,CAER,CAKO,SAASC,EAAa,CACzB,MAA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AAU","names":["Fragment","jsx","jsxs","BlockRenderer","blocks","className","customRenderers","block","BlockElement","CustomRenderer","ParagraphRenderer","HeadingRenderer","BulletListRenderer","NumberedListRenderer","CheckListRenderer","CodeBlockRenderer","BlockquoteRenderer","TableRenderer","ImageRenderer","DividerRenderer","CalloutRenderer","InlineContent","spans","span","index","SpanElement","content","styles","Tag","child","code","language","headers","rows","alignments","getAlignment","header","i","row","rowIndex","cell","cellIndex","calloutType","colors","colorStyle","useState","useCallback","useMemo","createDocument","insertBlock","appendBlock","removeBlock","updateBlock","moveBlock","findBlock","getBlockIndex","clearBlocks","setBlocks","updateMeta","markdownToBlocks","blocksToMarkdown","useDocument","initialBlocks","options","document","setDocument","insert","block","index","doc","append","remove","blockId","update","updates","move","newIndex","find","getIndex","clear","set","blocks","toMd","fromMd","markdown","meta","newMeta","useMarkdown","initialMarkdown","setMarkdownState","setMarkdown","newMarkdown","setBlocksFromBlocks","newBlocks","useBlockEditor","documentHook","selectedBlockId","setSelectedBlockId","selectedBlock","selectBlock","selectNext","currentIndex","selectPrevious","deleteSelected","updateSelectedContent","content","duplicateSelected","clonedBlock","moveSelectedUp","moveSelectedDown","paragraph","heading","h1","h2","h3","h4","h5","h6","bulletList","numberedList","checkListItem","checkList","codeBlock","blockquote","divider","image","callout","text","bold","italic","code","link","VERSION"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@create-markdown/react",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "React components and hooks for @create-markdown",
5
5
  "author": "Val Alexander <val@viewdue.ai>",
6
6
  "license": "MIT",
@@ -26,14 +26,9 @@
26
26
  "types": "./dist/index.d.ts",
27
27
  "exports": {
28
28
  ".": {
29
- "import": {
30
- "types": "./dist/index.d.ts",
31
- "default": "./dist/index.js"
32
- },
33
- "require": {
34
- "types": "./dist/index.d.ts",
35
- "default": "./dist/index.cjs"
36
- }
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/index.cjs"
37
32
  }
38
33
  },
39
34
  "files": [
@@ -41,17 +36,23 @@
41
36
  ],
42
37
  "devDependencies": {
43
38
  "@testing-library/react": "^16.0.0",
44
- "@types/react": "^18.2.0",
39
+ "@types/react": "^18.3.0",
40
+ "@types/react-dom": "^18.3.0",
45
41
  "jsdom": "^25.0.0",
46
42
  "react": "^18.2.0",
47
43
  "react-dom": "^18.2.0",
48
44
  "typescript": "^5.3.0",
49
- "vitest": "^2.1.0"
45
+ "vite": "^7.1.11",
46
+ "vitest": "^4.1.2",
47
+ "@create-markdown/core": "^2.0.2"
50
48
  },
51
49
  "peerDependencies": {
52
- "@create-markdown/core": ">=2.0.0",
50
+ "@create-markdown/core": ">=2.0.2",
53
51
  "react": ">=18.0.0"
54
52
  },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
55
56
  "engines": {
56
57
  "node": ">=20.0.0"
57
58
  },