react-inline-markdown-editor 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var m=require('react'),view=require('@codemirror/view'),state=require('@codemirror/state'),langMarkdown=require('@codemirror/lang-markdown'),commands=require('@codemirror/commands'),language=require('@codemirror/language'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var m__namespace=/*#__PURE__*/_interopNamespace(m);var p=view.Decoration.replace({}),k=class extends view.WidgetType{toDOM(){let n=document.createElement("span");return n.textContent="\u2022",n.className="ob-list-mark",n}eq(){return true}};function l(a,n,d){for(let t of a.selection.ranges)if(t.from>=n&&t.to<=d||t.from<=d&&t.to>=n)return true;return false}function g(a,n){let d=a.doc.lineAt(n);for(let t of a.selection.ranges)if(t.from>=d.from&&t.from<=d.to)return true;return false}function E(a){let{state:n}=a,d=[],t=(i,r,o)=>{i<r&&d.push({from:i,to:r,deco:o});},c=i=>view.Decoration.mark({class:i});return language.syntaxTree(n).cursor().iterate(i=>{let{name:r,from:o,to:e}=i;if(/^ATXHeading[1-6]$/.test(r)){let s=r.slice(-1);t(o,e,c(`ob-h${s}`));}if(r==="HeaderMark"&&(g(n,o)?t(o,e,c("ob-syntax")):t(o,e,p)),r==="StrongEmphasis"&&(l(n,o,e)||t(o,e,c("ob-bold"))),r==="Emphasis"&&(l(n,o,e)||t(o,e,c("ob-italic"))),r==="EmphasisMark"){let s=i.node.parent?.from??o,f=i.node.parent?.to??e;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Strikethrough"&&(l(n,o,e)||t(o,e,c("ob-strikethrough"))),r==="StrikethroughMark"){let s=i.node.parent?.from??o,f=i.node.parent?.to??e;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="InlineCode"&&(l(n,o,e)||t(o,e,c("ob-code"))),r==="CodeMark"&&i.node.parent?.name==="InlineCode"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Link"&&(l(n,o,e)||t(o,e,c("ob-link"))),r==="LinkMark"&&i.node.parent?.name==="Link"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="URL"&&i.node.parent?.name==="Link"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Image"&&(l(n,o,e)||t(o,e,c("ob-image"))),r==="LinkMark"&&i.node.parent?.name==="Image"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="URL"&&i.node.parent?.name==="Image"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Blockquote"&&t(o,e,c("ob-blockquote")),r==="BlockquoteMark"&&(g(n,o),t(o,e,c("ob-blockquote-mark"))),r==="ListMark"){let s=n.doc.sliceString(o,e);(s==="-"||s==="*"||s==="+")&&!g(n,o)?t(o,e,view.Decoration.replace({widget:new k})):t(o,e,c("ob-list-mark"));}r==="FencedCode"&&t(o,e,c("ob-code-block")),r==="CodeMark"&&i.node.parent?.name==="FencedCode"&&t(o,e,c("ob-fence-mark")),r==="CodeInfo"&&t(o,e,c("ob-code-info")),r==="HorizontalRule"&&t(o,e,c("ob-hr"));}),view.Decoration.set(d.map(({from:i,to:r,deco:o})=>o.range(i,r)),true)}var C=view.ViewPlugin.fromClass(class{constructor(a){this.decorations=E(a);}update(a){(a.docChanged||a.selectionSet||a.viewportChanged||language.syntaxTree(a.startState)!==language.syntaxTree(a.state))&&(this.decorations=E(a.view));}},{decorations:a=>a.decorations});var w=view.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:true});var M=view.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:false});var x=new state.Compartment;function S(a){return a==="dark"?w:M}function F(a){return [langMarkdown.markdown({base:langMarkdown.markdownLanguage}),commands.history(),view.keymap.of([...commands.defaultKeymap,...commands.historyKeymap,commands.indentWithTab]),view.EditorView.lineWrapping,view.EditorView.contentAttributes.of({spellcheck:"true"}),view.drawSelection(),view.dropCursor(),view.rectangularSelection(),view.crosshairCursor(),C,x.of(S(a))]}var $=({value:a,onChange:n,theme:d="dark",className:t,style:c,height:i="100%"})=>{let r=m__namespace.useRef(null),o=m__namespace.useRef(null),e=m__namespace.useRef(n);m__namespace.useLayoutEffect(()=>{e.current=n;});let s=m__namespace.useRef(false);return m__namespace.useEffect(()=>{if(!r.current)return;let f=view.EditorView.updateListener.of(y=>{y.docChanged&&(s.current=true,e.current(y.state.doc.toString()));}),b=new view.EditorView({state:state.EditorState.create({doc:a,extensions:[...F(d),f]}),parent:r.current});return o.current=b,()=>{b.destroy(),o.current=null;}},[]),m__namespace.useEffect(()=>{let f=o.current;if(!f)return;if(s.current){s.current=false;return}let b=f.state.doc.toString();b!==a&&f.dispatch({changes:{from:0,to:b.length,insert:a},annotations:[]});},[a]),m__namespace.useEffect(()=>{let f=o.current;f&&f.dispatch({effects:x.reconfigure(S(d))});},[d]),jsxRuntime.jsx("div",{ref:r,className:t,style:{height:i,...c}})};exports.InlineMarkdownEditor=$;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var b=require('react'),view=require('@codemirror/view'),state=require('@codemirror/state'),langMarkdown=require('@codemirror/lang-markdown'),commands=require('@codemirror/commands'),language=require('@codemirror/language'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var b__namespace=/*#__PURE__*/_interopNamespace(b);var x=view.Decoration.replace({}),M=class extends view.WidgetType{toDOM(){let n=document.createElement("span");return n.textContent="\u2022",n.className="ob-list-mark",n}eq(){return true}},S=class extends view.WidgetType{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 true;return false}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 true;return false}function V(t){let{state:n}=t,a=[],e=(c,i,o)=>{c<i&&a.push({from:c,to:i,deco:o});},l=c=>view.Decoration.mark({class:c});return language.syntaxTree(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,view.Decoration.replace({widget:new S(s[2],s[1])})),false}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,view.Decoration.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"));}),view.Decoration.set(a.map(({from:c,to:i,deco:o})=>o.range(c,i)),true)}var F=view.ViewPlugin.fromClass(class{constructor(t){this.decorations=V(t);}update(t){(t.docChanged||t.selectionSet||t.viewportChanged||language.syntaxTree(t.startState)!==language.syntaxTree(t.state))&&(this.decorations=V(t.view));}},{decorations:t=>t.decorations});var W=view.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:true});var B=view.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:false});var R=new state.Compartment;function L(t){return t==="dark"?W:B}function D(t,n){return [...n?[view.placeholder(n)]:[],langMarkdown.markdown({base:langMarkdown.markdownLanguage}),commands.history(),view.keymap.of([...commands.defaultKeymap,...commands.historyKeymap,commands.indentWithTab]),view.EditorView.lineWrapping,view.EditorView.contentAttributes.of({spellcheck:"true"}),view.drawSelection(),view.dropCursor(),view.rectangularSelection(),view.crosshairCursor(),F,R.of(L(t))]}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:state.EditorSelection.range(i.from+n.length,i.from+n.length+r.length)}});t.dispatch(l.update(c,{scrollIntoView:true})),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:state.EditorSelection.range(i,i+3)}});t.dispatch(n.update(a,{scrollIntoView:true})),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:true})),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:true})),t.focus();}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 jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:me[t]})})}var K=({getView:t,theme:n,onImageUpload:a})=>{let e=b__namespace.useRef(null),[l,c]=b__namespace.useState(false),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(true);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(false);}}},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})=>jsxRuntime.jsx("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:jsxRuntime.jsx(pe,{name:h})});return jsxRuntime.jsxs("div",{style:{display:"flex",gap:"2px",flexWrap:"wrap",padding:"5px 8px",background:i.bg,borderBottom:`1px solid ${i.border}`},children:[jsxRuntime.jsx(s,{name:"bold",title:"Bold",onClick:o(q)}),jsxRuntime.jsx(s,{name:"italic",title:"Italic",onClick:o(P)}),jsxRuntime.jsx(s,{name:"link",title:"Link",onClick:o(U)}),jsxRuntime.jsx(s,{name:"bullet",title:"Bullet list",onClick:o($)}),jsxRuntime.jsx(s,{name:"numbered",title:"Numbered list",onClick:o(A)}),jsxRuntime.jsx(s,{name:"quote",title:"Quote",onClick:o(J)}),jsxRuntime.jsx(s,{name:"code",title:"Inline code",onClick:o(N)}),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(s,{name:"image",title:"Upload image",disabled:l,onClick:()=>e.current?.click()}),jsxRuntime.jsx("input",{ref:e,type:"file",accept:"image/*",onChange:r,style:{display:"none"}})]})]})};var be=({value:t,onChange:n,theme:a="dark",toolbar:e=false,onImageUpload:l,placeholder:c,className:i,style:o,height:r="100%"})=>{let d=b__namespace.useRef(null),s=b__namespace.useRef(null),h=b__namespace.useRef(n);b__namespace.useLayoutEffect(()=>{h.current=n;});let p=b__namespace.useRef(false);return b__namespace.useEffect(()=>{if(!d.current)return;let f=view.EditorView.updateListener.of(k=>{k.docChanged&&(p.current=true,h.current(k.state.doc.toString()));}),u=new view.EditorView({state:state.EditorState.create({doc:t,extensions:[...D(a,c),f]}),parent:d.current});return s.current=u,()=>{u.destroy(),s.current=null;}},[]),b__namespace.useEffect(()=>{let f=s.current;if(!f)return;if(p.current){p.current=false;return}let u=f.state.doc.toString();u!==t&&f.dispatch({changes:{from:0,to:u.length,insert:t},annotations:[]});},[t]),b__namespace.useEffect(()=>{let f=s.current;f&&f.dispatch({effects:R.reconfigure(L(a))});},[a]),jsxRuntime.jsxs("div",{className:i,style:o,children:[e&&jsxRuntime.jsx(K,{getView:()=>s.current,theme:a,onImageUpload:l}),jsxRuntime.jsx("div",{ref:d,style:{height:r}})]})};exports.InlineMarkdownEditor=be;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/editor.ts","../src/InlineMarkdownEditor.tsx"],"names":["HIDE","Decoration","BulletWidget","WidgetType","s","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","syntaxTree","node","name","level","parentFrom","parentTo","markText","liveMarkdownDecorations","ViewPlugin","update","instance","darkTheme","EditorView","lightTheme","themeCompartment","Compartment","getThemeExtension","theme","buildExtensions","markdown","markdownLanguage","history","keymap","defaultKeymap","historyKeymap","indentWithTab","drawSelection","dropCursor","rectangularSelection","crosshairCursor","InlineMarkdownEditor","value","onChange","className","style","height","containerRef","m","viewRef","onChangeRef","skipNextSync","updateListener","EditorState","current","jsx"],"mappings":"0nBAgBA,IAAMA,CAAAA,CAAOC,gBAAW,OAAA,CAAQ,EAAE,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GACdrC,CAAAA,CAAK,QAAA,CAAS,CACZ,OAAA,CAAS,CAAE,KAAM,CAAA,CAAG,EAAA,CAAIiD,EAAQ,MAAA,CAAQ,MAAA,CAAQZ,CAAM,CAAA,CAEtD,WAAA,CAAa,EACf,CAAC,EAEL,CAAA,CAAG,CAACA,CAAK,CAAC,CAAA,CAGJM,uBAAU,IAAM,CACpB,IAAM3C,CAAAA,CAAO4C,CAAAA,CAAQ,QAChB5C,CAAAA,EACLA,CAAAA,CAAK,SAAS,CACZ,OAAA,CAASoB,EAAiB,WAAA,CAAYE,CAAAA,CAAkBC,CAAK,CAAC,CAChE,CAAC,EACH,CAAA,CAAG,CAACA,CAAK,CAAC,EAGR2B,cAAAA,CAAC,KAAA,CAAA,CACC,IAAKR,CAAAA,CACL,SAAA,CAAWH,EACX,KAAA,CAAO,CAAE,OAAAE,CAAAA,CAAQ,GAAGD,CAAM,CAAA,CAC5B,CAEJ","file":"index.cjs","sourcesContent":["// 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\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 if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-image\"));\n }\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/editor.ts\nimport { markdown, markdownLanguage } from \"@codemirror/lang-markdown\";\nimport { history, defaultKeymap, historyKeymap, indentWithTab } from \"@codemirror/commands\";\nimport { EditorView, keymap, drawSelection, dropCursor, rectangularSelection, crosshairCursor } 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(theme: \"dark\" | \"light\"): Extension[] {\n return [\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/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\";\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 /** Class applied to the outer container div */\n className?: string;\n /** Inline styles for the outer container div */\n style?: React.CSSProperties;\n /** Initial height. Defaults to \"100%\". Override with a px/vh value. */\n height?: string;\n};\n\nexport const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps> = ({\n value,\n onChange,\n theme = \"dark\",\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 // Keep onChange stable in a ref so the CM6 listener never goes stale\n const onChangeRef = React.useRef(onChange);\n React.useLayoutEffect(() => { onChangeRef.current = onChange; });\n\n // Flag: was the last doc change initiated from inside CM6?\n // Used to skip the value-sync effect when we already have the latest content.\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((update: ViewUpdate) => {\n if (update.docChanged) {\n skipNextSync.current = true;\n onChangeRef.current(update.state.doc.toString());\n }\n });\n\n const view = new EditorView({\n state: EditorState.create({\n doc: value,\n extensions: [...buildExtensions(theme), 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 // Skip if CM6 itself caused this value change\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 // Don't push this onto the undo stack — it's an external change\n annotations: [],\n });\n }\n }, [value]);\n\n // ── Swap theme at runtime via Compartment (no remount needed) ────────\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\n ref={containerRef}\n className={className}\n style={{ height, ...style }}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/editor.ts","../src/commands.ts","../src/Toolbar.tsx","../src/InlineMarkdownEditor.tsx"],"names":["HIDE","Decoration","BulletWidget","WidgetType","s","ImageWidget","url","alt","other","img","span","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","syntaxTree","node","name","level","parentFrom","parentTo","m","markText","liveMarkdownDecorations","ViewPlugin","update","instance","darkTheme","EditorView","lightTheme","themeCompartment","Compartment","getThemeExtension","theme","buildExtensions","placeholderText","placeholderExt","markdown","markdownLanguage","history","keymap","defaultKeymap","historyKeymap","indentWithTab","drawSelection","dropCursor","rectangularSelection","crosshairCursor","wrap","before","after","placeholder","tr","text","EditorSelection","toggleBold","toggleItalic","toggleInlineCode","insertLink","selected","insert","urlStart","prefixLines","prefix","changes","seen","startLine","endLine","i","ln","toggleBulletList","toggleNumberedList","toggleQuote","insertImageMarkdown","pos","ICONS","Icon","jsx","Toolbar","getView","onImageUpload","fileRef","C","uploading","setUploading","palette","run","cmd","v","handleFile","e","file","err","btnStyle","Button","title","onClick","disabled","jsxs","Fragment","InlineMarkdownEditor","value","onChange","toolbar","className","style","height","containerRef","b","viewRef","onChangeRef","skipNextSync","updateListener","EditorState","current"],"mappings":"0nBAgBA,IAAMA,CAAAA,CAAOC,eAAAA,C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A,EACC1B,cAAAA,CAACC,EAAA,CACC,OAAA,CAAS,IAAM+B,CAAAA,CAAQ,QACvB,KAAA,CAAO5E,CAAAA,CACP,aAAA,CAAe+C,CAAAA,CACjB,EAEFH,cAAAA,CAAC,KAAA,CAAA,CAAI,GAAA,CAAK8B,CAAAA,CAAc,MAAO,CAAE,MAAA,CAAAD,CAAO,CAAA,CAAG,GAC7C,CAEJ","file":"index.cjs","sourcesContent":["// 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/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/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","// 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/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"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -7,11 +7,17 @@ type InlineMarkdownEditorProps = {
|
|
|
7
7
|
onChange: (next: string) => void;
|
|
8
8
|
/** Visual theme. Defaults to "dark". */
|
|
9
9
|
theme?: "dark" | "light";
|
|
10
|
+
/** Render the formatting toolbar above the editor. Defaults to false. */
|
|
11
|
+
toolbar?: boolean;
|
|
12
|
+
/** Upload handler. When provided, the toolbar shows an image button. */
|
|
13
|
+
onImageUpload?: (file: File) => Promise<string>;
|
|
14
|
+
/** Text shown when the document is empty. */
|
|
15
|
+
placeholder?: string;
|
|
10
16
|
/** Class applied to the outer container div */
|
|
11
17
|
className?: string;
|
|
12
18
|
/** Inline styles for the outer container div */
|
|
13
19
|
style?: React.CSSProperties;
|
|
14
|
-
/**
|
|
20
|
+
/** Editor height. Defaults to "100%". Accepts any CSS length. */
|
|
15
21
|
height?: string;
|
|
16
22
|
};
|
|
17
23
|
declare const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,17 @@ type InlineMarkdownEditorProps = {
|
|
|
7
7
|
onChange: (next: string) => void;
|
|
8
8
|
/** Visual theme. Defaults to "dark". */
|
|
9
9
|
theme?: "dark" | "light";
|
|
10
|
+
/** Render the formatting toolbar above the editor. Defaults to false. */
|
|
11
|
+
toolbar?: boolean;
|
|
12
|
+
/** Upload handler. When provided, the toolbar shows an image button. */
|
|
13
|
+
onImageUpload?: (file: File) => Promise<string>;
|
|
14
|
+
/** Text shown when the document is empty. */
|
|
15
|
+
placeholder?: string;
|
|
10
16
|
/** Class applied to the outer container div */
|
|
11
17
|
className?: string;
|
|
12
18
|
/** Inline styles for the outer container div */
|
|
13
19
|
style?: React.CSSProperties;
|
|
14
|
-
/**
|
|
20
|
+
/** Editor height. Defaults to "100%". Accepts any CSS length. */
|
|
15
21
|
height?: string;
|
|
16
22
|
};
|
|
17
23
|
declare const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as m from'react';import {Decoration,ViewPlugin,EditorView,WidgetType,keymap,drawSelection,dropCursor,rectangularSelection,crosshairCursor}from'@codemirror/view';import {Compartment,EditorState}from'@codemirror/state';import {markdown,markdownLanguage}from'@codemirror/lang-markdown';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {syntaxTree}from'@codemirror/language';import {jsx}from'react/jsx-runtime';var p=Decoration.replace({}),k=class extends WidgetType{toDOM(){let n=document.createElement("span");return n.textContent="\u2022",n.className="ob-list-mark",n}eq(){return true}};function l(a,n,d){for(let t of a.selection.ranges)if(t.from>=n&&t.to<=d||t.from<=d&&t.to>=n)return true;return false}function g(a,n){let d=a.doc.lineAt(n);for(let t of a.selection.ranges)if(t.from>=d.from&&t.from<=d.to)return true;return false}function E(a){let{state:n}=a,d=[],t=(i,r,o)=>{i<r&&d.push({from:i,to:r,deco:o});},c=i=>Decoration.mark({class:i});return syntaxTree(n).cursor().iterate(i=>{let{name:r,from:o,to:e}=i;if(/^ATXHeading[1-6]$/.test(r)){let s=r.slice(-1);t(o,e,c(`ob-h${s}`));}if(r==="HeaderMark"&&(g(n,o)?t(o,e,c("ob-syntax")):t(o,e,p)),r==="StrongEmphasis"&&(l(n,o,e)||t(o,e,c("ob-bold"))),r==="Emphasis"&&(l(n,o,e)||t(o,e,c("ob-italic"))),r==="EmphasisMark"){let s=i.node.parent?.from??o,f=i.node.parent?.to??e;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Strikethrough"&&(l(n,o,e)||t(o,e,c("ob-strikethrough"))),r==="StrikethroughMark"){let s=i.node.parent?.from??o,f=i.node.parent?.to??e;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="InlineCode"&&(l(n,o,e)||t(o,e,c("ob-code"))),r==="CodeMark"&&i.node.parent?.name==="InlineCode"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Link"&&(l(n,o,e)||t(o,e,c("ob-link"))),r==="LinkMark"&&i.node.parent?.name==="Link"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="URL"&&i.node.parent?.name==="Link"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Image"&&(l(n,o,e)||t(o,e,c("ob-image"))),r==="LinkMark"&&i.node.parent?.name==="Image"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="URL"&&i.node.parent?.name==="Image"){let s=i.node.parent.from,f=i.node.parent.to;l(n,s,f)?t(o,e,c("ob-syntax")):t(o,e,p);}if(r==="Blockquote"&&t(o,e,c("ob-blockquote")),r==="BlockquoteMark"&&(g(n,o),t(o,e,c("ob-blockquote-mark"))),r==="ListMark"){let s=n.doc.sliceString(o,e);(s==="-"||s==="*"||s==="+")&&!g(n,o)?t(o,e,Decoration.replace({widget:new k})):t(o,e,c("ob-list-mark"));}r==="FencedCode"&&t(o,e,c("ob-code-block")),r==="CodeMark"&&i.node.parent?.name==="FencedCode"&&t(o,e,c("ob-fence-mark")),r==="CodeInfo"&&t(o,e,c("ob-code-info")),r==="HorizontalRule"&&t(o,e,c("ob-hr"));}),Decoration.set(d.map(({from:i,to:r,deco:o})=>o.range(i,r)),true)}var C=ViewPlugin.fromClass(class{constructor(a){this.decorations=E(a);}update(a){(a.docChanged||a.selectionSet||a.viewportChanged||syntaxTree(a.startState)!==syntaxTree(a.state))&&(this.decorations=E(a.view));}},{decorations:a=>a.decorations});var w=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:true});var M=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:false});var x=new Compartment;function S(a){return a==="dark"?w:M}function F(a){return [markdown({base:markdownLanguage}),history(),keymap.of([...defaultKeymap,...historyKeymap,indentWithTab]),EditorView.lineWrapping,EditorView.contentAttributes.of({spellcheck:"true"}),drawSelection(),dropCursor(),rectangularSelection(),crosshairCursor(),C,x.of(S(a))]}var $=({value:a,onChange:n,theme:d="dark",className:t,style:c,height:i="100%"})=>{let r=m.useRef(null),o=m.useRef(null),e=m.useRef(n);m.useLayoutEffect(()=>{e.current=n;});let s=m.useRef(false);return m.useEffect(()=>{if(!r.current)return;let f=EditorView.updateListener.of(y=>{y.docChanged&&(s.current=true,e.current(y.state.doc.toString()));}),b=new EditorView({state:EditorState.create({doc:a,extensions:[...F(d),f]}),parent:r.current});return o.current=b,()=>{b.destroy(),o.current=null;}},[]),m.useEffect(()=>{let f=o.current;if(!f)return;if(s.current){s.current=false;return}let b=f.state.doc.toString();b!==a&&f.dispatch({changes:{from:0,to:b.length,insert:a},annotations:[]});},[a]),m.useEffect(()=>{let f=o.current;f&&f.dispatch({effects:x.reconfigure(S(d))});},[d]),jsx("div",{ref:r,className:t,style:{height:i,...c}})};export{$ as InlineMarkdownEditor};//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import*as b from'react';import {Decoration,ViewPlugin,EditorView,WidgetType,placeholder,keymap,drawSelection,dropCursor,rectangularSelection,crosshairCursor}from'@codemirror/view';import {Compartment,EditorState,EditorSelection}from'@codemirror/state';import {markdown,markdownLanguage}from'@codemirror/lang-markdown';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {syntaxTree}from'@codemirror/language';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var x=Decoration.replace({}),M=class extends WidgetType{toDOM(){let n=document.createElement("span");return n.textContent="\u2022",n.className="ob-list-mark",n}eq(){return true}},S=class extends WidgetType{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 true;return false}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 true;return false}function V(t){let{state:n}=t,a=[],e=(c,i,o)=>{c<i&&a.push({from:c,to:i,deco:o});},l=c=>Decoration.mark({class:c});return syntaxTree(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,Decoration.replace({widget:new S(s[2],s[1])})),false}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,Decoration.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"));}),Decoration.set(a.map(({from:c,to:i,deco:o})=>o.range(c,i)),true)}var F=ViewPlugin.fromClass(class{constructor(t){this.decorations=V(t);}update(t){(t.docChanged||t.selectionSet||t.viewportChanged||syntaxTree(t.startState)!==syntaxTree(t.state))&&(this.decorations=V(t.view));}},{decorations:t=>t.decorations});var W=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:true});var B=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:false});var R=new Compartment;function L(t){return t==="dark"?W:B}function D(t,n){return [...n?[placeholder(n)]:[],markdown({base:markdownLanguage}),history(),keymap.of([...defaultKeymap,...historyKeymap,indentWithTab]),EditorView.lineWrapping,EditorView.contentAttributes.of({spellcheck:"true"}),drawSelection(),dropCursor(),rectangularSelection(),crosshairCursor(),F,R.of(L(t))]}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:EditorSelection.range(i.from+n.length,i.from+n.length+r.length)}});t.dispatch(l.update(c,{scrollIntoView:true})),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:EditorSelection.range(i,i+3)}});t.dispatch(n.update(a,{scrollIntoView:true})),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:true})),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:true})),t.focus();}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 jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:me[t]})})}var K=({getView:t,theme:n,onImageUpload:a})=>{let e=b.useRef(null),[l,c]=b.useState(false),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(true);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(false);}}},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})=>jsx("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:jsx(pe,{name:h})});return jsxs("div",{style:{display:"flex",gap:"2px",flexWrap:"wrap",padding:"5px 8px",background:i.bg,borderBottom:`1px solid ${i.border}`},children:[jsx(s,{name:"bold",title:"Bold",onClick:o(q)}),jsx(s,{name:"italic",title:"Italic",onClick:o(P)}),jsx(s,{name:"link",title:"Link",onClick:o(U)}),jsx(s,{name:"bullet",title:"Bullet list",onClick:o($)}),jsx(s,{name:"numbered",title:"Numbered list",onClick:o(A)}),jsx(s,{name:"quote",title:"Quote",onClick:o(J)}),jsx(s,{name:"code",title:"Inline code",onClick:o(N)}),a&&jsxs(Fragment,{children:[jsx(s,{name:"image",title:"Upload image",disabled:l,onClick:()=>e.current?.click()}),jsx("input",{ref:e,type:"file",accept:"image/*",onChange:r,style:{display:"none"}})]})]})};var be=({value:t,onChange:n,theme:a="dark",toolbar:e=false,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(false);return b.useEffect(()=>{if(!d.current)return;let f=EditorView.updateListener.of(k=>{k.docChanged&&(p.current=true,h.current(k.state.doc.toString()));}),u=new EditorView({state:EditorState.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=false;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]),jsxs("div",{className:i,style:o,children:[e&&jsx(K,{getView:()=>s.current,theme:a,onImageUpload:l}),jsx("div",{ref:d,style:{height:r}})]})};export{be as InlineMarkdownEditor};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/editor.ts","../src/InlineMarkdownEditor.tsx"],"names":["HIDE","Decoration","BulletWidget","WidgetType","s","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","syntaxTree","node","name","level","parentFrom","parentTo","markText","liveMarkdownDecorations","ViewPlugin","update","instance","darkTheme","EditorView","lightTheme","themeCompartment","Compartment","getThemeExtension","theme","buildExtensions","markdown","markdownLanguage","history","keymap","defaultKeymap","historyKeymap","indentWithTab","drawSelection","dropCursor","rectangularSelection","crosshairCursor","InlineMarkdownEditor","value","onChange","className","style","height","containerRef","viewRef","onChangeRef","skipNextSync","updateListener","EditorState","current","jsx"],"mappings":"ycAgBA,IAAMA,CAAAA,CAAOC,WAAW,OAAA,CAAQ,EAAE,CAAA,CAG5BC,CAAAA,CAAN,cAA2BC,UAAW,CACpC,OAAqB,CACnB,IAAMC,EAAI,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA,CACvC,OAAAA,EAAE,WAAA,CAAc,QAAA,CAChBA,EAAE,SAAA,CAAY,cAAA,CACPA,CACT,CACA,EAAA,EAAc,CACZ,OAAO,KACT,CACF,CAAA,CAIA,SAASC,EAAgBC,CAAAA,CAAoBC,CAAAA,CAAcC,EAAqB,CAC9E,IAAA,IAAWC,KAASH,CAAAA,CAAM,SAAA,CAAU,OAElC,GADIG,CAAAA,CAAM,MAAQF,CAAAA,EAAQE,CAAAA,CAAM,IAAMD,CAAAA,EA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AAA,CACC,IAAKP,CAAAA,CACL,SAAA,CAAWH,EACX,KAAA,CAAO,CAAE,OAAAE,CAAAA,CAAQ,GAAGD,CAAM,CAAA,CAC5B,CAEJ","file":"index.mjs","sourcesContent":["// 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\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 if (!isCursorInRange(state, from, to)) {\n add(from, to, mark(\"ob-image\"));\n }\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/editor.ts\nimport { markdown, markdownLanguage } from \"@codemirror/lang-markdown\";\nimport { history, defaultKeymap, historyKeymap, indentWithTab } from \"@codemirror/commands\";\nimport { EditorView, keymap, drawSelection, dropCursor, rectangularSelection, crosshairCursor } 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(theme: \"dark\" | \"light\"): Extension[] {\n return [\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/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\";\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 /** Class applied to the outer container div */\n className?: string;\n /** Inline styles for the outer container div */\n style?: React.CSSProperties;\n /** Initial height. Defaults to \"100%\". Override with a px/vh value. */\n height?: string;\n};\n\nexport const InlineMarkdownEditor: React.FC<InlineMarkdownEditorProps> = ({\n value,\n onChange,\n theme = \"dark\",\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 // Keep onChange stable in a ref so the CM6 listener never goes stale\n const onChangeRef = React.useRef(onChange);\n React.useLayoutEffect(() => { onChangeRef.current = onChange; });\n\n // Flag: was the last doc change initiated from inside CM6?\n // Used to skip the value-sync effect when we already have the latest content.\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((update: ViewUpdate) => {\n if (update.docChanged) {\n skipNextSync.current = true;\n onChangeRef.current(update.state.doc.toString());\n }\n });\n\n const view = new EditorView({\n state: EditorState.create({\n doc: value,\n extensions: [...buildExtensions(theme), 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 // Skip if CM6 itself caused this value change\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 // Don't push this onto the undo stack — it's an external change\n annotations: [],\n });\n }\n }, [value]);\n\n // ── Swap theme at runtime via Compartment (no remount needed) ────────\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\n ref={containerRef}\n className={className}\n style={{ height, ...style }}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/decorations.ts","../src/theme-dark.ts","../src/theme-light.ts","../src/editor.ts","../src/commands.ts","../src/Toolbar.tsx","../src/InlineMarkdownEditor.tsx"],"names":["HIDE","Decoration","BulletWidget","WidgetType","s","ImageWidget","url","alt","other","img","span","isCursorInRange","state","from","to","range","isCursorOnLine","line","buildDecorations","view","entries","add","deco","mark","cls","syntaxTree","node","name","level","parentFrom","parentTo","m","markText","liveMarkdownDecorations","ViewPlugin","update","instance","darkTheme","EditorView","lightTheme","themeCompartment","Compartment","getThemeExtension","theme","buildExtensions","placeholderText","placeholderExt","markdown","markdownLanguage","history","keymap","defaultKeymap","historyKeymap","indentWithTab","drawSelection","dropCursor","rectangularSelection","crosshairCursor","wrap","before","after","placeholder","tr","text","EditorSelection","toggleBold","toggleItalic","toggleInlineCode","insertLink","selected","insert","urlStart","prefixLines","prefix","changes","seen","startLine","endLine","i","ln","toggleBulletList","toggleNumberedList","toggleQuote","insertImageMarkdown","pos","ICONS","Icon","jsx","Toolbar","getView","onImageUpload","fileRef","C","uploading","setUploading","palette","run","cmd","v","handleFile","e","file","err","btnStyle","Button","title","onClick","disabled","jsxs","Fragment","InlineMarkdownEditor","value","onChange","toolbar","className","style","height","containerRef","viewRef","onChangeRef","skipNextSync","updateListener","EditorState","current"],"mappings":"mfAgBA,IAAMA,CAAAA,CAAOC,UAAAA,CAAW,OAAA,CAAQ,EAAE,CAAA,CAG5BC,CAAAA,CAAN,cAA2BC,UAAW,CACpC,KAAA,EAAqB,CACnB,IAAMC,EAAI,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA,CACvC,OAAAA,CAAAA,CAAE,WAAA,CAAc,QAAA,CAChBA,EAAE,SAAA,CAAY,cAAA,CACPA,CACT,CACA,IAAc,CACZ,OAAO,KACT,CACF,EAGMC,CAAAA,CAAN,cAA0BF,UAAW,CACnC,WAAA,CACWG,CAAAA,CACAC,CAAAA,CACT,CACA,OAAM,CAHG,IAAA,CAAA,GAAA,CAAAD,CAAAA,CACA,IAAA,CAAA,GAAA,CAAAC,EAGX,CACA,EAAA,CAAGC,CAAAA,CAA6B,CAC9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I,CAACnG,CAAAA,CAAM,OAEX,GAAIqG,CAAAA,CAAa,QAAS,CACxBA,CAAAA,CAAa,OAAA,CAAU,KAAA,CACvB,MACF,CAEA,IAAMG,CAAAA,CAAUxG,CAAAA,CAAK,MAAM,GAAA,CAAI,QAAA,EAAS,CACpCwG,CAAAA,GAAYZ,GACd5F,CAAAA,CAAK,QAAA,CAAS,CACZ,OAAA,CAAS,CAAE,IAAA,CAAM,CAAA,CAAG,EAAA,CAAIwG,EAAQ,MAAA,CAAQ,MAAA,CAAQZ,CAAM,CAAA,CACtD,YAAa,EACf,CAAC,EAEL,EAAG,CAACA,CAAK,CAAC,CAAA,CAGJ,YAAU,IAAM,CACpB,IAAM5F,CAAAA,CAAOmG,EAAQ,OAAA,CAChBnG,CAAAA,EACLA,CAAAA,CAAK,QAAA,CAAS,CACZ,OAAA,CAASqB,CAAAA,CAAiB,WAAA,CAAYE,CAAAA,CAAkBC,CAAK,CAAC,CAChE,CAAC,EACH,CAAA,CAAG,CAACA,CAAK,CAAC,EAGRiE,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAWM,CAAAA,CAAW,MAAOC,CAAAA,CAC/B,QAAA,CAAA,CAAAF,CAAAA,EACC1B,GAAAA,CAACC,EAAA,CACC,OAAA,CAAS,IAAM8B,CAAAA,CAAQ,QACvB,KAAA,CAAO3E,CAAAA,CACP,aAAA,CAAe+C,CAAAA,CACjB,EAEFH,GAAAA,CAAC,KAAA,CAAA,CAAI,GAAA,CAAK8B,CAAAA,CAAc,MAAO,CAAE,MAAA,CAAAD,CAAO,CAAA,CAAG,GAC7C,CAEJ","file":"index.mjs","sourcesContent":["// 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/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/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","// 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/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"]}
|
package/package.json
CHANGED