react-inline-markdown-editor 2.1.1 → 2.1.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/README.md +5 -5
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -7
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ A controlled React Markdown editor with inline preview, powered by CodeMirror 6.
|
|
|
5
5
|
[](https://www.npmjs.com/package/react-inline-markdown-editor)
|
|
6
6
|
[](https://www.npmjs.com/package/react-inline-markdown-editor)
|
|
7
7
|
[](https://github.com/anasyd/react-inline-markdown-editor/actions/workflows/ci.yml)
|
|
8
|
-
[](.size-limit.json)
|
|
9
|
-
[](LICENSE)
|
|
8
|
+
[](https://github.com/anasyd/react-inline-markdown-editor/blob/main/package/.size-limit.json)
|
|
9
|
+
[](https://github.com/anasyd/react-inline-markdown-editor/blob/main/LICENSE)
|
|
10
10
|
|
|
11
|
-
[Live demo](https://www.anasyd.com/MD) · [npm package](https://www.npmjs.com/package/react-inline-markdown-editor) · [Releases](https://github.com/anasyd/react-inline-markdown-editor/releases) · [Changelog](CHANGELOG.md)
|
|
11
|
+
[Documentation](https://anasyd.github.io/react-inline-markdown-editor/) · [Live demo](https://www.anasyd.com/MD) · [npm package](https://www.npmjs.com/package/react-inline-markdown-editor) · [Releases](https://github.com/anasyd/react-inline-markdown-editor/releases) · [Changelog](https://github.com/anasyd/react-inline-markdown-editor/blob/main/package/CHANGELOG.md)
|
|
12
12
|
|
|
13
13
|

|
|
14
14
|
|
|
@@ -67,8 +67,8 @@ The editor uses CodeMirror's standard editing keymaps, including undo, redo, and
|
|
|
67
67
|
|
|
68
68
|
## Contributing
|
|
69
69
|
|
|
70
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup and [SECURITY.md](SECURITY.md) for private vulnerability reporting.
|
|
70
|
+
See [CONTRIBUTING.md](https://github.com/anasyd/react-inline-markdown-editor/blob/main/CONTRIBUTING.md) for setup and [SECURITY.md](https://github.com/anasyd/react-inline-markdown-editor/blob/main/SECURITY.md) for private vulnerability reporting.
|
|
71
71
|
|
|
72
72
|
## License
|
|
73
73
|
|
|
74
|
-
[MIT](LICENSE)
|
|
74
|
+
[MIT](https://github.com/anasyd/react-inline-markdown-editor/blob/main/LICENSE)
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var ne=Object.create;var M=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var se=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},z=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of ae(t))!le.call(e,c)&&c!==n&&M(e,c,{get:()=>t[c],enumerable:!(o=ie(t,c))||o.enumerable});return e};var q=(e,t,n)=>(n=e!=null?ne(ce(e)):{},z(t||!e||!e.__esModule?M(n,"default",{value:e,enumerable:!0}):n,e)),de=e=>z(M({},"__esModule",{value:!0}),e);var pe={};se(pe,{InlineMarkdownEditor:()=>re});module.exports=de(pe);var k=q(require("react")),D=require("@codemirror/view"),te=require("@codemirror/state");var L=require("@codemirror/lang-markdown"),C=require("@codemirror/commands"),m=require("@codemirror/view"),O=require("@codemirror/state");var h=require("@codemirror/view"),R=require("@codemirror/language"),E=h.Decoration.replace({}),I=class extends h.WidgetType{toDOM(){let t=document.createElement("span");return t.textContent="\u2022",t.className="ob-list-mark",t}eq(){return!0}},V=class extends h.WidgetType{constructor(n,o){super();this.url=n;this.alt=o}eq(n){return n.url===this.url&&n.alt===this.alt}toDOM(){let n=document.createElement("img");return n.src=this.url,n.alt=this.alt,n.className="ob-image-embed",n.style.maxWidth="100%",n.style.maxHeight="320px",n.style.minHeight="20px",n.style.borderRadius="6px",n.style.display="block",n.onerror=()=>{let o=document.createElement("span");o.className="ob-image",o.textContent=this.alt||this.url,n.replaceWith(o)},n}};function b(e,t,n){for(let o of e.selection.ranges)if(o.from>=t&&o.to<=n||o.from<=n&&o.to>=t)return!0;return!1}function S(e,t){let n=e.doc.lineAt(t);for(let o of e.selection.ranges)if(o.from>=n.from&&o.from<=n.to)return!0;return!1}function P(e){let{state:t}=e,n=[],o=(l,a,r)=>{l<a&&n.push({from:l,to:a,deco:r})},c=l=>h.Decoration.mark({class:l});return(0,R.syntaxTree)(t).cursor().iterate(l=>{let{name:a,from:r,to:i}=l;if(/^ATXHeading[1-6]$/.test(a)){let d=a.slice(-1);o(r,i,c(`ob-h${d}`))}if(a==="HeaderMark"&&(S(t,r)?o(r,i,c("ob-syntax")):o(r,i,E)),a==="StrongEmphasis"&&(b(t,r,i)||o(r,i,c("ob-bold"))),a==="Emphasis"&&(b(t,r,i)||o(r,i,c("ob-italic"))),a==="EmphasisMark"){let d=l.node.parent?.from??r,s=l.node.parent?.to??i;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="Strikethrough"&&(b(t,r,i)||o(r,i,c("ob-strikethrough"))),a==="StrikethroughMark"){let d=l.node.parent?.from??r,s=l.node.parent?.to??i;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="InlineCode"&&(b(t,r,i)||o(r,i,c("ob-code"))),a==="CodeMark"&&l.node.parent?.name==="InlineCode"){let d=l.node.parent.from,s=l.node.parent.to;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="Link"&&(b(t,r,i)||o(r,i,c("ob-link"))),a==="LinkMark"&&l.node.parent?.name==="Link"){let d=l.node.parent.from,s=l.node.parent.to;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="URL"&&l.node.parent?.name==="Link"){let d=l.node.parent.from,s=l.node.parent.to;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="Image"){if(!S(t,r)){let s=t.doc.sliceString(r,i).match(/^!\[([^\]]*)\]\(([^)\s]+)/);if(s)return o(r,i,h.Decoration.replace({widget:new V(s[2],s[1])})),!1}o(r,i,c("ob-image"))}if(a==="LinkMark"&&l.node.parent?.name==="Image"){let d=l.node.parent.from,s=l.node.parent.to;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="URL"&&l.node.parent?.name==="Image"){let d=l.node.parent.from,s=l.node.parent.to;b(t,d,s)?o(r,i,c("ob-syntax")):o(r,i,E)}if(a==="Blockquote"&&o(r,i,c("ob-blockquote")),a==="BlockquoteMark"&&(S(t,r),o(r,i,c("ob-blockquote-mark"))),a==="ListMark"){let d=t.doc.sliceString(r,i);(d==="-"||d==="*"||d==="+")&&!S(t,r)?o(r,i,h.Decoration.replace({widget:new I})):o(r,i,c("ob-list-mark"))}a==="FencedCode"&&o(r,i,c("ob-code-block")),a==="CodeMark"&&l.node.parent?.name==="FencedCode"&&o(r,i,c("ob-fence-mark")),a==="CodeInfo"&&o(r,i,c("ob-code-info")),a==="HorizontalRule"&&o(r,i,c("ob-hr"))}),h.Decoration.set(n.map(({from:l,to:a,deco:r})=>r.range(l,a)),!0)}var N=h.ViewPlugin.fromClass(class{constructor(e){this.decorations=P(e)}update(e){(e.docChanged||e.selectionSet||e.viewportChanged||(0,R.syntaxTree)(e.startState)!==(0,R.syntaxTree)(e.state))&&(this.decorations=P(e.view))}},{decorations:e=>e.decorations});var U=require("@codemirror/view"),$=U.EditorView.theme({"&":{backgroundColor:"#1e1e2e",color:"#cdd6f4",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#cdd6f4",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#cdd6f4",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#313244 !important"},".ob-h1":{color:"#cba6f7",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#cba6f7",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#cba6f7",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#cba6f7",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#cba6f7",fontWeight:"700"},".ob-h6":{color:"#a6adc8",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#cdd6f4"},".ob-italic":{fontStyle:"italic",color:"#cdd6f4"},".ob-strikethrough":{textDecoration:"line-through",color:"#6c7086"},".ob-code":{color:"#f38ba8",backgroundColor:"#313244",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#89b4fa",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#89b4fa"},".ob-syntax":{color:"#45475a",opacity:"0.7"},".ob-blockquote":{borderLeft:"3px solid #585b70",paddingLeft:"16px",color:"#9399b2",fontStyle:"italic"},".ob-blockquote-mark":{color:"#45475a"},".ob-list-mark":{color:"#89b4fa",fontWeight:"600"},".ob-hr":{color:"#45475a",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#181825",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#cdd6f4"},".ob-fence-mark":{color:"#45475a"},".ob-code-info":{color:"#a6e3a1",fontSize:"0.8em"},".ob-image":{color:"#f9e2af"}},{dark:!0});var A=require("@codemirror/view"),J=A.EditorView.theme({"&":{backgroundColor:"#fafafa",color:"#1a1a1a",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#1a1a1a",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#1a1a1a",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#e5e7eb !important"},".ob-h1":{color:"#7c3aed",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#7c3aed",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#7c3aed",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#7c3aed",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#7c3aed",fontWeight:"700"},".ob-h6":{color:"#9333ea",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#1a1a1a"},".ob-italic":{fontStyle:"italic",color:"#1a1a1a"},".ob-strikethrough":{textDecoration:"line-through",color:"#9ca3af"},".ob-code":{color:"#dc2626",backgroundColor:"#f3f4f6",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#2563eb",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#2563eb"},".ob-syntax":{color:"#d1d5db",opacity:"0.9"},".ob-blockquote":{borderLeft:"3px solid #d1d5db",paddingLeft:"16px",color:"#6b7280",fontStyle:"italic"},".ob-blockquote-mark":{color:"#d1d5db"},".ob-list-mark":{color:"#2563eb",fontWeight:"600"},".ob-hr":{color:"#d1d5db",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#f3f4f6",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#1a1a1a"},".ob-fence-mark":{color:"#d1d5db"},".ob-code-info":{color:"#16a34a",fontSize:"0.8em"},".ob-image":{color:"#d97706"}},{dark:!1});var T=new O.Compartment;function F(e){return e==="dark"?$:J}function Q(e,t){return[...t?[(0,m.placeholder)(t)]:[],(0,L.markdown)({base:L.markdownLanguage}),(0,C.history)(),m.keymap.of([...C.defaultKeymap,...C.historyKeymap,C.indentWithTab]),m.EditorView.lineWrapping,m.EditorView.contentAttributes.of({spellcheck:"true"}),(0,m.drawSelection)(),(0,m.dropCursor)(),(0,m.rectangularSelection)(),(0,m.crosshairCursor)(),N,T.of(F(e))]}var v=q(require("react"));var W=require("@codemirror/state");function B(e,t,n,o){let{state:c}=e,l=c.changeByRange(a=>{let i=c.sliceDoc(a.from,a.to)||o;return{changes:{from:a.from,to:a.to,insert:t+i+n},range:W.EditorSelection.range(a.from+t.length,a.from+t.length+i.length)}});e.dispatch(c.update(l,{scrollIntoView:!0})),e.focus()}var K=e=>B(e,"**","**","bold text"),X=e=>B(e,"*","*","italic text"),j=e=>B(e,"`","`","code"),G=e=>{let{state:t}=e,n=t.changeByRange(o=>{let c=t.sliceDoc(o.from,o.to)||"text",l=`[${c}](url)`,a=o.from+1+c.length+2;return{changes:{from:o.from,to:o.to,insert:l},range:W.EditorSelection.range(a,a+3)}});e.dispatch(t.update(n,{scrollIntoView:!0})),e.focus()};function H(e,t){let{state:n}=e,o=[],c=new Set;for(let l of n.selection.ranges){let a=n.doc.lineAt(l.from).number,r=n.doc.lineAt(l.to).number,i=0;for(let d=a;d<=r;d++)c.has(d)||(c.add(d),o.push({from:n.doc.line(d).from,insert:t(i)}),i++)}e.dispatch(n.update({changes:o,scrollIntoView:!0})),e.focus()}var Y=e=>H(e,()=>"- "),Z=e=>H(e,t=>`${t+1}. `),_=e=>H(e,()=>"> ");function ee(e,t,n){let{state:o}=e,c=o.selection.main.head,l=``;e.dispatch(o.update({changes:{from:c,insert:l},selection:{anchor:c+l.length},scrollIntoView:!0})),e.focus()}var f=require("react/jsx-runtime"),fe={bold:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z",italic:"M19 5h-6M11 19H5M15 5L9 19",link:"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1",bullet:"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01",numbered:"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2",quote:"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4",code:"M8 6l-6 6 6 6M16 6l6 6-6 6",image:"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"};function me({name:e}){return(0,f.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.jsx)("path",{d:fe[e]})})}var oe=({getView:e,theme:t,onImageUpload:n})=>{let o=v.useRef(null),[c,l]=v.useState(!1),a=t==="dark"?{bg:"#181825",border:"#313244",fg:"#cdd6f4",hover:"#313244"}:{bg:"#f3f4f6",border:"#d1d5db",fg:"#1a1a1a",hover:"#e5e7eb"},r=x=>()=>{let u=e();u&&x(u)},i=async x=>{let u=x.target.files?.[0];x.target.value="";let p=e();if(!(!u||!n||!p)){l(!0);try{let g=await n(u);ee(p,g,u.name)}catch(g){console.error("react-inline-markdown-editor: image upload failed",g)}finally{l(!1)}}},d={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",padding:0,border:"none",borderRadius:"5px",background:"transparent",color:a.fg,cursor:"pointer"},s=({name:x,title:u,onClick:p,disabled:g})=>(0,f.jsx)("button",{type:"button",title:u,onMouseDown:y=>y.preventDefault(),onClick:p,disabled:g,style:{...d,opacity:g?.5:1},onMouseEnter:y=>{y.currentTarget.style.background=a.hover},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:(0,f.jsx)(me,{name:x})});return(0,f.jsxs)("div",{style:{display:"flex",gap:"2px",flexWrap:"wrap",padding:"5px 8px",background:a.bg,borderBottom:`1px solid ${a.border}`},children:[(0,f.jsx)(s,{name:"bold",title:"Bold",onClick:r(K)}),(0,f.jsx)(s,{name:"italic",title:"Italic",onClick:r(X)}),(0,f.jsx)(s,{name:"link",title:"Link",onClick:r(G)}),(0,f.jsx)(s,{name:"bullet",title:"Bullet list",onClick:r(Y)}),(0,f.jsx)(s,{name:"numbered",title:"Numbered list",onClick:r(Z)}),(0,f.jsx)(s,{name:"quote",title:"Quote",onClick:r(_)}),(0,f.jsx)(s,{name:"code",title:"Inline code",onClick:r(j)}),n&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(s,{name:"image",title:"Upload image",disabled:c,onClick:()=>o.current?.click()}),(0,f.jsx)("input",{ref:o,type:"file",accept:"image/*",onChange:i,style:{display:"none"}})]})]})};var w=require("react/jsx-runtime"),re=({value:e,onChange:t,theme:n="dark",toolbar:o=!1,onImageUpload:c,placeholder:l,className:a,style:r,height:i="100%"})=>{let d=k.useRef(null),s=k.useRef(null),x=k.useRef(t);k.useLayoutEffect(()=>{x.current=t});let u=k.useRef(!1);return k.useEffect(()=>{if(!d.current)return;let p=D.EditorView.updateListener.of(y=>{y.docChanged&&(u.current=!0,x.current(y.state.doc.toString()))}),g=new D.EditorView({state:te.EditorState.create({doc:e,extensions:[...Q(n,l),p]}),parent:d.current});return s.current=g,()=>{g.destroy(),s.current=null}},[]),k.useEffect(()=>{let p=s.current;if(!p)return;if(u.current){u.current=!1;return}let g=p.state.doc.toString();g!==e&&p.dispatch({changes:{from:0,to:g.length,insert:e},annotations:[]})},[e]),k.useEffect(()=>{let p=s.current;p&&p.dispatch({effects:T.reconfigure(F(n))})},[n]),(0,w.jsxs)("div",{className:a,style:r,children:[o&&(0,w.jsx)(oe,{getView:()=>s.current,theme:n,onImageUpload:c}),(0,w.jsx)("div",{ref:d,style:{height:i}})]})};0&&(module.exports={InlineMarkdownEditor});
|
|
2
|
+
"use strict";var ie=Object.create;var M=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var de=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of ce(t))!se.call(e,c)&&c!==r&&M(e,c,{get:()=>t[c],enumerable:!(o=ae(t,c))||o.enumerable});return e};var P=(e,t,r)=>(r=e!=null?ie(le(e)):{},q(t||!e||!e.__esModule?M(r,"default",{value:e,enumerable:!0}):r,e)),fe=e=>q(M({},"__esModule",{value:!0}),e);var ue={};de(ue,{InlineMarkdownEditor:()=>re});module.exports=fe(ue);var h=P(require("react")),z=require("@codemirror/view"),I=require("@codemirror/state");var L=require("@codemirror/lang-markdown"),C=require("@codemirror/commands"),p=require("@codemirror/view"),Q=require("@codemirror/state");var g=require("@codemirror/view"),R=require("@codemirror/language"),E=g.Decoration.replace({}),V=class extends g.WidgetType{toDOM(){let t=document.createElement("span");return t.textContent="\u2022",t.className="ob-list-mark",t}eq(){return!0}},T=class extends g.WidgetType{constructor(r,o){super();this.url=r;this.alt=o}eq(r){return r.url===this.url&&r.alt===this.alt}toDOM(){let r=document.createElement("img");return r.src=this.url,r.alt=this.alt,r.className="ob-image-embed",r.style.maxWidth="100%",r.style.maxHeight="320px",r.style.minHeight="20px",r.style.borderRadius="6px",r.style.display="block",r.onerror=()=>{let o=document.createElement("span");o.className="ob-image",o.textContent=this.alt||this.url,r.replaceWith(o)},r}};function u(e,t,r){for(let o of e.selection.ranges)if(o.from>=t&&o.to<=r||o.from<=r&&o.to>=t)return!0;return!1}function S(e,t){let r=e.doc.lineAt(t);for(let o of e.selection.ranges)if(o.from>=r.from&&o.from<=r.to)return!0;return!1}function N(e){let{state:t}=e,r=[],o=(l,a,n)=>{l<a&&r.push({from:l,to:a,deco:n})},c=l=>g.Decoration.mark({class:l});return(0,R.syntaxTree)(t).cursor().iterate(l=>{let{name:a,from:n,to:i}=l;if(/^ATXHeading[1-6]$/.test(a)){let d=a.slice(-1);o(n,i,c(`ob-h${d}`))}if(a==="HeaderMark"&&(S(t,n)?o(n,i,c("ob-syntax")):o(n,i,E)),a==="StrongEmphasis"&&(u(t,n,i)||o(n,i,c("ob-bold"))),a==="Emphasis"&&(u(t,n,i)||o(n,i,c("ob-italic"))),a==="EmphasisMark"){let d=l.node.parent?.from??n,s=l.node.parent?.to??i;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="Strikethrough"&&(u(t,n,i)||o(n,i,c("ob-strikethrough"))),a==="StrikethroughMark"){let d=l.node.parent?.from??n,s=l.node.parent?.to??i;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="InlineCode"&&(u(t,n,i)||o(n,i,c("ob-code"))),a==="CodeMark"&&l.node.parent?.name==="InlineCode"){let d=l.node.parent.from,s=l.node.parent.to;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="Link"&&(u(t,n,i)||o(n,i,c("ob-link"))),a==="LinkMark"&&l.node.parent?.name==="Link"){let d=l.node.parent.from,s=l.node.parent.to;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="URL"&&l.node.parent?.name==="Link"){let d=l.node.parent.from,s=l.node.parent.to;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="Image"){if(!S(t,n)){let s=t.doc.sliceString(n,i).match(/^!\[([^\]]*)\]\(([^)\s]+)/);if(s)return o(n,i,g.Decoration.replace({widget:new T(s[2],s[1])})),!1}o(n,i,c("ob-image"))}if(a==="LinkMark"&&l.node.parent?.name==="Image"){let d=l.node.parent.from,s=l.node.parent.to;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="URL"&&l.node.parent?.name==="Image"){let d=l.node.parent.from,s=l.node.parent.to;u(t,d,s)?o(n,i,c("ob-syntax")):o(n,i,E)}if(a==="Blockquote"&&o(n,i,c("ob-blockquote")),a==="BlockquoteMark"&&(S(t,n),o(n,i,c("ob-blockquote-mark"))),a==="ListMark"){let d=t.doc.sliceString(n,i);(d==="-"||d==="*"||d==="+")&&!S(t,n)?o(n,i,g.Decoration.replace({widget:new V})):o(n,i,c("ob-list-mark"))}a==="FencedCode"&&o(n,i,c("ob-code-block")),a==="CodeMark"&&l.node.parent?.name==="FencedCode"&&o(n,i,c("ob-fence-mark")),a==="CodeInfo"&&o(n,i,c("ob-code-info")),a==="HorizontalRule"&&o(n,i,c("ob-hr"))}),g.Decoration.set(r.map(({from:l,to:a,deco:n})=>n.range(l,a)),!0)}var U=g.ViewPlugin.fromClass(class{constructor(e){this.decorations=N(e)}update(e){(e.docChanged||e.selectionSet||e.viewportChanged||(0,R.syntaxTree)(e.startState)!==(0,R.syntaxTree)(e.state))&&(this.decorations=N(e.view))}},{decorations:e=>e.decorations});var $=require("@codemirror/view"),A=$.EditorView.theme({"&":{backgroundColor:"#1e1e2e",color:"#cdd6f4",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#cdd6f4",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#cdd6f4",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#313244 !important"},".ob-h1":{color:"#cba6f7",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#cba6f7",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#cba6f7",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#cba6f7",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#cba6f7",fontWeight:"700"},".ob-h6":{color:"#a6adc8",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#cdd6f4"},".ob-italic":{fontStyle:"italic",color:"#cdd6f4"},".ob-strikethrough":{textDecoration:"line-through",color:"#6c7086"},".ob-code":{color:"#f38ba8",backgroundColor:"#313244",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#89b4fa",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#89b4fa"},".ob-syntax":{color:"#45475a",opacity:"0.7"},".ob-blockquote":{borderLeft:"3px solid #585b70",paddingLeft:"16px",color:"#9399b2",fontStyle:"italic"},".ob-blockquote-mark":{color:"#45475a"},".ob-list-mark":{color:"#89b4fa",fontWeight:"600"},".ob-hr":{color:"#45475a",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#181825",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#cdd6f4"},".ob-fence-mark":{color:"#45475a"},".ob-code-info":{color:"#a6e3a1",fontSize:"0.8em"},".ob-image":{color:"#f9e2af"}},{dark:!0});var J=require("@codemirror/view"),O=J.EditorView.theme({"&":{backgroundColor:"#fafafa",color:"#1a1a1a",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#1a1a1a",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#1a1a1a",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#e5e7eb !important"},".ob-h1":{color:"#7c3aed",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#7c3aed",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#7c3aed",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#7c3aed",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#7c3aed",fontWeight:"700"},".ob-h6":{color:"#9333ea",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#1a1a1a"},".ob-italic":{fontStyle:"italic",color:"#1a1a1a"},".ob-strikethrough":{textDecoration:"line-through",color:"#9ca3af"},".ob-code":{color:"#dc2626",backgroundColor:"#f3f4f6",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#2563eb",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#2563eb"},".ob-syntax":{color:"#d1d5db",opacity:"0.9"},".ob-blockquote":{borderLeft:"3px solid #d1d5db",paddingLeft:"16px",color:"#6b7280",fontStyle:"italic"},".ob-blockquote-mark":{color:"#d1d5db"},".ob-list-mark":{color:"#2563eb",fontWeight:"600"},".ob-hr":{color:"#d1d5db",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#f3f4f6",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#1a1a1a"},".ob-fence-mark":{color:"#d1d5db"},".ob-code-info":{color:"#16a34a",fontSize:"0.8em"},".ob-image":{color:"#d97706"}},{dark:!1});var F=new Q.Compartment;function W(e){return e==="dark"?A:O}function K(e,t){return[...t?[(0,p.placeholder)(t)]:[],(0,L.markdown)({base:L.markdownLanguage}),(0,C.history)(),p.keymap.of([...C.defaultKeymap,...C.historyKeymap,C.indentWithTab]),p.EditorView.lineWrapping,p.EditorView.contentAttributes.of({spellcheck:"true"}),(0,p.drawSelection)(),(0,p.dropCursor)(),(0,p.rectangularSelection)(),(0,p.crosshairCursor)(),U,F.of(W(e))]}var v=P(require("react"));var B=require("@codemirror/state");function H(e,t,r,o){let{state:c}=e,l=c.changeByRange(a=>{let i=c.sliceDoc(a.from,a.to)||o;return{changes:{from:a.from,to:a.to,insert:t+i+r},range:B.EditorSelection.range(a.from+t.length,a.from+t.length+i.length)}});e.dispatch(c.update(l,{scrollIntoView:!0})),e.focus()}var X=e=>H(e,"**","**","bold text"),j=e=>H(e,"*","*","italic text"),G=e=>H(e,"`","`","code"),Y=e=>{let{state:t}=e,r=t.changeByRange(o=>{let c=t.sliceDoc(o.from,o.to)||"text",l=`[${c}](url)`,a=o.from+1+c.length+2;return{changes:{from:o.from,to:o.to,insert:l},range:B.EditorSelection.range(a,a+3)}});e.dispatch(t.update(r,{scrollIntoView:!0})),e.focus()};function D(e,t){let{state:r}=e,o=[],c=new Set;for(let l of r.selection.ranges){let a=r.doc.lineAt(l.from).number,n=r.doc.lineAt(l.to).number,i=0;for(let d=a;d<=n;d++)c.has(d)||(c.add(d),o.push({from:r.doc.line(d).from,insert:t(i)}),i++)}e.dispatch(r.update({changes:o,scrollIntoView:!0})),e.focus()}var Z=e=>D(e,()=>"- "),_=e=>D(e,t=>`${t+1}. `),ee=e=>D(e,()=>"> ");function oe(e,t,r){let{state:o}=e,c=o.selection.main.head,l=``;e.dispatch(o.update({changes:{from:c,insert:l},selection:{anchor:c+l.length},scrollIntoView:!0})),e.focus()}var f=require("react/jsx-runtime"),me={bold:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z",italic:"M19 5h-6M11 19H5M15 5L9 19",link:"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1",bullet:"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01",numbered:"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2",quote:"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4",code:"M8 6l-6 6 6 6M16 6l6 6-6 6",image:"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"};function pe({name:e}){return(0,f.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.jsx)("path",{d:me[e]})})}var te=({getView:e,theme:t,onImageUpload:r})=>{let o=v.useRef(null),[c,l]=v.useState(!1),a=t==="dark"?{bg:"#181825",border:"#313244",fg:"#cdd6f4",hover:"#313244"}:{bg:"#f3f4f6",border:"#d1d5db",fg:"#1a1a1a",hover:"#e5e7eb"},n=k=>()=>{let m=e();m&&k(m)},i=async k=>{let m=k.target.files?.[0];k.target.value="";let b=e();if(!(!m||!r||!b)){l(!0);try{let x=await r(m);oe(b,x,m.name)}catch(x){console.error("react-inline-markdown-editor: image upload failed",x)}finally{l(!1)}}},d={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",padding:0,border:"none",borderRadius:"5px",background:"transparent",color:a.fg,cursor:"pointer"},s=({name:k,title:m,onClick:b,disabled:x})=>(0,f.jsx)("button",{type:"button",title:m,onMouseDown:y=>y.preventDefault(),onClick:b,disabled:x,style:{...d,opacity:x?.5:1},onMouseEnter:y=>{y.currentTarget.style.background=a.hover},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:(0,f.jsx)(pe,{name:k})});return(0,f.jsxs)("div",{style:{display:"flex",gap:"2px",flexWrap:"wrap",padding:"5px 8px",background:a.bg,borderBottom:`1px solid ${a.border}`},children:[(0,f.jsx)(s,{name:"bold",title:"Bold",onClick:n(X)}),(0,f.jsx)(s,{name:"italic",title:"Italic",onClick:n(j)}),(0,f.jsx)(s,{name:"link",title:"Link",onClick:n(Y)}),(0,f.jsx)(s,{name:"bullet",title:"Bullet list",onClick:n(Z)}),(0,f.jsx)(s,{name:"numbered",title:"Numbered list",onClick:n(_)}),(0,f.jsx)(s,{name:"quote",title:"Quote",onClick:n(ee)}),(0,f.jsx)(s,{name:"code",title:"Inline code",onClick:n(G)}),r&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(s,{name:"image",title:"Upload image",disabled:c,onClick:()=>o.current?.click()}),(0,f.jsx)("input",{ref:o,type:"file",accept:"image/*",onChange:i,style:{display:"none"}})]})]})};var w=require("react/jsx-runtime"),ne=I.Annotation.define(),re=({value:e,onChange:t,theme:r="dark",toolbar:o=!1,onImageUpload:c,placeholder:l,className:a,style:n,height:i="100%"})=>{let d=h.useRef(null),s=h.useRef(null),k=h.useRef(t);return h.useLayoutEffect(()=>{k.current=t}),h.useEffect(()=>{if(!d.current)return;let m=z.EditorView.updateListener.of(x=>{x.transactions.some(y=>y.docChanged&&!y.annotation(ne))&&k.current(x.state.doc.toString())}),b=new z.EditorView({state:I.EditorState.create({doc:e,extensions:[...K(r,l),m]}),parent:d.current});return s.current=b,()=>{b.destroy(),s.current=null}},[]),h.useEffect(()=>{let m=s.current;if(!m)return;let b=m.state.doc.toString();b!==e&&m.dispatch({changes:{from:0,to:b.length,insert:e},annotations:ne.of(!0)})},[e]),h.useEffect(()=>{let m=s.current;m&&m.dispatch({effects:F.reconfigure(W(r))})},[r]),(0,w.jsxs)("div",{className:a,style:n,children:[o&&(0,w.jsx)(te,{getView:()=>s.current,theme:r,onImageUpload:c}),(0,w.jsx)("div",{ref:d,style:{height:i}})]})};0&&(module.exports={InlineMarkdownEditor});
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/InlineMarkdownEditor.tsx","../src/editor.ts","../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/Toolbar.tsx","../src/commands.ts"],"sourcesContent":["export { InlineMarkdownEditor } from \"./InlineMarkdownEditor\";\nexport type { InlineMarkdownEditorProps } from \"./InlineMarkdownEditor\";\n","// src/InlineMarkdownEditor.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView, ViewUpdate } from \"@codemirror/view\";\nimport { EditorState } from \"@codemirror/state\";\nimport { buildExtensions, themeCompartment, getThemeExtension } from \"./editor\";\nimport { Toolbar } from \"./Toolbar\";\n\nexport type InlineMarkdownEditorProps = {\n /** Controlled markdown content */\n value: string;\n /** Called on every document change with the full new markdown string */\n onChange: (next: string) => void;\n /** Visual theme. Defaults to \"dark\". */\n theme?: \"dark\" | \"light\";\n /** Render the formatting toolbar above the editor. Defaults to false. */\n toolbar?: boolean;\n /** Upload handler. When provided, the toolbar shows an image button. */\n onImageUpload?: (file: File) => Promise<string>;\n /** Text shown when the document is empty. */\n placeholder?: string;\n /** Class applied to the outer container div */\n className?: string;\n /** Inline styles for the outer container div */\n style?: React.CSSProperties;\n /** Editor height. Defaults to \"100%\". Accepts any CSS length. */\n height?: string;\n};\n\nexport const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps> = ({\n value,\n onChange,\n theme = \"dark\",\n toolbar = false,\n onImageUpload,\n placeholder,\n className,\n style,\n height = \"100%\",\n}) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const viewRef = React.useRef<EditorView | null>(null);\n\n const onChangeRef = React.useRef(onChange);\n React.useLayoutEffect(() => {\n onChangeRef.current = onChange;\n });\n\n const skipNextSync = React.useRef(false);\n\n // Mount the editor once\n React.useEffect(() => {\n if (!containerRef.current) return;\n\n const updateListener = EditorView.updateListener.of(\n (update: ViewUpdate) => {\n if (update.docChanged) {\n skipNextSync.current = true;\n onChangeRef.current(update.state.doc.toString());\n }\n },\n );\n\n const view = new EditorView({\n state: EditorState.create({\n doc: value,\n extensions: [...buildExtensions(theme, placeholder), updateListener],\n }),\n parent: containerRef.current,\n });\n\n viewRef.current = view;\n\n return () => {\n view.destroy();\n viewRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // intentionally empty — mount once\n\n // Sync external value changes into CM6\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n\n if (skipNextSync.current) {\n skipNextSync.current = false;\n return;\n }\n\n const current = view.state.doc.toString();\n if (current !== value) {\n view.dispatch({\n changes: { from: 0, to: current.length, insert: value },\n annotations: [],\n });\n }\n }, [value]);\n\n // Swap theme at runtime via Compartment\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n view.dispatch({\n effects: themeCompartment.reconfigure(getThemeExtension(theme)),\n });\n }, [theme]);\n\n return (\n <div className={className} style={style}>\n {toolbar && (\n <Toolbar\n getView={() => viewRef.current}\n theme={theme}\n onImageUpload={onImageUpload}\n />\n )}\n <div ref={containerRef} style={{ height }} />\n </div>\n );\n};\n","// src/editor.ts\nimport { markdown, markdownLanguage } from \"@codemirror/lang-markdown\";\nimport { history, defaultKeymap, historyKeymap, indentWithTab } from \"@codemirror/commands\";\nimport { EditorView, keymap, drawSelection, dropCursor, rectangularSelection, crosshairCursor, placeholder as placeholderExt } from \"@codemirror/view\";\nimport { EditorState, Extension, Compartment } from \"@codemirror/state\";\nimport { liveMarkdownDecorations } from \"./decorations\";\nimport { darkTheme } from \"./theme-dark\";\nimport { lightTheme } from \"./theme-light\";\n\nexport const themeCompartment = new Compartment();\n\nexport function getThemeExtension(theme: \"dark\" | \"light\"): Extension {\n return theme === \"dark\" ? darkTheme : lightTheme;\n}\n\nexport function buildExtensions(\n theme: \"dark\" | \"light\",\n placeholderText?: string,\n): Extension[] {\n return [\n ...(placeholderText ? [placeholderExt(placeholderText)] : []),\n // Markdown language with GFM extensions\n markdown({ base: markdownLanguage }),\n\n // Undo/redo history\n history(),\n\n // Keyboard shortcuts: standard editing + history shortcuts\n keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),\n\n // Soft line wrapping\n EditorView.lineWrapping,\n\n // Spell check\n EditorView.contentAttributes.of({ spellcheck: \"true\" }),\n\n // Selection and cursor rendering\n drawSelection(),\n dropCursor(),\n\n // Allow rectangular selection with Alt+drag\n rectangularSelection(),\n crosshairCursor(),\n\n // Live-preview syntax decorations\n liveMarkdownDecorations,\n\n // Theme via Compartment (swappable at runtime)\n themeCompartment.of(getThemeExtension(theme)),\n ];\n}\n","// src/decorations.ts\nimport {\n ViewPlugin,\n DecorationSet,\n Decoration,\n ViewUpdate,\n WidgetType,\n EditorView,\n} from \"@codemirror/view\";\nimport { syntaxTree } from \"@codemirror/language\";\nimport { EditorState } from \"@codemirror/state\";\n\n// A widgetless replace decoration collapses the range out of layout entirely —\n// the same mechanism code-folding uses. A display:none widget would instead\n// leave a DOM node whose getBoundingClientRect is all-zeros, which breaks\n// posAtCoords hit-testing and makes vertical cursor motion skip lines.\nconst HIDE = Decoration.replace({});\n\n// Renders a list marker (-, *, +) as a typographic bullet.\nclass BulletWidget extends WidgetType {\n toDOM(): HTMLElement {\n const s = document.createElement(\"span\");\n s.textContent = \"•\";\n s.className = \"ob-list-mark\";\n return s;\n }\n eq(): boolean {\n return true;\n }\n}\n\n// Renders an  image. Falls back to alt text on a load error.\nclass ImageWidget extends WidgetType {\n constructor(\n readonly url: string,\n readonly alt: string,\n ) {\n super();\n }\n eq(other: ImageWidget): boolean {\n return other.url === this.url && other.alt === this.alt;\n }\n toDOM(): HTMLElement {\n const img = document.createElement(\"img\");\n img.src = this.url;\n img.alt = this.alt;\n img.className = \"ob-image-embed\";\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"320px\";\n img.style.minHeight = \"20px\";\n img.style.borderRadius = \"6px\";\n img.style.display = \"block\";\n img.onerror = () => {\n const span = document.createElement(\"span\");\n span.className = \"ob-image\";\n span.textContent = this.alt || this.url;\n img.replaceWith(span);\n };\n return img;\n }\n}\n\ntype DecoEntry = { from: number; to: number; deco: Decoration };\n\nfunction isCursorInRange(state: EditorState, from: number, to: number): boolean {\n for (const range of state.selection.ranges) {\n if (range.from >= from && range.to <= to) return true;\n if (range.from <= to && range.to >= from) return true;\n }\n return false;\n}\n\nfunction isCursorOnLine(state: EditorState, from: number): boolean {\n const line = state.doc.lineAt(from);\n for (const range of state.selection.ranges) {\n if (range.from >= line.from && range.from <= line.to) return true;\n }\n return false;\n}\n\nfunction buildDecorations(view: EditorView): DecorationSet {\n const { state } = view;\n const entries: DecoEntry[] = [];\n\n const add = (from: number, to: number, deco: Decoration) => {\n if (from < to) entries.push({ from, to, deco });\n };\n\n const mark = (cls: string) => Decoration.mark({ class: cls });\n\n syntaxTree(state).cursor().iterate((node) => {\n const { name, from, to } = node;\n\n // ── ATX Headings ──────────────────────────────────────────────────────\n // Level derived from node name: ATXHeading1 → h1, etc.\n if (/^ATXHeading[1-6]$/.test(name)) {\n const level = name.slice(-1); // \"1\"–\"6\"\n add(from, to, mark(`ob-h${level}`));\n }\n\n // HeaderMark = the leading `# ` characters in ATX headings\n if (name === \"HeaderMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide when cursor is elsewhere\n }\n }\n\n // ── Strong emphasis (bold): **text** or __text__ ───────────────────\n if (name === \"StrongEmphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-bold\"));\n }\n }\n\n // ── Emphasis (italic): *text* or _text_ ────────────────────────────\n if (name === \"Emphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-italic\"));\n }\n }\n\n // EmphasisMark = ** / * / __ / _ markers (shared by bold and italic)\n if (name === \"EmphasisMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide\n }\n }\n\n // ── Strikethrough: ~~text~~ (GFM) ─────────────────────────────────\n if (name === \"Strikethrough\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-strikethrough\"));\n }\n }\n if (name === \"StrikethroughMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Inline code: `code` ───────────────────────────────────────────\n if (name === \"InlineCode\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-code\"));\n }\n }\n // CodeMark inside InlineCode = the backtick(s)\n if (name === \"CodeMark\" && node.node.parent?.name === \"InlineCode\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Links: [text](url) ────────────────────────────────────────────\n if (name === \"Link\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-link\"));\n }\n }\n // LinkMark = [ ] ( ) characters in links\n if (name === \"LinkMark\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n // URL inside Link (the url part) — hide when cursor away\n if (name === \"URL\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Images:  ──────────────────────────────────────────\n if (name === \"Image\") {\n // Cursor off the line: replace the whole  with a rendered img.\n // return false so the iterator does not descend into the image's\n // LinkMark/URL children (their decorations would overlap the replace\n // and crash the range set).\n if (!isCursorOnLine(state, from)) {\n const text = state.doc.sliceString(from, to);\n const m = text.match(/^!\\[([^\\]]*)\\]\\(([^)\\s]+)/);\n if (m) {\n add(\n from,\n to,\n Decoration.replace({ widget: new ImageWidget(m[2], m[1]) }),\n );\n return false;\n }\n }\n add(from, to, mark(\"ob-image\"));\n }\n if (name === \"LinkMark\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n if (name === \"URL\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Blockquote ────────────────────────────────────────────────────\n if (name === \"Blockquote\") {\n add(from, to, mark(\"ob-blockquote\"));\n }\n if (name === \"BlockquoteMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-blockquote-mark\"));\n } else {\n add(from, to, mark(\"ob-blockquote-mark\")); // always show `>` but styled\n }\n }\n\n // ── List markers ─────────────────────────────────────────────────\n if (name === \"ListMark\") {\n const markText = state.doc.sliceString(from, to);\n const isBullet =\n markText === \"-\" || markText === \"*\" || markText === \"+\";\n if (isBullet && !isCursorOnLine(state, from)) {\n add(from, to, Decoration.replace({ widget: new BulletWidget() }));\n } else {\n add(from, to, mark(\"ob-list-mark\"));\n }\n }\n\n // ── Fenced code blocks ───────────────────────────────────────────\n if (name === \"FencedCode\") {\n add(from, to, mark(\"ob-code-block\"));\n }\n // CodeMark inside FencedCode = the ``` or ~~~ fence lines\n if (name === \"CodeMark\" && node.node.parent?.name === \"FencedCode\") {\n add(from, to, mark(\"ob-fence-mark\"));\n }\n // CodeInfo = language specifier after opening fence\n if (name === \"CodeInfo\") {\n add(from, to, mark(\"ob-code-info\"));\n }\n\n // ── Horizontal rule ──────────────────────────────────────────────\n if (name === \"HorizontalRule\") {\n add(from, to, mark(\"ob-hr\"));\n }\n });\n\n // Decoration.set sorts by `from` AND `startSide` — RangeSetBuilder cannot,\n // since mark and replace decorations carry different sides at the same offset.\n return Decoration.set(\n entries.map(({ from, to, deco }) => deco.range(from, to)),\n true\n );\n}\n\nexport const liveMarkdownDecorations = ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n // Rebuild on background-parse progress too: syntaxTree() returns a new\n // tree as the parser advances, and the initial mount often only has the\n // first viewport parsed — without this, off-screen lines never decorate.\n if (\n update.docChanged ||\n update.selectionSet ||\n update.viewportChanged ||\n syntaxTree(update.startState) !== syntaxTree(update.state)\n ) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n { decorations: (instance) => instance.decorations }\n);\n","// src/theme-dark.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const darkTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#1e1e2e\",\n color: \"#cdd6f4\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#cdd6f4\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#cdd6f4\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#313244 !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#cba6f7\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": {\n color: \"#cba6f7\",\n fontSize: \"1.5em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h3\": {\n color: \"#cba6f7\",\n fontSize: \"1.25em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h4\": { color: \"#cba6f7\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#cba6f7\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#a6adc8\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#cdd6f4\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#cdd6f4\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#6c7086\" },\n \".ob-code\": {\n color: \"#f38ba8\",\n backgroundColor: \"#313244\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#89b4fa\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#89b4fa\" },\n // Syntax markers (shown dimmed when cursor is active in the span)\n \".ob-syntax\": { color: \"#45475a\", opacity: \"0.7\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #585b70\",\n paddingLeft: \"16px\",\n color: \"#9399b2\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#45475a\" },\n // List markers\n \".ob-list-mark\": { color: \"#89b4fa\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#45475a\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#181825\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#cdd6f4\",\n },\n \".ob-fence-mark\": { color: \"#45475a\" },\n \".ob-code-info\": { color: \"#a6e3a1\", fontSize: \"0.8em\" },\n // Image alt text\n \".ob-image\": { color: \"#f9e2af\" },\n },\n { dark: true }\n);\n","// src/theme-light.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const lightTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#fafafa\",\n color: \"#1a1a1a\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#1a1a1a\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#1a1a1a\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#e5e7eb !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#7c3aed\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": { color: \"#7c3aed\", fontSize: \"1.5em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h3\": { color: \"#7c3aed\", fontSize: \"1.25em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h4\": { color: \"#7c3aed\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#7c3aed\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#9333ea\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#1a1a1a\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#1a1a1a\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#9ca3af\" },\n \".ob-code\": {\n color: \"#dc2626\",\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#2563eb\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#2563eb\" },\n // Syntax markers (dimmed when cursor is in span)\n \".ob-syntax\": { color: \"#d1d5db\", opacity: \"0.9\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #d1d5db\",\n paddingLeft: \"16px\",\n color: \"#6b7280\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#d1d5db\" },\n // List markers\n \".ob-list-mark\": { color: \"#2563eb\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#d1d5db\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#1a1a1a\",\n },\n \".ob-fence-mark\": { color: \"#d1d5db\" },\n \".ob-code-info\": { color: \"#16a34a\", fontSize: \"0.8em\" },\n // Image\n \".ob-image\": { color: \"#d97706\" },\n },\n { dark: false }\n);\n","// src/Toolbar.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView } from \"@codemirror/view\";\nimport {\n toggleBold,\n toggleItalic,\n toggleInlineCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n insertImageMarkdown,\n} from \"./commands\";\n\nexport type ToolbarProps = {\n /** Returns the live EditorView, or null before mount. */\n getView: () => EditorView | null;\n theme: \"dark\" | \"light\";\n onImageUpload?: (file: File) => Promise<string>;\n};\n\n// 24x24 stroke icons.\nconst ICONS: Record<string, string> = {\n bold: \"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z\",\n italic: \"M19 5h-6M11 19H5M15 5L9 19\",\n link: \"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1\",\n bullet: \"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01\",\n numbered: \"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2\",\n quote: \"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4\",\n code: \"M8 6l-6 6 6 6M16 6l6 6-6 6\",\n image:\n \"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0\",\n};\n\nfunction Icon({ name }: { name: string }): React.ReactElement {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ICONS[name]} />\n </svg>\n );\n}\n\nexport const Toolbar: React.FC<ToolbarProps> = ({\n getView,\n theme,\n onImageUpload,\n}) => {\n const fileRef = React.useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = React.useState(false);\n\n const palette =\n theme === \"dark\"\n ? { bg: \"#181825\", border: \"#313244\", fg: \"#cdd6f4\", hover: \"#313244\" }\n : { bg: \"#f3f4f6\", border: \"#d1d5db\", fg: \"#1a1a1a\", hover: \"#e5e7eb\" };\n\n const run = (cmd: (v: EditorView) => void) => () => {\n const v = getView();\n if (v) cmd(v);\n };\n\n const handleFile = async (\n e: React.ChangeEvent<HTMLInputElement>,\n ): Promise<void> => {\n const file = e.target.files?.[0];\n e.target.value = \"\";\n const v = getView();\n if (!file || !onImageUpload || !v) return;\n setUploading(true);\n try {\n const url = await onImageUpload(file);\n insertImageMarkdown(v, url, file.name);\n } catch (err) {\n console.error(\"react-inline-markdown-editor: image upload failed\", err);\n } finally {\n setUploading(false);\n }\n };\n\n const btnStyle: React.CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"30px\",\n height: \"30px\",\n padding: 0,\n border: \"none\",\n borderRadius: \"5px\",\n background: \"transparent\",\n color: palette.fg,\n cursor: \"pointer\",\n };\n\n const Button = ({\n name,\n title,\n onClick,\n disabled,\n }: {\n name: string;\n title: string;\n onClick: () => void;\n disabled?: boolean;\n }): React.ReactElement => (\n <button\n type=\"button\"\n title={title}\n onMouseDown={(e) => e.preventDefault()}\n onClick={onClick}\n disabled={disabled}\n style={{ ...btnStyle, opacity: disabled ? 0.5 : 1 }}\n onMouseEnter={(e) => {\n e.currentTarget.style.background = palette.hover;\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n <Icon name={name} />\n </button>\n );\n\n return (\n <div\n style={{\n display: \"flex\",\n gap: \"2px\",\n flexWrap: \"wrap\",\n padding: \"5px 8px\",\n background: palette.bg,\n borderBottom: `1px solid ${palette.border}`,\n }}\n >\n <Button name=\"bold\" title=\"Bold\" onClick={run(toggleBold)} />\n <Button name=\"italic\" title=\"Italic\" onClick={run(toggleItalic)} />\n <Button name=\"link\" title=\"Link\" onClick={run(insertLink)} />\n <Button\n name=\"bullet\"\n title=\"Bullet list\"\n onClick={run(toggleBulletList)}\n />\n <Button\n name=\"numbered\"\n title=\"Numbered list\"\n onClick={run(toggleNumberedList)}\n />\n <Button name=\"quote\" title=\"Quote\" onClick={run(toggleQuote)} />\n <Button name=\"code\" title=\"Inline code\" onClick={run(toggleInlineCode)} />\n {onImageUpload && (\n <>\n <Button\n name=\"image\"\n title=\"Upload image\"\n disabled={uploading}\n onClick={() => fileRef.current?.click()}\n />\n <input\n ref={fileRef}\n type=\"file\"\n accept=\"image/*\"\n onChange={handleFile}\n style={{ display: \"none\" }}\n />\n </>\n )}\n </div>\n );\n};\n","// src/commands.ts\n// Markdown text transforms. Each takes the EditorView and dispatches a\n// transaction. No React, no DOM beyond CodeMirror.\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorSelection } from \"@codemirror/state\";\n\n// Wrap each selection range in before/after. With an empty selection,\n// insert the placeholder and select it.\nfunction wrap(\n view: EditorView,\n before: string,\n after: string,\n placeholder: string,\n): void {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to);\n const text = selected || placeholder;\n return {\n changes: {\n from: range.from,\n to: range.to,\n insert: before + text + after,\n },\n range: EditorSelection.range(\n range.from + before.length,\n range.from + before.length + text.length,\n ),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBold = (view: EditorView): void =>\n wrap(view, \"**\", \"**\", \"bold text\");\n\nexport const toggleItalic = (view: EditorView): void =>\n wrap(view, \"*\", \"*\", \"italic text\");\n\nexport const toggleInlineCode = (view: EditorView): void =>\n wrap(view, \"`\", \"`\", \"code\");\n\n// Insert [text](url); leaves \"url\" selected so it can be typed over.\nexport const insertLink = (view: EditorView): void => {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to) || \"text\";\n const insert = `[${selected}](url)`;\n const urlStart = range.from + 1 + selected.length + 2;\n return {\n changes: { from: range.from, to: range.to, insert },\n range: EditorSelection.range(urlStart, urlStart + 3),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n};\n\n// Prefix every line touched by the selection. prefix(i) is called with the\n// zero-based index of the line within the run.\nfunction prefixLines(view: EditorView, prefix: (i: number) => string): void {\n const { state } = view;\n const changes: { from: number; insert: string }[] = [];\n const seen = new Set<number>();\n for (const range of state.selection.ranges) {\n const startLine = state.doc.lineAt(range.from).number;\n const endLine = state.doc.lineAt(range.to).number;\n let i = 0;\n for (let ln = startLine; ln <= endLine; ln++) {\n if (seen.has(ln)) continue;\n seen.add(ln);\n changes.push({ from: state.doc.line(ln).from, insert: prefix(i) });\n i++;\n }\n }\n view.dispatch(state.update({ changes, scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBulletList = (view: EditorView): void =>\n prefixLines(view, () => \"- \");\n\nexport const toggleNumberedList = (view: EditorView): void =>\n prefixLines(view, (i) => `${i + 1}. `);\n\nexport const toggleQuote = (view: EditorView): void =>\n prefixLines(view, () => \"> \");\n\n// Insert  at the primary cursor.\nexport function insertImageMarkdown(\n view: EditorView,\n url: string,\n alt: string,\n): void {\n const { state } = view;\n const pos = state.selection.main.head;\n const insert = ``;\n view.dispatch(\n state.update({\n changes: { from: pos, insert },\n selection: { anchor: pos + insert.length },\n scrollIntoView: true,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AC,EAEnD,CACF,EAEMC,EAAO,IAAI,aAAW,CAC1B,MAAO,eAAY,OAAO,CACxB,IAAKf,EACL,WAAY,CAAC,GAAGgB,EAAgBd,EAAOG,CAAW,EAAGQ,CAAc,CACrE,CAAC,EACD,OAAQJ,EAAa,OACvB,CAAC,EAED,OAAAC,EAAQ,QAAUK,EAEX,IAAM,CACXA,EAAK,QAAQ,EACbL,EAAQ,QAAU,IACpB,CAEF,EAAG,CAAC,CAAC,EAGC,YAAU,IAAM,CACpB,IAAMK,EAAOL,EAAQ,QACrB,GAAI,CAACK,EAAM,OAEX,GAAIH,EAAa,QAAS,CACxBA,EAAa,QAAU,GACvB,MACF,CAEA,IAAMK,EAAUF,EAAK,MAAM,IAAI,SAAS,EACpCE,IAAYjB,GACde,EAAK,SAAS,CACZ,QAAS,CAAE,KAAM,EAAG,GAAIE,EAAQ,OAAQ,OAAQjB,CAAM,EACtD,YAAa,CAAC,CAChB,CAAC,CAEL,EAAG,CAACA,CAAK,CAAC,EAGJ,YAAU,IAAM,CACpB,IAAMe,EAAOL,EAAQ,QAChBK,GACLA,EAAK,SAAS,CACZ,QAASG,EAAiB,YAAYC,EAAkBjB,CAAK,CAAC,CAChE,CAAC,CACH,EAAG,CAACA,CAAK,CAAC,KAGR,QAAC,OAAI,UAAWI,EAAW,MAAOC,EAC/B,UAAAJ,MACC,OAACiB,GAAA,CACC,QAAS,IAAMV,EAAQ,QACvB,MAAOR,EACP,cAAeE,EACjB,KAEF,OAAC,OAAI,IAAKK,EAAc,MAAO,CAAE,OAAAD,CAAO,EAAG,GAC7C,CAEJ","names":["index_exports","__export","InlineMarkdownEditor","__toCommonJS","React","import_view","import_state","import_lang_markdown","import_commands","import_view","import_state","import_view","import_language","HIDE","BulletWidget","s","ImageWidget","url","alt","other","img","span","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","node","name","level","parentFrom","parentTo","m","markText","liveMarkdownDecorations","update","instance","import_view","darkTheme","import_view","lightTheme","themeCompartment","getThemeExtension","theme","darkTheme","lightTheme","buildExtensions","placeholderText","placeholderExt","liveMarkdownDecorations","React","import_state","wrap","view","before","after","placeholder","state","tr","range","text","toggleBold","toggleItalic","toggleInlineCode","insertLink","selected","insert","urlStart","prefixLines","prefix","changes","seen","startLine","endLine","ln","toggleBulletList","toggleNumberedList","i","toggleQuote","insertImageMarkdown","url","alt","pos","import_jsx_runtime","ICONS","Icon","name","Toolbar","getView","theme","onImageUpload","fileRef","uploading","setUploading","palette","run","cmd","v","handleFile","e","file","url","insertImageMarkdown","err","btnStyle","Button","title","onClick","disabled","toggleBold","toggleItalic","insertLink","toggleBulletList","toggleNumberedList","toggleQuote","toggleInlineCode","import_jsx_runtime","InlineMarkdownEditor","value","onChange","theme","toolbar","onImageUpload","placeholder","className","style","height","containerRef","viewRef","onChangeRef","skipNextSync","updateListener","update","view","buildExtensions","current","themeCompartment","getThemeExtension","Toolbar"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/InlineMarkdownEditor.tsx","../src/editor.ts","../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/Toolbar.tsx","../src/commands.ts"],"sourcesContent":["export { InlineMarkdownEditor } from \"./InlineMarkdownEditor\";\nexport type { InlineMarkdownEditorProps } from \"./InlineMarkdownEditor\";\n","// src/InlineMarkdownEditor.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView, ViewUpdate } from \"@codemirror/view\";\nimport { Annotation, EditorState } from \"@codemirror/state\";\nimport { buildExtensions, themeCompartment, getThemeExtension } from \"./editor\";\nimport { Toolbar } from \"./Toolbar\";\n\nconst externalValue = Annotation.define<boolean>();\n\nexport type InlineMarkdownEditorProps = {\n /** Controlled markdown content */\n value: string;\n /** Called on every document change with the full new markdown string */\n onChange: (next: string) => void;\n /** Visual theme. Defaults to \"dark\". */\n theme?: \"dark\" | \"light\";\n /** Render the formatting toolbar above the editor. Defaults to false. */\n toolbar?: boolean;\n /** Upload handler. When provided, the toolbar shows an image button. */\n onImageUpload?: (file: File) => Promise<string>;\n /** Text shown when the document is empty. */\n placeholder?: string;\n /** Class applied to the outer container div */\n className?: string;\n /** Inline styles for the outer container div */\n style?: React.CSSProperties;\n /** Editor height. Defaults to \"100%\". Accepts any CSS length. */\n height?: string;\n};\n\nexport const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps> = ({\n value,\n onChange,\n theme = \"dark\",\n toolbar = false,\n onImageUpload,\n placeholder,\n className,\n style,\n height = \"100%\",\n}) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const viewRef = React.useRef<EditorView | null>(null);\n\n const onChangeRef = React.useRef(onChange);\n React.useLayoutEffect(() => {\n onChangeRef.current = onChange;\n });\n\n // Mount the editor once\n React.useEffect(() => {\n if (!containerRef.current) return;\n\n const updateListener = EditorView.updateListener.of(\n (update: ViewUpdate) => {\n if (update.transactions.some(tr => tr.docChanged && !tr.annotation(externalValue))) {\n onChangeRef.current(update.state.doc.toString());\n }\n },\n );\n\n const view = new EditorView({\n state: EditorState.create({\n doc: value,\n extensions: [...buildExtensions(theme, placeholder), updateListener],\n }),\n parent: containerRef.current,\n });\n\n viewRef.current = view;\n\n return () => {\n view.destroy();\n viewRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // intentionally empty — mount once\n\n // Sync external value changes into CM6\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n\n const current = view.state.doc.toString();\n if (current !== value) {\n view.dispatch({\n changes: { from: 0, to: current.length, insert: value },\n annotations: externalValue.of(true),\n });\n }\n }, [value]);\n\n // Swap theme at runtime via Compartment\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n view.dispatch({\n effects: themeCompartment.reconfigure(getThemeExtension(theme)),\n });\n }, [theme]);\n\n return (\n <div className={className} style={style}>\n {toolbar && (\n <Toolbar\n getView={() => viewRef.current}\n theme={theme}\n onImageUpload={onImageUpload}\n />\n )}\n <div ref={containerRef} style={{ height }} />\n </div>\n );\n};\n","// src/editor.ts\nimport { markdown, markdownLanguage } from \"@codemirror/lang-markdown\";\nimport { history, defaultKeymap, historyKeymap, indentWithTab } from \"@codemirror/commands\";\nimport { EditorView, keymap, drawSelection, dropCursor, rectangularSelection, crosshairCursor, placeholder as placeholderExt } from \"@codemirror/view\";\nimport { EditorState, Extension, Compartment } from \"@codemirror/state\";\nimport { liveMarkdownDecorations } from \"./decorations\";\nimport { darkTheme } from \"./theme-dark\";\nimport { lightTheme } from \"./theme-light\";\n\nexport const themeCompartment = new Compartment();\n\nexport function getThemeExtension(theme: \"dark\" | \"light\"): Extension {\n return theme === \"dark\" ? darkTheme : lightTheme;\n}\n\nexport function buildExtensions(\n theme: \"dark\" | \"light\",\n placeholderText?: string,\n): Extension[] {\n return [\n ...(placeholderText ? [placeholderExt(placeholderText)] : []),\n // Markdown language with GFM extensions\n markdown({ base: markdownLanguage }),\n\n // Undo/redo history\n history(),\n\n // Keyboard shortcuts: standard editing + history shortcuts\n keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),\n\n // Soft line wrapping\n EditorView.lineWrapping,\n\n // Spell check\n EditorView.contentAttributes.of({ spellcheck: \"true\" }),\n\n // Selection and cursor rendering\n drawSelection(),\n dropCursor(),\n\n // Allow rectangular selection with Alt+drag\n rectangularSelection(),\n crosshairCursor(),\n\n // Live-preview syntax decorations\n liveMarkdownDecorations,\n\n // Theme via Compartment (swappable at runtime)\n themeCompartment.of(getThemeExtension(theme)),\n ];\n}\n","// src/decorations.ts\nimport {\n ViewPlugin,\n DecorationSet,\n Decoration,\n ViewUpdate,\n WidgetType,\n EditorView,\n} from \"@codemirror/view\";\nimport { syntaxTree } from \"@codemirror/language\";\nimport { EditorState } from \"@codemirror/state\";\n\n// A widgetless replace decoration collapses the range out of layout entirely —\n// the same mechanism code-folding uses. A display:none widget would instead\n// leave a DOM node whose getBoundingClientRect is all-zeros, which breaks\n// posAtCoords hit-testing and makes vertical cursor motion skip lines.\nconst HIDE = Decoration.replace({});\n\n// Renders a list marker (-, *, +) as a typographic bullet.\nclass BulletWidget extends WidgetType {\n toDOM(): HTMLElement {\n const s = document.createElement(\"span\");\n s.textContent = \"•\";\n s.className = \"ob-list-mark\";\n return s;\n }\n eq(): boolean {\n return true;\n }\n}\n\n// Renders an  image. Falls back to alt text on a load error.\nclass ImageWidget extends WidgetType {\n constructor(\n readonly url: string,\n readonly alt: string,\n ) {\n super();\n }\n eq(other: ImageWidget): boolean {\n return other.url === this.url && other.alt === this.alt;\n }\n toDOM(): HTMLElement {\n const img = document.createElement(\"img\");\n img.src = this.url;\n img.alt = this.alt;\n img.className = \"ob-image-embed\";\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"320px\";\n img.style.minHeight = \"20px\";\n img.style.borderRadius = \"6px\";\n img.style.display = \"block\";\n img.onerror = () => {\n const span = document.createElement(\"span\");\n span.className = \"ob-image\";\n span.textContent = this.alt || this.url;\n img.replaceWith(span);\n };\n return img;\n }\n}\n\ntype DecoEntry = { from: number; to: number; deco: Decoration };\n\nfunction isCursorInRange(state: EditorState, from: number, to: number): boolean {\n for (const range of state.selection.ranges) {\n if (range.from >= from && range.to <= to) return true;\n if (range.from <= to && range.to >= from) return true;\n }\n return false;\n}\n\nfunction isCursorOnLine(state: EditorState, from: number): boolean {\n const line = state.doc.lineAt(from);\n for (const range of state.selection.ranges) {\n if (range.from >= line.from && range.from <= line.to) return true;\n }\n return false;\n}\n\nfunction buildDecorations(view: EditorView): DecorationSet {\n const { state } = view;\n const entries: DecoEntry[] = [];\n\n const add = (from: number, to: number, deco: Decoration) => {\n if (from < to) entries.push({ from, to, deco });\n };\n\n const mark = (cls: string) => Decoration.mark({ class: cls });\n\n syntaxTree(state).cursor().iterate((node) => {\n const { name, from, to } = node;\n\n // ── ATX Headings ──────────────────────────────────────────────────────\n // Level derived from node name: ATXHeading1 → h1, etc.\n if (/^ATXHeading[1-6]$/.test(name)) {\n const level = name.slice(-1); // \"1\"–\"6\"\n add(from, to, mark(`ob-h${level}`));\n }\n\n // HeaderMark = the leading `# ` characters in ATX headings\n if (name === \"HeaderMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide when cursor is elsewhere\n }\n }\n\n // ── Strong emphasis (bold): **text** or __text__ ───────────────────\n if (name === \"StrongEmphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-bold\"));\n }\n }\n\n // ── Emphasis (italic): *text* or _text_ ────────────────────────────\n if (name === \"Emphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-italic\"));\n }\n }\n\n // EmphasisMark = ** / * / __ / _ markers (shared by bold and italic)\n if (name === \"EmphasisMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide\n }\n }\n\n // ── Strikethrough: ~~text~~ (GFM) ─────────────────────────────────\n if (name === \"Strikethrough\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-strikethrough\"));\n }\n }\n if (name === \"StrikethroughMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Inline code: `code` ───────────────────────────────────────────\n if (name === \"InlineCode\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-code\"));\n }\n }\n // CodeMark inside InlineCode = the backtick(s)\n if (name === \"CodeMark\" && node.node.parent?.name === \"InlineCode\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Links: [text](url) ────────────────────────────────────────────\n if (name === \"Link\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-link\"));\n }\n }\n // LinkMark = [ ] ( ) characters in links\n if (name === \"LinkMark\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n // URL inside Link (the url part) — hide when cursor away\n if (name === \"URL\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Images:  ──────────────────────────────────────────\n if (name === \"Image\") {\n // Cursor off the line: replace the whole  with a rendered img.\n // return false so the iterator does not descend into the image's\n // LinkMark/URL children (their decorations would overlap the replace\n // and crash the range set).\n if (!isCursorOnLine(state, from)) {\n const text = state.doc.sliceString(from, to);\n const m = text.match(/^!\\[([^\\]]*)\\]\\(([^)\\s]+)/);\n if (m) {\n add(\n from,\n to,\n Decoration.replace({ widget: new ImageWidget(m[2], m[1]) }),\n );\n return false;\n }\n }\n add(from, to, mark(\"ob-image\"));\n }\n if (name === \"LinkMark\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n if (name === \"URL\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Blockquote ────────────────────────────────────────────────────\n if (name === \"Blockquote\") {\n add(from, to, mark(\"ob-blockquote\"));\n }\n if (name === \"BlockquoteMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-blockquote-mark\"));\n } else {\n add(from, to, mark(\"ob-blockquote-mark\")); // always show `>` but styled\n }\n }\n\n // ── List markers ─────────────────────────────────────────────────\n if (name === \"ListMark\") {\n const markText = state.doc.sliceString(from, to);\n const isBullet =\n markText === \"-\" || markText === \"*\" || markText === \"+\";\n if (isBullet && !isCursorOnLine(state, from)) {\n add(from, to, Decoration.replace({ widget: new BulletWidget() }));\n } else {\n add(from, to, mark(\"ob-list-mark\"));\n }\n }\n\n // ── Fenced code blocks ───────────────────────────────────────────\n if (name === \"FencedCode\") {\n add(from, to, mark(\"ob-code-block\"));\n }\n // CodeMark inside FencedCode = the ``` or ~~~ fence lines\n if (name === \"CodeMark\" && node.node.parent?.name === \"FencedCode\") {\n add(from, to, mark(\"ob-fence-mark\"));\n }\n // CodeInfo = language specifier after opening fence\n if (name === \"CodeInfo\") {\n add(from, to, mark(\"ob-code-info\"));\n }\n\n // ── Horizontal rule ──────────────────────────────────────────────\n if (name === \"HorizontalRule\") {\n add(from, to, mark(\"ob-hr\"));\n }\n });\n\n // Decoration.set sorts by `from` AND `startSide` — RangeSetBuilder cannot,\n // since mark and replace decorations carry different sides at the same offset.\n return Decoration.set(\n entries.map(({ from, to, deco }) => deco.range(from, to)),\n true\n );\n}\n\nexport const liveMarkdownDecorations = ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n // Rebuild on background-parse progress too: syntaxTree() returns a new\n // tree as the parser advances, and the initial mount often only has the\n // first viewport parsed — without this, off-screen lines never decorate.\n if (\n update.docChanged ||\n update.selectionSet ||\n update.viewportChanged ||\n syntaxTree(update.startState) !== syntaxTree(update.state)\n ) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n { decorations: (instance) => instance.decorations }\n);\n","// src/theme-dark.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const darkTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#1e1e2e\",\n color: \"#cdd6f4\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#cdd6f4\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#cdd6f4\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#313244 !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#cba6f7\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": {\n color: \"#cba6f7\",\n fontSize: \"1.5em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h3\": {\n color: \"#cba6f7\",\n fontSize: \"1.25em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h4\": { color: \"#cba6f7\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#cba6f7\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#a6adc8\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#cdd6f4\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#cdd6f4\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#6c7086\" },\n \".ob-code\": {\n color: \"#f38ba8\",\n backgroundColor: \"#313244\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#89b4fa\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#89b4fa\" },\n // Syntax markers (shown dimmed when cursor is active in the span)\n \".ob-syntax\": { color: \"#45475a\", opacity: \"0.7\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #585b70\",\n paddingLeft: \"16px\",\n color: \"#9399b2\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#45475a\" },\n // List markers\n \".ob-list-mark\": { color: \"#89b4fa\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#45475a\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#181825\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#cdd6f4\",\n },\n \".ob-fence-mark\": { color: \"#45475a\" },\n \".ob-code-info\": { color: \"#a6e3a1\", fontSize: \"0.8em\" },\n // Image alt text\n \".ob-image\": { color: \"#f9e2af\" },\n },\n { dark: true }\n);\n","// src/theme-light.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const lightTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#fafafa\",\n color: \"#1a1a1a\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#1a1a1a\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#1a1a1a\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#e5e7eb !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#7c3aed\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": { color: \"#7c3aed\", fontSize: \"1.5em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h3\": { color: \"#7c3aed\", fontSize: \"1.25em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h4\": { color: \"#7c3aed\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#7c3aed\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#9333ea\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#1a1a1a\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#1a1a1a\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#9ca3af\" },\n \".ob-code\": {\n color: \"#dc2626\",\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#2563eb\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#2563eb\" },\n // Syntax markers (dimmed when cursor is in span)\n \".ob-syntax\": { color: \"#d1d5db\", opacity: \"0.9\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #d1d5db\",\n paddingLeft: \"16px\",\n color: \"#6b7280\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#d1d5db\" },\n // List markers\n \".ob-list-mark\": { color: \"#2563eb\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#d1d5db\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#1a1a1a\",\n },\n \".ob-fence-mark\": { color: \"#d1d5db\" },\n \".ob-code-info\": { color: \"#16a34a\", fontSize: \"0.8em\" },\n // Image\n \".ob-image\": { color: \"#d97706\" },\n },\n { dark: false }\n);\n","// src/Toolbar.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView } from \"@codemirror/view\";\nimport {\n toggleBold,\n toggleItalic,\n toggleInlineCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n insertImageMarkdown,\n} from \"./commands\";\n\nexport type ToolbarProps = {\n /** Returns the live EditorView, or null before mount. */\n getView: () => EditorView | null;\n theme: \"dark\" | \"light\";\n onImageUpload?: (file: File) => Promise<string>;\n};\n\n// 24x24 stroke icons.\nconst ICONS: Record<string, string> = {\n bold: \"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z\",\n italic: \"M19 5h-6M11 19H5M15 5L9 19\",\n link: \"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1\",\n bullet: \"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01\",\n numbered: \"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2\",\n quote: \"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4\",\n code: \"M8 6l-6 6 6 6M16 6l6 6-6 6\",\n image:\n \"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0\",\n};\n\nfunction Icon({ name }: { name: string }): React.ReactElement {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ICONS[name]} />\n </svg>\n );\n}\n\nexport const Toolbar: React.FC<ToolbarProps> = ({\n getView,\n theme,\n onImageUpload,\n}) => {\n const fileRef = React.useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = React.useState(false);\n\n const palette =\n theme === \"dark\"\n ? { bg: \"#181825\", border: \"#313244\", fg: \"#cdd6f4\", hover: \"#313244\" }\n : { bg: \"#f3f4f6\", border: \"#d1d5db\", fg: \"#1a1a1a\", hover: \"#e5e7eb\" };\n\n const run = (cmd: (v: EditorView) => void) => () => {\n const v = getView();\n if (v) cmd(v);\n };\n\n const handleFile = async (\n e: React.ChangeEvent<HTMLInputElement>,\n ): Promise<void> => {\n const file = e.target.files?.[0];\n e.target.value = \"\";\n const v = getView();\n if (!file || !onImageUpload || !v) return;\n setUploading(true);\n try {\n const url = await onImageUpload(file);\n insertImageMarkdown(v, url, file.name);\n } catch (err) {\n console.error(\"react-inline-markdown-editor: image upload failed\", err);\n } finally {\n setUploading(false);\n }\n };\n\n const btnStyle: React.CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"30px\",\n height: \"30px\",\n padding: 0,\n border: \"none\",\n borderRadius: \"5px\",\n background: \"transparent\",\n color: palette.fg,\n cursor: \"pointer\",\n };\n\n const Button = ({\n name,\n title,\n onClick,\n disabled,\n }: {\n name: string;\n title: string;\n onClick: () => void;\n disabled?: boolean;\n }): React.ReactElement => (\n <button\n type=\"button\"\n title={title}\n onMouseDown={(e) => e.preventDefault()}\n onClick={onClick}\n disabled={disabled}\n style={{ ...btnStyle, opacity: disabled ? 0.5 : 1 }}\n onMouseEnter={(e) => {\n e.currentTarget.style.background = palette.hover;\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n <Icon name={name} />\n </button>\n );\n\n return (\n <div\n style={{\n display: \"flex\",\n gap: \"2px\",\n flexWrap: \"wrap\",\n padding: \"5px 8px\",\n background: palette.bg,\n borderBottom: `1px solid ${palette.border}`,\n }}\n >\n <Button name=\"bold\" title=\"Bold\" onClick={run(toggleBold)} />\n <Button name=\"italic\" title=\"Italic\" onClick={run(toggleItalic)} />\n <Button name=\"link\" title=\"Link\" onClick={run(insertLink)} />\n <Button\n name=\"bullet\"\n title=\"Bullet list\"\n onClick={run(toggleBulletList)}\n />\n <Button\n name=\"numbered\"\n title=\"Numbered list\"\n onClick={run(toggleNumberedList)}\n />\n <Button name=\"quote\" title=\"Quote\" onClick={run(toggleQuote)} />\n <Button name=\"code\" title=\"Inline code\" onClick={run(toggleInlineCode)} />\n {onImageUpload && (\n <>\n <Button\n name=\"image\"\n title=\"Upload image\"\n disabled={uploading}\n onClick={() => fileRef.current?.click()}\n />\n <input\n ref={fileRef}\n type=\"file\"\n accept=\"image/*\"\n onChange={handleFile}\n style={{ display: \"none\" }}\n />\n </>\n )}\n </div>\n );\n};\n","// src/commands.ts\n// Markdown text transforms. Each takes the EditorView and dispatches a\n// transaction. No React, no DOM beyond CodeMirror.\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorSelection } from \"@codemirror/state\";\n\n// Wrap each selection range in before/after. With an empty selection,\n// insert the placeholder and select it.\nfunction wrap(\n view: EditorView,\n before: string,\n after: string,\n placeholder: string,\n): void {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to);\n const text = selected || placeholder;\n return {\n changes: {\n from: range.from,\n to: range.to,\n insert: before + text + after,\n },\n range: EditorSelection.range(\n range.from + before.length,\n range.from + before.length + text.length,\n ),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBold = (view: EditorView): void =>\n wrap(view, \"**\", \"**\", \"bold text\");\n\nexport const toggleItalic = (view: EditorView): void =>\n wrap(view, \"*\", \"*\", \"italic text\");\n\nexport const toggleInlineCode = (view: EditorView): void =>\n wrap(view, \"`\", \"`\", \"code\");\n\n// Insert [text](url); leaves \"url\" selected so it can be typed over.\nexport const insertLink = (view: EditorView): void => {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to) || \"text\";\n const insert = `[${selected}](url)`;\n const urlStart = range.from + 1 + selected.length + 2;\n return {\n changes: { from: range.from, to: range.to, insert },\n range: EditorSelection.range(urlStart, urlStart + 3),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n};\n\n// Prefix every line touched by the selection. prefix(i) is called with the\n// zero-based index of the line within the run.\nfunction prefixLines(view: EditorView, prefix: (i: number) => string): void {\n const { state } = view;\n const changes: { from: number; insert: string }[] = [];\n const seen = new Set<number>();\n for (const range of state.selection.ranges) {\n const startLine = state.doc.lineAt(range.from).number;\n const endLine = state.doc.lineAt(range.to).number;\n let i = 0;\n for (let ln = startLine; ln <= endLine; ln++) {\n if (seen.has(ln)) continue;\n seen.add(ln);\n changes.push({ from: state.doc.line(ln).from, insert: prefix(i) });\n i++;\n }\n }\n view.dispatch(state.update({ changes, scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBulletList = (view: EditorView): void =>\n prefixLines(view, () => \"- \");\n\nexport const toggleNumberedList = (view: EditorView): void =>\n prefixLines(view, (i) => `${i + 1}. `);\n\nexport const toggleQuote = (view: EditorView): void =>\n prefixLines(view, () => \"> \");\n\n// Insert  at the primary cursor.\nexport function insertImageMarkdown(\n view: EditorView,\n url: string,\n alt: string,\n): void {\n const { state } = view;\n const pos = state.selection.main.head;\n const insert = ``;\n view.dispatch(\n state.update({\n changes: { from: pos, insert },\n selection: { anchor: pos + insert.length },\n scrollIntoView: true,\n }),\n );\n view.focus();\n}\n"],"mappings":";skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,0BAAAE,KAAA,eAAAC,GAAAH,ICGA,IAAAI,EAAuB,oBACvBC,EAAuC,4BACvCC,EAAwC,6BCJxC,IAAAC,EAA2C,qCAC3CC,EAAqE,gCACrEC,EAAoI,4BACpIC,EAAoD,6BCHpD,IAAAC,EAOO,4BAC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UK,EAEX,IAAM,CACXA,EAAK,QAAQ,EACbL,EAAQ,QAAU,IACpB,CAEF,EAAG,CAAC,CAAC,EAGC,YAAU,IAAM,CACpB,IAAMK,EAAOL,EAAQ,QACrB,GAAI,CAACK,EAAM,OAEX,IAAME,EAAUF,EAAK,MAAM,IAAI,SAAS,EACpCE,IAAYjB,GACde,EAAK,SAAS,CACZ,QAAS,CAAE,KAAM,EAAG,GAAIE,EAAQ,OAAQ,OAAQjB,CAAM,EACtD,YAAaF,GAAc,GAAG,EAAI,CACpC,CAAC,CAEL,EAAG,CAACE,CAAK,CAAC,EAGJ,YAAU,IAAM,CACpB,IAAMe,EAAOL,EAAQ,QAChBK,GACLA,EAAK,SAAS,CACZ,QAASG,EAAiB,YAAYC,EAAkBjB,CAAK,CAAC,CAChE,CAAC,CACH,EAAG,CAACA,CAAK,CAAC,KAGR,QAAC,OAAI,UAAWI,EAAW,MAAOC,EAC/B,UAAAJ,MACC,OAACiB,GAAA,CACC,QAAS,IAAMV,EAAQ,QACvB,MAAOR,EACP,cAAeE,EACjB,KAEF,OAAC,OAAI,IAAKK,EAAc,MAAO,CAAE,OAAAD,CAAO,EAAG,GAC7C,CAEJ","names":["index_exports","__export","InlineMarkdownEditor","__toCommonJS","React","import_view","import_state","import_lang_markdown","import_commands","import_view","import_state","import_view","import_language","HIDE","BulletWidget","s","ImageWidget","url","alt","other","img","span","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","node","name","level","parentFrom","parentTo","m","markText","liveMarkdownDecorations","update","instance","import_view","darkTheme","import_view","lightTheme","themeCompartment","getThemeExtension","theme","darkTheme","lightTheme","buildExtensions","placeholderText","placeholderExt","liveMarkdownDecorations","React","import_state","wrap","view","before","after","placeholder","state","tr","range","text","toggleBold","toggleItalic","toggleInlineCode","insertLink","selected","insert","urlStart","prefixLines","prefix","changes","seen","startLine","endLine","ln","toggleBulletList","toggleNumberedList","i","toggleQuote","insertImageMarkdown","url","alt","pos","import_jsx_runtime","ICONS","Icon","name","Toolbar","getView","theme","onImageUpload","fileRef","uploading","setUploading","palette","run","cmd","v","handleFile","e","file","url","insertImageMarkdown","err","btnStyle","Button","title","onClick","disabled","toggleBold","toggleItalic","insertLink","toggleBulletList","toggleNumberedList","toggleQuote","toggleInlineCode","import_jsx_runtime","externalValue","InlineMarkdownEditor","value","onChange","theme","toolbar","onImageUpload","placeholder","className","style","height","containerRef","viewRef","onChangeRef","updateListener","update","tr","view","buildExtensions","current","themeCompartment","getThemeExtension","Toolbar"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as b from"react";import{EditorView as X}from"@codemirror/view";import{EditorState as ge}from"@codemirror/state";import{markdown as _,markdownLanguage as ee}from"@codemirror/lang-markdown";import{history as oe,defaultKeymap as te,historyKeymap as re,indentWithTab as ne}from"@codemirror/commands";import{EditorView as H,keymap as ie,drawSelection as ae,dropCursor as ce,rectangularSelection as le,crosshairCursor as se,placeholder as de}from"@codemirror/view";import{Compartment as fe}from"@codemirror/state";import{ViewPlugin as G,Decoration as y,WidgetType as T}from"@codemirror/view";import{syntaxTree as w}from"@codemirror/language";var x=y.replace({}),M=class extends T{toDOM(){let n=document.createElement("span");return n.textContent="\u2022",n.className="ob-list-mark",n}eq(){return!0}},S=class extends T{constructor(a,e){super();this.url=a;this.alt=e}eq(a){return a.url===this.url&&a.alt===this.alt}toDOM(){let a=document.createElement("img");return a.src=this.url,a.alt=this.alt,a.className="ob-image-embed",a.style.maxWidth="100%",a.style.maxHeight="320px",a.style.minHeight="20px",a.style.borderRadius="6px",a.style.display="block",a.onerror=()=>{let e=document.createElement("span");e.className="ob-image",e.textContent=this.alt||this.url,a.replaceWith(e)},a}};function g(t,n,a){for(let e of t.selection.ranges)if(e.from>=n&&e.to<=a||e.from<=a&&e.to>=n)return!0;return!1}function E(t,n){let a=t.doc.lineAt(n);for(let e of t.selection.ranges)if(e.from>=a.from&&e.from<=a.to)return!0;return!1}function V(t){let{state:n}=t,a=[],e=(c,i,o)=>{c<i&&a.push({from:c,to:i,deco:o})},l=c=>y.mark({class:c});return w(n).cursor().iterate(c=>{let{name:i,from:o,to:r}=c;if(/^ATXHeading[1-6]$/.test(i)){let d=i.slice(-1);e(o,r,l(`ob-h${d}`))}if(i==="HeaderMark"&&(E(n,o)?e(o,r,l("ob-syntax")):e(o,r,x)),i==="StrongEmphasis"&&(g(n,o,r)||e(o,r,l("ob-bold"))),i==="Emphasis"&&(g(n,o,r)||e(o,r,l("ob-italic"))),i==="EmphasisMark"){let d=c.node.parent?.from??o,s=c.node.parent?.to??r;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="Strikethrough"&&(g(n,o,r)||e(o,r,l("ob-strikethrough"))),i==="StrikethroughMark"){let d=c.node.parent?.from??o,s=c.node.parent?.to??r;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="InlineCode"&&(g(n,o,r)||e(o,r,l("ob-code"))),i==="CodeMark"&&c.node.parent?.name==="InlineCode"){let d=c.node.parent.from,s=c.node.parent.to;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="Link"&&(g(n,o,r)||e(o,r,l("ob-link"))),i==="LinkMark"&&c.node.parent?.name==="Link"){let d=c.node.parent.from,s=c.node.parent.to;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="URL"&&c.node.parent?.name==="Link"){let d=c.node.parent.from,s=c.node.parent.to;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="Image"){if(!E(n,o)){let s=n.doc.sliceString(o,r).match(/^!\[([^\]]*)\]\(([^)\s]+)/);if(s)return e(o,r,y.replace({widget:new S(s[2],s[1])})),!1}e(o,r,l("ob-image"))}if(i==="LinkMark"&&c.node.parent?.name==="Image"){let d=c.node.parent.from,s=c.node.parent.to;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="URL"&&c.node.parent?.name==="Image"){let d=c.node.parent.from,s=c.node.parent.to;g(n,d,s)?e(o,r,l("ob-syntax")):e(o,r,x)}if(i==="Blockquote"&&e(o,r,l("ob-blockquote")),i==="BlockquoteMark"&&(E(n,o),e(o,r,l("ob-blockquote-mark"))),i==="ListMark"){let d=n.doc.sliceString(o,r);(d==="-"||d==="*"||d==="+")&&!E(n,o)?e(o,r,y.replace({widget:new M})):e(o,r,l("ob-list-mark"))}i==="FencedCode"&&e(o,r,l("ob-code-block")),i==="CodeMark"&&c.node.parent?.name==="FencedCode"&&e(o,r,l("ob-fence-mark")),i==="CodeInfo"&&e(o,r,l("ob-code-info")),i==="HorizontalRule"&&e(o,r,l("ob-hr"))}),y.set(a.map(({from:c,to:i,deco:o})=>o.range(c,i)),!0)}var F=G.fromClass(class{constructor(t){this.decorations=V(t)}update(t){(t.docChanged||t.selectionSet||t.viewportChanged||w(t.startState)!==w(t.state))&&(this.decorations=V(t.view))}},{decorations:t=>t.decorations});import{EditorView as Y}from"@codemirror/view";var W=Y.theme({"&":{backgroundColor:"#1e1e2e",color:"#cdd6f4",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#cdd6f4",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#cdd6f4",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#313244 !important"},".ob-h1":{color:"#cba6f7",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#cba6f7",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#cba6f7",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#cba6f7",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#cba6f7",fontWeight:"700"},".ob-h6":{color:"#a6adc8",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#cdd6f4"},".ob-italic":{fontStyle:"italic",color:"#cdd6f4"},".ob-strikethrough":{textDecoration:"line-through",color:"#6c7086"},".ob-code":{color:"#f38ba8",backgroundColor:"#313244",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#89b4fa",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#89b4fa"},".ob-syntax":{color:"#45475a",opacity:"0.7"},".ob-blockquote":{borderLeft:"3px solid #585b70",paddingLeft:"16px",color:"#9399b2",fontStyle:"italic"},".ob-blockquote-mark":{color:"#45475a"},".ob-list-mark":{color:"#89b4fa",fontWeight:"600"},".ob-hr":{color:"#45475a",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#181825",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#cdd6f4"},".ob-fence-mark":{color:"#45475a"},".ob-code-info":{color:"#a6e3a1",fontSize:"0.8em"},".ob-image":{color:"#f9e2af"}},{dark:!0});import{EditorView as Z}from"@codemirror/view";var B=Z.theme({"&":{backgroundColor:"#fafafa",color:"#1a1a1a",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#1a1a1a",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#1a1a1a",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#e5e7eb !important"},".ob-h1":{color:"#7c3aed",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#7c3aed",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#7c3aed",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#7c3aed",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#7c3aed",fontWeight:"700"},".ob-h6":{color:"#9333ea",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#1a1a1a"},".ob-italic":{fontStyle:"italic",color:"#1a1a1a"},".ob-strikethrough":{textDecoration:"line-through",color:"#9ca3af"},".ob-code":{color:"#dc2626",backgroundColor:"#f3f4f6",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#2563eb",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#2563eb"},".ob-syntax":{color:"#d1d5db",opacity:"0.9"},".ob-blockquote":{borderLeft:"3px solid #d1d5db",paddingLeft:"16px",color:"#6b7280",fontStyle:"italic"},".ob-blockquote-mark":{color:"#d1d5db"},".ob-list-mark":{color:"#2563eb",fontWeight:"600"},".ob-hr":{color:"#d1d5db",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#f3f4f6",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#1a1a1a"},".ob-fence-mark":{color:"#d1d5db"},".ob-code-info":{color:"#16a34a",fontSize:"0.8em"},".ob-image":{color:"#d97706"}},{dark:!1});var R=new fe;function L(t){return t==="dark"?W:B}function D(t,n){return[...n?[de(n)]:[],_({base:ee}),oe(),ie.of([...te,...re,ne]),H.lineWrapping,H.contentAttributes.of({spellcheck:"true"}),ae(),ce(),le(),se(),F,R.of(L(t))]}import*as C from"react";import{EditorSelection as z}from"@codemirror/state";function v(t,n,a,e){let{state:l}=t,c=l.changeByRange(i=>{let r=l.sliceDoc(i.from,i.to)||e;return{changes:{from:i.from,to:i.to,insert:n+r+a},range:z.range(i.from+n.length,i.from+n.length+r.length)}});t.dispatch(l.update(c,{scrollIntoView:!0})),t.focus()}var q=t=>v(t,"**","**","bold text"),P=t=>v(t,"*","*","italic text"),N=t=>v(t,"`","`","code"),U=t=>{let{state:n}=t,a=n.changeByRange(e=>{let l=n.sliceDoc(e.from,e.to)||"text",c=`[${l}](url)`,i=e.from+1+l.length+2;return{changes:{from:e.from,to:e.to,insert:c},range:z.range(i,i+3)}});t.dispatch(n.update(a,{scrollIntoView:!0})),t.focus()};function I(t,n){let{state:a}=t,e=[],l=new Set;for(let c of a.selection.ranges){let i=a.doc.lineAt(c.from).number,o=a.doc.lineAt(c.to).number,r=0;for(let d=i;d<=o;d++)l.has(d)||(l.add(d),e.push({from:a.doc.line(d).from,insert:n(r)}),r++)}t.dispatch(a.update({changes:e,scrollIntoView:!0})),t.focus()}var $=t=>I(t,()=>"- "),A=t=>I(t,n=>`${n+1}. `),J=t=>I(t,()=>"> ");function O(t,n,a){let{state:e}=t,l=e.selection.main.head,c=``;t.dispatch(e.update({changes:{from:l,insert:c},selection:{anchor:l+c.length},scrollIntoView:!0})),t.focus()}import{Fragment as ue,jsx as m,jsxs as Q}from"react/jsx-runtime";var me={bold:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z",italic:"M19 5h-6M11 19H5M15 5L9 19",link:"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1",bullet:"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01",numbered:"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2",quote:"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4",code:"M8 6l-6 6 6 6M16 6l6 6-6 6",image:"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"};function pe({name:t}){return m("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:m("path",{d:me[t]})})}var K=({getView:t,theme:n,onImageUpload:a})=>{let e=C.useRef(null),[l,c]=C.useState(!1),i=n==="dark"?{bg:"#181825",border:"#313244",fg:"#cdd6f4",hover:"#313244"}:{bg:"#f3f4f6",border:"#d1d5db",fg:"#1a1a1a",hover:"#e5e7eb"},o=h=>()=>{let p=t();p&&h(p)},r=async h=>{let p=h.target.files?.[0];h.target.value="";let f=t();if(!(!p||!a||!f)){c(!0);try{let u=await a(p);O(f,u,p.name)}catch(u){console.error("react-inline-markdown-editor: image upload failed",u)}finally{c(!1)}}},d={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",padding:0,border:"none",borderRadius:"5px",background:"transparent",color:i.fg,cursor:"pointer"},s=({name:h,title:p,onClick:f,disabled:u})=>m("button",{type:"button",title:p,onMouseDown:k=>k.preventDefault(),onClick:f,disabled:u,style:{...d,opacity:u?.5:1},onMouseEnter:k=>{k.currentTarget.style.background=i.hover},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},children:m(pe,{name:h})});return Q("div",{style:{display:"flex",gap:"2px",flexWrap:"wrap",padding:"5px 8px",background:i.bg,borderBottom:`1px solid ${i.border}`},children:[m(s,{name:"bold",title:"Bold",onClick:o(q)}),m(s,{name:"italic",title:"Italic",onClick:o(P)}),m(s,{name:"link",title:"Link",onClick:o(U)}),m(s,{name:"bullet",title:"Bullet list",onClick:o($)}),m(s,{name:"numbered",title:"Numbered list",onClick:o(A)}),m(s,{name:"quote",title:"Quote",onClick:o(J)}),m(s,{name:"code",title:"Inline code",onClick:o(N)}),a&&Q(ue,{children:[m(s,{name:"image",title:"Upload image",disabled:l,onClick:()=>e.current?.click()}),m("input",{ref:e,type:"file",accept:"image/*",onChange:r,style:{display:"none"}})]})]})};import{jsx as j,jsxs as he}from"react/jsx-runtime";var be=({value:t,onChange:n,theme:a="dark",toolbar:e=!1,onImageUpload:l,placeholder:c,className:i,style:o,height:r="100%"})=>{let d=b.useRef(null),s=b.useRef(null),h=b.useRef(n);b.useLayoutEffect(()=>{h.current=n});let p=b.useRef(!1);return b.useEffect(()=>{if(!d.current)return;let f=X.updateListener.of(k=>{k.docChanged&&(p.current=!0,h.current(k.state.doc.toString()))}),u=new X({state:ge.create({doc:t,extensions:[...D(a,c),f]}),parent:d.current});return s.current=u,()=>{u.destroy(),s.current=null}},[]),b.useEffect(()=>{let f=s.current;if(!f)return;if(p.current){p.current=!1;return}let u=f.state.doc.toString();u!==t&&f.dispatch({changes:{from:0,to:u.length,insert:t},annotations:[]})},[t]),b.useEffect(()=>{let f=s.current;f&&f.dispatch({effects:R.reconfigure(L(a))})},[a]),he("div",{className:i,style:o,children:[e&&j(K,{getView:()=>s.current,theme:a,onImageUpload:l}),j("div",{ref:d,style:{height:r}})]})};export{be as InlineMarkdownEditor};
|
|
2
|
+
import*as g from"react";import{EditorView as X}from"@codemirror/view";import{Annotation as be,EditorState as he}from"@codemirror/state";import{markdown as ee,markdownLanguage as oe}from"@codemirror/lang-markdown";import{history as te,defaultKeymap as ne,historyKeymap as re,indentWithTab as ie}from"@codemirror/commands";import{EditorView as H,keymap as ae,drawSelection as ce,dropCursor as le,rectangularSelection as se,crosshairCursor as de,placeholder as fe}from"@codemirror/view";import{Compartment as me}from"@codemirror/state";import{ViewPlugin as Y,Decoration as y,WidgetType as T}from"@codemirror/view";import{syntaxTree as w}from"@codemirror/language";var x=y.replace({}),M=class extends T{toDOM(){let r=document.createElement("span");return r.textContent="\u2022",r.className="ob-list-mark",r}eq(){return!0}},S=class extends T{constructor(a,e){super();this.url=a;this.alt=e}eq(a){return a.url===this.url&&a.alt===this.alt}toDOM(){let a=document.createElement("img");return a.src=this.url,a.alt=this.alt,a.className="ob-image-embed",a.style.maxWidth="100%",a.style.maxHeight="320px",a.style.minHeight="20px",a.style.borderRadius="6px",a.style.display="block",a.onerror=()=>{let e=document.createElement("span");e.className="ob-image",e.textContent=this.alt||this.url,a.replaceWith(e)},a}};function p(t,r,a){for(let e of t.selection.ranges)if(e.from>=r&&e.to<=a||e.from<=a&&e.to>=r)return!0;return!1}function E(t,r){let a=t.doc.lineAt(r);for(let e of t.selection.ranges)if(e.from>=a.from&&e.from<=a.to)return!0;return!1}function V(t){let{state:r}=t,a=[],e=(c,i,o)=>{c<i&&a.push({from:c,to:i,deco:o})},l=c=>y.mark({class:c});return w(r).cursor().iterate(c=>{let{name:i,from:o,to:n}=c;if(/^ATXHeading[1-6]$/.test(i)){let d=i.slice(-1);e(o,n,l(`ob-h${d}`))}if(i==="HeaderMark"&&(E(r,o)?e(o,n,l("ob-syntax")):e(o,n,x)),i==="StrongEmphasis"&&(p(r,o,n)||e(o,n,l("ob-bold"))),i==="Emphasis"&&(p(r,o,n)||e(o,n,l("ob-italic"))),i==="EmphasisMark"){let d=c.node.parent?.from??o,s=c.node.parent?.to??n;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="Strikethrough"&&(p(r,o,n)||e(o,n,l("ob-strikethrough"))),i==="StrikethroughMark"){let d=c.node.parent?.from??o,s=c.node.parent?.to??n;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="InlineCode"&&(p(r,o,n)||e(o,n,l("ob-code"))),i==="CodeMark"&&c.node.parent?.name==="InlineCode"){let d=c.node.parent.from,s=c.node.parent.to;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="Link"&&(p(r,o,n)||e(o,n,l("ob-link"))),i==="LinkMark"&&c.node.parent?.name==="Link"){let d=c.node.parent.from,s=c.node.parent.to;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="URL"&&c.node.parent?.name==="Link"){let d=c.node.parent.from,s=c.node.parent.to;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="Image"){if(!E(r,o)){let s=r.doc.sliceString(o,n).match(/^!\[([^\]]*)\]\(([^)\s]+)/);if(s)return e(o,n,y.replace({widget:new S(s[2],s[1])})),!1}e(o,n,l("ob-image"))}if(i==="LinkMark"&&c.node.parent?.name==="Image"){let d=c.node.parent.from,s=c.node.parent.to;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="URL"&&c.node.parent?.name==="Image"){let d=c.node.parent.from,s=c.node.parent.to;p(r,d,s)?e(o,n,l("ob-syntax")):e(o,n,x)}if(i==="Blockquote"&&e(o,n,l("ob-blockquote")),i==="BlockquoteMark"&&(E(r,o),e(o,n,l("ob-blockquote-mark"))),i==="ListMark"){let d=r.doc.sliceString(o,n);(d==="-"||d==="*"||d==="+")&&!E(r,o)?e(o,n,y.replace({widget:new M})):e(o,n,l("ob-list-mark"))}i==="FencedCode"&&e(o,n,l("ob-code-block")),i==="CodeMark"&&c.node.parent?.name==="FencedCode"&&e(o,n,l("ob-fence-mark")),i==="CodeInfo"&&e(o,n,l("ob-code-info")),i==="HorizontalRule"&&e(o,n,l("ob-hr"))}),y.set(a.map(({from:c,to:i,deco:o})=>o.range(c,i)),!0)}var F=Y.fromClass(class{constructor(t){this.decorations=V(t)}update(t){(t.docChanged||t.selectionSet||t.viewportChanged||w(t.startState)!==w(t.state))&&(this.decorations=V(t.view))}},{decorations:t=>t.decorations});import{EditorView as Z}from"@codemirror/view";var W=Z.theme({"&":{backgroundColor:"#1e1e2e",color:"#cdd6f4",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#cdd6f4",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#cdd6f4",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#313244 !important"},".ob-h1":{color:"#cba6f7",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#cba6f7",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#cba6f7",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#cba6f7",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#cba6f7",fontWeight:"700"},".ob-h6":{color:"#a6adc8",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#cdd6f4"},".ob-italic":{fontStyle:"italic",color:"#cdd6f4"},".ob-strikethrough":{textDecoration:"line-through",color:"#6c7086"},".ob-code":{color:"#f38ba8",backgroundColor:"#313244",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#89b4fa",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#89b4fa"},".ob-syntax":{color:"#45475a",opacity:"0.7"},".ob-blockquote":{borderLeft:"3px solid #585b70",paddingLeft:"16px",color:"#9399b2",fontStyle:"italic"},".ob-blockquote-mark":{color:"#45475a"},".ob-list-mark":{color:"#89b4fa",fontWeight:"600"},".ob-hr":{color:"#45475a",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#181825",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#cdd6f4"},".ob-fence-mark":{color:"#45475a"},".ob-code-info":{color:"#a6e3a1",fontSize:"0.8em"},".ob-image":{color:"#f9e2af"}},{dark:!0});import{EditorView as _}from"@codemirror/view";var B=_.theme({"&":{backgroundColor:"#fafafa",color:"#1a1a1a",fontFamily:"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif",fontSize:"16px",lineHeight:"1.7",height:"100%"},".cm-scroller":{overflow:"auto"},".cm-content":{padding:"24px 32px",caretColor:"#1a1a1a",maxWidth:"800px",margin:"0 auto"},".cm-focused":{outline:"none"},".cm-line":{padding:"1px 0"},".cm-cursor":{borderLeftColor:"#1a1a1a",borderLeftWidth:"2px"},".cm-selectionBackground, ::selection":{backgroundColor:"#e5e7eb !important"},".ob-h1":{color:"#7c3aed",fontSize:"2em",fontWeight:"700",lineHeight:"1.3",marginBottom:"4px"},".ob-h2":{color:"#7c3aed",fontSize:"1.5em",fontWeight:"700",lineHeight:"1.3"},".ob-h3":{color:"#7c3aed",fontSize:"1.25em",fontWeight:"700",lineHeight:"1.3"},".ob-h4":{color:"#7c3aed",fontSize:"1.1em",fontWeight:"700"},".ob-h5":{color:"#7c3aed",fontWeight:"700"},".ob-h6":{color:"#9333ea",fontWeight:"700"},".ob-bold":{fontWeight:"700",color:"#1a1a1a"},".ob-italic":{fontStyle:"italic",color:"#1a1a1a"},".ob-strikethrough":{textDecoration:"line-through",color:"#9ca3af"},".ob-code":{color:"#dc2626",backgroundColor:"#f3f4f6",borderRadius:"4px",padding:"1px 5px",fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace",fontSize:"0.9em"},".ob-link":{color:"#2563eb",textDecoration:"underline",cursor:"pointer"},".ob-link-text":{color:"#2563eb"},".ob-syntax":{color:"#d1d5db",opacity:"0.9"},".ob-blockquote":{borderLeft:"3px solid #d1d5db",paddingLeft:"16px",color:"#6b7280",fontStyle:"italic"},".ob-blockquote-mark":{color:"#d1d5db"},".ob-list-mark":{color:"#2563eb",fontWeight:"600"},".ob-hr":{color:"#d1d5db",letterSpacing:"4px"},".ob-code-block":{backgroundColor:"#f3f4f6",borderRadius:"6px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",fontSize:"0.9em",color:"#1a1a1a"},".ob-fence-mark":{color:"#d1d5db"},".ob-code-info":{color:"#16a34a",fontSize:"0.8em"},".ob-image":{color:"#d97706"}},{dark:!1});var R=new me;function L(t){return t==="dark"?W:B}function D(t,r){return[...r?[fe(r)]:[],ee({base:oe}),te(),ae.of([...ne,...re,ie]),H.lineWrapping,H.contentAttributes.of({spellcheck:"true"}),ce(),le(),se(),de(),F,R.of(L(t))]}import*as C from"react";import{EditorSelection as z}from"@codemirror/state";function v(t,r,a,e){let{state:l}=t,c=l.changeByRange(i=>{let n=l.sliceDoc(i.from,i.to)||e;return{changes:{from:i.from,to:i.to,insert:r+n+a},range:z.range(i.from+r.length,i.from+r.length+n.length)}});t.dispatch(l.update(c,{scrollIntoView:!0})),t.focus()}var q=t=>v(t,"**","**","bold text"),P=t=>v(t,"*","*","italic text"),N=t=>v(t,"`","`","code"),U=t=>{let{state:r}=t,a=r.changeByRange(e=>{let l=r.sliceDoc(e.from,e.to)||"text",c=`[${l}](url)`,i=e.from+1+l.length+2;return{changes:{from:e.from,to:e.to,insert:c},range:z.range(i,i+3)}});t.dispatch(r.update(a,{scrollIntoView:!0})),t.focus()};function I(t,r){let{state:a}=t,e=[],l=new Set;for(let c of a.selection.ranges){let i=a.doc.lineAt(c.from).number,o=a.doc.lineAt(c.to).number,n=0;for(let d=i;d<=o;d++)l.has(d)||(l.add(d),e.push({from:a.doc.line(d).from,insert:r(n)}),n++)}t.dispatch(a.update({changes:e,scrollIntoView:!0})),t.focus()}var $=t=>I(t,()=>"- "),A=t=>I(t,r=>`${r+1}. `),J=t=>I(t,()=>"> ");function O(t,r,a){let{state:e}=t,l=e.selection.main.head,c=``;t.dispatch(e.update({changes:{from:l,insert:c},selection:{anchor:l+c.length},scrollIntoView:!0})),t.focus()}import{Fragment as ge,jsx as m,jsxs as Q}from"react/jsx-runtime";var pe={bold:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z",italic:"M19 5h-6M11 19H5M15 5L9 19",link:"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1",bullet:"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01",numbered:"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2",quote:"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4",code:"M8 6l-6 6 6 6M16 6l6 6-6 6",image:"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"};function ue({name:t}){return m("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:m("path",{d:pe[t]})})}var K=({getView:t,theme:r,onImageUpload:a})=>{let e=C.useRef(null),[l,c]=C.useState(!1),i=r==="dark"?{bg:"#181825",border:"#313244",fg:"#cdd6f4",hover:"#313244"}:{bg:"#f3f4f6",border:"#d1d5db",fg:"#1a1a1a",hover:"#e5e7eb"},o=b=>()=>{let f=t();f&&b(f)},n=async b=>{let f=b.target.files?.[0];b.target.value="";let u=t();if(!(!f||!a||!u)){c(!0);try{let h=await a(f);O(u,h,f.name)}catch(h){console.error("react-inline-markdown-editor: image upload failed",h)}finally{c(!1)}}},d={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"30px",height:"30px",padding:0,border:"none",borderRadius:"5px",background:"transparent",color:i.fg,cursor:"pointer"},s=({name:b,title:f,onClick:u,disabled:h})=>m("button",{type:"button",title:f,onMouseDown:k=>k.preventDefault(),onClick:u,disabled:h,style:{...d,opacity:h?.5:1},onMouseEnter:k=>{k.currentTarget.style.background=i.hover},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},children:m(ue,{name:b})});return Q("div",{style:{display:"flex",gap:"2px",flexWrap:"wrap",padding:"5px 8px",background:i.bg,borderBottom:`1px solid ${i.border}`},children:[m(s,{name:"bold",title:"Bold",onClick:o(q)}),m(s,{name:"italic",title:"Italic",onClick:o(P)}),m(s,{name:"link",title:"Link",onClick:o(U)}),m(s,{name:"bullet",title:"Bullet list",onClick:o($)}),m(s,{name:"numbered",title:"Numbered list",onClick:o(A)}),m(s,{name:"quote",title:"Quote",onClick:o(J)}),m(s,{name:"code",title:"Inline code",onClick:o(N)}),a&&Q(ge,{children:[m(s,{name:"image",title:"Upload image",disabled:l,onClick:()=>e.current?.click()}),m("input",{ref:e,type:"file",accept:"image/*",onChange:n,style:{display:"none"}})]})]})};import{jsx as G,jsxs as xe}from"react/jsx-runtime";var j=be.define(),ke=({value:t,onChange:r,theme:a="dark",toolbar:e=!1,onImageUpload:l,placeholder:c,className:i,style:o,height:n="100%"})=>{let d=g.useRef(null),s=g.useRef(null),b=g.useRef(r);return g.useLayoutEffect(()=>{b.current=r}),g.useEffect(()=>{if(!d.current)return;let f=X.updateListener.of(h=>{h.transactions.some(k=>k.docChanged&&!k.annotation(j))&&b.current(h.state.doc.toString())}),u=new X({state:he.create({doc:t,extensions:[...D(a,c),f]}),parent:d.current});return s.current=u,()=>{u.destroy(),s.current=null}},[]),g.useEffect(()=>{let f=s.current;if(!f)return;let u=f.state.doc.toString();u!==t&&f.dispatch({changes:{from:0,to:u.length,insert:t},annotations:j.of(!0)})},[t]),g.useEffect(()=>{let f=s.current;f&&f.dispatch({effects:R.reconfigure(L(a))})},[a]),xe("div",{className:i,style:o,children:[e&&G(K,{getView:()=>s.current,theme:a,onImageUpload:l}),G("div",{ref:d,style:{height:n}})]})};export{ke as InlineMarkdownEditor};
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/InlineMarkdownEditor.tsx","../src/editor.ts","../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/Toolbar.tsx","../src/commands.ts"],"sourcesContent":["// src/InlineMarkdownEditor.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView, ViewUpdate } from \"@codemirror/view\";\nimport { EditorState } from \"@codemirror/state\";\nimport { buildExtensions, themeCompartment, getThemeExtension } from \"./editor\";\nimport { Toolbar } from \"./Toolbar\";\n\nexport type InlineMarkdownEditorProps = {\n /** Controlled markdown content */\n value: string;\n /** Called on every document change with the full new markdown string */\n onChange: (next: string) => void;\n /** Visual theme. Defaults to \"dark\". */\n theme?: \"dark\" | \"light\";\n /** Render the formatting toolbar above the editor. Defaults to false. */\n toolbar?: boolean;\n /** Upload handler. When provided, the toolbar shows an image button. */\n onImageUpload?: (file: File) => Promise<string>;\n /** Text shown when the document is empty. */\n placeholder?: string;\n /** Class applied to the outer container div */\n className?: string;\n /** Inline styles for the outer container div */\n style?: React.CSSProperties;\n /** Editor height. Defaults to \"100%\". Accepts any CSS length. */\n height?: string;\n};\n\nexport const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps> = ({\n value,\n onChange,\n theme = \"dark\",\n toolbar = false,\n onImageUpload,\n placeholder,\n className,\n style,\n height = \"100%\",\n}) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const viewRef = React.useRef<EditorView | null>(null);\n\n const onChangeRef = React.useRef(onChange);\n React.useLayoutEffect(() => {\n onChangeRef.current = onChange;\n });\n\n const skipNextSync = React.useRef(false);\n\n // Mount the editor once\n React.useEffect(() => {\n if (!containerRef.current) return;\n\n const updateListener = EditorView.updateListener.of(\n (update: ViewUpdate) => {\n if (update.docChanged) {\n skipNextSync.current = true;\n onChangeRef.current(update.state.doc.toString());\n }\n },\n );\n\n const view = new EditorView({\n state: EditorState.create({\n doc: value,\n extensions: [...buildExtensions(theme, placeholder), updateListener],\n }),\n parent: containerRef.current,\n });\n\n viewRef.current = view;\n\n return () => {\n view.destroy();\n viewRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // intentionally empty — mount once\n\n // Sync external value changes into CM6\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n\n if (skipNextSync.current) {\n skipNextSync.current = false;\n return;\n }\n\n const current = view.state.doc.toString();\n if (current !== value) {\n view.dispatch({\n changes: { from: 0, to: current.length, insert: value },\n annotations: [],\n });\n }\n }, [value]);\n\n // Swap theme at runtime via Compartment\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n view.dispatch({\n effects: themeCompartment.reconfigure(getThemeExtension(theme)),\n });\n }, [theme]);\n\n return (\n <div className={className} style={style}>\n {toolbar && (\n <Toolbar\n getView={() => viewRef.current}\n theme={theme}\n onImageUpload={onImageUpload}\n />\n )}\n <div ref={containerRef} style={{ height }} />\n </div>\n );\n};\n","// src/editor.ts\nimport { markdown, markdownLanguage } from \"@codemirror/lang-markdown\";\nimport { history, defaultKeymap, historyKeymap, indentWithTab } from \"@codemirror/commands\";\nimport { EditorView, keymap, drawSelection, dropCursor, rectangularSelection, crosshairCursor, placeholder as placeholderExt } from \"@codemirror/view\";\nimport { EditorState, Extension, Compartment } from \"@codemirror/state\";\nimport { liveMarkdownDecorations } from \"./decorations\";\nimport { darkTheme } from \"./theme-dark\";\nimport { lightTheme } from \"./theme-light\";\n\nexport const themeCompartment = new Compartment();\n\nexport function getThemeExtension(theme: \"dark\" | \"light\"): Extension {\n return theme === \"dark\" ? darkTheme : lightTheme;\n}\n\nexport function buildExtensions(\n theme: \"dark\" | \"light\",\n placeholderText?: string,\n): Extension[] {\n return [\n ...(placeholderText ? [placeholderExt(placeholderText)] : []),\n // Markdown language with GFM extensions\n markdown({ base: markdownLanguage }),\n\n // Undo/redo history\n history(),\n\n // Keyboard shortcuts: standard editing + history shortcuts\n keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),\n\n // Soft line wrapping\n EditorView.lineWrapping,\n\n // Spell check\n EditorView.contentAttributes.of({ spellcheck: \"true\" }),\n\n // Selection and cursor rendering\n drawSelection(),\n dropCursor(),\n\n // Allow rectangular selection with Alt+drag\n rectangularSelection(),\n crosshairCursor(),\n\n // Live-preview syntax decorations\n liveMarkdownDecorations,\n\n // Theme via Compartment (swappable at runtime)\n themeCompartment.of(getThemeExtension(theme)),\n ];\n}\n","// src/decorations.ts\nimport {\n ViewPlugin,\n DecorationSet,\n Decoration,\n ViewUpdate,\n WidgetType,\n EditorView,\n} from \"@codemirror/view\";\nimport { syntaxTree } from \"@codemirror/language\";\nimport { EditorState } from \"@codemirror/state\";\n\n// A widgetless replace decoration collapses the range out of layout entirely —\n// the same mechanism code-folding uses. A display:none widget would instead\n// leave a DOM node whose getBoundingClientRect is all-zeros, which breaks\n// posAtCoords hit-testing and makes vertical cursor motion skip lines.\nconst HIDE = Decoration.replace({});\n\n// Renders a list marker (-, *, +) as a typographic bullet.\nclass BulletWidget extends WidgetType {\n toDOM(): HTMLElement {\n const s = document.createElement(\"span\");\n s.textContent = \"•\";\n s.className = \"ob-list-mark\";\n return s;\n }\n eq(): boolean {\n return true;\n }\n}\n\n// Renders an  image. Falls back to alt text on a load error.\nclass ImageWidget extends WidgetType {\n constructor(\n readonly url: string,\n readonly alt: string,\n ) {\n super();\n }\n eq(other: ImageWidget): boolean {\n return other.url === this.url && other.alt === this.alt;\n }\n toDOM(): HTMLElement {\n const img = document.createElement(\"img\");\n img.src = this.url;\n img.alt = this.alt;\n img.className = \"ob-image-embed\";\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"320px\";\n img.style.minHeight = \"20px\";\n img.style.borderRadius = \"6px\";\n img.style.display = \"block\";\n img.onerror = () => {\n const span = document.createElement(\"span\");\n span.className = \"ob-image\";\n span.textContent = this.alt || this.url;\n img.replaceWith(span);\n };\n return img;\n }\n}\n\ntype DecoEntry = { from: number; to: number; deco: Decoration };\n\nfunction isCursorInRange(state: EditorState, from: number, to: number): boolean {\n for (const range of state.selection.ranges) {\n if (range.from >= from && range.to <= to) return true;\n if (range.from <= to && range.to >= from) return true;\n }\n return false;\n}\n\nfunction isCursorOnLine(state: EditorState, from: number): boolean {\n const line = state.doc.lineAt(from);\n for (const range of state.selection.ranges) {\n if (range.from >= line.from && range.from <= line.to) return true;\n }\n return false;\n}\n\nfunction buildDecorations(view: EditorView): DecorationSet {\n const { state } = view;\n const entries: DecoEntry[] = [];\n\n const add = (from: number, to: number, deco: Decoration) => {\n if (from < to) entries.push({ from, to, deco });\n };\n\n const mark = (cls: string) => Decoration.mark({ class: cls });\n\n syntaxTree(state).cursor().iterate((node) => {\n const { name, from, to } = node;\n\n // ── ATX Headings ──────────────────────────────────────────────────────\n // Level derived from node name: ATXHeading1 → h1, etc.\n if (/^ATXHeading[1-6]$/.test(name)) {\n const level = name.slice(-1); // \"1\"–\"6\"\n add(from, to, mark(`ob-h${level}`));\n }\n\n // HeaderMark = the leading `# ` characters in ATX headings\n if (name === \"HeaderMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide when cursor is elsewhere\n }\n }\n\n // ── Strong emphasis (bold): **text** or __text__ ───────────────────\n if (name === \"StrongEmphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-bold\"));\n }\n }\n\n // ── Emphasis (italic): *text* or _text_ ────────────────────────────\n if (name === \"Emphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-italic\"));\n }\n }\n\n // EmphasisMark = ** / * / __ / _ markers (shared by bold and italic)\n if (name === \"EmphasisMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide\n }\n }\n\n // ── Strikethrough: ~~text~~ (GFM) ─────────────────────────────────\n if (name === \"Strikethrough\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-strikethrough\"));\n }\n }\n if (name === \"StrikethroughMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Inline code: `code` ───────────────────────────────────────────\n if (name === \"InlineCode\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-code\"));\n }\n }\n // CodeMark inside InlineCode = the backtick(s)\n if (name === \"CodeMark\" && node.node.parent?.name === \"InlineCode\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Links: [text](url) ────────────────────────────────────────────\n if (name === \"Link\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-link\"));\n }\n }\n // LinkMark = [ ] ( ) characters in links\n if (name === \"LinkMark\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n // URL inside Link (the url part) — hide when cursor away\n if (name === \"URL\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Images:  ──────────────────────────────────────────\n if (name === \"Image\") {\n // Cursor off the line: replace the whole  with a rendered img.\n // return false so the iterator does not descend into the image's\n // LinkMark/URL children (their decorations would overlap the replace\n // and crash the range set).\n if (!isCursorOnLine(state, from)) {\n const text = state.doc.sliceString(from, to);\n const m = text.match(/^!\\[([^\\]]*)\\]\\(([^)\\s]+)/);\n if (m) {\n add(\n from,\n to,\n Decoration.replace({ widget: new ImageWidget(m[2], m[1]) }),\n );\n return false;\n }\n }\n add(from, to, mark(\"ob-image\"));\n }\n if (name === \"LinkMark\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n if (name === \"URL\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Blockquote ────────────────────────────────────────────────────\n if (name === \"Blockquote\") {\n add(from, to, mark(\"ob-blockquote\"));\n }\n if (name === \"BlockquoteMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-blockquote-mark\"));\n } else {\n add(from, to, mark(\"ob-blockquote-mark\")); // always show `>` but styled\n }\n }\n\n // ── List markers ─────────────────────────────────────────────────\n if (name === \"ListMark\") {\n const markText = state.doc.sliceString(from, to);\n const isBullet =\n markText === \"-\" || markText === \"*\" || markText === \"+\";\n if (isBullet && !isCursorOnLine(state, from)) {\n add(from, to, Decoration.replace({ widget: new BulletWidget() }));\n } else {\n add(from, to, mark(\"ob-list-mark\"));\n }\n }\n\n // ── Fenced code blocks ───────────────────────────────────────────\n if (name === \"FencedCode\") {\n add(from, to, mark(\"ob-code-block\"));\n }\n // CodeMark inside FencedCode = the ``` or ~~~ fence lines\n if (name === \"CodeMark\" && node.node.parent?.name === \"FencedCode\") {\n add(from, to, mark(\"ob-fence-mark\"));\n }\n // CodeInfo = language specifier after opening fence\n if (name === \"CodeInfo\") {\n add(from, to, mark(\"ob-code-info\"));\n }\n\n // ── Horizontal rule ──────────────────────────────────────────────\n if (name === \"HorizontalRule\") {\n add(from, to, mark(\"ob-hr\"));\n }\n });\n\n // Decoration.set sorts by `from` AND `startSide` — RangeSetBuilder cannot,\n // since mark and replace decorations carry different sides at the same offset.\n return Decoration.set(\n entries.map(({ from, to, deco }) => deco.range(from, to)),\n true\n );\n}\n\nexport const liveMarkdownDecorations = ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n // Rebuild on background-parse progress too: syntaxTree() returns a new\n // tree as the parser advances, and the initial mount often only has the\n // first viewport parsed — without this, off-screen lines never decorate.\n if (\n update.docChanged ||\n update.selectionSet ||\n update.viewportChanged ||\n syntaxTree(update.startState) !== syntaxTree(update.state)\n ) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n { decorations: (instance) => instance.decorations }\n);\n","// src/theme-dark.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const darkTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#1e1e2e\",\n color: \"#cdd6f4\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#cdd6f4\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#cdd6f4\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#313244 !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#cba6f7\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": {\n color: \"#cba6f7\",\n fontSize: \"1.5em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h3\": {\n color: \"#cba6f7\",\n fontSize: \"1.25em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h4\": { color: \"#cba6f7\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#cba6f7\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#a6adc8\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#cdd6f4\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#cdd6f4\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#6c7086\" },\n \".ob-code\": {\n color: \"#f38ba8\",\n backgroundColor: \"#313244\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#89b4fa\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#89b4fa\" },\n // Syntax markers (shown dimmed when cursor is active in the span)\n \".ob-syntax\": { color: \"#45475a\", opacity: \"0.7\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #585b70\",\n paddingLeft: \"16px\",\n color: \"#9399b2\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#45475a\" },\n // List markers\n \".ob-list-mark\": { color: \"#89b4fa\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#45475a\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#181825\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#cdd6f4\",\n },\n \".ob-fence-mark\": { color: \"#45475a\" },\n \".ob-code-info\": { color: \"#a6e3a1\", fontSize: \"0.8em\" },\n // Image alt text\n \".ob-image\": { color: \"#f9e2af\" },\n },\n { dark: true }\n);\n","// src/theme-light.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const lightTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#fafafa\",\n color: \"#1a1a1a\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#1a1a1a\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#1a1a1a\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#e5e7eb !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#7c3aed\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": { color: \"#7c3aed\", fontSize: \"1.5em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h3\": { color: \"#7c3aed\", fontSize: \"1.25em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h4\": { color: \"#7c3aed\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#7c3aed\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#9333ea\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#1a1a1a\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#1a1a1a\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#9ca3af\" },\n \".ob-code\": {\n color: \"#dc2626\",\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#2563eb\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#2563eb\" },\n // Syntax markers (dimmed when cursor is in span)\n \".ob-syntax\": { color: \"#d1d5db\", opacity: \"0.9\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #d1d5db\",\n paddingLeft: \"16px\",\n color: \"#6b7280\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#d1d5db\" },\n // List markers\n \".ob-list-mark\": { color: \"#2563eb\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#d1d5db\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#1a1a1a\",\n },\n \".ob-fence-mark\": { color: \"#d1d5db\" },\n \".ob-code-info\": { color: \"#16a34a\", fontSize: \"0.8em\" },\n // Image\n \".ob-image\": { color: \"#d97706\" },\n },\n { dark: false }\n);\n","// src/Toolbar.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView } from \"@codemirror/view\";\nimport {\n toggleBold,\n toggleItalic,\n toggleInlineCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n insertImageMarkdown,\n} from \"./commands\";\n\nexport type ToolbarProps = {\n /** Returns the live EditorView, or null before mount. */\n getView: () => EditorView | null;\n theme: \"dark\" | \"light\";\n onImageUpload?: (file: File) => Promise<string>;\n};\n\n// 24x24 stroke icons.\nconst ICONS: Record<string, string> = {\n bold: \"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z\",\n italic: \"M19 5h-6M11 19H5M15 5L9 19\",\n link: \"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1\",\n bullet: \"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01\",\n numbered: \"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2\",\n quote: \"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4\",\n code: \"M8 6l-6 6 6 6M16 6l6 6-6 6\",\n image:\n \"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0\",\n};\n\nfunction Icon({ name }: { name: string }): React.ReactElement {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ICONS[name]} />\n </svg>\n );\n}\n\nexport const Toolbar: React.FC<ToolbarProps> = ({\n getView,\n theme,\n onImageUpload,\n}) => {\n const fileRef = React.useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = React.useState(false);\n\n const palette =\n theme === \"dark\"\n ? { bg: \"#181825\", border: \"#313244\", fg: \"#cdd6f4\", hover: \"#313244\" }\n : { bg: \"#f3f4f6\", border: \"#d1d5db\", fg: \"#1a1a1a\", hover: \"#e5e7eb\" };\n\n const run = (cmd: (v: EditorView) => void) => () => {\n const v = getView();\n if (v) cmd(v);\n };\n\n const handleFile = async (\n e: React.ChangeEvent<HTMLInputElement>,\n ): Promise<void> => {\n const file = e.target.files?.[0];\n e.target.value = \"\";\n const v = getView();\n if (!file || !onImageUpload || !v) return;\n setUploading(true);\n try {\n const url = await onImageUpload(file);\n insertImageMarkdown(v, url, file.name);\n } catch (err) {\n console.error(\"react-inline-markdown-editor: image upload failed\", err);\n } finally {\n setUploading(false);\n }\n };\n\n const btnStyle: React.CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"30px\",\n height: \"30px\",\n padding: 0,\n border: \"none\",\n borderRadius: \"5px\",\n background: \"transparent\",\n color: palette.fg,\n cursor: \"pointer\",\n };\n\n const Button = ({\n name,\n title,\n onClick,\n disabled,\n }: {\n name: string;\n title: string;\n onClick: () => void;\n disabled?: boolean;\n }): React.ReactElement => (\n <button\n type=\"button\"\n title={title}\n onMouseDown={(e) => e.preventDefault()}\n onClick={onClick}\n disabled={disabled}\n style={{ ...btnStyle, opacity: disabled ? 0.5 : 1 }}\n onMouseEnter={(e) => {\n e.currentTarget.style.background = palette.hover;\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n <Icon name={name} />\n </button>\n );\n\n return (\n <div\n style={{\n display: \"flex\",\n gap: \"2px\",\n flexWrap: \"wrap\",\n padding: \"5px 8px\",\n background: palette.bg,\n borderBottom: `1px solid ${palette.border}`,\n }}\n >\n <Button name=\"bold\" title=\"Bold\" onClick={run(toggleBold)} />\n <Button name=\"italic\" title=\"Italic\" onClick={run(toggleItalic)} />\n <Button name=\"link\" title=\"Link\" onClick={run(insertLink)} />\n <Button\n name=\"bullet\"\n title=\"Bullet list\"\n onClick={run(toggleBulletList)}\n />\n <Button\n name=\"numbered\"\n title=\"Numbered list\"\n onClick={run(toggleNumberedList)}\n />\n <Button name=\"quote\" title=\"Quote\" onClick={run(toggleQuote)} />\n <Button name=\"code\" title=\"Inline code\" onClick={run(toggleInlineCode)} />\n {onImageUpload && (\n <>\n <Button\n name=\"image\"\n title=\"Upload image\"\n disabled={uploading}\n onClick={() => fileRef.current?.click()}\n />\n <input\n ref={fileRef}\n type=\"file\"\n accept=\"image/*\"\n onChange={handleFile}\n style={{ display: \"none\" }}\n />\n </>\n )}\n </div>\n );\n};\n","// src/commands.ts\n// Markdown text transforms. Each takes the EditorView and dispatches a\n// transaction. No React, no DOM beyond CodeMirror.\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorSelection } from \"@codemirror/state\";\n\n// Wrap each selection range in before/after. With an empty selection,\n// insert the placeholder and select it.\nfunction wrap(\n view: EditorView,\n before: string,\n after: string,\n placeholder: string,\n): void {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to);\n const text = selected || placeholder;\n return {\n changes: {\n from: range.from,\n to: range.to,\n insert: before + text + after,\n },\n range: EditorSelection.range(\n range.from + before.length,\n range.from + before.length + text.length,\n ),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBold = (view: EditorView): void =>\n wrap(view, \"**\", \"**\", \"bold text\");\n\nexport const toggleItalic = (view: EditorView): void =>\n wrap(view, \"*\", \"*\", \"italic text\");\n\nexport const toggleInlineCode = (view: EditorView): void =>\n wrap(view, \"`\", \"`\", \"code\");\n\n// Insert [text](url); leaves \"url\" selected so it can be typed over.\nexport const insertLink = (view: EditorView): void => {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to) || \"text\";\n const insert = `[${selected}](url)`;\n const urlStart = range.from + 1 + selected.length + 2;\n return {\n changes: { from: range.from, to: range.to, insert },\n range: EditorSelection.range(urlStart, urlStart + 3),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n};\n\n// Prefix every line touched by the selection. prefix(i) is called with the\n// zero-based index of the line within the run.\nfunction prefixLines(view: EditorView, prefix: (i: number) => string): void {\n const { state } = view;\n const changes: { from: number; insert: string }[] = [];\n const seen = new Set<number>();\n for (const range of state.selection.ranges) {\n const startLine = state.doc.lineAt(range.from).number;\n const endLine = state.doc.lineAt(range.to).number;\n let i = 0;\n for (let ln = startLine; ln <= endLine; ln++) {\n if (seen.has(ln)) continue;\n seen.add(ln);\n changes.push({ from: state.doc.line(ln).from, insert: prefix(i) });\n i++;\n }\n }\n view.dispatch(state.update({ changes, scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBulletList = (view: EditorView): void =>\n prefixLines(view, () => \"- \");\n\nexport const toggleNumberedList = (view: EditorView): void =>\n prefixLines(view, (i) => `${i + 1}. `);\n\nexport const toggleQuote = (view: EditorView): void =>\n prefixLines(view, () => \"> \");\n\n// Insert  at the primary cursor.\nexport function insertImageMarkdown(\n view: EditorView,\n url: string,\n alt: string,\n): void {\n const { state } = view;\n const pos = state.selection.main.head;\n const insert = ``;\n view.dispatch(\n state.update({\n changes: { from: pos, insert },\n selection: { anchor: pos + insert.length },\n scrollIntoView: true,\n }),\n );\n view.focus();\n}\n"],"mappings":";AAGA,UAAYA,MAAW,QACvB,OAAS,cAAAC,MAA8B,mBACvC,OAAS,eAAAC,OAAmB,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AI,IAAKY,EAAc,MAAO,CAAE,OAAAD,CAAO,EAAG,GAC7C,CAEJ","names":["React","EditorView","EditorState","markdown","markdownLanguage","history","defaultKeymap","historyKeymap","indentWithTab","EditorView","keymap","drawSelection","dropCursor","rectangularSelection","crosshairCursor","placeholderExt","Compartment","ViewPlugin","Decoration","WidgetType","syntaxTree","HIDE","BulletWidget","s","ImageWidget","url","alt","other","img","span","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","node","name","level","parentFrom","parentTo","m","markText","liveMarkdownDecorations","update","instance","EditorView","darkTheme","EditorView","lightTheme","themeCompartment","Compartment","getThemeExtension","theme","darkTheme","lightTheme","buildExtensions","placeholderText","placeholderExt","markdown","markdownLanguage","history","keymap","defaultKeymap","historyKeymap","indentWithTab","EditorView","drawSelection","dropCursor","rectangularSelection","crosshairCursor","liveMarkdownDecorations","React","EditorSelection","wrap","view","before","after","placeholder","state","tr","range","text","toggleBold","toggleItalic","toggleInlineCode","insertLink","selected","insert","urlStart","prefixLines","prefix","changes","seen","startLine","endLine","i","ln","toggleBulletList","toggleNumberedList","toggleQuote","insertImageMarkdown","url","alt","pos","Fragment","jsx","jsxs","ICONS","Icon","name","Toolbar","getView","theme","onImageUpload","fileRef","uploading","setUploading","palette","run","cmd","v","handleFile","e","file","url","insertImageMarkdown","err","btnStyle","Button","title","onClick","disabled","toggleBold","toggleItalic","insertLink","toggleBulletList","toggleNumberedList","toggleQuote","toggleInlineCode","jsx","jsxs","InlineMarkdownEditor","value","onChange","theme","toolbar","onImageUpload","placeholder","className","style","height","containerRef","viewRef","onChangeRef","skipNextSync","updateListener","EditorView","update","view","EditorState","buildExtensions","current","themeCompartment","getThemeExtension","Toolbar"]}
|
|
1
|
+
{"version":3,"sources":["../src/InlineMarkdownEditor.tsx","../src/editor.ts","../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/Toolbar.tsx","../src/commands.ts"],"sourcesContent":["// src/InlineMarkdownEditor.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView, ViewUpdate } from \"@codemirror/view\";\nimport { Annotation, EditorState } from \"@codemirror/state\";\nimport { buildExtensions, themeCompartment, getThemeExtension } from \"./editor\";\nimport { Toolbar } from \"./Toolbar\";\n\nconst externalValue = Annotation.define<boolean>();\n\nexport type InlineMarkdownEditorProps = {\n /** Controlled markdown content */\n value: string;\n /** Called on every document change with the full new markdown string */\n onChange: (next: string) => void;\n /** Visual theme. Defaults to \"dark\". */\n theme?: \"dark\" | \"light\";\n /** Render the formatting toolbar above the editor. Defaults to false. */\n toolbar?: boolean;\n /** Upload handler. When provided, the toolbar shows an image button. */\n onImageUpload?: (file: File) => Promise<string>;\n /** Text shown when the document is empty. */\n placeholder?: string;\n /** Class applied to the outer container div */\n className?: string;\n /** Inline styles for the outer container div */\n style?: React.CSSProperties;\n /** Editor height. Defaults to \"100%\". Accepts any CSS length. */\n height?: string;\n};\n\nexport const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps> = ({\n value,\n onChange,\n theme = \"dark\",\n toolbar = false,\n onImageUpload,\n placeholder,\n className,\n style,\n height = \"100%\",\n}) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const viewRef = React.useRef<EditorView | null>(null);\n\n const onChangeRef = React.useRef(onChange);\n React.useLayoutEffect(() => {\n onChangeRef.current = onChange;\n });\n\n // Mount the editor once\n React.useEffect(() => {\n if (!containerRef.current) return;\n\n const updateListener = EditorView.updateListener.of(\n (update: ViewUpdate) => {\n if (update.transactions.some(tr => tr.docChanged && !tr.annotation(externalValue))) {\n onChangeRef.current(update.state.doc.toString());\n }\n },\n );\n\n const view = new EditorView({\n state: EditorState.create({\n doc: value,\n extensions: [...buildExtensions(theme, placeholder), updateListener],\n }),\n parent: containerRef.current,\n });\n\n viewRef.current = view;\n\n return () => {\n view.destroy();\n viewRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // intentionally empty — mount once\n\n // Sync external value changes into CM6\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n\n const current = view.state.doc.toString();\n if (current !== value) {\n view.dispatch({\n changes: { from: 0, to: current.length, insert: value },\n annotations: externalValue.of(true),\n });\n }\n }, [value]);\n\n // Swap theme at runtime via Compartment\n React.useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n view.dispatch({\n effects: themeCompartment.reconfigure(getThemeExtension(theme)),\n });\n }, [theme]);\n\n return (\n <div className={className} style={style}>\n {toolbar && (\n <Toolbar\n getView={() => viewRef.current}\n theme={theme}\n onImageUpload={onImageUpload}\n />\n )}\n <div ref={containerRef} style={{ height }} />\n </div>\n );\n};\n","// src/editor.ts\nimport { markdown, markdownLanguage } from \"@codemirror/lang-markdown\";\nimport { history, defaultKeymap, historyKeymap, indentWithTab } from \"@codemirror/commands\";\nimport { EditorView, keymap, drawSelection, dropCursor, rectangularSelection, crosshairCursor, placeholder as placeholderExt } from \"@codemirror/view\";\nimport { EditorState, Extension, Compartment } from \"@codemirror/state\";\nimport { liveMarkdownDecorations } from \"./decorations\";\nimport { darkTheme } from \"./theme-dark\";\nimport { lightTheme } from \"./theme-light\";\n\nexport const themeCompartment = new Compartment();\n\nexport function getThemeExtension(theme: \"dark\" | \"light\"): Extension {\n return theme === \"dark\" ? darkTheme : lightTheme;\n}\n\nexport function buildExtensions(\n theme: \"dark\" | \"light\",\n placeholderText?: string,\n): Extension[] {\n return [\n ...(placeholderText ? [placeholderExt(placeholderText)] : []),\n // Markdown language with GFM extensions\n markdown({ base: markdownLanguage }),\n\n // Undo/redo history\n history(),\n\n // Keyboard shortcuts: standard editing + history shortcuts\n keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),\n\n // Soft line wrapping\n EditorView.lineWrapping,\n\n // Spell check\n EditorView.contentAttributes.of({ spellcheck: \"true\" }),\n\n // Selection and cursor rendering\n drawSelection(),\n dropCursor(),\n\n // Allow rectangular selection with Alt+drag\n rectangularSelection(),\n crosshairCursor(),\n\n // Live-preview syntax decorations\n liveMarkdownDecorations,\n\n // Theme via Compartment (swappable at runtime)\n themeCompartment.of(getThemeExtension(theme)),\n ];\n}\n","// src/decorations.ts\nimport {\n ViewPlugin,\n DecorationSet,\n Decoration,\n ViewUpdate,\n WidgetType,\n EditorView,\n} from \"@codemirror/view\";\nimport { syntaxTree } from \"@codemirror/language\";\nimport { EditorState } from \"@codemirror/state\";\n\n// A widgetless replace decoration collapses the range out of layout entirely —\n// the same mechanism code-folding uses. A display:none widget would instead\n// leave a DOM node whose getBoundingClientRect is all-zeros, which breaks\n// posAtCoords hit-testing and makes vertical cursor motion skip lines.\nconst HIDE = Decoration.replace({});\n\n// Renders a list marker (-, *, +) as a typographic bullet.\nclass BulletWidget extends WidgetType {\n toDOM(): HTMLElement {\n const s = document.createElement(\"span\");\n s.textContent = \"•\";\n s.className = \"ob-list-mark\";\n return s;\n }\n eq(): boolean {\n return true;\n }\n}\n\n// Renders an  image. Falls back to alt text on a load error.\nclass ImageWidget extends WidgetType {\n constructor(\n readonly url: string,\n readonly alt: string,\n ) {\n super();\n }\n eq(other: ImageWidget): boolean {\n return other.url === this.url && other.alt === this.alt;\n }\n toDOM(): HTMLElement {\n const img = document.createElement(\"img\");\n img.src = this.url;\n img.alt = this.alt;\n img.className = \"ob-image-embed\";\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"320px\";\n img.style.minHeight = \"20px\";\n img.style.borderRadius = \"6px\";\n img.style.display = \"block\";\n img.onerror = () => {\n const span = document.createElement(\"span\");\n span.className = \"ob-image\";\n span.textContent = this.alt || this.url;\n img.replaceWith(span);\n };\n return img;\n }\n}\n\ntype DecoEntry = { from: number; to: number; deco: Decoration };\n\nfunction isCursorInRange(state: EditorState, from: number, to: number): boolean {\n for (const range of state.selection.ranges) {\n if (range.from >= from && range.to <= to) return true;\n if (range.from <= to && range.to >= from) return true;\n }\n return false;\n}\n\nfunction isCursorOnLine(state: EditorState, from: number): boolean {\n const line = state.doc.lineAt(from);\n for (const range of state.selection.ranges) {\n if (range.from >= line.from && range.from <= line.to) return true;\n }\n return false;\n}\n\nfunction buildDecorations(view: EditorView): DecorationSet {\n const { state } = view;\n const entries: DecoEntry[] = [];\n\n const add = (from: number, to: number, deco: Decoration) => {\n if (from < to) entries.push({ from, to, deco });\n };\n\n const mark = (cls: string) => Decoration.mark({ class: cls });\n\n syntaxTree(state).cursor().iterate((node) => {\n const { name, from, to } = node;\n\n // ── ATX Headings ──────────────────────────────────────────────────────\n // Level derived from node name: ATXHeading1 → h1, etc.\n if (/^ATXHeading[1-6]$/.test(name)) {\n const level = name.slice(-1); // \"1\"–\"6\"\n add(from, to, mark(`ob-h${level}`));\n }\n\n // HeaderMark = the leading `# ` characters in ATX headings\n if (name === \"HeaderMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide when cursor is elsewhere\n }\n }\n\n // ── Strong emphasis (bold): **text** or __text__ ───────────────────\n if (name === \"StrongEmphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-bold\"));\n }\n }\n\n // ── Emphasis (italic): *text* or _text_ ────────────────────────────\n if (name === \"Emphasis\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-italic\"));\n }\n }\n\n // EmphasisMark = ** / * / __ / _ markers (shared by bold and italic)\n if (name === \"EmphasisMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\")); // show dimmed\n } else {\n add(from, to, HIDE); // hide\n }\n }\n\n // ── Strikethrough: ~~text~~ (GFM) ─────────────────────────────────\n if (name === \"Strikethrough\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-strikethrough\"));\n }\n }\n if (name === \"StrikethroughMark\") {\n const parentFrom = node.node.parent?.from ?? from;\n const parentTo = node.node.parent?.to ?? to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Inline code: `code` ───────────────────────────────────────────\n if (name === \"InlineCode\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-code\"));\n }\n }\n // CodeMark inside InlineCode = the backtick(s)\n if (name === \"CodeMark\" && node.node.parent?.name === \"InlineCode\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n\n // ── Links: [text](url) ────────────────────────────────────────────\n if (name === \"Link\") {\n if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-link\"));\n }\n }\n // LinkMark = [ ] ( ) characters in links\n if (name === \"LinkMark\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n // URL inside Link (the url part) — hide when cursor away\n if (name === \"URL\" && node.node.parent?.name === \"Link\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Images:  ──────────────────────────────────────────\n if (name === \"Image\") {\n // Cursor off the line: replace the whole  with a rendered img.\n // return false so the iterator does not descend into the image's\n // LinkMark/URL children (their decorations would overlap the replace\n // and crash the range set).\n if (!isCursorOnLine(state, from)) {\n const text = state.doc.sliceString(from, to);\n const m = text.match(/^!\\[([^\\]]*)\\]\\(([^)\\s]+)/);\n if (m) {\n add(\n from,\n to,\n Decoration.replace({ widget: new ImageWidget(m[2], m[1]) }),\n );\n return false;\n }\n }\n add(from, to, mark(\"ob-image\"));\n }\n if (name === \"LinkMark\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, mark(\"ob-syntax\"));\n } else {\n add(from, to, HIDE);\n }\n }\n if (name === \"URL\" && node.node.parent?.name === \"Image\") {\n const parentFrom = node.node.parent.from;\n const parentTo = node.node.parent.to;\n if (!isCursorInRange(state, parentFrom, parentTo)) {\n add(from, to, HIDE);\n } else {\n add(from, to, mark(\"ob-syntax\"));\n }\n }\n\n // ── Blockquote ────────────────────────────────────────────────────\n if (name === \"Blockquote\") {\n add(from, to, mark(\"ob-blockquote\"));\n }\n if (name === \"BlockquoteMark\") {\n if (isCursorOnLine(state, from)) {\n add(from, to, mark(\"ob-blockquote-mark\"));\n } else {\n add(from, to, mark(\"ob-blockquote-mark\")); // always show `>` but styled\n }\n }\n\n // ── List markers ─────────────────────────────────────────────────\n if (name === \"ListMark\") {\n const markText = state.doc.sliceString(from, to);\n const isBullet =\n markText === \"-\" || markText === \"*\" || markText === \"+\";\n if (isBullet && !isCursorOnLine(state, from)) {\n add(from, to, Decoration.replace({ widget: new BulletWidget() }));\n } else {\n add(from, to, mark(\"ob-list-mark\"));\n }\n }\n\n // ── Fenced code blocks ───────────────────────────────────────────\n if (name === \"FencedCode\") {\n add(from, to, mark(\"ob-code-block\"));\n }\n // CodeMark inside FencedCode = the ``` or ~~~ fence lines\n if (name === \"CodeMark\" && node.node.parent?.name === \"FencedCode\") {\n add(from, to, mark(\"ob-fence-mark\"));\n }\n // CodeInfo = language specifier after opening fence\n if (name === \"CodeInfo\") {\n add(from, to, mark(\"ob-code-info\"));\n }\n\n // ── Horizontal rule ──────────────────────────────────────────────\n if (name === \"HorizontalRule\") {\n add(from, to, mark(\"ob-hr\"));\n }\n });\n\n // Decoration.set sorts by `from` AND `startSide` — RangeSetBuilder cannot,\n // since mark and replace decorations carry different sides at the same offset.\n return Decoration.set(\n entries.map(({ from, to, deco }) => deco.range(from, to)),\n true\n );\n}\n\nexport const liveMarkdownDecorations = ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n // Rebuild on background-parse progress too: syntaxTree() returns a new\n // tree as the parser advances, and the initial mount often only has the\n // first viewport parsed — without this, off-screen lines never decorate.\n if (\n update.docChanged ||\n update.selectionSet ||\n update.viewportChanged ||\n syntaxTree(update.startState) !== syntaxTree(update.state)\n ) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n { decorations: (instance) => instance.decorations }\n);\n","// src/theme-dark.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const darkTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#1e1e2e\",\n color: \"#cdd6f4\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#cdd6f4\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#cdd6f4\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#313244 !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#cba6f7\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": {\n color: \"#cba6f7\",\n fontSize: \"1.5em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h3\": {\n color: \"#cba6f7\",\n fontSize: \"1.25em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n },\n \".ob-h4\": { color: \"#cba6f7\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#cba6f7\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#a6adc8\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#cdd6f4\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#cdd6f4\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#6c7086\" },\n \".ob-code\": {\n color: \"#f38ba8\",\n backgroundColor: \"#313244\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#89b4fa\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#89b4fa\" },\n // Syntax markers (shown dimmed when cursor is active in the span)\n \".ob-syntax\": { color: \"#45475a\", opacity: \"0.7\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #585b70\",\n paddingLeft: \"16px\",\n color: \"#9399b2\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#45475a\" },\n // List markers\n \".ob-list-mark\": { color: \"#89b4fa\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#45475a\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#181825\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#cdd6f4\",\n },\n \".ob-fence-mark\": { color: \"#45475a\" },\n \".ob-code-info\": { color: \"#a6e3a1\", fontSize: \"0.8em\" },\n // Image alt text\n \".ob-image\": { color: \"#f9e2af\" },\n },\n { dark: true }\n);\n","// src/theme-light.ts\nimport { EditorView } from \"@codemirror/view\";\nimport { Extension } from \"@codemirror/state\";\n\nexport const lightTheme: Extension = EditorView.theme(\n {\n \"&\": {\n backgroundColor: \"#fafafa\",\n color: \"#1a1a1a\",\n fontFamily:\n \"'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif\",\n fontSize: \"16px\",\n lineHeight: \"1.7\",\n height: \"100%\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n \".cm-content\": {\n padding: \"24px 32px\",\n caretColor: \"#1a1a1a\",\n maxWidth: \"800px\",\n margin: \"0 auto\",\n },\n \".cm-focused\": { outline: \"none\" },\n \".cm-line\": { padding: \"1px 0\" },\n \".cm-cursor\": { borderLeftColor: \"#1a1a1a\", borderLeftWidth: \"2px\" },\n \".cm-selectionBackground, ::selection\": {\n backgroundColor: \"#e5e7eb !important\",\n },\n // Headings\n \".ob-h1\": {\n color: \"#7c3aed\",\n fontSize: \"2em\",\n fontWeight: \"700\",\n lineHeight: \"1.3\",\n marginBottom: \"4px\",\n },\n \".ob-h2\": { color: \"#7c3aed\", fontSize: \"1.5em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h3\": { color: \"#7c3aed\", fontSize: \"1.25em\", fontWeight: \"700\", lineHeight: \"1.3\" },\n \".ob-h4\": { color: \"#7c3aed\", fontSize: \"1.1em\", fontWeight: \"700\" },\n \".ob-h5\": { color: \"#7c3aed\", fontWeight: \"700\" },\n \".ob-h6\": { color: \"#9333ea\", fontWeight: \"700\" },\n // Inline formatting\n \".ob-bold\": { fontWeight: \"700\", color: \"#1a1a1a\" },\n \".ob-italic\": { fontStyle: \"italic\", color: \"#1a1a1a\" },\n \".ob-strikethrough\": { textDecoration: \"line-through\", color: \"#9ca3af\" },\n \".ob-code\": {\n color: \"#dc2626\",\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"4px\",\n padding: \"1px 5px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace\",\n fontSize: \"0.9em\",\n },\n \".ob-link\": { color: \"#2563eb\", textDecoration: \"underline\", cursor: \"pointer\" },\n \".ob-link-text\": { color: \"#2563eb\" },\n // Syntax markers (dimmed when cursor is in span)\n \".ob-syntax\": { color: \"#d1d5db\", opacity: \"0.9\" },\n // Blockquote\n \".ob-blockquote\": {\n borderLeft: \"3px solid #d1d5db\",\n paddingLeft: \"16px\",\n color: \"#6b7280\",\n fontStyle: \"italic\",\n },\n \".ob-blockquote-mark\": { color: \"#d1d5db\" },\n // List markers\n \".ob-list-mark\": { color: \"#2563eb\", fontWeight: \"600\" },\n // Horizontal rule\n \".ob-hr\": { color: \"#d1d5db\", letterSpacing: \"4px\" },\n // Code block (fenced)\n \".ob-code-block\": {\n backgroundColor: \"#f3f4f6\",\n borderRadius: \"6px\",\n fontFamily: \"'JetBrains Mono', 'Fira Code', monospace\",\n fontSize: \"0.9em\",\n color: \"#1a1a1a\",\n },\n \".ob-fence-mark\": { color: \"#d1d5db\" },\n \".ob-code-info\": { color: \"#16a34a\", fontSize: \"0.8em\" },\n // Image\n \".ob-image\": { color: \"#d97706\" },\n },\n { dark: false }\n);\n","// src/Toolbar.tsx\n\"use client\";\n\nimport * as React from \"react\";\nimport { EditorView } from \"@codemirror/view\";\nimport {\n toggleBold,\n toggleItalic,\n toggleInlineCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n insertImageMarkdown,\n} from \"./commands\";\n\nexport type ToolbarProps = {\n /** Returns the live EditorView, or null before mount. */\n getView: () => EditorView | null;\n theme: \"dark\" | \"light\";\n onImageUpload?: (file: File) => Promise<string>;\n};\n\n// 24x24 stroke icons.\nconst ICONS: Record<string, string> = {\n bold: \"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z\",\n italic: \"M19 5h-6M11 19H5M15 5L9 19\",\n link: \"M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1\",\n bullet: \"M8 6h13M8 12h13M8 18h13M3.5 6h.01M3.5 12h.01M3.5 18h.01\",\n numbered: \"M10 6h11M10 12h11M10 18h11M4 5l1-1v5M3.5 9.5h2\",\n quote: \"M7 7H4v6h3l-1 4M16 7h-3v6h3l-1 4\",\n code: \"M8 6l-6 6 6 6M16 6l6 6-6 6\",\n image:\n \"M3 5h18v14H3zM3 16l5-5 4 4 3-3 5 5M9 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0\",\n};\n\nfunction Icon({ name }: { name: string }): React.ReactElement {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={ICONS[name]} />\n </svg>\n );\n}\n\nexport const Toolbar: React.FC<ToolbarProps> = ({\n getView,\n theme,\n onImageUpload,\n}) => {\n const fileRef = React.useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = React.useState(false);\n\n const palette =\n theme === \"dark\"\n ? { bg: \"#181825\", border: \"#313244\", fg: \"#cdd6f4\", hover: \"#313244\" }\n : { bg: \"#f3f4f6\", border: \"#d1d5db\", fg: \"#1a1a1a\", hover: \"#e5e7eb\" };\n\n const run = (cmd: (v: EditorView) => void) => () => {\n const v = getView();\n if (v) cmd(v);\n };\n\n const handleFile = async (\n e: React.ChangeEvent<HTMLInputElement>,\n ): Promise<void> => {\n const file = e.target.files?.[0];\n e.target.value = \"\";\n const v = getView();\n if (!file || !onImageUpload || !v) return;\n setUploading(true);\n try {\n const url = await onImageUpload(file);\n insertImageMarkdown(v, url, file.name);\n } catch (err) {\n console.error(\"react-inline-markdown-editor: image upload failed\", err);\n } finally {\n setUploading(false);\n }\n };\n\n const btnStyle: React.CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"30px\",\n height: \"30px\",\n padding: 0,\n border: \"none\",\n borderRadius: \"5px\",\n background: \"transparent\",\n color: palette.fg,\n cursor: \"pointer\",\n };\n\n const Button = ({\n name,\n title,\n onClick,\n disabled,\n }: {\n name: string;\n title: string;\n onClick: () => void;\n disabled?: boolean;\n }): React.ReactElement => (\n <button\n type=\"button\"\n title={title}\n onMouseDown={(e) => e.preventDefault()}\n onClick={onClick}\n disabled={disabled}\n style={{ ...btnStyle, opacity: disabled ? 0.5 : 1 }}\n onMouseEnter={(e) => {\n e.currentTarget.style.background = palette.hover;\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.background = \"transparent\";\n }}\n >\n <Icon name={name} />\n </button>\n );\n\n return (\n <div\n style={{\n display: \"flex\",\n gap: \"2px\",\n flexWrap: \"wrap\",\n padding: \"5px 8px\",\n background: palette.bg,\n borderBottom: `1px solid ${palette.border}`,\n }}\n >\n <Button name=\"bold\" title=\"Bold\" onClick={run(toggleBold)} />\n <Button name=\"italic\" title=\"Italic\" onClick={run(toggleItalic)} />\n <Button name=\"link\" title=\"Link\" onClick={run(insertLink)} />\n <Button\n name=\"bullet\"\n title=\"Bullet list\"\n onClick={run(toggleBulletList)}\n />\n <Button\n name=\"numbered\"\n title=\"Numbered list\"\n onClick={run(toggleNumberedList)}\n />\n <Button name=\"quote\" title=\"Quote\" onClick={run(toggleQuote)} />\n <Button name=\"code\" title=\"Inline code\" onClick={run(toggleInlineCode)} />\n {onImageUpload && (\n <>\n <Button\n name=\"image\"\n title=\"Upload image\"\n disabled={uploading}\n onClick={() => fileRef.current?.click()}\n />\n <input\n ref={fileRef}\n type=\"file\"\n accept=\"image/*\"\n onChange={handleFile}\n style={{ display: \"none\" }}\n />\n </>\n )}\n </div>\n );\n};\n","// src/commands.ts\n// Markdown text transforms. Each takes the EditorView and dispatches a\n// transaction. No React, no DOM beyond CodeMirror.\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorSelection } from \"@codemirror/state\";\n\n// Wrap each selection range in before/after. With an empty selection,\n// insert the placeholder and select it.\nfunction wrap(\n view: EditorView,\n before: string,\n after: string,\n placeholder: string,\n): void {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to);\n const text = selected || placeholder;\n return {\n changes: {\n from: range.from,\n to: range.to,\n insert: before + text + after,\n },\n range: EditorSelection.range(\n range.from + before.length,\n range.from + before.length + text.length,\n ),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBold = (view: EditorView): void =>\n wrap(view, \"**\", \"**\", \"bold text\");\n\nexport const toggleItalic = (view: EditorView): void =>\n wrap(view, \"*\", \"*\", \"italic text\");\n\nexport const toggleInlineCode = (view: EditorView): void =>\n wrap(view, \"`\", \"`\", \"code\");\n\n// Insert [text](url); leaves \"url\" selected so it can be typed over.\nexport const insertLink = (view: EditorView): void => {\n const { state } = view;\n const tr = state.changeByRange((range) => {\n const selected = state.sliceDoc(range.from, range.to) || \"text\";\n const insert = `[${selected}](url)`;\n const urlStart = range.from + 1 + selected.length + 2;\n return {\n changes: { from: range.from, to: range.to, insert },\n range: EditorSelection.range(urlStart, urlStart + 3),\n };\n });\n view.dispatch(state.update(tr, { scrollIntoView: true }));\n view.focus();\n};\n\n// Prefix every line touched by the selection. prefix(i) is called with the\n// zero-based index of the line within the run.\nfunction prefixLines(view: EditorView, prefix: (i: number) => string): void {\n const { state } = view;\n const changes: { from: number; insert: string }[] = [];\n const seen = new Set<number>();\n for (const range of state.selection.ranges) {\n const startLine = state.doc.lineAt(range.from).number;\n const endLine = state.doc.lineAt(range.to).number;\n let i = 0;\n for (let ln = startLine; ln <= endLine; ln++) {\n if (seen.has(ln)) continue;\n seen.add(ln);\n changes.push({ from: state.doc.line(ln).from, insert: prefix(i) });\n i++;\n }\n }\n view.dispatch(state.update({ changes, scrollIntoView: true }));\n view.focus();\n}\n\nexport const toggleBulletList = (view: EditorView): void =>\n prefixLines(view, () => \"- \");\n\nexport const toggleNumberedList = (view: EditorView): void =>\n prefixLines(view, (i) => `${i + 1}. `);\n\nexport const toggleQuote = (view: EditorView): void =>\n prefixLines(view, () => \"> \");\n\n// Insert  at the primary cursor.\nexport function insertImageMarkdown(\n view: EditorView,\n url: string,\n alt: string,\n): void {\n const { state } = view;\n const pos = state.selection.main.head;\n const insert = ``;\n view.dispatch(\n state.update({\n changes: { from: pos, insert },\n selection: { anchor: pos + insert.length },\n scrollIntoView: true,\n }),\n );\n view.focus();\n}\n"],"mappings":";AAGA,UAAYA,MAAW,QACvB,OAAS,cAAAC,MAA8B,mBACvC,OAAS,cAAAC,GAAY,eAAAC,OAAmB,oBCJxC,OAAS,YAAAC,GAAU,oBAAAC,OAAwB,4BAC3C,OAAS,WAAAC,GAAS,iBAAAC,GAAe,iBAAAC,GAAe,iBAAAC,OAAqB,uBACrE,OAAS,cAAAC,EAAY,UAAAC,GAAQ,iBAAAC,GAAe,cAAAC,GAAY,wBAAAC,GAAsB,mBAAAC,GAAiB,eAAeC,OAAsB,mBACpI,OAAiC,eAAAC,OAAmB,oBCHpD,OACE,cAAAC,EAEA,cAAAC,EAEA,cAAAC,MAEK,mBACP,OAAS,cAAAC,MAAkB,uBAO3B,IAAMC,EAAOH,EAAW,QAAQ,CAAC,CAAC,EAG5BI,EAAN,cAA2BH,CAAW,CACpC,OAAqB,CACnB,IAAMI,EAAI,SAAS,cAAc,MAAM,EACvC,OAAAA,EAAE,YAAc,SAChBA,EAAE,UAAY,eACPA,CACT,CACA,IAAc,CACZ,MAAO,EACT,CACF,EAGMC,EAAN,cAA0BL,CAAW,CACnC,YACWM,EACAC,EACT,CACA,MAAM,EAHG,SAAAD,EACA,SAAAC,CAGX,CACA,GAAGC,EAA6B,CAC9B,OAAOA,EAAM,MAAQ,KAAK,KAAOA,EAAM,MAAQ,KAAK,GACtD,CACA,OAAqB,CACnB,IAAMC,EAAM,SAAS,cAAc,KAAK,EACxC,OAAAA,EAAI,IAAM,KAAK,IACfA,EAAI,IAAM,KAAK,IACfA,EAAI,UAAY,iBAChBA,EAAI,MAAM,SAAW,OACrBA,EAAI,MAAM,UAAY,QACtBA,EAAI,MAAM,UAAY,OACtBA,EAAI,MAAM,aAAe,MACzBA,EAAI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,QAChBM,GACLA,EAAK,SAAS,CACZ,QAASI,EAAiB,YAAYC,EAAkBnB,CAAK,CAAC,CAChE,CAAC,CACH,EAAG,CAACA,CAAK,CAAC,EAGRN,GAAC,OAAI,UAAWU,EAAW,MAAOC,EAC/B,UAAAJ,GACCR,EAAC2B,EAAA,CACC,QAAS,IAAMZ,EAAQ,QACvB,MAAOR,EACP,cAAeE,EACjB,EAEFT,EAAC,OAAI,IAAKc,EAAc,MAAO,CAAE,OAAAD,CAAO,EAAG,GAC7C,CAEJ","names":["React","EditorView","Annotation","EditorState","markdown","markdownLanguage","history","defaultKeymap","historyKeymap","indentWithTab","EditorView","keymap","drawSelection","dropCursor","rectangularSelection","crosshairCursor","placeholderExt","Compartment","ViewPlugin","Decoration","WidgetType","syntaxTree","HIDE","BulletWidget","s","ImageWidget","url","alt","other","img","span","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","node","name","level","parentFrom","parentTo","m","markText","liveMarkdownDecorations","update","instance","EditorView","darkTheme","EditorView","lightTheme","themeCompartment","Compartment","getThemeExtension","theme","darkTheme","lightTheme","buildExtensions","placeholderText","placeholderExt","markdown","markdownLanguage","history","keymap","defaultKeymap","historyKeymap","indentWithTab","EditorView","drawSelection","dropCursor","rectangularSelection","crosshairCursor","liveMarkdownDecorations","React","EditorSelection","wrap","view","before","after","placeholder","state","tr","range","text","toggleBold","toggleItalic","toggleInlineCode","insertLink","selected","insert","urlStart","prefixLines","prefix","changes","seen","startLine","endLine","i","ln","toggleBulletList","toggleNumberedList","toggleQuote","insertImageMarkdown","url","alt","pos","Fragment","jsx","jsxs","ICONS","Icon","name","Toolbar","getView","theme","onImageUpload","fileRef","uploading","setUploading","palette","run","cmd","v","handleFile","e","file","url","insertImageMarkdown","err","btnStyle","Button","title","onClick","disabled","toggleBold","toggleItalic","insertLink","toggleBulletList","toggleNumberedList","toggleQuote","toggleInlineCode","jsx","jsxs","externalValue","Annotation","InlineMarkdownEditor","value","onChange","theme","toolbar","onImageUpload","placeholder","className","style","height","containerRef","viewRef","onChangeRef","updateListener","EditorView","update","tr","view","EditorState","buildExtensions","current","themeCompartment","getThemeExtension","Toolbar"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-inline-markdown-editor",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A React Markdown editor with live preview, powered by CodeMirror 6. Syntax markers appear on the active line.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
"author": "Anas Syed",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/anasyd/react-inline-markdown-editor.git"
|
|
17
|
+
"url": "git+https://github.com/anasyd/react-inline-markdown-editor.git",
|
|
18
|
+
"directory": "package"
|
|
18
19
|
},
|
|
19
20
|
"bugs": {
|
|
20
21
|
"url": "https://github.com/anasyd/react-inline-markdown-editor/issues"
|
|
21
22
|
},
|
|
22
|
-
"homepage": "https://
|
|
23
|
+
"homepage": "https://anasyd.github.io/react-inline-markdown-editor/",
|
|
23
24
|
"sideEffects": false,
|
|
24
25
|
"files": [
|
|
25
26
|
"dist",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
51
|
-
"@changesets/cli": "^3.1.0",
|
|
52
52
|
"@size-limit/file": "^14.3.0",
|
|
53
53
|
"@testing-library/dom": "^10.4.2",
|
|
54
54
|
"@testing-library/react": "^16.3.3",
|
|
@@ -70,9 +70,7 @@
|
|
|
70
70
|
"typecheck": "tsc --noEmit",
|
|
71
71
|
"test": "vitest run",
|
|
72
72
|
"check:package": "node scripts/check-client-directive.mjs && publint --pack npm && attw --pack .",
|
|
73
|
-
"size": "size-limit"
|
|
74
|
-
"version-packages": "changeset version && npm install --package-lock-only --ignore-scripts",
|
|
75
|
-
"release": "changeset publish --stage"
|
|
73
|
+
"size": "size-limit"
|
|
76
74
|
},
|
|
77
75
|
"dependencies": {
|
|
78
76
|
"@codemirror/commands": "^6.11.2",
|