@tiptap/cli 3.19.4 → 3.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -1,45 +1,41 @@
1
- # Tiptap – Pro License for Extensions, UI Components and Templates
1
+ # Tiptap pro license for extensions, UI components and templates
2
2
 
3
- ## 1. Object of License
3
+ Last updated October 20, 2026
4
4
 
5
- 1.1. These License Terms ("License Terms") consists of the terms and conditions governing the perpetual grant of use rights and use of the software products Tiptap Pro Extensions, Tiptap Pro UI Components and Tiptap Pro Templates ("Software") provided by Tiptap GmbH ("Licensor") by a user of the Software acting as entrepreneurs within the meaning of section 14 German Civil Code (BGB) ("End User") for the provision of the Software. Consumers as defined in section 13 German Civil Code (BGB) are not offered the use of the Software and the conclusion of these License Terms.
6
- 1.2. These License Terms are a legally binding agreement between the Licensor and all End Users. Other terms and conditions, in particular those of the End User, do not apply.
5
+ ## 1. OBJECT OF LICENSE
7
6
 
8
- ## 2. Grant of Use Rights
7
+ 1.1 These License Terms ("License Terms") consist of the terms and conditions governing the provision of Tiptap Pro Extensions, Tiptap Pro UI Components, Tiptap Pro Templates and other add-ons ("Pro Software"), by Tiptap GmbH ("Licensor") to its customers who are entrepreneurs within the meaning of section 14 German Civil Code (BGB) ("Customer") and the grant of use rights to the Pro Software, limited to the term of the respective Subscription. Extensions, UI components, templates and other software of the Licensor that are made available under an open-source license, in particular the MIT License, are not Pro Software, even if they are used together with the Pro Software; their use is governed exclusively by the respective open-source license. Consumers as defined in section 13 German Civil Code (BGB) are not offered the use of the Pro Software and the conclusion of these License Terms.
9
8
 
10
- 2.1. Upon full payment of the license fee, the Licensor will grant the End User the non-exclusive, non-sublicensable, non-transferable, unlimited in time to use the Software in accordance with this License Terms for their use within the scope of their business operations.
11
- 2.2. The End User's right of use includes the installation of the Software as well as loading, displaying, and running the installed Software, storing the Software in the memory for the purpose of executing it and the further development of the Software. The End User may use and/or integrate the Software in other software products and create derivative works of the Software.
12
- 2.3. The End User may distribute such further developments and the created derivative works of the Software in accordance with the following:
13
- 2.3.1. The End User may not distribute the Software, any parts of it, any modifications, or derivative works of the Software as a standalone product, but only as part of another software product or application.
14
- 2.3.2. The End User may not make the Software or parts of it available under a license that supersedes or negates the effect of this License Terms.
15
- 2.3.3. The End User may only distribute or otherwise make available the Software as part of another software product or application if these License Terms are agreed with users of software products or applications, which include the Software. In particular, the End User must include a copy of this License in any distribution or otherwise making available of the Software as part of another software product or application.
16
- 2.4. The Licensor does not grant the End User any further rights to the Software.
17
- 2.5. Using the Software in the name or for the account of a third party who is not the contractual partner is also considered unauthorized use of the Software. It is irrelevant here whether the third party pays the End User a fee for use or not.
9
+ 1.2 "Subscription" means a Subscription or an Add-on within the meaning of Section 2.4 of the ToS the paid subscription with a fixed term booked by the Customer that includes the use of the Pro Software, including where it forms part of a contract for other services of the Licensor, such as Tiptap Cloud. Tiptap Cloud is not Pro Software within the meaning of these License Terms.
18
10
 
19
- ## 3. Defects of the Software
11
+ 1.3 These License Terms supplement the Licensor's Terms of Service ("ToS"), which govern the provision of Tiptap Cloud as software as a service ("SaaS") and/or as on-premises software. Only Sections 1.3, 2, 3, 5.4, 6.1 to 6.4 and 6.6, 7 to 9, 10.1 to 10.4, 10.6, 10.7 and 11 to 15 of the ToS apply accordingly to the Pro Software. Terms not defined in these License Terms have the meaning given to them in the ToS.
20
12
 
21
- 3.1. The End User shall notify the Licensor of any defects without delay, reproducibly stating how and under what circumstances the error or defect occurs. The End User will actively support the Licensor in the search for the defect and, in particular, provide all further necessary documents and data which the Licensor requires for the analysis and elimination of the defect. If, after examination of a notice of defect, it turns out that the defect did not occur within the Licensor's area of responsibility, the Licensor may charge the End User for the costs of the examination at the respective applicable prices. This does not apply if the End User could not have recognized that the fault was not within the Licensor's area of responsibility when exercising the necessary diligence.
22
- 3.2. The End User must inspect the Software for obvious defects immediately upon receipt and notify the Licensor of any such defects without delay; otherwise, a warranty for these defects is excluded. The same applies if such a defect is discovered later. Section 377 of the German Commercial Code shall apply.
23
- 3.3. In the event of a defect, the Licensor is initially entitled to subsequent performance, i.e. at his own discretion to rectification of the defect or replacement delivery. As part of the replacement delivery, the End User shall, if necessary, accept a new version of the Software, unless this leads to unreasonable impairments. The End User's right to reduce the purchase price or withdraw from the contractual relationship regarding software purchase concluded with the Licensor at his discretion in the event that the repair or replacement delivery fails twice remains unaffected. The End User is not entitled to withdrawal in the case of insignificant defects.
24
- 3.4. The End User is not entitled to any defect rights insofar as the End User modifies the Software or has it modified by third parties, unless the End User proves that this modification is not the cause of the defect.
13
+ 1.4 These License Terms, together with the ToS, are integral parts of the Contract between the Licensor and the Customer. Other terms and conditions, in particular those of the Customer, do not apply, even if the Licensor does not expressly object to their application or performs its services in knowledge of such terms. In the event of conflicts, these License Terms take precedence over the ToS with respect to the scope of the use rights to the Pro Software, the distribution of the Pro Software and the creation of Derivative Works; in all other respects, the ToS take precedence.
25
14
 
26
- ## 4. Liability
15
+ ## 2. GRANT OF USE RIGHTS
27
16
 
28
- 4.1. The Licensor will be liable pursuant to statutory rules (a) in the event of intentional and grossly negligent damage; (b) in the event of injury to life, body or health; (c) under the provisions of the German Product Liability Act; and (d) within the scope of any guarantee assumed.
29
- 4.2. For simple negligent breach of a contractual duty which is material to achieve the purpose of the contract, and which the End User relies on and is entitled to rely on being fulfilled (material contractual obligations), the Licensor's liability will be limited in terms of the amount to the foreseeable damage and damage typical for such contracts. Otherwise, the Licensor's liability is precluded.
30
- 4.3. The above liability restrictions also apply accordingly in favor of the Licensor's vicarious agents.
31
- 4.4. In the event of loss of data, the Licensor will only be liable for the time and effort required to restore the data, subject to proper data backup by the End User.
17
+ 2.1 Subject to payment of the agreed fees in accordance with Section 9 of the ToS or, during a Trial Period, in accordance with Section 3 of the ToS, the Licensor will grant the Customer the non-exclusive, non-sublicensable, non-transferable right, limited to the term of the respective Subscription or Trial Period, to use the Pro Software in accordance with these License Terms within the scope of its business operations. Upon expiry or termination of the Subscription, including where the Subscription ends with Paddle due to cancellation, refund, chargeback or non-payment (Sections 10.6 and 10.7 of the ToS), or upon expiry of a Trial Period that is not followed by a Subscription, the Customer shall cease using the Pro Software and delete all copies of the Pro Software in its possession, including those contained in its software products, without undue delay, and in any event within thirty (30) days. This does not apply to copies in backups that could only be deleted with disproportionate effort; such copies may no longer be used.
32
18
 
33
- ## 5. Confidentiality
19
+ 2.2 The Customer's right of use includes the installation of the Pro Software as well as loading, displaying and running the installed Pro Software and storing the Pro Software to the extent necessary for its intended use. The Customer may use and/or integrate the Pro Software in its own software products. The Customer may further develop its own software and components, in particular extensions, nodes, marks and plugins, that use the Pro Software exclusively via its documented interfaces, extension points and configuration options or via the interfaces exported by the Pro Software ("Derivative Works").
34
20
 
35
- 5.1 The End User is required to maintain confidentiality in relation to all information arising in connection with these License Terms and their execution.
36
- 5.2 The End User is under obligation to ensure its employees also maintain confidentiality towards third parties.
37
- 5.3 This obligation does not apply to generally known documents and common knowledge, or documents and knowledge with which the End User was already acquainted when they were received, without the supplier being sworn to secrecy, or that are developed by the End User without use being made of any confidential documents or knowledge. This obligation also does not apply if the End User is required to disclose information by law or by official or court order.
38
- 5.4 Confidential information may only be forwarded to third parties after prior written consent from the Licensor.
21
+ 2.2.1 Any editing, translation, adaptation or other modification of the Pro Software is prohibited, irrespective of the form in which the Pro Software is available, unless mandatory statutory provisions provide otherwise, in particular sections 69d (1) and 69e German Copyright Act (UrhG).
39
22
 
40
- ## 6. Final Provisions
23
+ 2.2.2 Transformations carried out as part of the customary build process of the Customer’s software products, such as transpilation, bundling, minification and tree-shaking, do not constitute a modification within the meaning of Section 2.2.1. This does not apply to changes to the content or logic of the Pro Software, even if they are made as part of the build process. To the extent the Licensor provides Pro Software as code blocks to be inserted into and adapted within the Customer’s software products, in particular UI components and templates, the Customer may adapt such code blocks for use in its own software products; the prohibition of modification in this Section does not apply in this respect. Such code blocks, including any adaptations, remain Pro Software.
41
24
 
42
- 6.1. These License Terms are governed by the law of the Federal Republic of Germany. The UN Convention on Contracts for the International Sale of Goods (CISG) does not apply. The courts at the Licensor's registered office will have sole jurisdiction for all disputes regarding rights and duties arising from these License Terms, including their validity. However, the Licensor is entitled to file a claim against the End User at its general place of jurisdiction.
43
- 6.2. The End User is not entitled to assign or transfer rights or claims arising from the contractual relationship between the parties to third parties without the Licensor's prior written consent.
44
- 6.3. Amendments and additions to these License Terms require at least text form to be valid. This also applies to any amendment to this form clause.
45
- 6.4. If any provision(s) of these License Terms are or become invalid or unenforceable, this will not affect the validity of the other provisions of these License Terms. The parties will replace the invalid or unenforceable provision with a provision which is enforceable and practicable under statute and in economic terms reflects as closely as possible the essence and purpose of the invalid or unenforceable provision. Should these License Terms be incomplete, the parties will conclude an agreement with the content they would have agreed upon had they been aware of the omission when concluding these License Terms.
25
+ 2.2.3 If the Customer becomes aware of a defect in the Pro Software, it shall notify the Licensor and give the Licensor the opportunity to remedy the defect within a reasonable period before remedying it itself.
26
+
27
+ 2.3 The following applies to the use and distribution of the Pro Software and Derivative Works:
28
+
29
+ 2.3.1 The Customer shall not use the Pro Software or Derivative Works to develop, offer or support software products or services that compete with or substitute the Pro Software by making functionality of the Pro Software available to third parties for integration into, or the development of, such third parties’ own software products without such third parties having to obtain their own license from the Licensor. This applies in particular to editor frameworks, software development kits (SDKs), extension libraries, components, and hosted editor or collaboration services and APIs that make functionality of the Pro Software available in this manner.
30
+
31
+ 2.3.2 The Customer shall not distribute or otherwise make available to third parties the Pro Software, any parts thereof or Derivative Works containing parts of the Pro Software, whether on a standalone basis or as part of another software product, unless otherwise provided in a separate agreement. This does not apply to making the Pro Software available to users of the Customer's own software products to the extent technically necessary to operate those products, in particular by delivering it in compiled, minified or bundled form to the users' browsers or devices. In doing so, the Customer shall not make the Pro Software available under terms that grant users further rights to the Pro Software or give the impression of such rights.
32
+
33
+ 2.3.3 The Customer may publish its own code, including Derivative Works, under a license of its choice, including an open-source license, provided that (a) the code does not contain any Pro Software, in particular no code blocks within the meaning of Section 2.2 or adaptations thereof, and references the Pro Software solely as a package dependency (e.g. as an npm dependency in a package.json file) or through a comparable mechanism by which each recipient must obtain the Pro Software directly from the Licensor under its own license, (b) the Customer clearly states that the Pro Software is not covered by the license of its own code and that integrating the Pro Software into a software product, in particular by installing it as a package dependency or by adding code blocks of the Pro Software requires a separate license from the Licensor, and (c) the chosen license does not supersede or negate the effect of these License Terms with respect to the Pro Software. Copyright and license notices contained in the Pro Software shall not be removed or altered.
34
+
35
+ 2.4 The Licensor does not grant the Customer any further rights to the Pro Software.
36
+
37
+ 2.5 Using the Pro Software in the name or for the account of a third party who is not the contractual partner is also considered unauthorized use of the Pro Software. It is irrelevant here whether the third party pays the Customer a fee for use or not.
38
+
39
+ ## 3. FINAL PROVISIONS
40
+
41
+ Provisions which by their nature are intended to continue beyond the end of the Subscription shall remain unaffected by its termination. This applies in particular to the obligations set out in Section 2.1 following the end of the Subscription and to the requirements of Section 2.3.3 for code already published.
package/dist/index.js CHANGED
@@ -3,17 +3,17 @@ import zo from"path";import{Command as Ko}from"commander";import{z as ce}from"zo
3
3
  `),i=" ".repeat(or(t).length);return[`${t}${n}`,...r.map(o=>`${i}${o}`)].join(`
4
4
  `)}function or(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}var ke=zn((e,t)=>{let{loop:n=!0,pageSize:r=7,instructions:i}=e,o=Ft(!0),c=Zn(tr,e.theme),[l,p]=rt("idle"),f=Vn({status:l,theme:c}),m=Ft(),[x,w]=rt(!0),y=ot(()=>nr(e.choices),[e.choices]),O=ot(()=>{let k=y.findIndex(le),T=y.findLastIndex(le);if(k===-1)throw new Xn("[select prompt] No selectable choices. All choices are disabled.");return{first:k,last:T}},[y]),d=ot(()=>"default"in e?y.findIndex(k=>le(k)&&k.value===e.default):-1,[e.default,y]),[b,v]=rt(d===-1?O.first:d),A=y[b];Kn((k,T)=>{if(clearTimeout(m.current),w(!1),Gn(k))p("done"),t(A.value);else if(st(k)||Dt(k)){if(T.clearLine(0),n||st(k)&&b!==O.first||Dt(k)&&b!==O.last){let S=st(k)?-1:1,M=b;do M=(M+S+y.length)%y.length;while(!le(y[M]));v(M)}}else if(Hn(k)&&!Number.isNaN(Number(T.line))){let S=Number(T.line)-1,M=y[S];M!=null&&le(M)&&v(S),m.current=setTimeout(()=>{T.clearLine(0)},700)}else if(Yn(k))T.clearLine(0);else{let S=T.line.toLowerCase(),M=y.findIndex(re=>Ae.isSeparator(re)||!le(re)?!1:re.name.toLowerCase().startsWith(S));M!==-1&&v(M),m.current=setTimeout(()=>{T.clearLine(0)},700)}}),Jn(()=>()=>{clearTimeout(m.current)},[]);let D=c.style.message(e.message,l),U="",u="";typeof i=="string"&&(U=i);let h=qn({items:y,active:b,renderItem({item:k,isActive:T,index:S}){if(Ae.isSeparator(k))return` ${k.separator}`;let M=c.indexMode==="number"?`${S+1}. `:"";if(k.disabled){let nt=typeof k.disabled=="string"?k.disabled:"(disabled)";return c.style.disabled(`${M}${k.name} ${nt}`)}let re=T?c.style.highlight:nt=>nt,Wn=T?c.icon.cursor:" ";return re(rr(k.name,`${Wn} ${M}`))},pageSize:r,loop:n});if(l==="done")return`${f} ${D} ${c.style.answer(A.short)}`;let P=A.description?`
5
5
  ${c.style.description(A.description)}`:"";return`${[f,D,U].filter(Boolean).join(" ")}
6
- ${h}${u}${P}${er.cursorHide}`});import{Separator as we,input as Vo,confirm as Ul,checkbox as qo}from"@inquirer/prompts";import yr from"path";import $ from"path";import{createMatchPath as sr}from"tsconfig-paths";async function F(e,t){return sr(t.absoluteBaseUrl,t.paths)(e,void 0,()=>!0,[".ts",".tsx"])}import{cosmiconfig as mr}from"cosmiconfig";import ur from"fast-glob";import{loadConfig as dr}from"tsconfig-paths";import{z as C}from"zod";import Lt from"path";var g={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://tiptap.dev/docs/ui-components/install/next"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://tiptap.dev/docs/ui-components/install/next"}},"react-router":{name:"react-router",label:"React Router",links:{installation:"https://tiptap.dev/docs/ui-components/install/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:"https://tiptap.dev/docs/ui-components/install/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://tiptap.dev/docs/ui-components/install/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://tiptap.dev/docs/ui-components/install/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:"https://tiptap.dev/docs/ui-components/install/tanstack"}},manual:{name:"manual",label:"Manual",links:{installation:"https://tiptap.dev/docs/ui-components/install/next"}}};import ir from"path";import ar from"fs-extra";function $e(e="",t=!0){let n=ir.join(e,"package.json");return ar.readJSONSync(n,{throws:t})}import Bt from"fast-glob";import Mt from"fs-extra";import{loadConfig as cr}from"tsconfig-paths";var Wt=["**/node_modules/**",".next","public","dist","build"];async function L(e){let[t,n,r,i,o]=await Promise.all([Bt.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:Wt}),Mt.pathExists(Lt.resolve(e,"src")),pr(e),lr(e),$e(e,!1)]),c=await Mt.pathExists(Lt.resolve(e,`${n?"src/":""}app`)),l={framework:g.manual,isSrcDir:n,isRSC:!1,isTsx:r,aliasPrefix:i};return t.find(p=>p.startsWith("next.config."))?.length?(l.framework=c?g["next-app"]:g["next-pages"],l.isRSC=c,l):t.find(p=>p.startsWith("astro.config."))?.length?(l.framework=g.astro,l):t.find(p=>p.startsWith("composer.json"))?.length?(l.framework=g.laravel,l):t.find(p=>p.startsWith("app.config."))?.length&&[...Object.keys(o?.dependencies??{}),...Object.keys(o?.devDependencies??{})].find(p=>p.startsWith("@tanstack/start"))?(l.framework=g["tanstack-start"],l):t.find(p=>p.startsWith("react-router.config."))?.length?(l.framework=g["react-router"],l):(t.find(p=>p.startsWith("vite.config."))?.length&&(l.framework=g.vite),l)}async function lr(e){let t=await cr(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[n,r]of Object.entries(t.paths))if(r.includes("./*")||r.includes("./src/*")||r.includes("./app/*")||r.includes("./resources/js/*"))return n.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function pr(e){return(await Bt.glob("tsconfig.*",{cwd:e,deep:1,ignore:Wt})).length>0}async function zt(e,t=null){let[n,r]=await Promise.all([Y(e),t?Promise.resolve(t):L(e)]);if(n)return n;if(!r)return null;let i={rsc:r.isRSC,tsx:r.isTsx,aliases:{components:`${r.aliasPrefix}/components`,contexts:`${r.aliasPrefix}/contexts`,hooks:`${r.aliasPrefix}/hooks`,tiptapIcons:`${r.aliasPrefix}/components/tiptap-icons`,lib:`${r.aliasPrefix}/lib`,tiptapExtensions:`${r.aliasPrefix}/components/tiptap-extensions`,tiptapNodes:`${r.aliasPrefix}/components/tiptap-nodes`,tiptapUi:`${r.aliasPrefix}/components/tiptap-ui`,tiptapUiPrimitives:`${r.aliasPrefix}/components/tiptap-ui-primitives`,tiptapUiUtils:`${r.aliasPrefix}/components/tiptap-ui-utils`,styles:`${r.aliasPrefix}/styles`}};return await oe(e,i)}var at="@/components",ct="@/contexts",lt="@/hooks",pt="@/components/tiptap-icons",Re="@/lib",mt="@/components/tiptap-extension",ut="@/components/tiptap-node",dt="@/components/tiptap-ui",ft="@/components/tiptap-ui-primitive",gt="@/components/tiptap-ui-utils",ht="@/styles",fr=mr("components",{searchPlaces:["components.json"]}),se=C.object({rsc:C.coerce.boolean().default(!1),tsx:C.coerce.boolean().default(!0),aliases:C.object({components:C.string(),contexts:C.string().optional(),hooks:C.string().optional(),tiptapIcons:C.string().optional(),lib:C.string().optional(),tiptapExtensions:C.string().optional(),tiptapNodes:C.string().optional(),tiptapUi:C.string().optional(),tiptapUiPrimitives:C.string().optional(),tiptapUiUtils:C.string().optional(),styles:C.string().optional()})}),it=se.extend({resolvedPaths:C.object({cwd:C.string(),components:C.string(),contexts:C.string(),hooks:C.string(),tiptapIcons:C.string(),lib:C.string(),tiptapExtensions:C.string(),tiptapNodes:C.string(),tiptapUi:C.string(),tiptapUiPrimitives:C.string(),tiptapUiUtils:C.string(),styles:C.string()})}),gr=C.record(C.string(),it);async function Y(e,t){let n=await fr.search(e),r=await L(e),i={components:at,contexts:ct,hooks:lt,tiptapIcons:pt,lib:Re,tiptapExtensions:mt,tiptapNodes:ut,tiptapUi:dt,tiptapUiPrimitives:ft,tiptapUiUtils:gt,styles:ht},o=(l,p)=>Object.fromEntries(Object.entries(l).map(([f,m])=>[f,m.replace(/^@/,p)])),c;if(n){let l={...i,...n.config.aliases};r?.aliasPrefix?c=se.parse({...n.config,aliases:o(l,r.aliasPrefix)}):c=se.parse({...n.config,aliases:l})}else{let l=i;r?.aliasPrefix&&(l=o(l,r.aliasPrefix)),c=se.parse({rsc:r?.isRSC??!1,tsx:r?.isTsx??!0,aliases:l})}return await oe(e,c,t)}async function oe(e,t,n){let r=await dr(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());if(n){let o=$.isAbsolute(n)?n:$.resolve(e,n);return it.parse({...t,resolvedPaths:{cwd:e,components:o,contexts:$.resolve(o,"..","contexts"),hooks:$.resolve(o,"..","hooks"),tiptapIcons:$.resolve(o,"tiptap-icons"),lib:$.resolve(o,"..","lib"),tiptapExtensions:$.resolve(o,"tiptap-extension"),tiptapNodes:$.resolve(o,"tiptap-node"),tiptapUi:$.resolve(o,"tiptap-ui"),tiptapUiPrimitives:$.resolve(o,"tiptap-ui-primitive"),tiptapUiUtils:$.resolve(o,"tiptap-ui-utils"),styles:$.resolve(o,"..","styles")}})}return it.parse({...t,resolvedPaths:{cwd:e,components:await F(t.aliases.components,r),contexts:t.aliases.contexts?await F(t.aliases.contexts,r):$.resolve(await F(t.aliases.components,r)??e,"..","contexts"),hooks:t.aliases.hooks?await F(t.aliases.hooks,r):$.resolve(await F(t.aliases.components,r)??e,"..","hooks"),tiptapIcons:t.aliases.tiptapIcons?await F(t.aliases.tiptapIcons,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-icons"),lib:t.aliases.lib?await F(t.aliases.lib,r):$.resolve(await F(Re,r)??e,".."),tiptapExtensions:t.aliases.tiptapExtensions?await F(t.aliases.tiptapExtensions,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-extension"),tiptapNodes:t.aliases.tiptapNodes?await F(t.aliases.tiptapNodes,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-node"),tiptapUi:t.aliases.tiptapUi?await F(t.aliases.tiptapUi,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-ui"),tiptapUiPrimitives:t.aliases.tiptapUiPrimitives?await F(t.aliases.tiptapUiPrimitives,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-ui-primitive"),tiptapUiUtils:t.aliases.tiptapUiUtils?await F(t.aliases.tiptapUiUtils,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-ui-utils"),styles:t.aliases.styles?await F(t.aliases.styles,r):$.resolve(e,"styles")}})}async function Kt(e){let t={};for(let r of Object.keys(e.aliases)){if(!hr(r,e))continue;let i=e.resolvedPaths[r],o=await yt(e.resolvedPaths.cwd,i);if(!o){t[r]=e;continue}t[r]=await Y(o)}let n=gr.safeParse(t);return n.success?n.data:null}async function yt(e,t){let n=wt(e,t),r=$.relative(n,t),o=(await ur.glob("**/package.json",{cwd:n,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(c=>$.dirname(c)).find(c=>r.startsWith(c));return o?$.join(n,o):null}function hr(e,t){return Object.keys(t.resolvedPaths).includes(e)}function wt(e,t){let n=e.split($.sep),r=t.split($.sep),i=[];for(let o=0;o<Math.min(n.length,r.length)&&n[o]===r[o];o++)i.push(n[o]);return i.join($.sep)}import q from"chalk";var a={cyan:q.cyan,magenta:q.magenta,gray:q.gray,white:q.white,yellow:q.yellow,green:q.green,red:q.red,blue:q.blue,reset:q.reset,dim:q.dim,bold:q.bold,whiteBold:q.white.bold};var Pe=e=>e.map(String).join(" "),s={error(...e){console.log(a.red(Pe(e)))},warn(...e){console.log(a.yellow(Pe(e)))},info(...e){console.log(a.cyan(Pe(e)))},success(...e){console.log(a.green(Pe(e)))},log(...e){console.log(Pe(e))},break(){console.log("")}};import Vt from"fs-extra";async function qt(e){let t={};if(!Vt.existsSync(e.cwd)||!Vt.existsSync(yr.resolve(e.cwd,"package.json")))return t["1"]=!0,{errors:t,config:null};try{let n=await Y(e.cwd,e.path);return{errors:t,config:n}}catch(n){console.log("[preFlightAdd] - ",n),s.break(),s.error(`Make sure you are in a valid project directory. Run ${a.cyan("npx @tiptap/cli init")} to create a new project.`),s.break(),process.exit(1)}}import ue from"path";import{z as wr}from"zod";function _(e){if(s.error("Something went wrong. Please check the error below for more details."),s.error("If the problem persists, please open an issue on GitHub."),s.error(""),typeof e=="string"&&(s.error(e),s.break(),process.exit(1)),e instanceof wr.ZodError){s.error("Validation failed:");for(let[t,n]of Object.entries(e.flatten().fieldErrors))s.error(`- ${a.cyan(t)}: ${n}`);s.break(),process.exit(1)}e instanceof Error&&(s.error(e.message),s.break(),process.exit(1)),s.break(),process.exit(1)}import{z as R}from"zod";var Jt=R.enum(["registry:context","registry:extension","registry:hook","registry:icon","registry:lib","registry:node","registry:template","registry:ui-primitive","registry:ui","registry:ui-utils","registry:page","registry:component","registry:style","registry:asset"]),pe=["start","team","growth","enterprise","business"],xr=["open-source","light"],kr=[...pe,...xr],Pr=R.array(R.enum(kr)).default([]),Yt=R.object({path:R.string(),content:R.string().optional(),type:Jt,target:R.string().optional()}),ae=R.object({name:R.string(),type:Jt,description:R.string().optional(),dependencies:R.array(R.string()).optional(),devDependencies:R.array(R.string()).optional(),registryDependencies:R.array(R.string()).optional(),files:R.array(Yt).optional(),meta:R.record(R.string(),R.any()).optional(),plans:Pr.optional(),hide:R.boolean().default(!1).optional(),isNew:R.boolean().default(!1).optional()}),Ni=R.array(ae),Gt=R.array(ae.extend({files:R.array(R.union([R.string(),Yt])).optional()})),Ht=ae.pick({dependencies:!0,devDependencies:!0,files:!0});import xt from"deepmerge";import{HttpsProxyAgent as Tr}from"https-proxy-agent";import kt from"node-fetch";import{z as br}from"zod";import vr from"conf";var Ne=class{config;logger;constructor(t){this.logger=t,this.config=new vr({projectName:"tiptap-cli",clearInvalidConfig:!0,schema:{bearerToken:{type:"string"},authToken:{type:"string"},email:{type:"string"},loginDate:{type:"string"},plans:{type:"array",items:{type:"string"},default:[]},licenseAccepted:{type:"boolean"},licenseAcceptedDate:{type:"string"}}})}safeError(t,n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n??"Unknown error");try{this.logger.error(`${t}: ${r}`)}catch{}}setBearerToken(t,n){try{this.config.set("bearerToken",t),this.config.set("loginDate",new Date().toISOString()),n?.email&&this.config.set("email",n.email),n?.plans&&this.config.set("plans",n.plans)}catch(r){this.safeError("Failed to store bearer token",r)}}getBearerToken(){try{return this.config.get("bearerToken")??null}catch(t){return this.safeError("Failed to retrieve bearer token",t),null}}setAuthToken(t,n){try{this.config.set("authToken",t),this.config.set("loginDate",new Date().toISOString()),n?.email&&this.config.set("email",n.email),n?.plans&&this.config.set("plans",n.plans)}catch(r){this.safeError("Failed to store auth token",r)}}getAuthToken(){try{return this.config.get("authToken")??null}catch(t){return this.safeError("Failed to retrieve auth token",t),null}}getUserInfo(){return{email:this.config.get("email"),plans:this.config.get("plans")??[],loginDate:this.config.get("loginDate")}}getTokenExpiration(){let t=this.config.get("loginDate");if(!t)return null;let n=new Date(t);return n.setMonth(n.getMonth()+11),n.toISOString()}isValidToken(){let t=this.getBearerToken(),n=this.getAuthToken();if(!t&&!n)return!1;let r=this.getTokenExpiration();return r&&new Date(r)<=new Date?(this.clear(),!1):!0}clear(){try{this.config.clear()}catch(t){this.safeError("Failed to clear token storage",t)}}hasPlan(t){let n=this.config.get("plans")??[];return Array.isArray(n)&&n.includes(t)}setLicenseAccepted(){try{this.config.set("licenseAccepted",!0),this.config.set("licenseAcceptedDate",new Date().toISOString())}catch(t){this.safeError("Failed to store license acceptance",t)}}hasAcceptedLicense(){try{return this.config.get("licenseAccepted")??!1}catch(t){return this.safeError("Failed to retrieve license acceptance",t),!1}}clearLicenseAcceptance(){try{this.config.delete("licenseAccepted"),this.config.delete("licenseAcceptedDate")}catch(t){this.safeError("Failed to clear license acceptance",t)}}};var N=new Ne(s);var H="https://template.tiptap.dev",Pt=process.env.https_proxy?new Tr(process.env.https_proxy):void 0;async function Z(){try{let[e]=await je(["index.json"]);return Gt.parse(e)}catch(e){s.error(`
6
+ ${h}${u}${P}${er.cursorHide}`});import{Separator as we,input as Vo,confirm as Ul,checkbox as qo}from"@inquirer/prompts";import yr from"path";import $ from"path";import{createMatchPath as sr}from"tsconfig-paths";async function F(e,t){return sr(t.absoluteBaseUrl,t.paths)(e,void 0,()=>!0,[".ts",".tsx"])}import{cosmiconfig as mr}from"cosmiconfig";import ur from"fast-glob";import{loadConfig as dr}from"tsconfig-paths";import{z as C}from"zod";import Lt from"path";var g={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://tiptap.dev/docs/ui-components/install/next"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://tiptap.dev/docs/ui-components/install/next"}},"react-router":{name:"react-router",label:"React Router",links:{installation:"https://tiptap.dev/docs/ui-components/install/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:"https://tiptap.dev/docs/ui-components/install/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://tiptap.dev/docs/ui-components/install/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://tiptap.dev/docs/ui-components/install/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:"https://tiptap.dev/docs/ui-components/install/tanstack"}},manual:{name:"manual",label:"Manual",links:{installation:"https://tiptap.dev/docs/ui-components/install/next"}}};import ir from"path";import ar from"fs-extra";function $e(e="",t=!0){let n=ir.join(e,"package.json");return ar.readJSONSync(n,{throws:t})}import Bt from"fast-glob";import Mt from"fs-extra";import{loadConfig as cr}from"tsconfig-paths";var Wt=["**/node_modules/**",".next","public","dist","build"];async function L(e){let[t,n,r,i,o]=await Promise.all([Bt.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:Wt}),Mt.pathExists(Lt.resolve(e,"src")),pr(e),lr(e),$e(e,!1)]),c=await Mt.pathExists(Lt.resolve(e,`${n?"src/":""}app`)),l={framework:g.manual,isSrcDir:n,isRSC:!1,isTsx:r,aliasPrefix:i};return t.find(p=>p.startsWith("next.config."))?.length?(l.framework=c?g["next-app"]:g["next-pages"],l.isRSC=c,l):t.find(p=>p.startsWith("astro.config."))?.length?(l.framework=g.astro,l):t.find(p=>p.startsWith("composer.json"))?.length?(l.framework=g.laravel,l):t.find(p=>p.startsWith("app.config."))?.length&&[...Object.keys(o?.dependencies??{}),...Object.keys(o?.devDependencies??{})].find(p=>p.startsWith("@tanstack/start"))?(l.framework=g["tanstack-start"],l):t.find(p=>p.startsWith("react-router.config."))?.length?(l.framework=g["react-router"],l):(t.find(p=>p.startsWith("vite.config."))?.length&&(l.framework=g.vite),l)}async function lr(e){let t=await cr(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[n,r]of Object.entries(t.paths))if(r.includes("./*")||r.includes("./src/*")||r.includes("./app/*")||r.includes("./resources/js/*"))return n.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function pr(e){return(await Bt.glob("tsconfig.*",{cwd:e,deep:1,ignore:Wt})).length>0}async function zt(e,t=null){let[n,r]=await Promise.all([Y(e),t?Promise.resolve(t):L(e)]);if(n)return n;if(!r)return null;let i={rsc:r.isRSC,tsx:r.isTsx,aliases:{components:`${r.aliasPrefix}/components`,contexts:`${r.aliasPrefix}/contexts`,hooks:`${r.aliasPrefix}/hooks`,tiptapIcons:`${r.aliasPrefix}/components/tiptap-icons`,lib:`${r.aliasPrefix}/lib`,tiptapExtensions:`${r.aliasPrefix}/components/tiptap-extensions`,tiptapNodes:`${r.aliasPrefix}/components/tiptap-nodes`,tiptapUi:`${r.aliasPrefix}/components/tiptap-ui`,tiptapUiPrimitives:`${r.aliasPrefix}/components/tiptap-ui-primitives`,tiptapUiUtils:`${r.aliasPrefix}/components/tiptap-ui-utils`,styles:`${r.aliasPrefix}/styles`}};return await oe(e,i)}var at="@/components",ct="@/contexts",lt="@/hooks",pt="@/components/tiptap-icons",Re="@/lib",mt="@/components/tiptap-extension",ut="@/components/tiptap-node",dt="@/components/tiptap-ui",ft="@/components/tiptap-ui-primitive",gt="@/components/tiptap-ui-utils",ht="@/styles",fr=mr("components",{searchPlaces:["components.json"]}),se=C.object({rsc:C.coerce.boolean().default(!1),tsx:C.coerce.boolean().default(!0),aliases:C.object({components:C.string(),contexts:C.string().optional(),hooks:C.string().optional(),tiptapIcons:C.string().optional(),lib:C.string().optional(),tiptapExtensions:C.string().optional(),tiptapNodes:C.string().optional(),tiptapUi:C.string().optional(),tiptapUiPrimitives:C.string().optional(),tiptapUiUtils:C.string().optional(),styles:C.string().optional()})}),it=se.extend({resolvedPaths:C.object({cwd:C.string(),components:C.string(),contexts:C.string(),hooks:C.string(),tiptapIcons:C.string(),lib:C.string(),tiptapExtensions:C.string(),tiptapNodes:C.string(),tiptapUi:C.string(),tiptapUiPrimitives:C.string(),tiptapUiUtils:C.string(),styles:C.string()})}),gr=C.record(C.string(),it);async function Y(e,t){let n=await fr.search(e),r=await L(e),i={components:at,contexts:ct,hooks:lt,tiptapIcons:pt,lib:Re,tiptapExtensions:mt,tiptapNodes:ut,tiptapUi:dt,tiptapUiPrimitives:ft,tiptapUiUtils:gt,styles:ht},o=(l,p)=>Object.fromEntries(Object.entries(l).map(([f,m])=>[f,m.replace(/^@/,p)])),c;if(n){let l={...i,...n.config.aliases};r?.aliasPrefix?c=se.parse({...n.config,aliases:o(l,r.aliasPrefix)}):c=se.parse({...n.config,aliases:l})}else{let l=i;r?.aliasPrefix&&(l=o(l,r.aliasPrefix)),c=se.parse({rsc:r?.isRSC??!1,tsx:r?.isTsx??!0,aliases:l})}return await oe(e,c,t)}async function oe(e,t,n){let r=await dr(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());if(n){let o=$.isAbsolute(n)?n:$.resolve(e,n);return it.parse({...t,resolvedPaths:{cwd:e,components:o,contexts:$.resolve(o,"..","contexts"),hooks:$.resolve(o,"..","hooks"),tiptapIcons:$.resolve(o,"tiptap-icons"),lib:$.resolve(o,"..","lib"),tiptapExtensions:$.resolve(o,"tiptap-extension"),tiptapNodes:$.resolve(o,"tiptap-node"),tiptapUi:$.resolve(o,"tiptap-ui"),tiptapUiPrimitives:$.resolve(o,"tiptap-ui-primitive"),tiptapUiUtils:$.resolve(o,"tiptap-ui-utils"),styles:$.resolve(o,"..","styles")}})}return it.parse({...t,resolvedPaths:{cwd:e,components:await F(t.aliases.components,r),contexts:t.aliases.contexts?await F(t.aliases.contexts,r):$.resolve(await F(t.aliases.components,r)??e,"..","contexts"),hooks:t.aliases.hooks?await F(t.aliases.hooks,r):$.resolve(await F(t.aliases.components,r)??e,"..","hooks"),tiptapIcons:t.aliases.tiptapIcons?await F(t.aliases.tiptapIcons,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-icons"),lib:t.aliases.lib?await F(t.aliases.lib,r):$.resolve(await F(Re,r)??e,".."),tiptapExtensions:t.aliases.tiptapExtensions?await F(t.aliases.tiptapExtensions,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-extension"),tiptapNodes:t.aliases.tiptapNodes?await F(t.aliases.tiptapNodes,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-node"),tiptapUi:t.aliases.tiptapUi?await F(t.aliases.tiptapUi,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-ui"),tiptapUiPrimitives:t.aliases.tiptapUiPrimitives?await F(t.aliases.tiptapUiPrimitives,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-ui-primitive"),tiptapUiUtils:t.aliases.tiptapUiUtils?await F(t.aliases.tiptapUiUtils,r):$.resolve(await F(t.aliases.components,r)??e,"tiptap-ui-utils"),styles:t.aliases.styles?await F(t.aliases.styles,r):$.resolve(e,"styles")}})}async function Kt(e){let t={};for(let r of Object.keys(e.aliases)){if(!hr(r,e))continue;let i=e.resolvedPaths[r],o=await yt(e.resolvedPaths.cwd,i);if(!o){t[r]=e;continue}t[r]=await Y(o)}let n=gr.safeParse(t);return n.success?n.data:null}async function yt(e,t){let n=wt(e,t),r=$.relative(n,t),o=(await ur.glob("**/package.json",{cwd:n,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(c=>$.dirname(c)).find(c=>r.startsWith(c));return o?$.join(n,o):null}function hr(e,t){return Object.keys(t.resolvedPaths).includes(e)}function wt(e,t){let n=e.split($.sep),r=t.split($.sep),i=[];for(let o=0;o<Math.min(n.length,r.length)&&n[o]===r[o];o++)i.push(n[o]);return i.join($.sep)}import q from"chalk";var a={cyan:q.cyan,magenta:q.magenta,gray:q.gray,white:q.white,yellow:q.yellow,green:q.green,red:q.red,blue:q.blue,reset:q.reset,dim:q.dim,bold:q.bold,whiteBold:q.white.bold};var Pe=e=>e.map(String).join(" "),s={error(...e){console.log(a.red(Pe(e)))},warn(...e){console.log(a.yellow(Pe(e)))},info(...e){console.log(a.cyan(Pe(e)))},success(...e){console.log(a.green(Pe(e)))},log(...e){console.log(Pe(e))},break(){console.log("")}};import Vt from"fs-extra";async function qt(e){let t={};if(!Vt.existsSync(e.cwd)||!Vt.existsSync(yr.resolve(e.cwd,"package.json")))return t["1"]=!0,{errors:t,config:null};try{let n=await Y(e.cwd,e.path);return{errors:t,config:n}}catch(n){console.log("[preFlightAdd] - ",n),s.break(),s.error(`Make sure you are in a valid project directory. Run ${a.cyan("npx @tiptap/cli init")} to create a new project.`),s.break(),process.exit(1)}}import ue from"path";import{z as wr}from"zod";function _(e){if(s.error("Something went wrong. Please check the error below for more details."),s.error("If the problem persists, please open an issue on GitHub."),s.error(""),typeof e=="string"&&(s.error(e),s.break(),process.exit(1)),e instanceof wr.ZodError){s.error("Validation failed:");for(let[t,n]of Object.entries(e.flatten().fieldErrors))s.error(`- ${a.cyan(t)}: ${n}`);s.break(),process.exit(1)}e instanceof Error&&(s.error(e.message),s.break(),process.exit(1)),s.break(),process.exit(1)}import{z as R}from"zod";var Jt=R.enum(["registry:context","registry:extension","registry:hook","registry:icon","registry:lib","registry:node","registry:template","registry:ui-primitive","registry:ui","registry:ui-utils","registry:page","registry:component","registry:style","registry:asset"]),pe=["start","team","growth","enterprise","business"],xr=["open-source","light"],kr=[...pe,...xr],Pr=R.array(R.enum(kr)).default([]),Yt=R.object({path:R.string(),content:R.string().optional(),type:Jt,target:R.string().optional()}),ae=R.object({name:R.string(),type:Jt,description:R.string().optional(),dependencies:R.array(R.string()).optional(),devDependencies:R.array(R.string()).optional(),registryDependencies:R.array(R.string()).optional(),files:R.array(Yt).optional(),meta:R.record(R.string(),R.any()).optional(),plans:Pr.optional(),hide:R.boolean().default(!1).optional(),isNew:R.boolean().default(!1).optional()}),Ni=R.array(ae),Gt=R.array(ae.extend({files:R.array(R.union([R.string(),Yt])).optional()})),Ht=ae.pick({dependencies:!0,devDependencies:!0,files:!0});import xt from"deepmerge";import{HttpsProxyAgent as Tr}from"https-proxy-agent";import kt from"node-fetch";import{z as br}from"zod";import vr from"conf";var Ne=class{config;logger;constructor(t){this.logger=t,this.config=new vr({projectName:"tiptap-cli",clearInvalidConfig:!0,schema:{bearerToken:{type:"string"},authToken:{type:"string"},email:{type:"string"},loginDate:{type:"string"},plans:{type:"array",items:{type:"string"},default:[]},licenseAccepted:{type:"boolean"},licenseAcceptedDate:{type:"string"}}})}safeError(t,n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n??"Unknown error");try{this.logger.error(`${t}: ${r}`)}catch{}}setBearerToken(t,n){try{this.config.set("bearerToken",t),this.config.set("loginDate",new Date().toISOString()),n?.email&&this.config.set("email",n.email),n?.plans&&this.config.set("plans",n.plans)}catch(r){this.safeError("Failed to store bearer token",r)}}getBearerToken(){try{return this.config.get("bearerToken")??null}catch(t){return this.safeError("Failed to retrieve bearer token",t),null}}setAuthToken(t,n){try{this.config.set("authToken",t),this.config.set("loginDate",new Date().toISOString()),n?.email&&this.config.set("email",n.email),n?.plans&&this.config.set("plans",n.plans)}catch(r){this.safeError("Failed to store auth token",r)}}getAuthToken(){try{return this.config.get("authToken")??null}catch(t){return this.safeError("Failed to retrieve auth token",t),null}}getUserInfo(){return{email:this.config.get("email"),plans:this.config.get("plans")??[],loginDate:this.config.get("loginDate")}}getTokenExpiration(){let t=this.config.get("loginDate");if(!t)return null;let n=new Date(t);return n.setMonth(n.getMonth()+11),n.toISOString()}isValidToken(){let t=this.getBearerToken(),n=this.getAuthToken();if(!t&&!n)return!1;let r=this.getTokenExpiration();return r&&new Date(r)<=new Date?(this.clearSession(),!1):!0}clear(){try{this.config.clear()}catch(t){this.safeError("Failed to clear token storage",t)}}clearSession(){try{this.config.delete("bearerToken"),this.config.delete("authToken"),this.config.delete("email"),this.config.delete("loginDate"),this.config.delete("plans")}catch(t){this.safeError("Failed to clear token storage",t)}}hasPlan(t){let n=this.config.get("plans")??[];return Array.isArray(n)&&n.includes(t)}setLicenseAccepted(){try{this.config.set("licenseAccepted",!0),this.config.set("licenseAcceptedDate",new Date().toISOString())}catch(t){this.safeError("Failed to store license acceptance",t)}}hasAcceptedLicense(){try{return this.config.get("licenseAccepted")??!1}catch(t){return this.safeError("Failed to retrieve license acceptance",t),!1}}clearLicenseAcceptance(){try{this.config.delete("licenseAccepted"),this.config.delete("licenseAcceptedDate")}catch(t){this.safeError("Failed to clear license acceptance",t)}}};var j=new Ne(s);var H="https://template.tiptap.dev",Pt=process.env.https_proxy?new Tr(process.env.https_proxy):void 0;async function Z(){try{let[e]=await je(["index.json"]);return Gt.parse(e)}catch(e){s.error(`
7
7
  `),_(e)}}function vt(e,t){let n=t?` at ${a.cyan(t)}`:"";switch(e.status){case 400:return new Error(`The registry rejected the request${n}.
8
- Please check the selected components and try again.`);case 401:return N.clear(),new Error(`You are not authorized to access the component${n}.
8
+ Please check the selected components and try again.`);case 401:return j.clearSession(),new Error(`You are not authorized to access the component${n}.
9
9
  Please run ${a.cyan("@tiptap/cli login")} to log in to your Tiptap Cloud account.`);case 404:return new Error(`The component${n} was not found.
10
10
  It may not exist at the registry. Please make sure it is a valid component.`);case 403:return new Error(`You do not have access to the component${n}.
11
11
  Your account may not have the required subscription plan for this component.
12
12
  Please upgrade your subscription or use a component available in your current plan.`);case 429:return new Error(`Too many registry requests${n}.
13
13
  Please wait a moment and try again.`);default:return e.status>=500?new Error(`The Tiptap registry is temporarily unavailable${n}.
14
14
  Please try again later.`):new Error(`The registry returned an unexpected response${n}.
15
- Please try again.`)}}async function Sr(e,t){let n=Zt(e),r=await kt(n,{agent:Pt,headers:t});if(!r.ok)throw vt(r,n);return r.json()}async function Ir(e,t){let n=await kt(`${H}/api/registry/components/batch`,{method:"POST",agent:Pt,headers:t,body:JSON.stringify({components:e})});if(!n.ok)throw vt(n);return await n.json()}async function je(e){try{let t=N.getBearerToken(),n={"Content-Type":"application/json"};t&&(n.Authorization=`Bearer ${t}`);let r=e.map(i=>i.includes("/components/")?i.replace(/.*\/components\//,"").replace(".json",""):i.replace(".json",""));return r.length>1?await Ir(r,n):Promise.all(e.map(i=>Sr(i,n)))}catch(t){return s.error(`
16
- `),_(t),[]}}async function Cr(e){let t=await kt(`${H}/api/registry/dependencies`,{method:"POST",agent:Pt,headers:{"Content-Type":"application/json"},body:JSON.stringify({components:e})});if(!t.ok)throw vt(t,`${H}/api/registry/dependencies`);return await t.json()}async function Xt(e,t){try{if(!await Z())return null;e.includes("index")&&e.unshift("index");let r=await Tt(e),i=await je(r),o=br.array(ae).parse(i);if(!o)return null;let l=(await L(t.resolvedPaths.cwd))?.framework.name,p=xt.all(o.map(y=>y.dependencies??[])),f=xt.all(o.map(y=>y.devDependencies??[])),m=Er(f,l),x=new Set((Array.isArray(p)?p:[]).map(y=>String(y))),w=m.filter(y=>!x.has(y));return Ht.parse({dependencies:p,devDependencies:w,files:xt.all(o.map(y=>y.files??[]))})}catch(n){return _(n),null}}async function Tt(e){return(await Cr(e)).map(r=>Zt(`components/${r}.json`))}function Zt(e){if(Ar(e))return new URL(e).toString();if(!H)throw new Error("No registry URL found");if(e==="index.json")return`${H}/r/${e}`;if(e.startsWith("components/")){let t=e.replace("components/","").replace(".json","");return`${H}/api/registry/components/${t}`}return`${H}/${e}`}function Ar(e){try{return new URL(e),!0}catch{return!1}}function Qt(){return new Map([["registry:ui","tiptapUi"],["registry:ui-primitive","tiptapUiPrimitives"],["registry:ui-utils","tiptapUiUtils"],["registry:extension","tiptapExtensions"],["registry:node","tiptapNodes"],["registry:context","contexts"],["registry:hook","hooks"],["registry:lib","lib"],["registry:context","components"],["registry:template","tiptapTemplates"],["registry:component","components"],["registry:icon","tiptapIcons"],["registry:style","styles"]])}function en(e){let t=new Map;return e.forEach(n=>{n.registryDependencies&&n.registryDependencies.forEach(r=>{t.set(r,n)})}),t}function Er(e,t){let n=Array.isArray(e)?e:[];if(!n.length)return[];let r=n.map(i=>String(i));if(t){let i=r.includes("sass"),o=r.includes("sass-embedded");if(i||o){let c=[...r],l=[g.astro.name,g.laravel.name,g.vite.name,g["tanstack-start"].name,g["react-router"].name],p=[g["next-app"].name,g["next-pages"].name];return l.includes(t)?c=c.filter(f=>f!=="sass"):p.includes(t)&&(c=c.filter(f=>f!=="sass-embedded")),c}}return r}import $r from"ora";var Rr={frames:[`${a.cyan("\u2588")}`,`${a.cyan("\u2588")}`,`${a.cyan("\u2588")}`," "," "," "],interval:200};function I(e,t){return $r({text:e,spinner:Rr,color:"cyan",isSilent:t?.silent})}import{detect as Nr}from"@antfu/ni";import tn from"fs-extra";import nn from"path";async function K(e,{withFallback:t}={withFallback:!1}){let n=await Nr({programmatic:!0,cwd:e});if(n==="deno"&&(n=void 0),n==="yarn@berry")return"yarn";if(n==="pnpm@6")return"pnpm";if(n==="bun")return"bun";if(!t)return n??"npm";let r=process.env.npm_config_user_agent||"";return r.startsWith("yarn")?"yarn":r.startsWith("pnpm")?"pnpm":r.startsWith("bun")?"bun":"npm"}function me(e){let t=tn.existsSync(nn.join(e,"bun.lock")),n=tn.existsSync(nn.join(e,"bunfig.toml"));return!!(t&&n)}import{execa as jr}from"execa";async function bt(e,t,n){if(e=Array.from(new Set(e)),!e?.length)return;n={silent:!1,...n};let r=I("Installing dependencies.",{silent:n.silent}).start(),i=await K(t.resolvedPaths.cwd);await jr(i,[i==="npm"?"install":"add",...i==="npm"?["--save"]:[],...e],{cwd:t.resolvedPaths.cwd}),r.stopAndPersist({symbol:a.cyan("\u2714")})}import{existsSync as Le,promises as ve}from"fs";import W,{basename as Hr}from"path";import{promises as Kr}from"fs";import{tmpdir as Vr}from"os";import cn from"path";var _e=async({sourceFile:e,config:t,packageManager:n})=>{let r=e.getImportDeclarations();for(let i of r){let o=_r(i.getModuleSpecifierValue(),t);me(t.resolvedPaths.cwd)&&o.endsWith(".scss")&&(o=o.replace(/\.scss$/,".css")),o&&i.setModuleSpecifier(o)}return e};function _r(e,t){if(!e.startsWith("@/registry/")){let n=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${n}/`)}return e.match(/@\/registry\/tiptap-templates\/([^/]+)\/components\//)?e.replace(/@\/registry\/tiptap-templates\/([^/]+)\/components\//,`${t.aliases.components}/tiptap-templates/$1/`):e.match(/@\/registry\/tiptap-templates\/([^/]+)\/(?!components\/)/)?e.replace(/@\/registry\/tiptap-templates\/([^/]+)\//,`${t.aliases.components}/tiptap-templates/$1/`):t.aliases.components&&e.match(/@\/registry\/components/)?e.replace(/@\/registry\/components/,t.aliases.components):t.aliases.contexts&&e.match(/@\/registry\/contexts/)?e.replace(/@\/registry\/contexts/,t.aliases.contexts):t.aliases.tiptapExtensions&&e.match(/@\/registry\/tiptap-extension/)?e.replace(/@\/registry\/tiptap-extension/,t.aliases.tiptapExtensions):t.aliases.hooks&&e.match(/@\/registry\/hooks/)?e.replace(/@\/registry\/hooks/,t.aliases.hooks):t.aliases.tiptapIcons&&e.match(/@\/registry\/tiptap-icons/)?e.replace(/@\/registry\/tiptap-icons/,t.aliases.tiptapIcons):t.aliases.lib&&e.match(/@\/registry\/lib/)?e.replace(/@\/registry\/lib/,t.aliases.lib):t.aliases.tiptapNodes&&e.match(/@\/registry\/tiptap-node/)?e.replace(/@\/registry\/tiptap-node/,t.aliases.tiptapNodes):t.aliases.tiptapUiPrimitives&&e.match(/@\/registry\/tiptap-ui-primitive/)?e.replace(/@\/registry\/tiptap-ui-primitive/,t.aliases.tiptapUiPrimitives):t.aliases.tiptapUiUtils&&e.match(/@\/registry\/tiptap-ui-utils/)?e.replace(/@\/registry\/tiptap-ui-utils/,t.aliases.tiptapUiUtils):t.aliases.tiptapUi&&e.match(/@\/registry\/tiptap-ui/)?e.replace(/@\/registry\/tiptap-ui/,t.aliases.tiptapUi):t.aliases.styles&&e.match(/@\/registry\/styles/)?e.replace(/@\/registry\/styles/,t.aliases.styles):e.replace(/^@\/registry\/[^/]+(?:\/.*\/)?/,t.aliases.components+"/")}import{transformFromAstSync as Or}from"@babel/core";import{parse as Fr}from"@babel/parser";import Dr from"@babel/plugin-transform-typescript";import*as Oe from"recast";var Ur={sourceType:"module",allowImportExportEverywhere:!0,allowReturnOutsideFunction:!0,startLine:1,tokens:!0,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},rn=async({sourceFile:e,config:t})=>{let n=e.getFullText();if(t.tsx)return n;let r=Oe.parse(n,{parser:{parse:o=>Fr(o,Ur)}}),i=Or(r,n,{cloneInputAst:!1,code:!1,ast:!0,plugins:[Dr],configFile:!1});if(!i||!i.ast)throw new Error("Failed to transform JSX");return Oe.print(i.ast).code};import{SyntaxKind as Lr}from"ts-morph";var Mr=/^["']use client["']$/g,Fe=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let n=e.getFirstChildByKind(Lr.ExpressionStatement);return n&&Mr.test(n.getText())&&n.remove(),e};import{Node as De,SyntaxKind as E}from"ts-morph";var Br=[{name:"cta",matchType:"contains",caseSensitive:!1,onlyInFiles:["notion-like-editor.tsx"]},{name:"initialContent",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]},{name:"JSONContent",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]},{name:"onCreate",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]},{name:"getDocumentId",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]}];function B(e,t,n){return t.some(r=>{if(r.onlyInFiles&&!r.onlyInFiles.some(c=>n.endsWith(c)))return!1;let i=r.caseSensitive?e:e.toLowerCase(),o=r.caseSensitive?r.name:r.name.toLowerCase();switch(r.matchType){case"exact":return i===o;case"contains":return i.includes(o);case"startsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);case"regex":return r.pattern?new RegExp(r.pattern,r.caseSensitive?"":"i").test(i):!1;default:return!1}})}function Wr(e,t){let n=t.name;return n===g["next-app"].name||n===g["next-pages"].name?`NEXT_PUBLIC_${e}`:n===g.astro.name?`PUBLIC_${e}`:n===g.vite.name||n===g["tanstack-start"].name||n===g["react-router"].name?`VITE_${e}`:(n===g.laravel.name||n===g.manual.name,e)}function on(e){return e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_)/,"")}async function zr(e,t){let n=await L(t.resolvedPaths.cwd);if(!n)return;let r=[],i=e.getDescendantsOfKind(E.BinaryExpression);for(let l of i)if(l.getOperatorToken().getKind()===E.BarBarToken){let f=l.getLeft().getText();if(f.match(/^process\.env\.[A-Z_]+$/)){let m=f.match(/process\.env\.([A-Z_]+)/);if(m&&m[1]){let x=on(m[1]),w=n.framework.name,y;w===g.astro.name?y=`import.meta.env.PUBLIC_${x}`:w===g.vite.name||w===g["tanstack-start"].name||w===g["react-router"].name?y=`import.meta.env.VITE_${x}`:w===g["next-app"].name||w===g["next-pages"].name?y=`process.env.NEXT_PUBLIC_${x}`:y=`process.env.${x}`;let O=l.getRight().getText(),d=`${y} || ${O}`;r.push({node:l,newText:d})}}}let o=e.getDescendantsOfKind(E.CallExpression);for(let l of o){let f=l.getExpression().getText();if(f.match(/^alert$/)){let m=l.getArguments();if(m.length>0){let w=m[0].getText();if(w.includes("TIPTAP_COLLAB_TOKEN")||w.includes("TIPTAP_COLLAB_DOC_PREFIX")||w.includes("TIPTAP_AI_TOKEN")){let y=w,O=["TIPTAP_COLLAB_DOC_PREFIX","TIPTAP_COLLAB_APP_ID","TIPTAP_COLLAB_TOKEN","TIPTAP_AI_APP_ID","TIPTAP_AI_TOKEN","USE_JWT_TOKEN_API_ENDPOINT"];for(let d of O){let b=Wr(d,n.framework);y=y.replace(new RegExp(d,"g"),b)}if(y!==w){let d=`${f}(${y})`;r.push({node:l,newText:d})}}}}}let c=e.getDescendantsOfKind(E.PropertyAccessExpression);for(let l of c){let p=l.getText();if(p.match(/^process\.env\.[A-Z_]+$/)){if(l.getParent()?.getKind()===E.BinaryExpression)continue;let m=p.match(/process\.env\.([A-Z_]+)/);if(m&&m[1]){let x=on(m[1]),w=n.framework.name,y;w===g.astro.name?y=`import.meta.env.PUBLIC_${x}`:w===g.vite.name||w===g["tanstack-start"].name||w===g["react-router"].name?y=`import.meta.env.VITE_${x}`:w===g["next-app"].name||w===g["next-pages"].name?y=`process.env.NEXT_PUBLIC_${x}`:y=`process.env.${x}`,r.push({node:l,newText:y})}}}for(let{node:l,newText:p}of r)try{l.replaceWithText(p)}catch(f){console.warn(`Skipping transformation of node: ${f}`)}}var Ue=async({sourceFile:e,config:t})=>{let n=Br,r=e.getFilePath(),i=[],o=e.getImportDeclarations();for(let u of o){let h=u.getModuleSpecifierValue();if(n.some(S=>B(h,[S],r))){i.push({node:u,action:"remove"});continue}let P=u.getDefaultImport();if(P&&B(P.getText(),n,r)){i.push({node:u,action:"remove"});continue}let k=u.getNamedImports(),T=k.filter(S=>B(S.getName(),n,r));T.length>0&&(T.forEach(M=>i.push({node:M,action:"remove"})),k.filter(M=>!T.includes(M)).length===0&&!P&&i.push({node:u,action:"remove"}))}let c=e.getExportDeclarations();for(let u of c){let h=u.getNamedExports(),P=h.filter(k=>B(k.getName(),n,r));P.length>0&&(P.forEach(T=>i.push({node:T,action:"remove"})),h.filter(T=>!P.includes(T)).length===0&&i.push({node:u,action:"remove"}))}let l=e.getVariableStatements();for(let u of l){let h=u.getDeclarations(),P=h.filter(k=>B(k.getName(),n,r));P.length>0&&(h.length===P.length?i.push({node:u,action:"remove"}):P.forEach(k=>i.push({node:k,action:"remove"})))}let p=e.getFunctions();for(let u of p){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let f=e.getInterfaces();for(let u of f){let h=u.getName();B(h,n,r)&&i.push({node:u,action:"remove"})}let m=e.getTypeAliases();for(let u of m){let h=u.getName();B(h,n,r)&&i.push({node:u,action:"remove"})}let x=e.getDescendantsOfKind(E.PropertySignature);for(let u of x){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let w=e.getDescendantsOfKind(E.JsxElement);for(let u of w){let h=u.getOpeningElement().getTagNameNode().getText();B(h,n,r)&&i.push({node:u,action:"replace",newText:""})}let y=e.getDescendantsOfKind(E.JsxSelfClosingElement);for(let u of y){let h=u.getTagNameNode().getText();B(h,n,r)&&i.push({node:u,action:"replace",newText:""})}let O=e.getDescendantsOfKind(E.PropertyAssignment);for(let u of O){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let d=e.getDescendantsOfKind(E.JsxAttribute);for(let u of d){let h=u.getNameNode().getText();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let b=e.getDescendantsOfKind(E.Parameter);for(let u of b){let h=u.getName();if(h&&B(h,n,r)){let P=u.getParent();if(P&&(De.isFunctionDeclaration(P)||De.isArrowFunction(P)||De.isFunctionExpression(P)||De.isMethodDeclaration(P))){let k=P.getParameters(),T=k.indexOf(u);if(T!==-1){if(T===k.length-1&&T>0){let S=u.getPreviousSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}else{let S=u.getNextSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}i.push({node:u,action:"remove"})}}}}let v=e.getDescendantsOfKind(E.CallExpression);for(let u of v){let h=u.getArguments();for(let P=0;P<h.length;P++){let k=h[P],T=k.getText();if(B(T,n,r)){if(P===h.length-1){let S=k.getPreviousSibling();S&&S.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}else{let S=k.getNextSibling();S&&S.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}i.push({node:k,action:"remove"})}}}let A=e.getDescendantsOfKind(E.BindingElement);for(let u of A){let h=u.getName();if(h&&B(h,n,r)){let P=u.getParent();if(P){let k=P.getDescendantsOfKind(E.BindingElement);if(k.indexOf(u)===k.length-1){let S=u.getPreviousSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}else{let S=u.getNextSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}}i.push({node:u,action:"remove"})}}let D=e.getDescendantsOfKind(E.Identifier);for(let u of D){let h=u.getText();if(B(h,n,r)){let P=u.getParent();if(P){let k=P.getKind();if(k===E.CallExpression){let T=P;T.getExpression()===u?i.push({node:T,action:"remove"}):T.getArguments().findIndex(re=>re===u)!==-1&&i.push({node:u,action:"remove"})}if(k===E.PropertyAccessExpression){let T=P;T.getName()===h&&i.push({node:T,action:"remove"})}if((k===E.VariableDeclaration||k===E.BinaryExpression||k===E.IfStatement||k===E.ConditionalExpression)&&i.push({node:u,action:"remove"}),k===E.PropertyAssignment){let T=P;T.getInitializer()===u&&i.push({node:T,action:"remove"})}}}}let U=e.getDescendantsOfKind(E.ShorthandPropertyAssignment);for(let u of U){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}await zr(e,t),i.sort((u,h)=>{let P=u.node.getStart?.()??0;return(h.node.getStart?.()??0)-P});for(let{node:u,action:h,newText:P}of i)try{if(u.wasForgotten?.()===!0)continue;h==="remove"?typeof u.remove=="function"&&u.remove():h==="replace"&&P!==void 0&&u.replaceWithText(P)}catch{}return e};import*as sn from"sass";async function an(e){try{return sn.compileString(e,{style:"expanded"}).css}catch(t){throw new Error(`Failed to compile SCSS to CSS: ${t instanceof Error?t.message:String(t)}`)}}import{Project as qr,ScriptKind as Jr}from"ts-morph";var Yr=new qr({compilerOptions:{}});async function Gr(e){let t=await Kr.mkdtemp(cn.join(Vr(),"tiptap-"));return cn.join(t,e)}async function ln(e,t=[_e,Fe,Ue]){let n=me(e.config.resolvedPaths.cwd);if(e.filename.endsWith(".scss")&&n)return await an(e.raw);if(e.filename.endsWith(".scss")||e.filename.endsWith(".css")||e.filename.endsWith(".json"))return e.raw;let r=await Gr(e.filename),i=Yr.createSourceFile(r,e.raw,{scriptKind:Jr.TSX});for(let o of t)await o({sourceFile:i,...e});return e.transformJsx?await rn({sourceFile:i,...e}):i.getText()}import{confirm as Xr}from"@inquirer/prompts";var Zr="scss.d.ts",Qr=`declare module "*.scss";
15
+ Please try again.`)}}async function Sr(e,t){let n=Zt(e),r=await kt(n,{agent:Pt,headers:t});if(!r.ok)throw vt(r,n);return r.json()}async function Ir(e,t){let n=await kt(`${H}/api/registry/components/batch`,{method:"POST",agent:Pt,headers:t,body:JSON.stringify({components:e})});if(!n.ok)throw vt(n);return await n.json()}async function je(e){try{let t=j.getBearerToken(),n={"Content-Type":"application/json"};t&&(n.Authorization=`Bearer ${t}`);let r=e.map(i=>i.includes("/components/")?i.replace(/.*\/components\//,"").replace(".json",""):i.replace(".json",""));return r.length>1?await Ir(r,n):Promise.all(e.map(i=>Sr(i,n)))}catch(t){return s.error(`
16
+ `),_(t),[]}}async function Cr(e){let t=await kt(`${H}/api/registry/dependencies`,{method:"POST",agent:Pt,headers:{"Content-Type":"application/json"},body:JSON.stringify({components:e})});if(!t.ok)throw vt(t,`${H}/api/registry/dependencies`);return await t.json()}async function Xt(e,t){try{if(!await Z())return null;e.includes("index")&&e.unshift("index");let r=await Tt(e),i=await je(r),o=br.array(ae).parse(i);if(!o)return null;let l=(await L(t.resolvedPaths.cwd))?.framework.name,p=xt.all(o.map(y=>y.dependencies??[])),f=xt.all(o.map(y=>y.devDependencies??[])),m=Er(f,l),x=new Set((Array.isArray(p)?p:[]).map(y=>String(y))),w=m.filter(y=>!x.has(y));return Ht.parse({dependencies:p,devDependencies:w,files:xt.all(o.map(y=>y.files??[]))})}catch(n){return _(n),null}}async function Tt(e){return(await Cr(e)).map(r=>Zt(`components/${r}.json`))}function Zt(e){if(Ar(e))return new URL(e).toString();if(!H)throw new Error("No registry URL found");if(e==="index.json")return`${H}/r/${e}`;if(e.startsWith("components/")){let t=e.replace("components/","").replace(".json","");return`${H}/api/registry/components/${t}`}return`${H}/${e}`}function Ar(e){try{return new URL(e),!0}catch{return!1}}function Qt(){return new Map([["registry:ui","tiptapUi"],["registry:ui-primitive","tiptapUiPrimitives"],["registry:ui-utils","tiptapUiUtils"],["registry:extension","tiptapExtensions"],["registry:node","tiptapNodes"],["registry:context","contexts"],["registry:hook","hooks"],["registry:lib","lib"],["registry:context","components"],["registry:template","tiptapTemplates"],["registry:component","components"],["registry:icon","tiptapIcons"],["registry:style","styles"]])}function en(e){let t=new Map;return e.forEach(n=>{n.registryDependencies&&n.registryDependencies.forEach(r=>{t.set(r,n)})}),t}function Er(e,t){let n=Array.isArray(e)?e:[];if(!n.length)return[];let r=n.map(i=>String(i));if(t){let i=r.includes("sass"),o=r.includes("sass-embedded");if(i||o){let c=[...r],l=[g.astro.name,g.laravel.name,g.vite.name,g["tanstack-start"].name,g["react-router"].name],p=[g["next-app"].name,g["next-pages"].name];return l.includes(t)?c=c.filter(f=>f!=="sass"):p.includes(t)&&(c=c.filter(f=>f!=="sass-embedded")),c}}return r}import $r from"ora";var Rr={frames:[`${a.cyan("\u2588")}`,`${a.cyan("\u2588")}`,`${a.cyan("\u2588")}`," "," "," "],interval:200};function I(e,t){return $r({text:e,spinner:Rr,color:"cyan",isSilent:t?.silent})}import{detect as Nr}from"@antfu/ni";import tn from"fs-extra";import nn from"path";async function K(e,{withFallback:t}={withFallback:!1}){let n=await Nr({programmatic:!0,cwd:e}),r=(()=>{switch(n){case"yarn":case"yarn@berry":return"yarn";case"pnpm":case"pnpm@6":return"pnpm";case"bun":return"bun";case"npm":return"npm";default:return}})();if(!t)return r??"npm";let i=process.env.npm_config_user_agent||"";return i.startsWith("yarn")?"yarn":i.startsWith("pnpm")?"pnpm":i.startsWith("bun")?"bun":"npm"}function me(e){let t=tn.existsSync(nn.join(e,"bun.lock")),n=tn.existsSync(nn.join(e,"bunfig.toml"));return!!(t&&n)}import{execa as jr}from"execa";async function bt(e,t,n){if(e=Array.from(new Set(e)),!e?.length)return;n={silent:!1,...n};let r=I("Installing dependencies.",{silent:n.silent}).start(),i=await K(t.resolvedPaths.cwd);await jr(i,[i==="npm"?"install":"add",...i==="npm"?["--save"]:[],...e],{cwd:t.resolvedPaths.cwd}),r.stopAndPersist({symbol:a.cyan("\u2714")})}import{existsSync as Le,promises as ve}from"fs";import W,{basename as Hr}from"path";import{promises as Kr}from"fs";import{tmpdir as Vr}from"os";import cn from"path";var _e=async({sourceFile:e,config:t,packageManager:n})=>{let r=e.getImportDeclarations();for(let i of r){let o=_r(i.getModuleSpecifierValue(),t);me(t.resolvedPaths.cwd)&&o.endsWith(".scss")&&(o=o.replace(/\.scss$/,".css")),o&&i.setModuleSpecifier(o)}return e};function _r(e,t){if(!e.startsWith("@/registry/")){let n=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${n}/`)}return e.match(/@\/registry\/tiptap-templates\/([^/]+)\/components\//)?e.replace(/@\/registry\/tiptap-templates\/([^/]+)\/components\//,`${t.aliases.components}/tiptap-templates/$1/`):e.match(/@\/registry\/tiptap-templates\/([^/]+)\/(?!components\/)/)?e.replace(/@\/registry\/tiptap-templates\/([^/]+)\//,`${t.aliases.components}/tiptap-templates/$1/`):t.aliases.components&&e.match(/@\/registry\/components/)?e.replace(/@\/registry\/components/,t.aliases.components):t.aliases.contexts&&e.match(/@\/registry\/contexts/)?e.replace(/@\/registry\/contexts/,t.aliases.contexts):t.aliases.tiptapExtensions&&e.match(/@\/registry\/tiptap-extension/)?e.replace(/@\/registry\/tiptap-extension/,t.aliases.tiptapExtensions):t.aliases.hooks&&e.match(/@\/registry\/hooks/)?e.replace(/@\/registry\/hooks/,t.aliases.hooks):t.aliases.tiptapIcons&&e.match(/@\/registry\/tiptap-icons/)?e.replace(/@\/registry\/tiptap-icons/,t.aliases.tiptapIcons):t.aliases.lib&&e.match(/@\/registry\/lib/)?e.replace(/@\/registry\/lib/,t.aliases.lib):t.aliases.tiptapNodes&&e.match(/@\/registry\/tiptap-node/)?e.replace(/@\/registry\/tiptap-node/,t.aliases.tiptapNodes):t.aliases.tiptapUiPrimitives&&e.match(/@\/registry\/tiptap-ui-primitive/)?e.replace(/@\/registry\/tiptap-ui-primitive/,t.aliases.tiptapUiPrimitives):t.aliases.tiptapUiUtils&&e.match(/@\/registry\/tiptap-ui-utils/)?e.replace(/@\/registry\/tiptap-ui-utils/,t.aliases.tiptapUiUtils):t.aliases.tiptapUi&&e.match(/@\/registry\/tiptap-ui/)?e.replace(/@\/registry\/tiptap-ui/,t.aliases.tiptapUi):t.aliases.styles&&e.match(/@\/registry\/styles/)?e.replace(/@\/registry\/styles/,t.aliases.styles):e.replace(/^@\/registry\/[^/]+(?:\/.*\/)?/,t.aliases.components+"/")}import{transformFromAstSync as Or}from"@babel/core";import{parse as Fr}from"@babel/parser";import Dr from"@babel/plugin-transform-typescript";import*as Oe from"recast";var Ur={sourceType:"module",allowImportExportEverywhere:!0,allowReturnOutsideFunction:!0,startLine:1,tokens:!0,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},rn=async({sourceFile:e,config:t})=>{let n=e.getFullText();if(t.tsx)return n;let r=Oe.parse(n,{parser:{parse:o=>Fr(o,Ur)}}),i=Or(r,n,{cloneInputAst:!1,code:!1,ast:!0,plugins:[Dr],configFile:!1});if(!i||!i.ast)throw new Error("Failed to transform JSX");return Oe.print(i.ast).code};import{SyntaxKind as Lr}from"ts-morph";var Mr=/^["']use client["']$/g,Fe=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let n=e.getFirstChildByKind(Lr.ExpressionStatement);return n&&Mr.test(n.getText())&&n.remove(),e};import{Node as De,SyntaxKind as E}from"ts-morph";var Br=[{name:"cta",matchType:"contains",caseSensitive:!1,onlyInFiles:["notion-like-editor.tsx"]},{name:"initialContent",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]},{name:"JSONContent",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]},{name:"onCreate",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]},{name:"getDocumentId",matchType:"exact",caseSensitive:!0,onlyInFiles:["notion-like-editor.tsx"]}];function B(e,t,n){return t.some(r=>{if(r.onlyInFiles&&!r.onlyInFiles.some(c=>n.endsWith(c)))return!1;let i=r.caseSensitive?e:e.toLowerCase(),o=r.caseSensitive?r.name:r.name.toLowerCase();switch(r.matchType){case"exact":return i===o;case"contains":return i.includes(o);case"startsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);case"regex":return r.pattern?new RegExp(r.pattern,r.caseSensitive?"":"i").test(i):!1;default:return!1}})}function Wr(e,t){let n=t.name;return n===g["next-app"].name||n===g["next-pages"].name?`NEXT_PUBLIC_${e}`:n===g.astro.name?`PUBLIC_${e}`:n===g.vite.name||n===g["tanstack-start"].name||n===g["react-router"].name?`VITE_${e}`:(n===g.laravel.name||n===g.manual.name,e)}function on(e){return e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_)/,"")}async function zr(e,t){let n=await L(t.resolvedPaths.cwd);if(!n)return;let r=[],i=e.getDescendantsOfKind(E.BinaryExpression);for(let l of i)if(l.getOperatorToken().getKind()===E.BarBarToken){let f=l.getLeft().getText();if(f.match(/^process\.env\.[A-Z_]+$/)){let m=f.match(/process\.env\.([A-Z_]+)/);if(m&&m[1]){let x=on(m[1]),w=n.framework.name,y;w===g.astro.name?y=`import.meta.env.PUBLIC_${x}`:w===g.vite.name||w===g["tanstack-start"].name||w===g["react-router"].name?y=`import.meta.env.VITE_${x}`:w===g["next-app"].name||w===g["next-pages"].name?y=`process.env.NEXT_PUBLIC_${x}`:y=`process.env.${x}`;let O=l.getRight().getText(),d=`${y} || ${O}`;r.push({node:l,newText:d})}}}let o=e.getDescendantsOfKind(E.CallExpression);for(let l of o){let f=l.getExpression().getText();if(f.match(/^alert$/)){let m=l.getArguments();if(m.length>0){let w=m[0].getText();if(w.includes("TIPTAP_COLLAB_TOKEN")||w.includes("TIPTAP_COLLAB_DOC_PREFIX")||w.includes("TIPTAP_AI_TOKEN")){let y=w,O=["TIPTAP_COLLAB_DOC_PREFIX","TIPTAP_COLLAB_APP_ID","TIPTAP_COLLAB_TOKEN","TIPTAP_AI_APP_ID","TIPTAP_AI_TOKEN","USE_JWT_TOKEN_API_ENDPOINT"];for(let d of O){let b=Wr(d,n.framework);y=y.replace(new RegExp(d,"g"),b)}if(y!==w){let d=`${f}(${y})`;r.push({node:l,newText:d})}}}}}let c=e.getDescendantsOfKind(E.PropertyAccessExpression);for(let l of c){let p=l.getText();if(p.match(/^process\.env\.[A-Z_]+$/)){if(l.getParent()?.getKind()===E.BinaryExpression)continue;let m=p.match(/process\.env\.([A-Z_]+)/);if(m&&m[1]){let x=on(m[1]),w=n.framework.name,y;w===g.astro.name?y=`import.meta.env.PUBLIC_${x}`:w===g.vite.name||w===g["tanstack-start"].name||w===g["react-router"].name?y=`import.meta.env.VITE_${x}`:w===g["next-app"].name||w===g["next-pages"].name?y=`process.env.NEXT_PUBLIC_${x}`:y=`process.env.${x}`,r.push({node:l,newText:y})}}}for(let{node:l,newText:p}of r)try{l.replaceWithText(p)}catch(f){console.warn(`Skipping transformation of node: ${f}`)}}var Ue=async({sourceFile:e,config:t})=>{let n=Br,r=e.getFilePath(),i=[],o=e.getImportDeclarations();for(let u of o){let h=u.getModuleSpecifierValue();if(n.some(S=>B(h,[S],r))){i.push({node:u,action:"remove"});continue}let P=u.getDefaultImport();if(P&&B(P.getText(),n,r)){i.push({node:u,action:"remove"});continue}let k=u.getNamedImports(),T=k.filter(S=>B(S.getName(),n,r));T.length>0&&(T.forEach(M=>i.push({node:M,action:"remove"})),k.filter(M=>!T.includes(M)).length===0&&!P&&i.push({node:u,action:"remove"}))}let c=e.getExportDeclarations();for(let u of c){let h=u.getNamedExports(),P=h.filter(k=>B(k.getName(),n,r));P.length>0&&(P.forEach(T=>i.push({node:T,action:"remove"})),h.filter(T=>!P.includes(T)).length===0&&i.push({node:u,action:"remove"}))}let l=e.getVariableStatements();for(let u of l){let h=u.getDeclarations(),P=h.filter(k=>B(k.getName(),n,r));P.length>0&&(h.length===P.length?i.push({node:u,action:"remove"}):P.forEach(k=>i.push({node:k,action:"remove"})))}let p=e.getFunctions();for(let u of p){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let f=e.getInterfaces();for(let u of f){let h=u.getName();B(h,n,r)&&i.push({node:u,action:"remove"})}let m=e.getTypeAliases();for(let u of m){let h=u.getName();B(h,n,r)&&i.push({node:u,action:"remove"})}let x=e.getDescendantsOfKind(E.PropertySignature);for(let u of x){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let w=e.getDescendantsOfKind(E.JsxElement);for(let u of w){let h=u.getOpeningElement().getTagNameNode().getText();B(h,n,r)&&i.push({node:u,action:"replace",newText:""})}let y=e.getDescendantsOfKind(E.JsxSelfClosingElement);for(let u of y){let h=u.getTagNameNode().getText();B(h,n,r)&&i.push({node:u,action:"replace",newText:""})}let O=e.getDescendantsOfKind(E.PropertyAssignment);for(let u of O){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let d=e.getDescendantsOfKind(E.JsxAttribute);for(let u of d){let h=u.getNameNode().getText();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}let b=e.getDescendantsOfKind(E.Parameter);for(let u of b){let h=u.getName();if(h&&B(h,n,r)){let P=u.getParent();if(P&&(De.isFunctionDeclaration(P)||De.isArrowFunction(P)||De.isFunctionExpression(P)||De.isMethodDeclaration(P))){let k=P.getParameters(),T=k.indexOf(u);if(T!==-1){if(T===k.length-1&&T>0){let S=u.getPreviousSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}else{let S=u.getNextSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}i.push({node:u,action:"remove"})}}}}let v=e.getDescendantsOfKind(E.CallExpression);for(let u of v){let h=u.getArguments();for(let P=0;P<h.length;P++){let k=h[P],T=k.getText();if(B(T,n,r)){if(P===h.length-1){let S=k.getPreviousSibling();S&&S.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}else{let S=k.getNextSibling();S&&S.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}i.push({node:k,action:"remove"})}}}let A=e.getDescendantsOfKind(E.BindingElement);for(let u of A){let h=u.getName();if(h&&B(h,n,r)){let P=u.getParent();if(P){let k=P.getDescendantsOfKind(E.BindingElement);if(k.indexOf(u)===k.length-1){let S=u.getPreviousSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}else{let S=u.getNextSibling();S?.getKind()===E.CommaToken&&i.push({node:S,action:"remove"})}}i.push({node:u,action:"remove"})}}let D=e.getDescendantsOfKind(E.Identifier);for(let u of D){let h=u.getText();if(B(h,n,r)){let P=u.getParent();if(P){let k=P.getKind();if(k===E.CallExpression){let T=P;T.getExpression()===u?i.push({node:T,action:"remove"}):T.getArguments().findIndex(re=>re===u)!==-1&&i.push({node:u,action:"remove"})}if(k===E.PropertyAccessExpression){let T=P;T.getName()===h&&i.push({node:T,action:"remove"})}if((k===E.VariableDeclaration||k===E.BinaryExpression||k===E.IfStatement||k===E.ConditionalExpression)&&i.push({node:u,action:"remove"}),k===E.PropertyAssignment){let T=P;T.getInitializer()===u&&i.push({node:T,action:"remove"})}}}}let U=e.getDescendantsOfKind(E.ShorthandPropertyAssignment);for(let u of U){let h=u.getName();h&&B(h,n,r)&&i.push({node:u,action:"remove"})}await zr(e,t),i.sort((u,h)=>{let P=u.node.getStart?.()??0;return(h.node.getStart?.()??0)-P});for(let{node:u,action:h,newText:P}of i)try{if(u.wasForgotten?.()===!0)continue;h==="remove"?typeof u.remove=="function"&&u.remove():h==="replace"&&P!==void 0&&u.replaceWithText(P)}catch{}return e};import*as sn from"sass";async function an(e){try{return sn.compileString(e,{style:"expanded"}).css}catch(t){throw new Error(`Failed to compile SCSS to CSS: ${t instanceof Error?t.message:String(t)}`)}}import{Project as qr,ScriptKind as Jr}from"ts-morph";var Yr=new qr({compilerOptions:{}});async function Gr(e){let t=await Kr.mkdtemp(cn.join(Vr(),"tiptap-"));return cn.join(t,e)}async function ln(e,t=[_e,Fe,Ue]){let n=me(e.config.resolvedPaths.cwd);if(e.filename.endsWith(".scss")&&n)return await an(e.raw);if(e.filename.endsWith(".scss")||e.filename.endsWith(".css")||e.filename.endsWith(".json"))return e.raw;let r=await Gr(e.filename),i=Yr.createSourceFile(r,e.raw,{scriptKind:Jr.TSX});for(let o of t)await o({sourceFile:i,...e});return e.transformJsx?await rn({sourceFile:i,...e}):i.getText()}import{confirm as Xr}from"@inquirer/prompts";var Zr="scss.d.ts",Qr=`declare module "*.scss";
17
17
  `;async function St(e,t,n){let r={filesCreated:[],filesUpdated:[],filesSkipped:[],errors:[]};if(!e?.length)return r;n={overwrite:!1,force:!1,silent:!1,...n};let i=I("Updating files.",{silent:n.silent})?.start();try{let[o,c]=await Promise.all([L(t.resolvedPaths.cwd),K(t.resolvedPaths.cwd)]);for(let p of e)try{if(!p.content)continue;let f;try{f=oo(p,t,{isSrcDir:o?.isSrcDir,framework:o?.framework.name,commonRoot:to(e.map(d=>d.path),p.path)})}catch(d){r.errors.push({file:p.path,error:`Failed to resolve file path: ${d instanceof Error?d.message:String(d)}`});continue}if(!f)continue;let m=Hr(p.path),x=W.dirname(f);t.tsx||(f=f.replace(/\.tsx?$/,d=>d===".tsx"?".jsx":".js")),me(t.resolvedPaths.cwd)&&f.endsWith(".scss")&&(f=f.replace(/\.scss$/,".css"));let y=!1;try{y=Le(f)}catch(d){r.errors.push({file:f,error:`Failed to check if file exists: ${d instanceof Error?d.message:String(d)}`});continue}let O;try{O=await ln({filename:p.path,raw:p.content,config:t,transformJsx:!t.tsx,packageManager:c},[_e,Fe,Ue])}catch(d){r.errors.push({file:f,error:`Failed to transform content: ${d instanceof Error?d.message:String(d)}`});continue}if(y)try{let d=await ve.readFile(f,"utf-8"),[b,v]=await Promise.all([pn(d),pn(O)]);if(b===v){r.filesSkipped.push(W.relative(t.resolvedPaths.cwd,f));continue}}catch(d){r.errors.push({file:f,error:`Failed to read or normalize existing file: ${d instanceof Error?d.message:String(d)}`});continue}if(y&&!n.overwrite){i?.stop(),n.rootSpinner&&n.rootSpinner?.stop();try{if(!await Xr({message:a.reset(`The file ${a.cyan(m)} already exists. Would you like to overwrite?`),theme:{prefix:a.cyan("?"),style:{message:b=>a.reset(b)}}})){r.filesSkipped.push(W.relative(t.resolvedPaths.cwd,f)),n.rootSpinner&&n.rootSpinner.start();continue}}catch(d){r.errors.push({file:f,error:`Failed to get user confirmation: ${d instanceof Error?d.message:String(d)}`});continue}finally{i?.start(),n.rootSpinner&&n.rootSpinner.start()}}try{Le(x)||await ve.mkdir(x,{recursive:!0}),await ve.writeFile(f,O,"utf-8"),y?r.filesUpdated.push(W.relative(t.resolvedPaths.cwd,f)):r.filesCreated.push(W.relative(t.resolvedPaths.cwd,f))}catch(d){r.errors.push({file:f,error:`Failed to write file: ${d instanceof Error?d.message:String(d)}`})}}catch(f){r.errors.push({file:p.path||"unknown",error:`Unexpected error processing file: ${f instanceof Error?f.message:String(f)}`})}if([...r.filesCreated,...r.filesUpdated].some(p=>p.endsWith(".scss"))){let p=await so(t.resolvedPaths.cwd,o?.isSrcDir??!1);p&&r.filesCreated.push(p)}}catch(o){s.error(`An error occurred while updating files: ${o instanceof Error?o.message:String(o)}`)}finally{if(!(r.filesCreated.length||r.filesUpdated.length)&&!r.filesSkipped.length&&i?.info("No files updated."),r.filesCreated.length){if(i?.stopAndPersist({symbol:a.cyan("\u2714"),text:`Created ${r.filesCreated.length} ${r.filesCreated.length===1?"file":"files"}:`}),!n.silent)for(let c of r.filesCreated)s.log(` - ${c}`)}else i?.stop();if(r.filesUpdated.length&&(I(`Updated ${r.filesUpdated.length} ${r.filesUpdated.length===1?"file":"files"}:`,{silent:n.silent})?.info(),!n.silent))for(let c of r.filesUpdated)s.log(` - ${c}`);if(r.filesSkipped.length&&(I(`Skipped ${r.filesSkipped.length} ${r.filesUpdated.length===1?"file":"files"}: (use --overwrite to overwrite)`,{silent:n.silent})?.info(),!n.silent))for(let c of r.filesSkipped)s.log(` - ${c}`);if(r.errors.length&&(I(`Failed to process ${r.errors.length} ${r.errors.length===1?"file":"files"}:`,{silent:n.silent})?.fail(),!n.silent))for(let{file:c,error:l}of r.errors)s.error(` - ${c}: ${l}`);n.silent||s.break()}return r}function eo(e,t,n){return n||(e.type==="registry:ui"?t.resolvedPaths.tiptapUi:e.type==="registry:ui-primitive"?t.resolvedPaths.tiptapUiPrimitives:e.type==="registry:ui-utils"?t.resolvedPaths.tiptapUiUtils:e.type==="registry:extension"?t.resolvedPaths.tiptapExtensions:e.type==="registry:node"?t.resolvedPaths.tiptapNodes:e.type==="registry:icon"?t.resolvedPaths.tiptapIcons:e.type==="registry:hook"?t.resolvedPaths.hooks:e.type==="registry:lib"?t.resolvedPaths.lib:e.type==="registry:context"?t.resolvedPaths.contexts:e.type==="registry:template"||e.type==="registry:component"?t.resolvedPaths.components:e.type==="registry:style"?t.resolvedPaths.styles:t.resolvedPaths.components)}function to(e,t){let n=e.map(c=>c.replace(/^\//,"")),r=t.replace(/^\//,""),i=r.split("/").slice(0,-1).join("/");if(!i)return"";let o=i.split("/");for(let c=o.length;c>0;c--){let l=o.slice(0,c).join("/");if(n.some(f=>f!==r&&f.startsWith(l+"/")))return"/"+l}return"/"+i}async function pn(e){return e.replace(/\r\n/g,`
18
18
  `).trim()}function no(e,t){if(!t)return"";if(t==="next-app")return e;if(t==="next-pages"){let n=e.replace(/^app\//,"pages/");return n=n.replace(/\/page(\.[jt]sx?)$/,"$1"),n}if(t==="react-router"){let n=e.replace(/^app\//,"app/routes/");return n=n.replace(/\/page(\.[jt]sx?)$/,"$1"),n}if(t==="laravel"){let n=e.replace(/^app\//,"resources/js/pages/");return n=n.replace(/\/page(\.[jt]sx?)$/,"$1"),n}return""}function ro(e,t){let n=e.replace(/^\/|\/$/g,""),r=t.replace(/^\/|\/$/g,""),i=n.split("/"),o=r.split("/"),c=o[o.length-1],l=i.findIndex(p=>p===c);return l===-1?i[i.length-1]:i.slice(l+1).join("/")}function oo(e,t,n){if(!e.target&&e.path.includes("tiptap-templates/")&&e.type!=="registry:page"){let o=e.path.match(/tiptap-templates\/([^/]+)\/(.*)/);if(o){let[,c,l]=o;if(l.startsWith("components/")){let p=l.replace("components/","");return W.join(t.resolvedPaths.components,"tiptap-templates",c,p)}return W.join(t.resolvedPaths.components,"tiptap-templates",c,l)}}if(e.target&&e.path.includes("tiptap-templates/")&&e.target.includes("/data/")){let o=e.path.match(/tiptap-templates\/([^/]+)\//);if(o){let c=o[1],l=e.target.split("/data/")[1];return W.join(t.resolvedPaths.components,"tiptap-templates",c,"data",l)}}if(e.target){if(e.target.startsWith("~/"))return W.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let o=e.target;return e.type==="registry:page"&&(o=no(o,n.framework),!o)?"":n.isSrcDir?W.join(t.resolvedPaths.cwd,"src",o.replace("src/","")):W.join(t.resolvedPaths.cwd,o.replace("src/",""))}let r=eo(e,t),i=ro(e.path,r);return W.join(r,i)}async function so(e,t){let n=t?W.join(e,"src"):e,r=W.join(n,Zr);return Le(r)?null:(Le(n)||await ve.mkdir(n,{recursive:!0}),await ve.writeFile(r,Qr,"utf-8"),W.relative(e,r))}import{z as ao}from"zod";import{execa as io}from"execa";async function It(e,t,n){e=Array.from(new Set(e));let r=$e(t.resolvedPaths.cwd,!1),i=new Set(Object.keys(r?.dependencies??{}));if(e=e.filter(p=>!i.has(p)),!e?.length)return;n={silent:!1,...n};let o=I("Installing development dependencies.",{silent:n.silent})?.start(),c=await K(t.resolvedPaths.cwd);o?.start(),await io(c,[c==="npm"?"install":"add",c==="npm"?"--save-dev":"-D",...e],{cwd:t.resolvedPaths.cwd}),o?.stopAndPersist({symbol:a.cyan("\u2714")})}async function Me(e,t,n){n={overwrite:!1,silent:!1,isNewProject:!1,...n};let r=await Kt(t);return r&&r.tiptapUi&&r.tiptapUi.resolvedPaths.cwd!==t.resolvedPaths.cwd?await lo(e,t,r,{...n}):await co(e,t,n)}async function co(e,t,n){let r=I("Checking registry",{silent:n.silent}).start(),i=await Xt(e,t);return i?(r.stopAndPersist({symbol:a.cyan("\u2714")}),await bt(i.dependencies,t,{silent:n.silent}),await It(i.devDependencies,t,{silent:n.silent}),await St(i.files,t,{overwrite:n.overwrite,silent:n.silent})):(r?.fail(),_(new Error("Failed to fetch components from registry")))}async function lo(e,t,n,r){let i=I("Checking registry",{silent:r.silent}).start(),o=await Tt(e),c=await je(o),l=ao.array(ae).parse(c);if(!l.length)return i?.fail(),_(new Error("Failed to fetch components from registry"));i.stopAndPersist({symbol:a.cyan("\u2714")});let p=en(l),f=Qt(),m=[],x=[],w=[],y=I("Installing components")?.start();for(let d of l){let b=f.get(d.type),v=p.get(d.name);if(!b)continue;let A=(d.type==="registry:ui"||v?.type==="registry:ui")&&n.tiptapUi||t;if(!A.resolvedPaths.tiptapUi)continue;let D=wt(t.resolvedPaths.cwd,A.resolvedPaths.tiptapUi),U=await yt(D,A.resolvedPaths.cwd)??A.resolvedPaths.cwd;await bt(d.dependencies||[],A,{silent:!0}),await It(d.devDependencies||[],A,{silent:!0});let u=await St(d.files||[],A,{overwrite:r.overwrite,silent:!0,rootSpinner:y});if(u.errors&&u.errors.length>0){I(`Encountered ${u.errors.length} errors:`,{silent:r.silent})?.fail();for(let{file:h,error:P}of u.errors)s.error(` - ${h}: ${P}`)}m.push(...u.filesCreated.map(h=>ue.relative(D,ue.join(U,h)))),x.push(...u.filesUpdated.map(h=>ue.relative(D,ue.join(U,h)))),w.push(...u.filesSkipped.map(h=>ue.relative(D,ue.join(U,h))))}if(y.stopAndPersist({symbol:a.cyan("\u2714")}),m.sort(),x.sort(),w.sort(),!(m.length||x.length)&&!w.length&&I("No files updated",{silent:r.silent})?.info(),m.length){I(`Created ${m.length} ${m.length===1?"file":"files"}:`,{silent:r.silent})?.stopAndPersist({symbol:a.cyan("\u2714")});for(let d of m)s.log(` - ${d}`)}if(x.length){I(`Updated ${x.length} ${x.length===1?"file":"files"}:`,{silent:r.silent})?.info();for(let d of x)s.log(` - ${d}`)}if(w.length){I(`Skipped ${w.length} ${w.length===1?"file":"files"}: (use --overwrite to overwrite)`,{silent:r.silent})?.info();for(let d of w)s.log(` - ${d}`)}return{filesCreated:m,filesUpdated:x,filesSkipped:w}}function de(e){return e.split(/[-_]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}import Ke from"node-fetch";import{HttpsProxyAgent as ko}from"https-proxy-agent";import z from"fs-extra";import Q from"path";import un from"os";import{execa as Be}from"execa";import mn from"yaml";var We="https://registry.tiptap.dev/",fe="//registry.tiptap.dev/:_authToken",Te="@tiptap-pro:registry";async function po(e){try{let t=Q.join(e,".gitignore"),n=".npmrc",r="";if(await z.pathExists(t)&&(r=await z.readFile(t,"utf8")),!r.split(`
19
19
  `).some(c=>c.trim()===n||c.trim()==="/.npmrc"||c.trim()==="**/.npmrc")){let c=r.trim()?`${r}
@@ -26,17 +26,17 @@ ${n}
26
26
  `))}function go(e,t){let n=[],r=new Set,i=e.split(`
27
27
  `);for(let o of i){let c=o.trim();if(!c){n.push(o);continue}if(c.startsWith("#")){n.push(o);continue}let l=o.indexOf("=");if(l!==-1){let p=o.substring(0,l).trim();p===Te?(n.push(`${Te}=${We}`),r.add(p)):p===fe?(n.push(`${fe}=${t}`),r.add(p)):n.push(o)}else n.push(o)}return{lines:n,processedKeys:r}}async function dn(e,t){try{let n=await ho(t);if(n)return n;if(e==="npm")return await yo(t);let r=await wo();return r||(e==="yarn"?await xo():null)}catch{return null}}async function ho(e){let t=Q.join(e,".npmrc");if(z.existsSync(t)){let n=await z.readFile(t,"utf8");return fn(n)}return null}async function yo(e){let{stdout:t}=await Be("npm",["config","get",fe],{cwd:e});return t&&t!=="undefined"?t.trim():null}async function wo(){let e=Q.join(un.homedir(),".npmrc");if(z.existsSync(e)){let t=await z.readFile(e,"utf8");return fn(t)}return null}async function xo(){let e=Q.join(un.homedir(),".yarnrc");return z.existsSync(e)?(await z.readFile(e,"utf8")).split(`
28
28
  `).map(r=>r.match(/^"\/\/registry\.tiptap\.dev\/:_authToken"\s+"?([^"\s]+)"?/)).find(r=>r!==null)?.[1]??null:null}function fn(e){let t=e.split(`
29
- `).filter(r=>r.startsWith("//registry.tiptap.dev/:_authToken="));return t.length===0?null:t[0].split("=")[1]?.trim()||null}var Ve=`${H}/api/cli/v1`,qe=process.env.https_proxy?new ko(process.env.https_proxy):void 0;async function gn(e){try{let t=await e.clone().json();if(t&&typeof t=="object"&&"error"in t&&typeof t.error=="string")return t.error;if(t&&typeof t=="object"&&"message"in t&&typeof t.message=="string")return t.message}catch{return null}return null}function Po(e,t){switch(e.status){case 400:return"The authentication request was not accepted. Please check your email and password, then try again.";case 401:return"Invalid email or password. Please check your credentials and try again.";case 403:return"Your account is not allowed to use registry authentication. Please check your Tiptap Cloud account access.";case 429:return"Too many login attempts. Please wait a moment and try again.";default:return t&&e.status>=500?t:e.status>=500?"Tiptap authentication is temporarily unavailable. Please try again later.":"Authentication failed. Please try again."}}function vo(e,t){switch(e.status){case 401:case 403:return"Your login succeeded, but your session could not be verified. Please run tiptap login again.";case 429:return"Your plans could not be loaded because there were too many requests. Please wait a moment and try again.";default:return t&&e.status>=500?t:e.status>=500?"Your plans could not be loaded because Tiptap Cloud is temporarily unavailable. Please try again later.":"Your plans could not be loaded. Please try again."}}async function hn({email:e,password:t,packageManager:n,writeConfig:r=!0,cwd:i}){let o=I("Authenticating with Tiptap registry...")?.start();try{if(!e||!t)return o?.fail("Authentication failed"),{success:!1,error:"Invalid credentials"};let c=await To(e,t),l=[],p=await Ke(`${Ve}/plans`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c.bearerToken}`},agent:qe});if(!p.ok){o?.fail("Authentication failed (could not load user plans)");let m=await gn(p);return{success:!1,error:vo(p,m)}}return l=(await p.json()).map(m=>m.name),l.length?(N.setBearerToken(c.bearerToken,{email:e,plans:l}),N.setAuthToken(c.authToken),r&&!await ze(c.authToken,n,i)?(o?.fail("Failed to save authentication token"),{success:!1,error:"Could not save authentication token"}):(o?.stopAndPersist({symbol:a.cyan("\u2714"),text:"Authentication successful"}),{success:!0,tokens:c})):(o?.fail("Authentication failed (no active plans)"),{success:!1,error:"No active plans found for user"})}catch(c){return o?.fail("Authentication failed"),{success:!1,error:c instanceof Error?c.message:"Unknown error during authentication"}}}async function To(e,t){let n=await Ke(`${Ve}/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t}),agent:qe});if(!n.ok){let i=await gn(n);throw new Error(Po(n,i))}let r=await n.json();return{bearerToken:r.token,authToken:r.authToken}}async function be(){try{let e=N.getBearerToken();if(!e)return{authenticated:!1};if(!N.isValidToken())return{authenticated:!1};let t=[];try{let i=await Ke(`${Ve}/plans`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},agent:qe});if(!i.ok)return N.clear(),{authenticated:!1};t=(await i.json()).map(l=>l.name);let c=N.getUserInfo();N.setBearerToken(e,{email:c.email,plans:t})}catch{return N.clear(),{authenticated:!1}}let n=N.getUserInfo(),r=N.getTokenExpiration();return{authenticated:!0,user:n.email||"unknown user",plans:t,expires:r,token:e}}catch(e){return s.error(`Auth status check error: ${e instanceof Error?e.message:"Unknown error"}`),{authenticated:!1}}}async function yn(){try{let e=N.getBearerToken();return e&&((await Ke(`${Ve}/logout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},agent:qe})).ok||s.warn("Logout API call failed, but clearing local tokens anyway")),N.clear(),{success:!0}}catch(e){return N.clear(),{success:!1,error:e instanceof Error?e.message:"Unknown error during logout"}}}import{Command as Se}from"commander";import{execa as bo}from"execa";import{z as ge}from"zod";import{confirm as So,input as Io,password as Co}from"@inquirer/prompts";var wn=ge.object({cwd:ge.string(),email:ge.string().optional(),password:ge.string().optional(),writeConfig:ge.boolean().optional(),showMessage:ge.boolean().default(!0)}),Ao=(e,t={})=>Io({message:a.reset(e),required:t.required??!0,validate:t.validate??(n=>n?!0:"This field is required"),theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Eo=(e,t={})=>Co({message:a.reset(e),validate:t.validate??(n=>n?!0:"This field is required"),mask:"*",theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Ie=(e,t=!0)=>So({message:a.reset(e),default:t,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}});function $o(e){switch(e){case"npm":return".npmrc (via npm config)";case"yarn":return".yarnrc.yml or .npmrc (depending on Yarn version)";case"pnpm":case"bun":return".npmrc";default:return"configuration file"}}async function Ro(e,t,n){s.log(`To use this token, add it to your project's package manager configuration in ${a.cyan(n)}:`),e==="npm"?(s.log("Run these commands in your project directory:"),s.log(" npm config set @tiptap-pro:registry https://registry.tiptap.dev/"),s.log(` npm config set //registry.tiptap.dev/:_authToken ${t}`),s.log(`
29
+ `).filter(r=>r.startsWith("//registry.tiptap.dev/:_authToken="));return t.length===0?null:t[0].split("=")[1]?.trim()||null}var Ve=`${H}/api/cli/v1`,qe=process.env.https_proxy?new ko(process.env.https_proxy):void 0;async function gn(e){try{let t=await e.clone().json();if(t&&typeof t=="object"&&"error"in t&&typeof t.error=="string")return t.error;if(t&&typeof t=="object"&&"message"in t&&typeof t.message=="string")return t.message}catch{return null}return null}function Po(e,t){switch(e.status){case 400:return"The authentication request was not accepted. Please check your email and password, then try again.";case 401:return"Invalid email or password. Please check your credentials and try again.";case 403:return"Your account is not allowed to use registry authentication. Please check your Tiptap Cloud account access.";case 429:return"Too many login attempts. Please wait a moment and try again.";default:return t&&e.status>=500?t:e.status>=500?"Tiptap authentication is temporarily unavailable. Please try again later.":"Authentication failed. Please try again."}}function vo(e,t){switch(e.status){case 401:case 403:return"Your login succeeded, but your session could not be verified. Please run tiptap login again.";case 429:return"Your plans could not be loaded because there were too many requests. Please wait a moment and try again.";default:return t&&e.status>=500?t:e.status>=500?"Your plans could not be loaded because Tiptap Cloud is temporarily unavailable. Please try again later.":"Your plans could not be loaded. Please try again."}}async function hn({email:e,password:t,packageManager:n,writeConfig:r=!0,cwd:i}){let o=I("Authenticating with Tiptap registry...")?.start();try{if(!e||!t)return o?.fail("Authentication failed"),{success:!1,error:"Invalid credentials"};let c=await To(e,t),l=[],p=await Ke(`${Ve}/plans`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c.bearerToken}`},agent:qe});if(!p.ok){o?.fail("Authentication failed (could not load user plans)");let m=await gn(p);return{success:!1,error:vo(p,m)}}return l=(await p.json()).map(m=>m.name),l.length?(j.setBearerToken(c.bearerToken,{email:e,plans:l}),j.setAuthToken(c.authToken),r&&!await ze(c.authToken,n,i)?(o?.fail("Failed to save authentication token"),{success:!1,error:"Could not save authentication token"}):(o?.stopAndPersist({symbol:a.cyan("\u2714"),text:"Authentication successful"}),{success:!0,tokens:c})):(o?.fail("Authentication failed (no active plans)"),{success:!1,error:"No active plans found for user"})}catch(c){return o?.fail("Authentication failed"),{success:!1,error:c instanceof Error?c.message:"Unknown error during authentication"}}}async function To(e,t){let n=await Ke(`${Ve}/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t}),agent:qe});if(!n.ok){let i=await gn(n);throw new Error(Po(n,i))}let r=await n.json();return{bearerToken:r.token,authToken:r.authToken}}async function be(){try{let e=j.getBearerToken();if(!e)return{authenticated:!1};if(!j.isValidToken())return{authenticated:!1};let t=[];try{let i=await Ke(`${Ve}/plans`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},agent:qe});if(!i.ok)return i.status===401&&j.clearSession(),{authenticated:!1};t=(await i.json()).map(l=>l.name);let c=j.getUserInfo();j.setBearerToken(e,{email:c.email,plans:t})}catch{return{authenticated:!1}}let n=j.getUserInfo(),r=j.getTokenExpiration();return{authenticated:!0,user:n.email||"unknown user",plans:t,expires:r,token:e}}catch(e){return s.error(`Auth status check error: ${e instanceof Error?e.message:"Unknown error"}`),{authenticated:!1}}}async function yn(){try{let e=j.getBearerToken();return e&&((await Ke(`${Ve}/logout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},agent:qe})).ok||s.warn("Logout API call failed, but clearing local tokens anyway")),j.clearSession(),{success:!0}}catch(e){return j.clearSession(),{success:!1,error:e instanceof Error?e.message:"Unknown error during logout"}}}import{Command as Se}from"commander";import{execa as bo}from"execa";import{z as ge}from"zod";import{confirm as So,input as Io,password as Co}from"@inquirer/prompts";var wn=ge.object({cwd:ge.string(),email:ge.string().optional(),password:ge.string().optional(),writeConfig:ge.boolean().optional(),showMessage:ge.boolean().default(!0)}),Ao=(e,t={})=>Io({message:a.reset(e),required:t.required??!0,validate:t.validate??(n=>n?!0:"This field is required"),theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Eo=(e,t={})=>Co({message:a.reset(e),validate:t.validate??(n=>n?!0:"This field is required"),mask:"*",theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Ie=(e,t=!0)=>So({message:a.reset(e),default:t,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}});function $o(e){switch(e){case"npm":return".npmrc (via npm config)";case"yarn":return".yarnrc.yml or .npmrc (depending on Yarn version)";case"pnpm":case"bun":return".npmrc";default:return"configuration file"}}async function Ro(e,t,n){s.log(`To use this token, add it to your project's package manager configuration in ${a.cyan(n)}:`),e==="npm"?(s.log("Run these commands in your project directory:"),s.log(" npm config set @tiptap-pro:registry https://registry.tiptap.dev/"),s.log(` npm config set //registry.tiptap.dev/:_authToken ${t}`),s.log(`
30
30
  Or add to your project's .npmrc file:`),s.log(" @tiptap-pro:registry=https://registry.tiptap.dev/"),s.log(` //registry.tiptap.dev/:_authToken=${t}`)):e==="yarn"?await No(n)?(s.log("Run these commands in your project directory:"),s.log(" yarn config set @tiptap-pro:registry https://registry.tiptap.dev/"),s.log(` yarn config set //registry.tiptap.dev/:_authToken ${t}`)):(s.log("Add to your project's .yarnrc.yml file:"),s.log(`npmScopes:
31
31
  tiptap-pro:
32
32
  npmRegistryServer: "https://registry.tiptap.dev/"
33
33
  npmAuthToken: "${t}"`)):(e==="pnpm"||e==="bun")&&(s.log("Add to your project's .npmrc file:"),s.log(a.cyan(`@tiptap-pro:registry=https://registry.tiptap.dev/
34
34
  //registry.tiptap.dev/:_authToken=${t}`)))}async function No(e){try{return(await bo("yarn",["--version"],{cwd:e})).stdout.startsWith("1.")}catch{return!1}}async function At(e){let{email:t,password:n,writeConfig:r,showMessage:i}=e,{cwd:o}=e;t||(t=await Ao("Email:",{validate:p=>p?!0:"Please enter your email"})),n||(n=await Eo("Password:",{validate:p=>p?!0:"Please enter your password"})),(!t||!n)&&(s.error("Authentication cancelled"),process.exit(0));let c=await K(o);if(r===void 0){let p=$o(c);r=await Ie(`Would you like to save the auth token to your ${p}?`),r===void 0&&(s.error("Authentication cancelled"),process.exit(0))}let l=await hn({email:t,password:n,packageManager:c,writeConfig:r??!1,cwd:o});return l.success&&l.tokens?(r&&i?(s.log(`
35
35
  Registry auth token saved to project directory for ${a.cyan(c)}`),s.log(`.npmrc file saved at: ${a.cyan(o)}`),s.log(`Project path: ${a.cyan(o)}`)):l.tokens.authToken&&i&&(s.log(`
36
- Registry Auth Token: ${a.cyan(l.tokens.authToken)}`),s.log("This token should be added to your project's configuration:"),await Ro(c,l.tokens.authToken,o)),i&&s.log("Bearer token saved globally for CLI authentication"),!0):(s.error("Authentication failed: "+l.error),!1)}async function jo(e){let t=await K(e),n=await be();if(n.authenticated){if(s.success(`Authenticated as ${a.cyan(n.user??"unknown user")}`),n.plans&&n.plans.length>0?n.plans.length===1?s.log(`Plan: ${a.cyan(n.plans[0])}`):s.log(`Plans: ${a.cyan(n.plans.join(", "))}`):s.log(`Plans: ${a.cyan("No active plans")}`),n.expires){let i=new Date(n.expires),o=new Date,c=Math.ceil((i.getTime()-o.getTime())/(1e3*60*60*24));c>30?s.log(`Token expires: ${a.cyan(i.toDateString())} (${c} days)`):c>0?s.log(`Token expires: ${a.yellow(i.toDateString())} (${c} days)`):s.log(`Token expires: ${a.red("Expired")}`)}if(n.token){let i=n.token.substring(0,10)+"...";s.log(`Bearer token: ${a.cyan(i)}`)}let r=await dn(t,e);if(r){let i=r.substring(0,10)+"...";s.log(`Registry token: ${a.cyan(i)}`)}else s.log(`Registry token: ${a.yellow("Not configured for this project")}`),s.log(`Run ${a.cyan("@tiptap/cli login --write-config")} to configure for this project`)}else s.log("Not authenticated with Tiptap registry"),s.log(`Run ${a.cyan("@tiptap/cli login")} to authenticate`)}var xn=new Se().command("login").description("log in to your Tiptap Cloud account").option("-e, --email <email>","your account email").option("-p, --password <password>","your account password").option("--write-config","write the auth token to your package manager config",void 0).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{try{let t=wn.parse(e);await At(t)}catch(t){_(t)}}),kn=new Se().command("status").description("review your Tiptap Cloud authentication status").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{let t=wn.parse(e),{cwd:n}=t;try{await jo(n)}catch(r){_(r)}}),Pn=new Se().command("logout").description("log out from your Tiptap registry account").action(async()=>{try{let e=I("Logging out...")?.start(),t=await yn();t.success?e?.stopAndPersist({symbol:a.cyan("\u2714"),text:"Successfully logged out"}):(e?.fail("Logout failed"),s.error("Logout failed: "+t.error))}catch(e){_(e)}});async function _o(){s.log(""),s.log(a.yellow("\u{1F4CB} Tiptap Pro License Information")),s.log("");let e=N.hasAcceptedLicense(),t=N.getUserInfo();e?(s.log(`${a.cyan("\u2714")} Pro License and Terms of Service accepted`),t.email&&s.log(` Accepted by: ${a.cyan(t.email)}`),s.log("")):(s.log(a.yellow("\u26A0 Pro License and Terms of Service not yet accepted")),s.log(" License acceptance is required for using paid components"),s.log("")),s.log("License Details:"),s.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),s.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),s.log(""),s.log("About Paid Components:"),s.log(" Some paid UI components or templates are limited to specific plans."),s.log(" The license is valid during your trial period and active subscription."),s.log(""),e&&(s.log(a.gray("Available commands:")),s.log(a.gray(` \u2022 ${a.cyan("tiptap license forget me")} - Reset license acceptance`)),s.log(""))}async function Oo(){if(!N.hasAcceptedLicense()){s.log(a.yellow("\u26A0 License has not been accepted yet"));return}await Ie("Are you sure you want to reset your license acceptance?",!1)?(N.clearLicenseAcceptance(),s.log(`${a.cyan("\u2714")} License acceptance has been reset`),s.log(" You will need to accept the license again when installing paid components")):s.log("License acceptance reset cancelled")}var vn=new Se().command("license").description("display Tiptap Pro license information and acceptance status").action(async()=>{try{await _o()}catch(e){_(e)}}).addCommand(new Se().command("forget me").description("reset license acceptance status").action(async()=>{try{await Oo()}catch(e){_(e)}}));function Fo(e){return e.some(t=>t.plans&&t.plans.some(n=>pe.includes(n)))}async function Do(e){if(e.filter(n=>n.plans&&n.plans.some(r=>pe.includes(r))).length===0)return!0;if(N.hasAcceptedLicense())return s.log(`${a.cyan("\u2714")} Pro license accepted`),!0;s.log(""),s.log(a.yellow("\u{1F4CB} License Agreement")),s.log(""),s.log("Integrating paid components requires accepting:"),s.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),s.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),s.log(""),s.log(a.gray(" Valid during trial and active subscription")),s.log("");try{return await Ie("Do you accept the Pro license and terms of service?",!1)?(N.setLicenseAccepted(),s.log(`${a.cyan("\u2714")} License accepted`),!0):(s.log(a.gray("License not accepted")),s.log(a.gray("Tip: You can still install free components")),!1)}catch{return s.log(a.gray("License acceptance cancelled")),!1}}async function he(e,t){try{if(!Fo(e))return!0;if((await be()).authenticated){let i=await K(t);await Uo(i,t)}else{if(s.log(""),s.log(a.yellow("\u{1F510} Authentication Required")),s.log(""),s.log("Pro components require authentication."),s.log(`Run ${a.cyan("tiptap login")} or create an account at ${a.cyan("https://cloud.tiptap.dev")}`),s.log(""),!await Ie("Would you like to login now?",!0))return s.log(""),s.log(a.gray("Authentication cancelled")),s.log(a.gray("Tip: You can still install free components")),!1;if(!await At({cwd:t,writeConfig:!0,showMessage:!1}))return!1}return!!await Do(e)}catch(n){return s.error(`Authentication check failed: ${n instanceof Error?n.message:"Unknown error"}`),!1}}async function Uo(e,t){let n=I("Creating registry configuration...")?.start();try{if(!(await be()).authenticated)return n?.fail("Cannot create configuration - user not authenticated"),!1;let i=N.getAuthToken();if(!i)return n?.fail("No authentication token found"),!1;if(!await ze(i,e,t))return n?.fail("Failed to save authentication token"),!1;n?.stopAndPersist({symbol:a.cyan("\u2714"),text:".npmrc created successfully"})}catch(r){n?.fail("Failed to create registry configuration"),s.error(`Configuration error: ${r instanceof Error?r.message:"Unknown error"}`)}}import Je from"process";function Tn(){return Je.stdout.columns||80}function bn(e,t,n){let r=n?.borderColor||"gray",i=n?.padding!==!1,o="",c="",l="",p="",f="-",m="",x=Tn(),w=Math.min(x-4,80),y=a[r],O=y(o+f.repeat(w-2)+c),d=y(l+f.repeat(w-2)+p),b=y(m),v=[];i&&v.push(""),v.push(O),v.push(`${b}${" ".repeat(w-2)}${b}`);let A=Math.floor((w-4-Et(e).length)/2),D=e.padStart(A+Et(e).length).padEnd(w-4);return v.push(`${b} ${D} ${b}`),v.push(`${b}${" ".repeat(w-2)}${b}`),t.forEach(U=>{let u=Et(U).length,h=w-4-u,P=U+" ".repeat(Math.max(0,h));v.push(`${b} ${P} ${b}`)}),t.length>0&&v.push(`${b}${" ".repeat(w-2)}${b}`),v.push(d),i&&v.push(""),v}function Ye(e,t){let n=t?[t]:[];return bn(`${e}`,n,{borderColor:"gray"})}function Ge(e,t){return bn(`\u26A0\uFE0F ${e}`,t,{borderColor:"yellow"})}function G(e){e.forEach(t=>s.log(t))}function Et(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function He(e,t){let n=[];return n.push(""),n.push(a.cyan(e)),n.push(""),t.forEach(r=>{n.push(` \u2022 ${r}`)}),n.push(""),n}function Xe(){Je.stdout.write("\x1B[2J\x1B[0f"),Je.platform==="win32"&&Je.stdout.write("\x1B[2J\x1B[3J\x1B[H")}function $t(){let e=Math.min(Tn()-4,80);return a.gray("-".repeat(e))}import{existsSync as Sn}from"fs";import In from"path";function Cn(e){let t=e.name;return t===g["next-app"].name||t===g["next-pages"].name?"NEXT_PUBLIC_":t===g.astro.name?"PUBLIC_":t===g.vite.name||t===g["tanstack-start"].name||t===g["react-router"].name?"VITE_":(t===g.laravel.name||t===g.manual.name,"")}function An(e){if(!e?.resolvedPaths?.styles)return"scss";let t=e.resolvedPaths.styles,n=In.join(t,"_variables.scss"),r=In.join(t,"_variables.css");return Sn(r)?"css":(Sn(n),"scss")}function En(e,t){let n=e?.name||"unknown",r=t?.resolvedPaths?.styles?.includes("/src/"),i=t?.resolvedPaths?.components?.includes("/src/"),o="your main CSS file",c="./styles/";switch(n){case g["next-app"].name:i?(o="src/app/globals.css",c="../styles/"):r?(o="app/globals.css",c="../src/styles/"):(o="app/globals.css",c="../styles/");break;case g["next-pages"].name:i||r?(o="src/styles/globals.css",c="./"):(o="styles/globals.css",c="./");break;case g.vite.name:o="src/index.css",c="./styles/";break;case g["react-router"].name:o="src/index.css",c="./styles/";break;case g["tanstack-start"].name:o="src/index.css",c="./styles/";break;case g.astro.name:r?(o="src/layouts/Layout.astro",c="../styles/"):(o="src/layouts/Layout.astro",c="../../styles/");break;case g.laravel.name:o="resources/css/app.css",c="../styles/";break;case g.manual.name:default:i||r?(o="src/index.css",c="./styles/"):(o="your main CSS file",c="./styles/");break}return{cssFile:o,importPath:c}}function ye(e,t){let n=An(t),{cssFile:r,importPath:i}=En(e,t),o=["The editor requires these style imports:","",`Add to ${a.cyan(r)}:`,"",a.yellow(` @import '${i}_variables.${n}';`),a.yellow(` @import '${i}_keyframe-animations.${n}';`),"","Without these imports, the editor will not display correctly.","",`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/getting-started/style")}`],c=Ge("Action Required: Import Styles",o);G(c)}function Ze(e){let t=Cn(e),n=["The Notion-like template requires environment variables for collaborative features:","",a.yellow(`${t}TIPTAP_COLLAB_DOC_PREFIX`)+" - Document prefix (required)",a.yellow(`${t}TIPTAP_COLLAB_APP_ID`)+" - Document Server App ID (required)",a.yellow(`${t}TIPTAP_COLLAB_TOKEN`)+" - JWT token for collaboration (required)",a.yellow(`${t}TIPTAP_AI_APP_ID`)+" - AI App ID (required)",a.yellow(`${t}TIPTAP_AI_TOKEN`)+" - JWT token for AI (required)","","Get these credentials from your account at cloud.tiptap.dev","",`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/templates/notion-like-editor")}`],r=Ge("Action Required: Environment Setup",n);G(r)}function Qe(e,t){let n=Cn(e),r=An(t),{cssFile:i,importPath:o}=En(e,t),c=["The Notion-like template is a complete editor application that requires","additional configuration before it can be used:","",a.cyan("1. Import Required Styles"),` Add to ${a.yellow(i)}:`,a.gray(` @import '${o}_variables.${r}';`),a.gray(` @import '${o}_keyframe-animations.${r}';`),"",a.cyan("2. Add Environment Variables (for collaborative features)")," Add to your .env file:",a.gray(` ${n}TIPTAP_COLLAB_DOC_PREFIX - Document prefix`),a.gray(` ${n}TIPTAP_COLLAB_APP_ID - Document Server App ID`),a.gray(` ${n}TIPTAP_COLLAB_TOKEN - JWT token for collaboration`),a.gray(` ${n}TIPTAP_AI_APP_ID - AI App ID`),a.gray(` ${n}TIPTAP_AI_TOKEN - JWT token for AI`),"",`Get credentials at ${a.cyan("https://cloud.tiptap.dev")}`,`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/templates/notion-like-editor")}`],l=Ge("Next Steps: Configure your Editor",c);G(l)}function et(){s.log(""),s.log(a.cyan("\u2192 Table Node integration guide:")),s.log(` ${a.dim("https://tiptap.dev/docs/ui-components/node-components/table-node#usage")}`),s.log("")}import{existsSync as tt,promises as $n}from"fs";import j from"path";function Lo(e){if(!e?.resolvedPaths?.styles)return"scss";let t=e.resolvedPaths.styles,n=j.join(t,"_variables.scss"),r=j.join(t,"_variables.css");return tt(r)?"css":(tt(n),"scss")}function Mo(e,t){let n=e.name,r=t.resolvedPaths.cwd,i=t.resolvedPaths.components?.includes("/src/"),o=t.resolvedPaths.styles?.includes("/src/"),c=[];switch(n){case g["next-app"].name:i?c=[j.join(r,"src/app/globals.css"),j.join(r,"src/app/globals.scss")]:c=[j.join(r,"app/globals.css"),j.join(r,"app/globals.scss")];break;case g["next-pages"].name:i?c=[j.join(r,"src/styles/globals.css"),j.join(r,"src/styles/globals.scss")]:c=[j.join(r,"styles/globals.css"),j.join(r,"styles/globals.scss")];break;case g.vite.name:case g["react-router"].name:case g["tanstack-start"].name:c=[j.join(r,"src/index.css"),j.join(r,"src/main.css"),j.join(r,"src/App.css")];break;case g.astro.name:c=[j.join(r,"src/styles/main.css"),j.join(r,"src/styles/global.css")];break;case g.laravel.name:c=[j.join(r,"resources/css/app.css")];break;case g.manual.name:default:i||o?c=[j.join(r,"src/index.css"),j.join(r,"src/main.css"),j.join(r,"src/App.css"),j.join(r,"src/styles/main.css")]:c=[j.join(r,"index.css"),j.join(r,"main.css"),j.join(r,"styles/main.css")];break}for(let l of c)if(tt(l))return l;return c[0]||null}function Bo(e,t){let n=j.dirname(e),r=j.relative(n,t);return r=r.replace(/\\/g,"/"),r.startsWith(".")||(r="./"+r),r.endsWith("/")||(r+="/"),r}function Wo(e,t){let n=new RegExp(`@import\\s+['"].*_variables\\.${t}['"]`,"i"),r=new RegExp(`@import\\s+['"].*_keyframe-animations\\.${t}['"]`,"i");return n.test(e)&&r.test(e)}async function ee(e,t,n){try{if(![...e.filesCreated||[],...e.filesUpdated||[],...e.filesSkipped||[]].some(x=>x.includes("_variables.")||x.includes("_keyframe-animations.")))return{success:!0,message:"No style files to import"};let o=Lo(t),c=Mo(n,t);if(!c)return{success:!1,message:"Could not determine main CSS file location"};if(!tt(c))return{success:!1,message:`Main CSS file not found at ${c}`};let l=await $n.readFile(c,"utf-8");if(Wo(l,o))return{success:!0,message:"Style imports already exist",filePath:c};let p=Bo(c,t.resolvedPaths.styles),m=`${[`@import '${p}_variables.${o}';`,`@import '${p}_keyframe-animations.${o}';`].join(`
36
+ Registry Auth Token: ${a.cyan(l.tokens.authToken)}`),s.log("This token should be added to your project's configuration:"),await Ro(c,l.tokens.authToken,o)),i&&s.log("Bearer token saved globally for CLI authentication"),!0):(s.error("Authentication failed: "+l.error),!1)}async function jo(e){let t=await K(e),n=await be();if(n.authenticated){if(s.success(`Authenticated as ${a.cyan(n.user??"unknown user")}`),n.plans&&n.plans.length>0?n.plans.length===1?s.log(`Plan: ${a.cyan(n.plans[0])}`):s.log(`Plans: ${a.cyan(n.plans.join(", "))}`):s.log(`Plans: ${a.cyan("No active plans")}`),n.expires){let i=new Date(n.expires),o=new Date,c=Math.ceil((i.getTime()-o.getTime())/(1e3*60*60*24));c>30?s.log(`Token expires: ${a.cyan(i.toDateString())} (${c} days)`):c>0?s.log(`Token expires: ${a.yellow(i.toDateString())} (${c} days)`):s.log(`Token expires: ${a.red("Expired")}`)}if(n.token){let i=n.token.substring(0,10)+"...";s.log(`Bearer token: ${a.cyan(i)}`)}let r=await dn(t,e);if(r){let i=r.substring(0,10)+"...";s.log(`Registry token: ${a.cyan(i)}`)}else s.log(`Registry token: ${a.yellow("Not configured for this project")}`),s.log(`Run ${a.cyan("@tiptap/cli login --write-config")} to configure for this project`)}else s.log("Not authenticated with Tiptap registry"),s.log(`Run ${a.cyan("@tiptap/cli login")} to authenticate`)}var xn=new Se().command("login").description("log in to your Tiptap Cloud account").option("-e, --email <email>","your account email").option("-p, --password <password>","your account password").option("--write-config","write the auth token to your package manager config",void 0).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{try{let t=wn.parse(e);await At(t)}catch(t){_(t)}}),kn=new Se().command("status").description("review your Tiptap Cloud authentication status").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{let t=wn.parse(e),{cwd:n}=t;try{await jo(n)}catch(r){_(r)}}),Pn=new Se().command("logout").description("log out from your Tiptap registry account").action(async()=>{try{let e=I("Logging out...")?.start(),t=await yn();t.success?e?.stopAndPersist({symbol:a.cyan("\u2714"),text:"Successfully logged out"}):(e?.fail("Logout failed"),s.error("Logout failed: "+t.error))}catch(e){_(e)}});async function _o(){s.log(""),s.log(a.yellow("\u{1F4CB} Tiptap Pro License Information")),s.log("");let e=j.hasAcceptedLicense(),t=j.getUserInfo();e?(s.log(`${a.cyan("\u2714")} Pro License and Terms of Service accepted`),t.email&&s.log(` Accepted by: ${a.cyan(t.email)}`),s.log("")):(s.log(a.yellow("\u26A0 Pro License and Terms of Service not yet accepted")),s.log(" License acceptance is required for using paid components"),s.log("")),s.log("License Details:"),s.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),s.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),s.log(""),s.log("About Paid Components:"),s.log(" Some paid UI components or templates are limited to specific plans."),s.log(" The license is valid during your trial period and active subscription."),s.log(""),e&&(s.log(a.gray("Available commands:")),s.log(a.gray(` \u2022 ${a.cyan("tiptap license forget me")} - Reset license acceptance`)),s.log(""))}async function Oo(){if(!j.hasAcceptedLicense()){s.log(a.yellow("\u26A0 License has not been accepted yet"));return}await Ie("Are you sure you want to reset your license acceptance?",!1)?(j.clearLicenseAcceptance(),s.log(`${a.cyan("\u2714")} License acceptance has been reset`),s.log(" You will need to accept the license again when installing paid components")):s.log("License acceptance reset cancelled")}var vn=new Se().command("license").description("display Tiptap Pro license information and acceptance status").action(async()=>{try{await _o()}catch(e){_(e)}}).addCommand(new Se().command("forget me").description("reset license acceptance status").action(async()=>{try{await Oo()}catch(e){_(e)}}));function Fo(e){return e.some(t=>t.plans&&t.plans.some(n=>pe.includes(n)))}async function Do(e){if(e.filter(n=>n.plans&&n.plans.some(r=>pe.includes(r))).length===0)return!0;if(j.hasAcceptedLicense())return s.log(`${a.cyan("\u2714")} Pro license accepted`),!0;s.log(""),s.log(a.yellow("\u{1F4CB} License Agreement")),s.log(""),s.log("Integrating paid components requires accepting:"),s.log(` \u2022 Pro License: ${a.cyan("https://tiptap.dev/pro-license")}`),s.log(` \u2022 Terms of Service: ${a.cyan("https://tiptap.dev/terms-of-service")}`),s.log(""),s.log(a.gray(" Valid during trial and active subscription")),s.log("");try{return await Ie("Do you accept the Pro license and terms of service?",!1)?(j.setLicenseAccepted(),s.log(`${a.cyan("\u2714")} License accepted`),!0):(s.log(a.gray("License not accepted")),s.log(a.gray("Tip: You can still install free components")),!1)}catch{return s.log(a.gray("License acceptance cancelled")),!1}}async function he(e,t){try{if(!Fo(e))return!0;if((await be()).authenticated){let i=await K(t);await Uo(i,t)}else{if(s.log(""),s.log(a.yellow("\u{1F510} Authentication Required")),s.log(""),s.log("Pro components require authentication."),s.log(`Run ${a.cyan("tiptap login")} or create an account at ${a.cyan("https://cloud.tiptap.dev")}`),s.log(""),!await Ie("Would you like to login now?",!0))return s.log(""),s.log(a.gray("Authentication cancelled")),s.log(a.gray("Tip: You can still install free components")),!1;if(!await At({cwd:t,writeConfig:!0,showMessage:!1}))return!1}return!!await Do(e)}catch(n){return s.error(`Authentication check failed: ${n instanceof Error?n.message:"Unknown error"}`),!1}}async function Uo(e,t){let n=I("Creating registry configuration...")?.start();try{if(!(await be()).authenticated)return n?.fail("Cannot create configuration - user not authenticated"),!1;let i=j.getAuthToken();if(!i)return n?.fail("No authentication token found"),!1;if(!await ze(i,e,t))return n?.fail("Failed to save authentication token"),!1;n?.stopAndPersist({symbol:a.cyan("\u2714"),text:".npmrc created successfully"})}catch(r){n?.fail("Failed to create registry configuration"),s.error(`Configuration error: ${r instanceof Error?r.message:"Unknown error"}`)}}import Je from"process";function Tn(){return Je.stdout.columns||80}function bn(e,t,n){let r=n?.borderColor||"gray",i=n?.padding!==!1,o="",c="",l="",p="",f="-",m="",x=Tn(),w=Math.min(x-4,80),y=a[r],O=y(o+f.repeat(w-2)+c),d=y(l+f.repeat(w-2)+p),b=y(m),v=[];i&&v.push(""),v.push(O),v.push(`${b}${" ".repeat(w-2)}${b}`);let A=Math.floor((w-4-Et(e).length)/2),D=e.padStart(A+Et(e).length).padEnd(w-4);return v.push(`${b} ${D} ${b}`),v.push(`${b}${" ".repeat(w-2)}${b}`),t.forEach(U=>{let u=Et(U).length,h=w-4-u,P=U+" ".repeat(Math.max(0,h));v.push(`${b} ${P} ${b}`)}),t.length>0&&v.push(`${b}${" ".repeat(w-2)}${b}`),v.push(d),i&&v.push(""),v}function Ye(e,t){let n=t?[t]:[];return bn(`${e}`,n,{borderColor:"gray"})}function Ge(e,t){return bn(`\u26A0\uFE0F ${e}`,t,{borderColor:"yellow"})}function G(e){e.forEach(t=>s.log(t))}function Et(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function He(e,t){let n=[];return n.push(""),n.push(a.cyan(e)),n.push(""),t.forEach(r=>{n.push(` \u2022 ${r}`)}),n.push(""),n}function Xe(){Je.stdout.write("\x1B[2J\x1B[0f"),Je.platform==="win32"&&Je.stdout.write("\x1B[2J\x1B[3J\x1B[H")}function $t(){let e=Math.min(Tn()-4,80);return a.gray("-".repeat(e))}import{existsSync as Sn}from"fs";import In from"path";function Cn(e){let t=e.name;return t===g["next-app"].name||t===g["next-pages"].name?"NEXT_PUBLIC_":t===g.astro.name?"PUBLIC_":t===g.vite.name||t===g["tanstack-start"].name||t===g["react-router"].name?"VITE_":(t===g.laravel.name||t===g.manual.name,"")}function An(e){if(!e?.resolvedPaths?.styles)return"scss";let t=e.resolvedPaths.styles,n=In.join(t,"_variables.scss"),r=In.join(t,"_variables.css");return Sn(r)?"css":(Sn(n),"scss")}function En(e,t){let n=e?.name||"unknown",r=t?.resolvedPaths?.styles?.includes("/src/"),i=t?.resolvedPaths?.components?.includes("/src/"),o="your main CSS file",c="./styles/";switch(n){case g["next-app"].name:i?(o="src/app/globals.css",c="../styles/"):r?(o="app/globals.css",c="../src/styles/"):(o="app/globals.css",c="../styles/");break;case g["next-pages"].name:i||r?(o="src/styles/globals.css",c="./"):(o="styles/globals.css",c="./");break;case g.vite.name:o="src/index.css",c="./styles/";break;case g["react-router"].name:o="src/index.css",c="./styles/";break;case g["tanstack-start"].name:o="src/index.css",c="./styles/";break;case g.astro.name:r?(o="src/layouts/Layout.astro",c="../styles/"):(o="src/layouts/Layout.astro",c="../../styles/");break;case g.laravel.name:o="resources/css/app.css",c="../styles/";break;case g.manual.name:default:i||r?(o="src/index.css",c="./styles/"):(o="your main CSS file",c="./styles/");break}return{cssFile:o,importPath:c}}function ye(e,t){let n=An(t),{cssFile:r,importPath:i}=En(e,t),o=["The editor requires these style imports:","",`Add to ${a.cyan(r)}:`,"",a.yellow(` @import '${i}_variables.${n}';`),a.yellow(` @import '${i}_keyframe-animations.${n}';`),"","Without these imports, the editor will not display correctly.","",`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/getting-started/style")}`],c=Ge("Action Required: Import Styles",o);G(c)}function Ze(e){let t=Cn(e),n=["The Notion-like template requires environment variables for collaborative features:","",a.yellow(`${t}TIPTAP_COLLAB_DOC_PREFIX`)+" - Document prefix (required)",a.yellow(`${t}TIPTAP_COLLAB_APP_ID`)+" - Document Server App ID (required)",a.yellow(`${t}TIPTAP_COLLAB_TOKEN`)+" - JWT token for collaboration (required)",a.yellow(`${t}TIPTAP_AI_APP_ID`)+" - AI App ID (required)",a.yellow(`${t}TIPTAP_AI_TOKEN`)+" - JWT token for AI (required)","","Get these credentials from your account at cloud.tiptap.dev","",`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/templates/notion-like-editor")}`],r=Ge("Action Required: Environment Setup",n);G(r)}function Qe(e,t){let n=Cn(e),r=An(t),{cssFile:i,importPath:o}=En(e,t),c=["The Notion-like template is a complete editor application that requires","additional configuration before it can be used:","",a.cyan("1. Import Required Styles"),` Add to ${a.yellow(i)}:`,a.gray(` @import '${o}_variables.${r}';`),a.gray(` @import '${o}_keyframe-animations.${r}';`),"",a.cyan("2. Add Environment Variables (for collaborative features)")," Add to your .env file:",a.gray(` ${n}TIPTAP_COLLAB_DOC_PREFIX - Document prefix`),a.gray(` ${n}TIPTAP_COLLAB_APP_ID - Document Server App ID`),a.gray(` ${n}TIPTAP_COLLAB_TOKEN - JWT token for collaboration`),a.gray(` ${n}TIPTAP_AI_APP_ID - AI App ID`),a.gray(` ${n}TIPTAP_AI_TOKEN - JWT token for AI`),"",`Get credentials at ${a.cyan("https://cloud.tiptap.dev")}`,`Setup guide: ${a.cyan("https://tiptap.dev/docs/ui-components/templates/notion-like-editor")}`],l=Ge("Next Steps: Configure your Editor",c);G(l)}function et(){s.log(""),s.log(a.cyan("\u2192 Table Node integration guide:")),s.log(` ${a.dim("https://tiptap.dev/docs/ui-components/node-components/table-node#usage")}`),s.log("")}import{existsSync as tt,promises as $n}from"fs";import N from"path";function Lo(e){if(!e?.resolvedPaths?.styles)return"scss";let t=e.resolvedPaths.styles,n=N.join(t,"_variables.scss"),r=N.join(t,"_variables.css");return tt(r)?"css":(tt(n),"scss")}function Mo(e,t){let n=e.name,r=t.resolvedPaths.cwd,i=t.resolvedPaths.components?.includes("/src/"),o=t.resolvedPaths.styles?.includes("/src/"),c=[];switch(n){case g["next-app"].name:i?c=[N.join(r,"src/app/globals.css"),N.join(r,"src/app/globals.scss")]:c=[N.join(r,"app/globals.css"),N.join(r,"app/globals.scss")];break;case g["next-pages"].name:i?c=[N.join(r,"src/styles/globals.css"),N.join(r,"src/styles/globals.scss")]:c=[N.join(r,"styles/globals.css"),N.join(r,"styles/globals.scss")];break;case g.vite.name:case g["react-router"].name:case g["tanstack-start"].name:c=[N.join(r,"src/index.css"),N.join(r,"src/main.css"),N.join(r,"src/App.css")];break;case g.astro.name:c=[N.join(r,"src/styles/main.css"),N.join(r,"src/styles/global.css")];break;case g.laravel.name:c=[N.join(r,"resources/css/app.css")];break;case g.manual.name:default:i||o?c=[N.join(r,"src/index.css"),N.join(r,"src/main.css"),N.join(r,"src/App.css"),N.join(r,"src/styles/main.css")]:c=[N.join(r,"index.css"),N.join(r,"main.css"),N.join(r,"styles/main.css")];break}for(let l of c)if(tt(l))return l;return c[0]||null}function Bo(e,t){let n=N.dirname(e),r=N.relative(n,t);return r=r.replace(/\\/g,"/"),r.startsWith(".")||(r="./"+r),r.endsWith("/")||(r+="/"),r}function Wo(e,t){let n=new RegExp(`@import\\s+['"].*_variables\\.${t}['"]`,"i"),r=new RegExp(`@import\\s+['"].*_keyframe-animations\\.${t}['"]`,"i");return n.test(e)&&r.test(e)}async function ee(e,t,n){try{if(![...e.filesCreated||[],...e.filesUpdated||[],...e.filesSkipped||[]].some(x=>x.includes("_variables.")||x.includes("_keyframe-animations.")))return{success:!0,message:"No style files to import"};let o=Lo(t),c=Mo(n,t);if(!c)return{success:!1,message:"Could not determine main CSS file location"};if(!tt(c))return{success:!1,message:`Main CSS file not found at ${c}`};let l=await $n.readFile(c,"utf-8");if(Wo(l,o))return{success:!0,message:"Style imports already exist",filePath:c};let p=Bo(c,t.resolvedPaths.styles),m=`${[`@import '${p}_variables.${o}';`,`@import '${p}_keyframe-animations.${o}';`].join(`
37
37
  `)}
38
38
 
39
- ${l}`;return await $n.writeFile(c,m,"utf-8"),{success:!0,message:"Style imports added",filePath:c}}catch(r){return s.error(`Failed to auto-import styles: ${r instanceof Error?r.message:String(r)}`),{success:!1,message:`Failed to auto-import styles: ${r instanceof Error?r.message:String(r)}`}}}function te(e){if(!e.success){s.warn(a.yellow(`\u26A0 ${e.message}`));return}if(e.message==="No style files to import"||e.message==="Style imports already exist")return;let n=(e.filePath?j.relative(process.cwd(),e.filePath):"main CSS file").replace(/\.\.\//g,"");s.log(`${a.green("\u2714")} Style imports automatically added to ${a.cyan(n)}`),s.log("")}var Jo=ce.object({components:ce.array(ce.string()).optional(),cwd:ce.string(),path:ce.string().optional(),silent:ce.boolean(),overwrite:ce.boolean()}),Yo=1e3,Rn=92,Go=48,Ho=4,Ce={emptyRegistry:a.red("\u274C No components or templates found"),operationCancelled:a.gray("Operation cancelled"),missingDirectory:a.red("\u274C Directory not found. Use init to initialize a project first.")},Nt={icon:{cursor:a.cyan("\u25B8"),checked:a.cyan("\u25C9"),unchecked:"\u25CB"},style:{highlight:e=>a.cyan(e),message:e=>e,answer:e=>""},prefix:{done:a.cyan("\u2714"),idle:a.cyan("?")}};function Xo(e){return e?.replace(/\s+/g," ").trim()??""}function Zo(e,t){let n=e.split(" "),r=[],i="";for(let o of n){let c=i?`${i} ${o}`:o;c.length>t&&i?(r.push(i),i=o):i=c}return i&&r.push(i),r}function Qo(){let e=process.stdout.columns;return e?Math.max(Go,Math.min(Rn,e-Ho)):Rn}function es(e){let t=Rt(e);return e?.includes("light")||e?.includes("open-source")?"Open Source - MIT":t}function ts(e){let t=es(e.plans),n=`${a.bold(de(e.name))} ${a.dim(`(${t})`)}:`,r=Xo(e.description);if(!r)return n;let i=Zo(r,Qo()).map(o=>` ${o}`);return[n,...i].join(`
39
+ ${l}`;return await $n.writeFile(c,m,"utf-8"),{success:!0,message:"Style imports added",filePath:c}}catch(r){return s.error(`Failed to auto-import styles: ${r instanceof Error?r.message:String(r)}`),{success:!1,message:`Failed to auto-import styles: ${r instanceof Error?r.message:String(r)}`}}}function te(e){if(!e.success){s.warn(a.yellow(`\u26A0 ${e.message}`));return}if(e.message==="No style files to import"||e.message==="Style imports already exist")return;let n=(e.filePath?N.relative(process.cwd(),e.filePath):"main CSS file").replace(/\.\.\//g,"");s.log(`${a.green("\u2714")} Style imports automatically added to ${a.cyan(n)}`),s.log("")}var Jo=ce.object({components:ce.array(ce.string()).optional(),cwd:ce.string(),path:ce.string().optional(),silent:ce.boolean(),overwrite:ce.boolean()}),Yo=1e3,Rn=92,Go=48,Ho=4,Ce={emptyRegistry:a.red("\u274C No components or templates found"),operationCancelled:a.gray("Operation cancelled"),missingDirectory:a.red("\u274C Directory not found. Use init to initialize a project first.")},Nt={icon:{cursor:a.cyan("\u25B8"),checked:a.cyan("\u25C9"),unchecked:"\u25CB"},style:{highlight:e=>a.cyan(e),message:e=>e,answer:e=>""},prefix:{done:a.cyan("\u2714"),idle:a.cyan("?")}};function Xo(e){return e?.replace(/\s+/g," ").trim()??""}function Zo(e,t){let n=e.split(" "),r=[],i="";for(let o of n){let c=i?`${i} ${o}`:o;c.length>t&&i?(r.push(i),i=o):i=c}return i&&r.push(i),r}function Qo(){let e=process.stdout.columns;return e?Math.max(Go,Math.min(Rn,e-Ho)):Rn}function es(e){let t=Rt(e);return e?.includes("light")||e?.includes("open-source")?"Open Source - MIT":t}function ts(e){let t=es(e.plans),n=`${a.bold(de(e.name))} ${a.dim(`(${t})`)}:`,r=Xo(e.description);if(!r)return n;let i=Zo(r,Qo()).map(o=>` ${o}`);return[n,...i].join(`
40
40
  `)}function Rt(e){if(!e?.length)return"Free";if(e.includes("light")||e.includes("open-source"))return"Open source (MIT)";let t=pe.find(r=>e.includes(r));if(!t)return"Free";let n=`${t[0].toUpperCase()}${t.slice(1)}`;return t==="start"?`${n} plan \u2022 Trial`:`${n} plan`}function ns(e,t){return t?e.filter(n=>t.includes(n.name)):e}function jt(e){for(let t=0;t<e;t++)process.stdout.write("\x1B[1A"),process.stdout.write("\x1B[2K")}var rs=e=>({templates:e.filter(t=>t.type==="registry:template"),newComponents:e.filter(t=>t.isNew===!0),ui:e.filter(t=>t.type==="registry:ui"),primitives:e.filter(t=>t.type==="registry:ui-primitive"),uiUtils:e.filter(t=>t.type==="registry:ui-utils"),nodes:e.filter(t=>t.type==="registry:node")});async function os(e,t=!0){let n="What would you like to integrate?",r=[],i=e.ui.length===0&&e.nodes.length===0&&e.newComponents.length===0;if(e.templates.length===0||r.push({name:"Templates - Full editor applications",value:"templates"}),i||r.push({name:"UI Components - Individual editor building blocks",value:"components"}),r.length===0)return s.break(),console.log(Ce.emptyRegistry),null;try{t&&console.log($t());let c=await ke({message:a.reset(n),pageSize:Yo,theme:Nt,choices:r});return t&&console.log($t()),c}catch{return jt(4),console.log(Ce.operationCancelled),null}}async function ss(e,t){let n=[];if(!t)return n;let r=(o,c)=>{let l=o.filter(p=>t.includes(p.name));l.length>0&&(n.push(new we("")),n.push(new we(a.whiteBold(` ${c}`))),l.forEach(p=>{let f=Rt(p.plans),x=de(p.name).padEnd(35);n.push({name:`${x} ${a.dim(f)}`,value:p.name})}),n.push(new we(" ")))};return((o,c)=>{let l=o.filter(p=>t.includes(p.name));l.length>0&&(n.push(new we("")),n.push(new we(a.whiteBold(` ${c}`))),l.forEach(p=>{let f=Rt(p.plans),x=de(p.name).padEnd(35),w=p.description?`
41
41
  ${a.dim(p.description)}`:"";n.push({name:`${x} ${a.dim(f)}${w}`,value:p.name})}),n.push(new we(" ")))})(e.newComponents,"NEW COMPONENTS"),r(e.ui,"UI COMPONENTS"),r(e.nodes,"NODE COMPONENTS"),r(e.primitives,"PRIMITIVES"),n}async function is(e,t){let n=await ss(e,t);if(n.length===0)return[];try{s.log(""),s.log(a.cyan(" Press Space to select \u2022 A to toggle all \u2022 Enter to confirm"));let r=await qo({message:"Choose UI components to install:",pageSize:20,choices:n,theme:Nt,validate:i=>i.length===0?"Select at least one component (use Space to select, then Enter to confirm)":!0});return r&&r.length>0&&(s.log(""),s.log(a.cyan("Selected components:")),r.forEach(i=>{s.log(` ${a.cyan("\u2022")} ${de(i)}`)})),s.log(""),r||[]}catch{return jt(25),console.log(Ce.operationCancelled),[]}}async function as(e){try{let t=e.map(r=>({name:ts(r),value:r.name}));s.log("");let n=await ke({message:"Choose an editor template to install:",pageSize:20,choices:t,theme:Nt});return n&&(s.log(""),s.log(a.cyan("Selected template:")),s.log(` ${a.cyan("\u2022")} ${de(n)}`)),s.log(""),n?[n]:[]}catch{return jt(25),console.log(Ce.operationCancelled),[]}}async function _t(e,t=!0){if(e.components?.length)return e.components;let n;try{n=await Z()}catch(c){if(c instanceof Error&&c.message.includes("You are not authorized")){if(!await he([{name:"unknown",plans:["start"]}],e.cwd))return s.error("Authentication failed. Cannot proceed with component selection."),[];try{n=await Z()}catch{return s.break(),_(new Error("[prompts] - Failed to fetch registry index after authentication.")),[]}}else return s.break(),_(c),[]}if(!n)return s.break(),_(new Error("[prompts] - Failed to fetch registry index.")),[];let r=rs(n),i=await os(r,t);if(!i)return[];let o=n.filter(c=>!(c.hide??!1)).map(c=>c.name);switch(i){case"components":return await is(r,o)||[];case"templates":{let c=ns(r.templates,o);return await as(c)||[]}default:return[]}}var Nn=new Ko().name("add").description("add Tiptap UI components or templates as source code to your project").argument("[components...]","the components to add").option("-o, --overwrite","overwrite existing files.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-p, --path <path>","the path to add the component to.").option("-s, --silent","mute output.",!1).action(async(e,t)=>{try{Xe();let n=Ye("Tiptap UI Components","Install UI components or templates as editable source code in your project");G(n);let r=He("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);G(r),await Vo({message:a.reset(`Press ${a.cyan("Enter")} to add components or templates...`),theme:{prefix:{done:"",idle:""}}}),s.log(""),s.log(""),s.log("");let i=Jo.parse({components:e,cwd:zo.resolve(t.cwd),...t});if(i.components?.length||(i.components=await _t(i)),!i.components?.length)return;let o=await Z();if(!o)throw new Error("Failed to fetch registry index.");let c=i.components.map(w=>{let y=o.find(O=>O.name===w);return{name:w,plans:y?.plans||[]}});await he(c,i.cwd)||(s.error("Authentication failed. Cannot proceed with paid component download."),s.log("You can try again with only free components, or authenticate first."),process.exit(1));let{errors:p,config:f}=await qt(i);if(p["1"]&&(s.warn(`
42
42
  ${Ce.missingDirectory}`),process.exit(0)),!f)throw new Error(`Failed to read config at ${a.cyan(i.cwd)}.`);let m=await Me(i.components,f,i);if(!m)throw new Error("Component addition failed.");let x=(m.filesCreated?.length||0)+(m.filesUpdated?.length||0)+(m.filesSkipped?.length||0);if(m&&x>0){let w=[...m.filesCreated||[],...m.filesUpdated||[],...m.filesSkipped||[]],y=w.some(d=>d.includes("notion")),O=w.some(d=>d.includes("simple")&&d.includes("editor"));if(y){s.log(""),m.filesCreated.length>0?s.log(`${a.green("\u2714")} Notion template installed - ${m.filesCreated.length} files added to ${a.cyan("src/components/")}`):s.log(`${a.green("\u2714")} Notion template already installed - ${m.filesSkipped.length} files skipped`),s.log("");let d=await L(i.cwd);if(d){let b=await ee(m,f,d.framework);te(b),b.success?Ze(d.framework):Qe(d.framework,f)}}else if(O){s.log(""),m.filesCreated.length>0?s.log(`${a.green("\u2714")} Simple editor template installed - ${m.filesCreated.length} files added to ${a.cyan("src/components/")}`):s.log(`${a.green("\u2714")} Simple editor template already installed - ${m.filesSkipped.length} files skipped`),s.log("");let d=await L(i.cwd);if(d){let b=await ee(m,f,d.framework);te(b),b.success||ye(d.framework,f)}}else{s.log(""),m.filesCreated.length>0?s.log(`${a.green("\u2714")} Components installed - ${m.filesCreated.length} files added to ${a.cyan("src/components/")}`):m.filesSkipped.length>0&&s.log(`${a.green("\u2714")} Components already installed - ${m.filesSkipped.length} files skipped`),s.log("");let d=await L(i.cwd);if(d){let v=await ee(m,f,d.framework);te(v),v.success||ye(d.framework,f)}i.components.includes("table-node")&&et()}}}catch(n){s.break(),_(n)}});import{Command as cs}from"commander";var jn=new cs().name("info").description("get information about your project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{s.info("> project info"),console.log(await L(e.cwd)),s.break();try{let t=await Y(e.cwd);s.info("> config"),console.log(t)}catch{s.info("")}});import Ln from"path";import{Command as Es}from"commander";import{confirm as $s,input as Rs}from"@inquirer/prompts";import{z as X}from"zod";import ps from"path";import On from"fs-extra";async function Fn(e){let t={};if(!On.existsSync(e.cwd)||!On.existsSync(ps.resolve(e.cwd,"package.json")))return t["1"]=!0,{errors:t,projectInfo:null};let n=I("Verifying framework.",{silent:e.silent}).start(),r=await L(e.cwd);(!r||r?.framework.name==="manual")&&(t["7"]=!0,n?.fail(),s.break(),r?.framework.links.installation&&s.error(`We could not detect a supported framework at ${a.cyan(e.cwd)}.
@@ -352,5 +352,5 @@ The built-in AI tools let you:
352
352
 
353
353
  ## Extendability
354
354
 
355
- This template is designed to grow with your needs. New Tiptap Cloud features will be seamlessly compatible with the same UI system\u2014no rewrites required.`;async function Un(e,t){let n=ne.join(e,"README.md"),r={"simple-editor":Cs,"notion-like-editor":As},i=t&&t in r?r[t]:"";try{i.trim()&&await V.writeFile(n,i,"utf-8")}catch{}}var Ns=X.object({cwd:X.string(),components:X.array(X.string()).optional(),silent:X.boolean(),isNewProject:X.boolean(),srcDir:X.boolean().optional(),reactCompiler:X.boolean().optional(),framework:X.string().optional().refine(e=>!e||xe[e],{message:"Invalid framework. Please use 'next' or 'vite'."})}),Ot=(e,t=!0)=>$s({message:a.reset(e),default:t,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Mn=new Es().name("init").description("initialize your project and install Tiptap UI components as source code").argument("[components...]","the components to add").option("-f, --framework <framework>","the framework to use. (next, vite)").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",!1).option("--src-dir","use the src directory when creating a new project (specific to next).",!1).option("--react-compiler","enable React Compiler when creating a new project (specific to next).",!1).action(async(e,t)=>{try{Xe();let n=Ye("Tiptap UI Components","Install UI components or templates as editable source code in your project");G(n);let r=He("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);G(r),await Rs({message:a.reset(`Press ${a.cyan("Enter")} to initialize a project...`),theme:{prefix:{done:"",idle:""}}}),s.log("");let i=Ns.parse({cwd:Ln.resolve(t.cwd),isNewProject:!1,components:e,...t}),o=await js(i),c=(o?.filesCreated?.length||0)+(o?.filesUpdated?.length||0)+(o?.filesSkipped?.length||0);if(o&&c>0){let l=[...o.filesCreated||[],...o.filesUpdated||[],...o.filesSkipped||[]],p=l.some(m=>m.includes("notion")),f=l.some(m=>m.includes("simple")&&m.includes("editor"));if(p){s.log(""),o.filesCreated.length>0?s.log(`${a.green("\u2714")} Notion template installed - ${o.filesCreated.length} files added to ${a.cyan("src/components/")}`):s.log(`${a.green("\u2714")} Notion template already installed - ${o.filesSkipped.length} files skipped`),s.log("");let m=o.framework||o.projectInfo?.framework;if(m){let x=await ee({filesCreated:o.filesCreated,filesUpdated:o.filesUpdated,filesSkipped:o.filesSkipped},o.config,m);te(x),x.success?Ze(m):Qe(m,o.config)}}else if(f){s.log(""),o.filesCreated.length>0?s.log(`${a.green("\u2714")} Simple editor template installed - ${o.filesCreated.length} files added to ${a.cyan("src/components/")}`):s.log(`${a.green("\u2714")} Simple editor template already installed - ${o.filesSkipped.length} files skipped`),s.log("");let m=o.framework||o.projectInfo?.framework;if(m){let x=await ee({filesCreated:o.filesCreated,filesUpdated:o.filesUpdated,filesSkipped:o.filesSkipped},o.config,m);te(x),x.success||ye(m,o.config)}}else{if(s.log(""),o.filesCreated.length>0?s.log(`${a.green("\u2714")} Components installed - ${o.filesCreated.length} files added to ${a.cyan("src/components/")}`):o.filesSkipped.length>0&&s.log(`${a.green("\u2714")} Components already installed - ${o.filesSkipped.length} files skipped`),s.log(""),o?.projectInfo?.framework){let x=await ee({filesCreated:o.filesCreated,filesUpdated:o.filesUpdated,filesSkipped:o.filesSkipped},o.config,o.projectInfo.framework);te(x),x.success||ye(o?.projectInfo?.framework,o.config)}o.selectedComponents?.includes("table-node")&&et()}}s.break()}catch(n){s.break(),_(n)}});async function js(e){let{cwd:t,skipPreflight:n,components:r,silent:i}=e,o={...e},c,l=(v,A,D=[],U)=>({config:v,projectInfo:A,framework:c,selectedComponents:D,filesCreated:U?.filesCreated||[],filesUpdated:U?.filesUpdated||[],filesSkipped:U?.filesSkipped||[],errors:[]}),p;if(n)p=await L(t);else{let v=await Fn(e);if(v.errors["1"]){let{projectPath:D,framework:U}=await Dn(e);D||process.exit(0),o={...o,cwd:D,isNewProject:!0},c=U,s.log("")}p=v.projectInfo}if(c==="next-monorepo"){let v=Ln.resolve(o.cwd,"apps/web"),A=await Y(v);return l(A,p)}let f=await zt(o.cwd,p),m=f?await Os(f):await _s(await Y(o.cwd));s.log("");let x=r||[];if(!x.length){if(!await Ot("Would you like to add a template or UI components to your project?")){let A=await oe(o.cwd,m);return l(A,p)}if(x=await _t({...o,overwrite:!1},!0),!x.length){let A=await oe(o.cwd,m);return l(A,p)}}let w;try{if(w=await Z(),!w)throw new Error("Failed to fetch registry index.")}catch(v){if(v instanceof Error&&v.message.includes("You are not authorized")){let A=x.map(U=>({name:U,plans:["start"]}));if(await he(A,o.cwd)||(s.error("Authentication failed. Cannot proceed with paid component download."),s.log("You can try again with only free components, or authenticate first."),process.exit(1)),w=await Z(),!w)throw new Error("Failed to fetch registry index after authentication.")}else throw v}let y=x.map(v=>{let A=w.find(D=>D.name===v);return{name:v,plans:A?.plans||[]}});await he(y,o.cwd)||(s.error("Authentication failed. Cannot proceed with paid component download."),s.log("You can try again with only free components, or authenticate first."),process.exit(1));let d=await oe(o.cwd,m),b=await Me(x,d,{overwrite:!1,silent:i,isNewProject:o.isNewProject||p?.framework.name==="next-app"});return l(d,p,x,b||{filesCreated:[],filesUpdated:[],filesSkipped:[]})}async function _s(e=null){s.log(""),s.log(a.cyan("Project Configuration")),s.log("");let t=await Ot(`Would you like to use ${a.cyan("TypeScript")} (recommended)?`,e?.tsx??!0),n=await Ot(`Are you using ${a.cyan("React Server Components")}?`,e?.rsc??!0);return se.parse({rsc:n,tsx:t,aliases:{components:at,contexts:ct,hooks:lt,tiptapIcons:pt,lib:Re,tiptapExtensions:mt,tiptapNodes:ut,tiptapUi:dt,tiptapUiPrimitives:ft,tiptapUiUtils:gt,styles:ht}})}async function Os(e){return se.parse({rsc:e?.rsc,tsx:e?.tsx,aliases:e?.aliases})}import{Command as Ds}from"commander";var Bn={name:"@tiptap/cli",version:"3.19.4",description:"Tiptap CLI",publishConfig:{access:"public"},author:{name:"tiptap",url:"https://github.com/ueberdosis/tiptap"},files:["dist"],keywords:["cli","components","nextjs","react","templates","tiptap","@tiptap/cli","ui"],license:"SEE LICENSE IN LICENSE.md",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:"./dist/index.js",scripts:{dev:"tsup --watch",build:"tsup",test:"vitest run","test:watch":"vitest",typecheck:"tsc --noEmit",clean:"rm -rf dist","start:dev":"cross-env REGISTRY_URL=http://localhost:3000 node dist/index.js","start:prod":"cross-env REGISTRY_URL=https://template.tiptap.dev node dist/index.js",start:"node dist/index.js","pub:beta":"pnpm build && pnpm publish --no-git-checks --access public --tag beta","pub:release":"pnpm build && pnpm publish --access public"},dependencies:{"@antfu/ni":"^30.2.0","@babel/core":"^7.29.7","@babel/parser":"^7.29.7","@babel/plugin-transform-typescript":"^7.29.7","@inquirer/core":"^11.2.1","@inquirer/figures":"^2.0.7","@inquirer/prompts":"^8.5.2","@inquirer/type":"^4.0.7","ansi-escapes":"^7.3.0",chalk:"^5.6.2",commander:"^14.0.3",conf:"^15.1.0",cosmiconfig:"^9.0.2",deepmerge:"^4.3.1",execa:"^9.6.1","fast-glob":"^3.3.3","fs-extra":"^11.3.5","https-proxy-agent":"^9.1.0","jsonc-parser":"^3.3.1","node-fetch":"^3.3.2",ora:"^9.4.1",recast:"^0.23.11",sass:"^1.101.0","ts-morph":"^28.0.0","tsconfig-paths":"^4.2.0",yaml:"^2.9.0","yoctocolors-cjs":"^2.1.3",zod:"^4.4.3"},devDependencies:{"@babel/plugin-transform-typescript":"^7.26.5","@types/babel__core":"^7.20.5","@types/conf":"^3.0.3","@types/fs-extra":"^11.0.4","@types/prompts":"^2.4.9","cross-env":"^10.1.0",tsup:"^8.5.1","type-fest":"^5.7.0",typescript:"^5.9.3",vitest:"^4.1.9"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Us(){let e=new Ds().name("tiptap").description("add components and dependencies to your project").version(Bn.version||"1.0.0","-v, --version","display the CLI version number");e.addCommand(Mn).addCommand(Nn).addCommand(jn).addCommand(xn).addCommand(Pn).addCommand(kn).addCommand(vn),e.parse()}Us();
355
+ This template is designed to grow with your needs. New Tiptap Cloud features will be seamlessly compatible with the same UI system\u2014no rewrites required.`;async function Un(e,t){let n=ne.join(e,"README.md"),r={"simple-editor":Cs,"notion-like-editor":As},i=t&&t in r?r[t]:"";try{i.trim()&&await V.writeFile(n,i,"utf-8")}catch{}}var Ns=X.object({cwd:X.string(),components:X.array(X.string()).optional(),silent:X.boolean(),isNewProject:X.boolean(),srcDir:X.boolean().optional(),reactCompiler:X.boolean().optional(),framework:X.string().optional().refine(e=>!e||xe[e],{message:"Invalid framework. Please use 'next' or 'vite'."})}),Ot=(e,t=!0)=>$s({message:a.reset(e),default:t,theme:{prefix:{done:a.cyan("\u2714"),idle:"?"}}}),Mn=new Es().name("init").description("initialize your project and install Tiptap UI components as source code").argument("[components...]","the components to add").option("-f, --framework <framework>","the framework to use. (next, vite)").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",!1).option("--src-dir","use the src directory when creating a new project (specific to next).",!1).option("--react-compiler","enable React Compiler when creating a new project (specific to next).",!1).action(async(e,t)=>{try{Xe();let n=Ye("Tiptap UI Components","Install UI components or templates as editable source code in your project");G(n);let r=He("What are Tiptap UI Components?",["React UI components that help you develop an editor","They install as source code (not npm packages) in your src/components/","UI components are a foundation for customization rather than a fixed library"]);G(r),await Rs({message:a.reset(`Press ${a.cyan("Enter")} to initialize a project...`),theme:{prefix:{done:"",idle:""}}}),s.log("");let i=Ns.parse({cwd:Ln.resolve(t.cwd),isNewProject:!1,components:e,...t}),o=await js(i),c=(o?.filesCreated?.length||0)+(o?.filesUpdated?.length||0)+(o?.filesSkipped?.length||0);if(o&&c>0){let l=[...o.filesCreated||[],...o.filesUpdated||[],...o.filesSkipped||[]],p=l.some(m=>m.includes("notion")),f=l.some(m=>m.includes("simple")&&m.includes("editor"));if(p){s.log(""),o.filesCreated.length>0?s.log(`${a.green("\u2714")} Notion template installed - ${o.filesCreated.length} files added to ${a.cyan("src/components/")}`):s.log(`${a.green("\u2714")} Notion template already installed - ${o.filesSkipped.length} files skipped`),s.log("");let m=o.framework||o.projectInfo?.framework;if(m){let x=await ee({filesCreated:o.filesCreated,filesUpdated:o.filesUpdated,filesSkipped:o.filesSkipped},o.config,m);te(x),x.success?Ze(m):Qe(m,o.config)}}else if(f){s.log(""),o.filesCreated.length>0?s.log(`${a.green("\u2714")} Simple editor template installed - ${o.filesCreated.length} files added to ${a.cyan("src/components/")}`):s.log(`${a.green("\u2714")} Simple editor template already installed - ${o.filesSkipped.length} files skipped`),s.log("");let m=o.framework||o.projectInfo?.framework;if(m){let x=await ee({filesCreated:o.filesCreated,filesUpdated:o.filesUpdated,filesSkipped:o.filesSkipped},o.config,m);te(x),x.success||ye(m,o.config)}}else{if(s.log(""),o.filesCreated.length>0?s.log(`${a.green("\u2714")} Components installed - ${o.filesCreated.length} files added to ${a.cyan("src/components/")}`):o.filesSkipped.length>0&&s.log(`${a.green("\u2714")} Components already installed - ${o.filesSkipped.length} files skipped`),s.log(""),o?.projectInfo?.framework){let x=await ee({filesCreated:o.filesCreated,filesUpdated:o.filesUpdated,filesSkipped:o.filesSkipped},o.config,o.projectInfo.framework);te(x),x.success||ye(o?.projectInfo?.framework,o.config)}o.selectedComponents?.includes("table-node")&&et()}}s.break()}catch(n){s.break(),_(n)}});async function js(e){let{cwd:t,skipPreflight:n,components:r,silent:i}=e,o={...e},c,l=(v,A,D=[],U)=>({config:v,projectInfo:A,framework:c,selectedComponents:D,filesCreated:U?.filesCreated||[],filesUpdated:U?.filesUpdated||[],filesSkipped:U?.filesSkipped||[],errors:[]}),p;if(n)p=await L(t);else{let v=await Fn(e);if(v.errors["1"]){let{projectPath:D,framework:U}=await Dn(e);D||process.exit(0),o={...o,cwd:D,isNewProject:!0},c=U,s.log("")}p=v.projectInfo}if(c==="next-monorepo"){let v=Ln.resolve(o.cwd,"apps/web"),A=await Y(v);return l(A,p)}let f=await zt(o.cwd,p),m=f?await Os(f):await _s(await Y(o.cwd));s.log("");let x=r||[];if(!x.length){if(!await Ot("Would you like to add a template or UI components to your project?")){let A=await oe(o.cwd,m);return l(A,p)}if(x=await _t({...o,overwrite:!1},!0),!x.length){let A=await oe(o.cwd,m);return l(A,p)}}let w;try{if(w=await Z(),!w)throw new Error("Failed to fetch registry index.")}catch(v){if(v instanceof Error&&v.message.includes("You are not authorized")){let A=x.map(U=>({name:U,plans:["start"]}));if(await he(A,o.cwd)||(s.error("Authentication failed. Cannot proceed with paid component download."),s.log("You can try again with only free components, or authenticate first."),process.exit(1)),w=await Z(),!w)throw new Error("Failed to fetch registry index after authentication.")}else throw v}let y=x.map(v=>{let A=w.find(D=>D.name===v);return{name:v,plans:A?.plans||[]}});await he(y,o.cwd)||(s.error("Authentication failed. Cannot proceed with paid component download."),s.log("You can try again with only free components, or authenticate first."),process.exit(1));let d=await oe(o.cwd,m),b=await Me(x,d,{overwrite:!1,silent:i,isNewProject:o.isNewProject||p?.framework.name==="next-app"});return l(d,p,x,b||{filesCreated:[],filesUpdated:[],filesSkipped:[]})}async function _s(e=null){s.log(""),s.log(a.cyan("Project Configuration")),s.log("");let t=await Ot(`Would you like to use ${a.cyan("TypeScript")} (recommended)?`,e?.tsx??!0),n=await Ot(`Are you using ${a.cyan("React Server Components")}?`,e?.rsc??!0);return se.parse({rsc:n,tsx:t,aliases:{components:at,contexts:ct,hooks:lt,tiptapIcons:pt,lib:Re,tiptapExtensions:mt,tiptapNodes:ut,tiptapUi:dt,tiptapUiPrimitives:ft,tiptapUiUtils:gt,styles:ht}})}async function Os(e){return se.parse({rsc:e?.rsc,tsx:e?.tsx,aliases:e?.aliases})}import{Command as Ds}from"commander";var Bn={name:"@tiptap/cli",version:"3.19.5",description:"Tiptap CLI",publishConfig:{access:"public"},author:{name:"tiptap",url:"https://github.com/ueberdosis/tiptap"},files:["dist"],keywords:["cli","components","nextjs","react","templates","tiptap","@tiptap/cli","ui"],license:"SEE LICENSE IN LICENSE.md",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:"./dist/index.js",scripts:{dev:"tsup --watch",build:"tsup",test:"vitest run","test:watch":"vitest",typecheck:"tsc --noEmit",clean:"rm -rf dist","start:dev":"cross-env REGISTRY_URL=http://localhost:3000 node dist/index.js","start:prod":"cross-env REGISTRY_URL=https://template.tiptap.dev node dist/index.js",start:"node dist/index.js","pub:beta":"pnpm build && pnpm publish --no-git-checks --access public --tag beta","pub:release":"pnpm build && pnpm publish --access public"},dependencies:{"@antfu/ni":"^30.6.0","@babel/core":"^7.29.7","@babel/parser":"^7.29.9","@babel/plugin-transform-typescript":"^7.29.9","@inquirer/core":"^11.2.1","@inquirer/figures":"^2.0.9","@inquirer/prompts":"^8.7.3","@inquirer/type":"^4.2.0","ansi-escapes":"^7.3.0",chalk:"^5.6.2",commander:"^14.0.3",conf:"^15.1.0",cosmiconfig:"^9.0.2",deepmerge:"^4.3.1",execa:"^9.6.1","fast-glob":"^3.3.3","fs-extra":"^11.4.1","https-proxy-agent":"^9.1.0","jsonc-parser":"^3.3.1","node-fetch":"^3.3.2",ora:"^9.4.1",recast:"^0.23.21",sass:"^1.105.1","ts-morph":"^28.0.0","tsconfig-paths":"^4.2.0",yaml:"^2.9.1","yoctocolors-cjs":"^2.1.3",zod:"^4.6.5"},devDependencies:{"@babel/plugin-transform-typescript":"^7.26.5","@types/babel__core":"^7.20.5","@types/conf":"^3.0.3","@types/fs-extra":"^11.0.4","@types/prompts":"^2.4.9","cross-env":"^10.1.0",tsup:"^8.5.1","type-fest":"^5.10.0",typescript:"^5.9.3",vitest:"^4.1.11"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Us(){let e=new Ds().name("tiptap").description("add components and dependencies to your project").version(Bn.version||"1.0.0","-v, --version","display the CLI version number");e.addCommand(Mn).addCommand(Nn).addCommand(jn).addCommand(xn).addCommand(Pn).addCommand(kn).addCommand(vn),e.parse()}Us();
356
356
  //# sourceMappingURL=index.js.map