@avocadostudio-ai/cli 0.24.0 → 0.26.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.
@@ -1 +1 @@
1
- import{P as u}from"./chunk-2CNEFIQP-BCM0jyMr.js";import{g as p,s as f,i as l}from"./PuckPrototypeRoute-BMFSrgRi.js";import{g as d}from"./index-C8b9WNzA.js";import{a4 as h,a5 as w,a6 as g,r as s,j as m}from"./index-BWf4GeHX.js";function y(e,t,r){if(typeof window>"u")throw new Error("getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=g.fromSchema(t).serializeFragment(e.content,{document:window.document});return new XMLSerializer().serializeToString(n)}function x(e,t){if(typeof window>"u")throw new Error("generateHTML can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const r=d(t),n=w.fromJSON(r,e);return y(n,r)}function v(e,t,r){if(typeof window>"u")throw new Error("generateJSON can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=d(t),o=new window.DOMParser().parseFromString(e,"text/html");if(!o)throw new Error("Failed to parse HTML string");return h.fromSchema(n).parse(o.body,r).toJSON()}l();var M=p("RichTextEditor",f);function z({content:e,field:t}){const{tiptap:r={},options:n}=t,{extensions:o=[]}=r,i=s.useMemo(()=>[u.configure(n),...o],[t,o]),a=s.useMemo(()=>typeof e=="object"&&(e==null?void 0:e.type)==="doc"?e:typeof e=="string"?/<\/?[a-z][\s\S]*>/i.test(e)?v(e,i):{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}:{type:"doc",content:[]},[e,i]),c=s.useMemo(()=>x(a,i),[a,i]);return m.jsx("div",{className:M(),children:m.jsx("div",{className:"rich-text",dangerouslySetInnerHTML:{__html:c}})})}export{z as RichTextRender};
1
+ import{P as u}from"./chunk-2CNEFIQP-kdd7MquI.js";import{g as p,s as f,i as l}from"./PuckPrototypeRoute-CFwlZaQP.js";import{g as d}from"./index-bSPYizZ6.js";import{a4 as h,a5 as w,a6 as g,r as s,j as m}from"./index-Cy-PEt_d.js";function y(e,t,r){if(typeof window>"u")throw new Error("getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=g.fromSchema(t).serializeFragment(e.content,{document:window.document});return new XMLSerializer().serializeToString(n)}function x(e,t){if(typeof window>"u")throw new Error("generateHTML can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const r=d(t),n=w.fromJSON(r,e);return y(n,r)}function v(e,t,r){if(typeof window>"u")throw new Error("generateJSON can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=d(t),o=new window.DOMParser().parseFromString(e,"text/html");if(!o)throw new Error("Failed to parse HTML string");return h.fromSchema(n).parse(o.body,r).toJSON()}l();var M=p("RichTextEditor",f);function z({content:e,field:t}){const{tiptap:r={},options:n}=t,{extensions:o=[]}=r,i=s.useMemo(()=>[u.configure(n),...o],[t,o]),a=s.useMemo(()=>typeof e=="object"&&(e==null?void 0:e.type)==="doc"?e:typeof e=="string"?/<\/?[a-z][\s\S]*>/i.test(e)?v(e,i):{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}:{type:"doc",content:[]},[e,i]),c=s.useMemo(()=>x(a,i),[a,i]);return m.jsx("div",{className:M(),children:m.jsx("div",{className:"rich-text",dangerouslySetInnerHTML:{__html:c}})})}export{z as RichTextRender};
@@ -1,4 +1,4 @@
1
- import{b as K,i as de}from"./PuckPrototypeRoute-BMFSrgRi.js";import{N as b,w as A,m as k,M as x,a as M,b as T,t as R,n as ce,c as pe,i as he,d as fe,e as me,f as ge,h as ke,j as ye,r as Y,E as _,k as B,l as be,o as ve,p as Z,q as Le,s as Me,u as W}from"./index-C8b9WNzA.js";import{a7 as P,a8 as $,a9 as I,aa as Ae,ab as Te,ac as xe,ad as U,ae as Ce,af as Q}from"./index-BWf4GeHX.js";var H=(e,t)=>{if(e==="slot")return 0;if(e instanceof Function)return e(t);const{children:n,...r}=t??{};if(e==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},Ie=/^\s*>\s$/,we=b.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return H("blockquote",{...k(this.options.HTMLAttributes,e),children:H("slot",{})})},parseMarkdown:(e,t)=>{var n;const r=(n=t.parseBlockChildren)!=null?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";const n=">",r=[];return e.content.forEach((s,o)=>{var i,a;const p=((a=(i=t.renderChild)==null?void 0:i.call(t,s,o))!=null?a:t.renderChildren([s])).split(`
1
+ import{b as K,i as de}from"./PuckPrototypeRoute-CFwlZaQP.js";import{N as b,w as A,m as k,M as x,a as M,b as T,t as R,n as ce,c as pe,i as he,d as fe,e as me,f as ge,h as ke,j as ye,r as Y,E as _,k as B,l as be,o as ve,p as Z,q as Le,s as Me,u as W}from"./index-bSPYizZ6.js";import{a7 as P,a8 as $,a9 as I,aa as Ae,ab as Te,ac as xe,ad as U,ae as Ce,af as Q}from"./index-Cy-PEt_d.js";var H=(e,t)=>{if(e==="slot")return 0;if(e instanceof Function)return e(t);const{children:n,...r}=t??{};if(e==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},Ie=/^\s*>\s$/,we=b.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return H("blockquote",{...k(this.options.HTMLAttributes,e),children:H("slot",{})})},parseMarkdown:(e,t)=>{var n;const r=(n=t.parseBlockChildren)!=null?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";const n=">",r=[];return e.content.forEach((s,o)=>{var i,a;const p=((a=(i=t.renderChild)==null?void 0:i.call(t,s,o))!=null?a:t.renderChildren([s])).split(`
2
2
  `).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(p.join(`
3
3
  `))}),r.join(`
4
4
  ${n}
@@ -1 +1 @@
1
- import{b as E,c as M,i as z}from"./PuckPrototypeRoute-BMFSrgRi.js";import{a as U}from"./index-DxOQxIUC.js";import{r as H,j as J}from"./index-BWf4GeHX.js";import"./index-C8b9WNzA.js";z();z();var w=(o,i)=>{var e,r,u,n,a,c,s,g,d,v,_,A,x,f,B,k,p,L,m,h,C,R,S,j,I,T,b,q;const t=o.editor;if(!t)return{};const l=()=>t.can().chain();return{isAlignLeft:t.isActive({textAlign:"left"}),canAlignLeft:!i&&((r=(e=l()).setTextAlign)==null?void 0:r.call(e,"left").run()),isAlignCenter:t.isActive({textAlign:"center"}),canAlignCenter:!i&&((n=(u=l()).setTextAlign)==null?void 0:n.call(u,"center").run()),isAlignRight:t.isActive({textAlign:"right"}),canAlignRight:!i&&((c=(a=l()).setTextAlign)==null?void 0:c.call(a,"right").run()),isAlignJustify:t.isActive({textAlign:"justify"}),canAlignJustify:!i&&((g=(s=l()).setTextAlign)==null?void 0:g.call(s,"justify").run()),isBold:t.isActive("bold"),canBold:!i&&((v=(d=l()).toggleBold)==null?void 0:v.call(d).run()),isItalic:t.isActive("italic"),canItalic:!i&&((A=(_=l()).toggleItalic)==null?void 0:A.call(_).run()),isUnderline:t.isActive("underline"),canUnderline:!i&&((f=(x=l()).toggleUnderline)==null?void 0:f.call(x).run()),isStrike:t.isActive("strike"),canStrike:!i&&((k=(B=l()).toggleStrike)==null?void 0:k.call(B).run()),isInlineCode:t.isActive("code"),canInlineCode:!i&&((L=(p=l()).toggleCode)==null?void 0:L.call(p).run()),isBulletList:t.isActive("bulletList"),canBulletList:!i&&((h=(m=l()).toggleBulletList)==null?void 0:h.call(m).run()),isOrderedList:t.isActive("orderedList"),canOrderedList:!i&&((R=(C=l()).toggleOrderedList)==null?void 0:R.call(C).run()),isCodeBlock:t.isActive("codeBlock"),canCodeBlock:!i&&((j=(S=l()).toggleCodeBlock)==null?void 0:j.call(S).run()),isBlockquote:t.isActive("blockquote"),canBlockquote:!i&&((T=(I=l()).toggleBlockquote)==null?void 0:T.call(I).run()),canHorizontalRule:!i&&((q=(b=l()).setHorizontalRule)==null?void 0:q.call(b).run())}},K=({editor:o,field:i,readOnly:e,inline:r})=>{const{tiptap:u={}}=i,{selector:n}=u,a=H.useMemo(()=>s=>E(E({},w(s,e)),n?n(s,e):{}),[n,e]),c=U({editor:o,selector:a});return!o||!c?null:J.jsx(M,{editor:o,editorState:c,field:i,readOnly:e,inline:r})};export{K as LoadedRichTextMenuFull};
1
+ import{b as E,c as M,i as z}from"./PuckPrototypeRoute-CFwlZaQP.js";import{a as U}from"./index-BI9xm3sn.js";import{r as H,j as J}from"./index-Cy-PEt_d.js";import"./index-bSPYizZ6.js";z();z();var w=(o,i)=>{var e,r,u,n,a,c,s,g,d,v,_,A,x,f,B,k,p,L,m,h,C,R,S,j,I,T,b,q;const t=o.editor;if(!t)return{};const l=()=>t.can().chain();return{isAlignLeft:t.isActive({textAlign:"left"}),canAlignLeft:!i&&((r=(e=l()).setTextAlign)==null?void 0:r.call(e,"left").run()),isAlignCenter:t.isActive({textAlign:"center"}),canAlignCenter:!i&&((n=(u=l()).setTextAlign)==null?void 0:n.call(u,"center").run()),isAlignRight:t.isActive({textAlign:"right"}),canAlignRight:!i&&((c=(a=l()).setTextAlign)==null?void 0:c.call(a,"right").run()),isAlignJustify:t.isActive({textAlign:"justify"}),canAlignJustify:!i&&((g=(s=l()).setTextAlign)==null?void 0:g.call(s,"justify").run()),isBold:t.isActive("bold"),canBold:!i&&((v=(d=l()).toggleBold)==null?void 0:v.call(d).run()),isItalic:t.isActive("italic"),canItalic:!i&&((A=(_=l()).toggleItalic)==null?void 0:A.call(_).run()),isUnderline:t.isActive("underline"),canUnderline:!i&&((f=(x=l()).toggleUnderline)==null?void 0:f.call(x).run()),isStrike:t.isActive("strike"),canStrike:!i&&((k=(B=l()).toggleStrike)==null?void 0:k.call(B).run()),isInlineCode:t.isActive("code"),canInlineCode:!i&&((L=(p=l()).toggleCode)==null?void 0:L.call(p).run()),isBulletList:t.isActive("bulletList"),canBulletList:!i&&((h=(m=l()).toggleBulletList)==null?void 0:h.call(m).run()),isOrderedList:t.isActive("orderedList"),canOrderedList:!i&&((R=(C=l()).toggleOrderedList)==null?void 0:R.call(C).run()),isCodeBlock:t.isActive("codeBlock"),canCodeBlock:!i&&((j=(S=l()).toggleCodeBlock)==null?void 0:j.call(S).run()),isBlockquote:t.isActive("blockquote"),canBlockquote:!i&&((T=(I=l()).toggleBlockquote)==null?void 0:T.call(I).run()),canHorizontalRule:!i&&((q=(b=l()).setHorizontalRule)==null?void 0:q.call(b).run())}},K=({editor:o,field:i,readOnly:e,inline:r})=>{const{tiptap:u={}}=i,{selector:n}=u,a=H.useMemo(()=>s=>E(E({},w(s,e)),n?n(s,e):{}),[n,e]),c=U({editor:o,selector:a});return!o||!c?null:J.jsx(M,{editor:o,editorState:c,field:i,readOnly:e,inline:r})};export{K as LoadedRichTextMenuFull};
@@ -1 +1 @@
1
- import{o as u,r as o,ag as l,ah as b,ai as C,j as a,aj as E}from"./index-BWf4GeHX.js";import{v as S}from"./index-C8b9WNzA.js";var g=(...n)=>t=>{n.forEach(r=>{typeof r=="function"?r(t):r&&(r.current=t)})},w=({contentComponent:n})=>{const t=l.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(t)})};function y(){const n=new Set;let t={};return{subscribe(r){return n.add(r),()=>{n.delete(r)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(r,e){t={...t,[r]:E.createPortal(e.reactElement,e.element,r)},n.forEach(i=>i())},removeRenderer(r){const e={...t};delete e[r],t=e,n.forEach(i=>i())}}}var x=class extends u.Component{constructor(n){var t;super(n),this.editorContentRef=u.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((t=n.editor)!=null&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const t=this.props.editor;if(t&&!t.isDestroyed&&((n=t.view.dom)!=null&&n.parentNode)){if(t.contentComponent)return;const r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),t.contentComponent=y(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!((n=t.view.dom)!=null&&n.parentNode))return;const r=document.createElement("div");r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r})}catch{}}}render(){const{editor:n,innerRef:t,...r}=this.props;return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:g(t,this.editorContentRef),...r}),(n==null?void 0:n.contentComponent)&&a.jsx(w,{contentComponent:n.contentComponent})]})}},D=o.forwardRef((n,t)=>{const r=u.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return u.createElement(x,{key:r,innerRef:t,...n})}),R=u.memo(D),T=typeof window<"u"?o.useLayoutEffect:o.useEffect,_=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}};function N(n){var t;const[r]=o.useState(()=>new _(n.editor)),e=b.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,n.selector,(t=n.equalityFn)!=null?t:C);return T(()=>r.watch(n.editor),[n.editor,r]),o.useDebugValue(e),e}var I=!1,d=typeof window>"u",M=d||!!(typeof window<"u"&&window.next),j=class p{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?d||M?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...e)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...e)},onBlur:(...e)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...e)},onCreate:(...e)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...e)},onDestroy:(...e)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...e)},onFocus:(...e)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...e)},onSelectionUpdate:(...e)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...e)},onTransaction:(...e)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...e)},onUpdate:(...e)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...e)},onContentError:(...e)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...e)},onDrop:(...e)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...e)},onPaste:(...e)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...e)},onDelete:(...e)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...e)}};return new S(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,r){return Object.keys(t).every(e=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(e)?!0:e==="extensions"&&t.extensions&&r.extensions?t.extensions.length!==r.extensions.length?!1:t.extensions.every((i,s)=>{var h;return i===((h=r.extensions)==null?void 0:h[s])}):t[e]===r[e])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?p.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((e,i)=>e===t[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===t&&this.setEditor(null))},1)}};function z(n={},t=[]){const r=o.useRef(n);r.current=n;const[e]=o.useState(()=>new j(r)),i=l.useSyncExternalStore(e.subscribe,e.getEditor,e.getServerSnapshot);return o.useDebugValue(i),o.useEffect(e.onRender(t)),N({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&s===0?0:s+1}),i}var f=o.createContext({editor:null});f.Consumer;var O=o.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),V=()=>o.useContext(O);u.forwardRef((n,t)=>{const{onDragStart:r}=V(),e=n.as||"div";return a.jsx(e,{...n,ref:t,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...n.style}})});u.createContext({markViewContentRef:()=>{}});var c=o.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});c.displayName="TiptapContext";var P=()=>o.useContext(c);function v({editor:n,instance:t,children:r}){const e=n??t;if(!e)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=o.useMemo(()=>({editor:e}),[e]),s=o.useMemo(()=>({editor:e}),[e]);return a.jsx(f.Provider,{value:s,children:a.jsx(c.Provider,{value:i,children:r})})}v.displayName="Tiptap";function m({...n}){const{editor:t}=P();return a.jsx(R,{editor:t,...n})}m.displayName="Tiptap.Content";Object.assign(v,{Content:m});export{R as E,N as a,z as u};
1
+ import{o as u,r as o,ag as l,ah as b,ai as C,j as a,aj as E}from"./index-Cy-PEt_d.js";import{v as S}from"./index-bSPYizZ6.js";var g=(...n)=>t=>{n.forEach(r=>{typeof r=="function"?r(t):r&&(r.current=t)})},w=({contentComponent:n})=>{const t=l.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(t)})};function y(){const n=new Set;let t={};return{subscribe(r){return n.add(r),()=>{n.delete(r)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(r,e){t={...t,[r]:E.createPortal(e.reactElement,e.element,r)},n.forEach(i=>i())},removeRenderer(r){const e={...t};delete e[r],t=e,n.forEach(i=>i())}}}var x=class extends u.Component{constructor(n){var t;super(n),this.editorContentRef=u.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((t=n.editor)!=null&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const t=this.props.editor;if(t&&!t.isDestroyed&&((n=t.view.dom)!=null&&n.parentNode)){if(t.contentComponent)return;const r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),t.contentComponent=y(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!((n=t.view.dom)!=null&&n.parentNode))return;const r=document.createElement("div");r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r})}catch{}}}render(){const{editor:n,innerRef:t,...r}=this.props;return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:g(t,this.editorContentRef),...r}),(n==null?void 0:n.contentComponent)&&a.jsx(w,{contentComponent:n.contentComponent})]})}},D=o.forwardRef((n,t)=>{const r=u.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return u.createElement(x,{key:r,innerRef:t,...n})}),R=u.memo(D),T=typeof window<"u"?o.useLayoutEffect:o.useEffect,_=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}};function N(n){var t;const[r]=o.useState(()=>new _(n.editor)),e=b.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,n.selector,(t=n.equalityFn)!=null?t:C);return T(()=>r.watch(n.editor),[n.editor,r]),o.useDebugValue(e),e}var I=!1,d=typeof window>"u",M=d||!!(typeof window<"u"&&window.next),j=class p{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?d||M?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...e)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...e)},onBlur:(...e)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...e)},onCreate:(...e)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...e)},onDestroy:(...e)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...e)},onFocus:(...e)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...e)},onSelectionUpdate:(...e)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...e)},onTransaction:(...e)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...e)},onUpdate:(...e)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...e)},onContentError:(...e)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...e)},onDrop:(...e)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...e)},onPaste:(...e)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...e)},onDelete:(...e)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...e)}};return new S(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,r){return Object.keys(t).every(e=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(e)?!0:e==="extensions"&&t.extensions&&r.extensions?t.extensions.length!==r.extensions.length?!1:t.extensions.every((i,s)=>{var h;return i===((h=r.extensions)==null?void 0:h[s])}):t[e]===r[e])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?p.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((e,i)=>e===t[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===t&&this.setEditor(null))},1)}};function z(n={},t=[]){const r=o.useRef(n);r.current=n;const[e]=o.useState(()=>new j(r)),i=l.useSyncExternalStore(e.subscribe,e.getEditor,e.getServerSnapshot);return o.useDebugValue(i),o.useEffect(e.onRender(t)),N({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&s===0?0:s+1}),i}var f=o.createContext({editor:null});f.Consumer;var O=o.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),V=()=>o.useContext(O);u.forwardRef((n,t)=>{const{onDragStart:r}=V(),e=n.as||"div";return a.jsx(e,{...n,ref:t,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...n.style}})});u.createContext({markViewContentRef:()=>{}});var c=o.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});c.displayName="TiptapContext";var P=()=>o.useContext(c);function v({editor:n,instance:t,children:r}){const e=n??t;if(!e)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=o.useMemo(()=>({editor:e}),[e]),s=o.useMemo(()=>({editor:e}),[e]);return a.jsx(f.Provider,{value:s,children:a.jsx(c.Provider,{value:i,children:r})})}v.displayName="Tiptap";function m({...n}){const{editor:t}=P();return a.jsx(R,{editor:t,...n})}m.displayName="Tiptap.Content";Object.assign(v,{Content:m});export{R as E,N as a,z as u};