@white-give/editor-react 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -117125,7 +117125,7 @@ const Oqe = () => {
117125
117125
  });
117126
117126
  return zr(() => {
117127
117127
  o && (o.storage.container = e, o.storage.options = r, i(o));
117128
- }, [o, e, r, i]), console.log(r, e), /* @__PURE__ */ Y("div", { className: "white-editor-namespace white-give-editor-wrapper", children: /* @__PURE__ */ rt("div", { className: "flex flex-col ", children: [
117128
+ }, [o, e, r, i]), console.log(r, e), /* @__PURE__ */ Y("div", { className: "white-editor-namespace white-give-editor-wrapper", children: /* @__PURE__ */ rt("div", { className: "flex flex-col w-full h-full", children: [
117129
117129
  r.layout?.toolbar?.show && /* @__PURE__ */ Y("div", { className: "w-full flex-none border-b border-[#d9d9d9]", children: /* @__PURE__ */ Y(rWe, {}) }),
117130
117130
  /* @__PURE__ */ rt("div", { className: "w-full flex-1 min-h-0 flex overflow-hidden", id: e, children: [
117131
117131
  t.showToc && r.layout.toc.show && /* @__PURE__ */ Y(hWe, {}),
package/dist/index.d.ts CHANGED
@@ -118,27 +118,23 @@ declare module '@tiptap/core' {
118
118
 
119
119
  declare module '@tiptap/core' {
120
120
  interface Commands<ReturnType> {
121
- insertDatetime: {
122
- insertDatetime: (options: any) => ReturnType;
121
+ setEcharts: {
122
+ setEcharts: (options: any) => ReturnType;
123
123
  };
124
- }
125
- }
126
-
127
- declare module '@tiptap/core' {
128
- interface Commands<ReturnType> {
129
- setHr: {
130
- setHr: (option: any) => ReturnType;
124
+ updateEcharts: {
125
+ updateEcharts: (options: any) => ReturnType;
131
126
  };
132
127
  }
133
128
  }
134
129
 
130
+
135
131
  declare module '@tiptap/core' {
136
132
  interface Commands<ReturnType> {
137
- setImage: {
138
- setImage: (options: any, replace?: any) => ReturnType;
133
+ setFile: {
134
+ setFile: (options: any) => ReturnType;
139
135
  };
140
- setInlineImage: {
141
- setInlineImage: (options: any, replace?: any) => ReturnType;
136
+ insertFile: {
137
+ insertFile: (options: any) => ReturnType;
142
138
  };
143
139
  }
144
140
  }
@@ -146,11 +142,8 @@ declare module '@tiptap/core' {
146
142
 
147
143
  declare module '@tiptap/core' {
148
144
  interface Commands<ReturnType> {
149
- setEcharts: {
150
- setEcharts: (options: any) => ReturnType;
151
- };
152
- updateEcharts: {
153
- updateEcharts: (options: any) => ReturnType;
145
+ insertDatetime: {
146
+ insertDatetime: (options: any) => ReturnType;
154
147
  };
155
148
  }
156
149
  }
@@ -158,11 +151,11 @@ declare module '@tiptap/core' {
158
151
 
159
152
  declare module '@tiptap/core' {
160
153
  interface Commands<ReturnType> {
161
- setFile: {
162
- setFile: (options: any) => ReturnType;
154
+ setFormatPainter: {
155
+ setFormatPainter: (once: any) => ReturnType;
163
156
  };
164
- insertFile: {
165
- insertFile: (options: any) => ReturnType;
157
+ unsetFormatPainter: {
158
+ unsetFormatPainter: () => ReturnType;
166
159
  };
167
160
  }
168
161
  }
@@ -179,14 +172,21 @@ declare module '@tiptap/core' {
179
172
  }
180
173
  }
181
174
 
175
+ declare module '@tiptap/core' {
176
+ interface Commands<ReturnType> {
177
+ setHr: {
178
+ setHr: (option: any) => ReturnType;
179
+ };
180
+ }
181
+ }
182
182
 
183
183
  declare module '@tiptap/core' {
184
184
  interface Commands<ReturnType> {
185
- setFormatPainter: {
186
- setFormatPainter: (once: any) => ReturnType;
185
+ setImage: {
186
+ setImage: (options: any, replace?: any) => ReturnType;
187
187
  };
188
- unsetFormatPainter: {
189
- unsetFormatPainter: () => ReturnType;
188
+ setInlineImage: {
189
+ setInlineImage: (options: any, replace?: any) => ReturnType;
190
190
  };
191
191
  }
192
192
  }
@@ -203,19 +203,23 @@ declare module '@tiptap/core' {
203
203
 
204
204
  declare module '@tiptap/core' {
205
205
  interface Commands<ReturnType> {
206
- setLineHeight: {
207
- setLineHeight: (lineHeight: any) => ReturnType;
206
+ indent: {
207
+ indent: () => ReturnType;
208
208
  };
209
- unsetLineHeight: {
210
- unsetLineHeight: () => ReturnType;
209
+ outdent: {
210
+ outdent: () => ReturnType;
211
211
  };
212
212
  }
213
213
  }
214
214
 
215
+
215
216
  declare module '@tiptap/core' {
216
217
  interface Commands<ReturnType> {
217
- insertMention: {
218
- insertMention: (options: any) => ReturnType;
218
+ setLineHeight: {
219
+ setLineHeight: (lineHeight: any) => ReturnType;
220
+ };
221
+ unsetLineHeight: {
222
+ unsetLineHeight: () => ReturnType;
219
223
  };
220
224
  }
221
225
  }
@@ -232,14 +236,10 @@ declare module '@tiptap/core' {
232
236
  }
233
237
  }
234
238
 
235
-
236
239
  declare module '@tiptap/core' {
237
240
  interface Commands<ReturnType> {
238
- indent: {
239
- indent: () => ReturnType;
240
- };
241
- outdent: {
242
- outdent: () => ReturnType;
241
+ insertMention: {
242
+ insertMention: (options: any) => ReturnType;
243
243
  };
244
244
  }
245
245
  }
@@ -259,11 +259,8 @@ declare module '@tiptap/core' {
259
259
 
260
260
  declare module '@tiptap/core' {
261
261
  interface Commands<ReturnType> {
262
- setNodeAlign: {
263
- setNodeAlign: (options: any) => ReturnType;
264
- };
265
- unsetNodeAlign: {
266
- unsetNodeAlign: () => ReturnType;
262
+ insertTag: {
263
+ insertTag: (options: any) => ReturnType;
267
264
  };
268
265
  }
269
266
  }
@@ -271,8 +268,11 @@ declare module '@tiptap/core' {
271
268
 
272
269
  declare module '@tiptap/core' {
273
270
  interface Commands<ReturnType> {
274
- insertTag: {
275
- insertTag: (options: any) => ReturnType;
271
+ setNodeAlign: {
272
+ setNodeAlign: (options: any) => ReturnType;
273
+ };
274
+ unsetNodeAlign: {
275
+ unsetNodeAlign: () => ReturnType;
276
276
  };
277
277
  }
278
278
  }
@@ -453,4 +453,4 @@ Valid keys: `+JSON.stringify(Object.keys(me),null," "));var le=xe(st,ve,He,qe,o
453
453
  });
454
454
  <\/script>
455
455
  </body>
456
- </html>`},u=()=>{const c=l();Vje(c,()=>{console.log("打印完成")})};return F.jsxs("div",{className:"px-[12px] py-[5px] flex items-center gap-[0.4rem] cursor-pointer hover:bg-[rgb(242,243,245)]",onClick:u,children:[F.jsx("i",{className:"w-iconfont icon-export-pdf"}),"导出为PDF"]})}function $je(){const{editor:t,options:e}=Ot(),[r,n]=j.useState(!1),i=async()=>{if(!t)return;const o=t.getHTML();try{await navigator.clipboard.writeText(o)}catch(s){console.error("Failed to copy: ",s)}},a=()=>{if(!t)return;const o=new Blob([t.getText()],{type:"text/plain;charset=utf-8"}),{title:s}=e.document??{},l=s!==""?e.document?.title:"无标题文档";zje.saveAs(o,`${l}.txt`),n(!1)};return F.jsxs("div",{className:"flex items-center gap-[20px] text-[#333] foot-action",children:[e.layout.foot.copy&&F.jsxs("span",{className:"cursor-pointer flex items-center gap-[0.4rem] text-[14px] hover:text-[#007aff]",onClick:i,children:[F.jsx("i",{className:"w-iconfont icon-copy-content"}),"复制全文"]}),F.jsx(ol,{trigger:"click",placement:"top",value:r,onVisibleChange:n,contentStyle:{padding:"6px 0",boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08)"},content:F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"px-[12px] py-[5px] flex items-center gap-[0.4rem] cursor-pointer hover:bg-[rgb(242,243,245)]",onClick:a,children:[F.jsx("i",{className:"w-iconfont icon-text"}),"导出为文本"]}),F.jsx(Hje,{})]}),children:e.layout.foot.download&&F.jsxs("span",{className:"cursor-pointer flex items-center gap-[0.4rem] text-[14px] hover:text-[#007aff]",children:[F.jsx("i",{className:"w-iconfont icon-down"}),"下载"]})})]})}function Uje(){return F.jsxs("div",{className:"w-full h-full flex items-center justify-between",children:[F.jsx(Lje,{}),F.jsx($je,{})]})}const jje=({size:t="1em",top:e="30%",title:r="暂无数据"})=>F.jsxs("div",{className:"flex items-center justify-center flex-col gap-2",style:{paddingTop:e},children:[F.jsxs("svg",{className:"icon",viewBox:"0 0 1030 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,children:[F.jsx("path",{d:"M927.053254 896q0 1.254249-0.496852 2.508497t-1.484497 2.508497q-0.993704 1.248189-2.48426 2.49032-1.478438 1.248189-3.453728 2.48426-1.969231 1.230012-4.429254 2.447905-2.453964 1.217893-5.392663 2.423669-2.938698 1.199716-6.343953 2.381254-3.405254 1.187598-7.277065 2.3449-3.87787 1.163361-8.198059 2.302485-4.320189 1.133065-9.088757 2.241893t-9.967338 2.181302q-5.210888 1.084592-10.82168 2.126769-5.616852 1.048237-11.645728 2.060119-6.022817 1.005822-12.439479 1.97529-6.422722 0.969467-13.208994 1.90258-6.792331 0.933112-13.948213 1.817751-7.149822 0.890698-14.645018 1.738982-7.495195 0.842225-15.311527 1.635977-7.822391 0.799811-15.94168 1.551148-8.125349 0.745278-16.541539 1.442082-8.404071 0.702864-17.086863 1.345137-8.670675 0.648331-17.589776 1.24213-8.919101 0.593799-18.068449 1.127006-9.14329 0.539266-18.480474 1.01794-9.349302 0.484734-18.874319 0.908876-9.518959 0.424142-19.201515 0.787693-9.676497 0.36355-19.492355 0.666508-9.809799 0.302959-19.728663 0.551385-9.918864 0.242367-19.928615 0.430201-9.997633 0.181775-20.067977 0.302959-10.064284 0.127243-20.170982 0.187834-10.100639 0.060592-20.213396 0.060592-10.118817 0-20.219456-0.060592-10.100639-0.060592-20.164923-0.181775-10.070343-0.121183-20.074035-0.302959-10.003692-0.187834-19.922557-0.43626-9.924923-0.242367-19.734722-0.545325-9.815858-0.309018-19.492355-0.672568-9.676497-0.36355-19.201514-0.787693-9.518959-0.424142-18.868261-0.908876-9.343243-0.478675-18.486532-1.01794-9.14329-0.533207-18.062391-1.127006t-17.595834-1.24213q-8.676734-0.642272-17.086864-1.345137-8.41013-0.696805-16.535479-1.442082-8.11929-0.751337-15.935622-1.551148-7.822391-0.793751-15.317585-1.635977-7.495195-0.848284-14.651077-1.732923-7.149822-0.890698-13.936095-1.817751-6.798391-0.933112-13.208994-1.908639-6.422722-0.969467-12.445539-1.981349-6.028876-1.005822-11.645727-2.05406-5.622911-1.042178-10.821681-2.12071t-9.967337-2.187361q-4.768568-1.108828-9.088757-2.241893-4.326249-1.139124-8.19806-2.302485-3.871811-1.163361-7.277065-2.3449-3.405254-1.181538-6.343953-2.381254-2.938698-1.205775-5.392663-2.423669-2.460024-1.217893-4.429254-2.447905-1.97529-1.236071-3.453728-2.48426-1.490556-1.24213-2.48426-2.49032-0.987645-1.254249-1.484497-2.508497t-0.496852-2.508497z",fill:"#007bff",opacity:".1"}),F.jsx("path",{d:"M117.426746 376.832c0 8.70703 6.695385 15.36 15.450887 15.36 8.755503 0 15.450888-6.65297 15.450888-15.36 0-8.70097-6.695385-15.36-15.450888-15.36-8.240473 0-15.450888 7.168-15.450887 15.36z m814.776804 455.16497c-19.571124 5.12-23.691361 9.222059-28.326627 28.16303-5.150296-19.449941-9.270533-23.552-28.326627-28.16303 19.056095-5.12 23.691361-9.209941 28.326627-28.15697 4.635266 18.94703 8.755503 23.552 28.326627 28.15697zM203.436686 323.07503c-25.23645 6.65297-30.386746 11.77297-37.08213 36.864-6.695385-25.08497-11.84568-30.21103-37.08213-36.864 25.23645-6.65903 30.386746-12.288 37.08213-36.864 6.180355 25.08497 11.84568 30.20497 37.08213 36.864z m618.035503-88.064c-15.450888 4.096-18.541065 7.168-22.661301 22.528-4.120237-15.36-7.210414-18.432-22.661302-22.528 15.450888-4.096 18.541065-7.168 22.661302-22.528 3.605207 15.36 7.210414 18.432 22.661301 22.528z m66.438817-78.848c-40.172308 10.24-48.412781 18.94097-59.228402 58.87697-10.300592-39.929941-19.056095-48.128-59.228403-58.87697 40.172308-10.24 48.412781-18.94703 59.228403-58.88303 10.300592 39.42703 19.056095 48.128 59.228402 58.88303z",fill:"#007bff",opacity:".5"}),F.jsx("path",{d:"M422.32426 713.21297v4.096l33.991953 31.23503 130.302485-62.97903-117.941775 75.26703v36.864l19.056095-18.432v-0.51503 0.51503l19.056094 18.432 100.945799-122.88v-4.096l-185.410651 42.49297z",fill:"#007bff",opacity:".2"}),F.jsx("path",{d:"M865.249704 551.936v-1.024c0-1.024-0.51503-1.53297-0.515029-2.55697v-0.51503L754.003314 260.61103c-15.965917-48.64303-61.288521-81.41103-112.79148-81.41103H389.362367c-51.502959 0-96.825562 32.768-112.791479 81.41103L165.839527 547.84v0.51503c-0.51503 1.024-0.51503 1.53297-0.51503 2.55697v206.848c0 65.02097 53.048047 117.76 118.456805 117.76h463.526627c65.408757 0 118.456805-52.73903 118.456805-117.76v-204.8c-0.51503-0.50897-0.51503-0.50897-0.51503-1.024zM305.412544 271.36q0-0.50897 0.51503-0.50897c11.330651-36.864 45.322604-60.93103 83.434793-60.93103h251.334438c38.112189 0 72.104142 24.06703 83.949822 60.416q0 0.51503 0.51503 0.51503l102.490887 266.24H592.284024c-8.755503 0-15.450888 6.65297-15.450888 15.36 0 33.792-27.811598 61.44-61.80355 61.44-33.991953 0-61.80355-27.648-61.80355-61.44 0-8.70703-6.695385-15.36-15.450888-15.36H202.921657l102.490887-265.73103zM834.347929 757.76c0 48.128-39.142249 87.04-87.55503 87.04h-463.526627c-48.412781 0-87.55503-38.912-87.555029-87.04V568.32h228.158106c7.210414 43.52303 45.322604 76.8 91.160237 76.8 45.837633 0 83.949822-33.27697 91.160236-76.8H834.347929v189.44z",fill:"#007bff",opacity:".5"}),F.jsx("path",{d:"M515.029586 578.566059c-14.420828 0-25.751479-11.264-25.751479-25.6v-51.2H254.939645l84.464852-219.136 0.51503-1.024c7.210414-21.504 26.781538-35.84 49.44284-35.84h251.334438c22.661302 0 42.232426 14.336 49.44284 35.84l0.51503 1.024 84.464852 219.136H540.781065v51.2c0 14.336-11.330651 25.6-25.751479 25.6z",fill:"#007bff",opacity:".2"})]}),F.jsx("p",{className:"text-[#666]",children:r})]}),Gje=()=>{const{editor:t,options:e,setPage:r}=Ot(),[n,i]=j.useState([]),[a,o]=j.useState(""),s=j.useMemo(()=>dK(()=>{if(t){const u=t.storage.tableOfContents?.content;u&&i(u)}},200),[t]);j.useEffect(()=>{if(!t)return;s();const u=()=>{s()};return t.on("update",u),()=>{t.off("update",u)}},[t,s]);const l=u=>{if(!t)return;o(u.id);const c=t.view.dom.querySelector(`[data-toc-id="${u.id}"]`);if(!c)return;c.scrollIntoView({behavior:"smooth"});const f=t.view.posAtDOM(c,0),{tr:d}=t.view.state,h=d.doc.nodeAt(f);if(h){const p=f+h.nodeSize;d.setSelection(ir.create(d.doc,p))}else d.setSelection(new ir(d.doc.resolve(f)));t.view.dispatch(d),t.view.focus()};return F.jsxs("div",{className:"w-[260px] h-full flex flex-col overflow-hidden",children:[e?.layout?.foot?.show&&F.jsx("div",{className:"h-[50px] flex-none flex items-center px-4 text-[15px] text-[#666] hover:text-[#333]",children:F.jsxs("span",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>r(u=>({...u,showToc:!1})),children:[F.jsx("i",{className:"w-iconfont icon-left !text-[12px]"}),"收起大纲"]})}),F.jsx("div",{className:"overflow-y-auto min-h-0",children:n?.length>0?F.jsx("ul",{className:"flex-1 px-4 py-2 space-y-[0.3rem]",children:n.map(u=>F.jsx("li",{className:`cursor-pointer text-[#333] text-[14px] h-[34px] block leading-[34px] pr-2 hover:text-[#101219] rounded text-ellipsis overflow-hidden whitespace-nowrap ${a===u.id?"font-bold bg-[#f5f5f5]":""}`,style:{textIndent:`${u.level}rem`},onClick:()=>l(u),children:u.textContent},u.id))}):F.jsx(jje,{size:"120px"})})]})},Xoe=["top","right","bottom","left"],Iq=["start","end"],Lq=Xoe.reduce((t,e)=>t.concat(e,e+"-"+Iq[0],e+"-"+Iq[1]),[]),vl=Math.min,ha=Math.max,u_=Math.round,rl=t=>({x:t,y:t}),Wje={left:"right",right:"left",bottom:"top",top:"bottom"},qje={start:"end",end:"start"};function zI(t,e,r){return ha(t,vl(e,r))}function Cu(t,e){return typeof t=="function"?t(e):t}function Fo(t){return t.split("-")[0]}function ss(t){return t.split("-")[1]}function Zoe(t){return t==="x"?"y":"x"}function r5(t){return t==="y"?"height":"width"}const Kje=new Set(["top","bottom"]);function Ys(t){return Kje.has(Fo(t))?"y":"x"}function n5(t){return Zoe(Ys(t))}function Joe(t,e,r){r===void 0&&(r=!1);const n=ss(t),i=n5(t),a=r5(i);let o=i==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=f_(o)),[o,f_(o)]}function Yje(t){const e=f_(t);return[c_(t),e,c_(e)]}function c_(t){return t.replace(/start|end/g,e=>qje[e])}const Pq=["left","right"],Bq=["right","left"],Xje=["top","bottom"],Zje=["bottom","top"];function Jje(t,e,r){switch(t){case"top":case"bottom":return r?e?Bq:Pq:e?Pq:Bq;case"left":case"right":return e?Xje:Zje;default:return[]}}function Qje(t,e,r,n){const i=ss(t);let a=Jje(Fo(t),r==="start",n);return i&&(a=a.map(o=>o+"-"+i),e&&(a=a.concat(a.map(c_)))),a}function f_(t){return t.replace(/left|right|bottom|top/g,e=>Wje[e])}function eGe(t){return{top:0,right:0,bottom:0,left:0,...t}}function i5(t){return typeof t!="number"?eGe(t):{top:t,right:t,bottom:t,left:t}}function Ev(t){const{x:e,y:r,width:n,height:i}=t;return{width:n,height:i,top:r,left:e,right:e+n,bottom:r+i,x:e,y:r}}function zq(t,e,r){let{reference:n,floating:i}=t;const a=Ys(e),o=n5(e),s=r5(o),l=Fo(e),u=a==="y",c=n.x+n.width/2-i.width/2,f=n.y+n.height/2-i.height/2,d=n[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:n.y-i.height};break;case"bottom":h={x:c,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:f};break;case"left":h={x:n.x-i.width,y:f};break;default:h={x:n.x,y:n.y}}switch(ss(e)){case"start":h[o]-=d*(r&&u?-1:1);break;case"end":h[o]+=d*(r&&u?-1:1);break}return h}const tGe=async(t,e,r)=>{const{placement:n="bottom",strategy:i="absolute",middleware:a=[],platform:o}=r,s=a.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:c,y:f}=zq(u,n,l),d=n,h={},p=0;for(let v=0;v<s.length;v++){const{name:g,fn:m}=s[v],{x:y,y:b,data:x,reset:w}=await m({x:c,y:f,initialPlacement:n,placement:d,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:t,floating:e}});c=y??c,f=b??f,h={...h,[g]:{...h[g],...x}},w&&p<=50&&(p++,typeof w=="object"&&(w.placement&&(d=w.placement),w.rects&&(u=w.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):w.rects),{x:c,y:f}=zq(u,d,l)),v=-1)}return{x:c,y:f,placement:d,strategy:i,middlewareData:h}};async function Mv(t,e){var r;e===void 0&&(e={});const{x:n,y:i,platform:a,rects:o,elements:s,strategy:l}=t,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=Cu(e,t),p=i5(h),g=s[d?f==="floating"?"reference":"floating":f],m=Ev(await a.getClippingRect({element:(r=await(a.isElement==null?void 0:a.isElement(g)))==null||r?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),y=f==="floating"?{x:n,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),x=await(a.isElement==null?void 0:a.isElement(b))?await(a.getScale==null?void 0:a.getScale(b))||{x:1,y:1}:{x:1,y:1},w=Ev(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:y,offsetParent:b,strategy:l}):y);return{top:(m.top-w.top+p.top)/x.y,bottom:(w.bottom-m.bottom+p.bottom)/x.y,left:(m.left-w.left+p.left)/x.x,right:(w.right-m.right+p.right)/x.x}}const rGe=t=>({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:i,rects:a,platform:o,elements:s,middlewareData:l}=e,{element:u,padding:c=0}=Cu(t,e)||{};if(u==null)return{};const f=i5(c),d={x:r,y:n},h=n5(i),p=r5(h),v=await o.getDimensions(u),g=h==="y",m=g?"top":"left",y=g?"bottom":"right",b=g?"clientHeight":"clientWidth",x=a.reference[p]+a.reference[h]-d[h]-a.floating[p],w=d[h]-a.reference[h],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let C=_?_[b]:0;(!C||!await(o.isElement==null?void 0:o.isElement(_)))&&(C=s.floating[b]||a.floating[p]);const D=x/2-w/2,O=C/2-v[p]/2-1,I=vl(f[m],O),L=vl(f[y],O),V=I,H=C-v[p]-L,Y=C/2-v[p]/2+D,te=zI(V,Y,H),Q=!l.arrow&&ss(i)!=null&&Y!==te&&a.reference[p]/2-(Y<V?I:L)-v[p]/2<0,ue=Q?Y<V?Y-V:Y-H:0;return{[h]:d[h]+ue,data:{[h]:te,centerOffset:Y-te-ue,...Q&&{alignmentOffset:ue}},reset:Q}}});function nGe(t,e,r){return(t?[...r.filter(i=>ss(i)===t),...r.filter(i=>ss(i)!==t)]:r.filter(i=>Fo(i)===i)).filter(i=>t?ss(i)===t||(e?c_(i)!==i:!1):!0)}const iGe=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,n,i;const{rects:a,middlewareData:o,placement:s,platform:l,elements:u}=e,{crossAxis:c=!1,alignment:f,allowedPlacements:d=Lq,autoAlignment:h=!0,...p}=Cu(t,e),v=f!==void 0||d===Lq?nGe(f||null,h,d):d,g=await Mv(e,p),m=((r=o.autoPlacement)==null?void 0:r.index)||0,y=v[m];if(y==null)return{};const b=Joe(y,a,await(l.isRTL==null?void 0:l.isRTL(u.floating)));if(s!==y)return{reset:{placement:v[0]}};const x=[g[Fo(y)],g[b[0]],g[b[1]]],w=[...((n=o.autoPlacement)==null?void 0:n.overflows)||[],{placement:y,overflows:x}],_=v[m+1];if(_)return{data:{index:m+1,overflows:w},reset:{placement:_}};const C=w.map(I=>{const L=ss(I.placement);return[I.placement,L&&c?I.overflows.slice(0,2).reduce((V,H)=>V+H,0):I.overflows[0],I.overflows]}).sort((I,L)=>I[1]-L[1]),O=((i=C.filter(I=>I[2].slice(0,ss(I[0])?2:3).every(L=>L<=0))[0])==null?void 0:i[0])||C[0][0];return O!==s?{data:{index:m+1,overflows:w},reset:{placement:O}}:{}}}},aGe=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r,n;const{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:l,elements:u}=e,{mainAxis:c=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:v=!0,...g}=Cu(t,e);if((r=a.arrow)!=null&&r.alignmentOffset)return{};const m=Fo(i),y=Ys(s),b=Fo(s)===s,x=await(l.isRTL==null?void 0:l.isRTL(u.floating)),w=d||(b||!v?[f_(s)]:Yje(s)),_=p!=="none";!d&&_&&w.push(...Qje(s,v,p,x));const C=[s,...w],D=await Mv(e,g),O=[];let I=((n=a.flip)==null?void 0:n.overflows)||[];if(c&&O.push(D[m]),f){const Y=Joe(i,o,x);O.push(D[Y[0]],D[Y[1]])}if(I=[...I,{placement:i,overflows:O}],!O.every(Y=>Y<=0)){var L,V;const Y=(((L=a.flip)==null?void 0:L.index)||0)+1,te=C[Y];if(te&&(!(f==="alignment"?y!==Ys(te):!1)||I.every(ie=>Ys(ie.placement)===y?ie.overflows[0]>0:!0)))return{data:{index:Y,overflows:I},reset:{placement:te}};let Q=(V=I.filter(ue=>ue.overflows[0]<=0).sort((ue,ie)=>ue.overflows[1]-ie.overflows[1])[0])==null?void 0:V.placement;if(!Q)switch(h){case"bestFit":{var H;const ue=(H=I.filter(ie=>{if(_){const Se=Ys(ie.placement);return Se===y||Se==="y"}return!0}).map(ie=>[ie.placement,ie.overflows.filter(Se=>Se>0).reduce((Se,me)=>Se+me,0)]).sort((ie,Se)=>ie[1]-Se[1])[0])==null?void 0:H[0];ue&&(Q=ue);break}case"initialPlacement":Q=s;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};function Fq(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Vq(t){return Xoe.some(e=>t[e]>=0)}const oGe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...i}=Cu(t,e);switch(n){case"referenceHidden":{const a=await Mv(e,{...i,elementContext:"reference"}),o=Fq(a,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Vq(o)}}}case"escaped":{const a=await Mv(e,{...i,altBoundary:!0}),o=Fq(a,r.floating);return{data:{escapedOffsets:o,escaped:Vq(o)}}}default:return{}}}}};function Qoe(t){const e=vl(...t.map(a=>a.left)),r=vl(...t.map(a=>a.top)),n=ha(...t.map(a=>a.right)),i=ha(...t.map(a=>a.bottom));return{x:e,y:r,width:n-e,height:i-r}}function sGe(t){const e=t.slice().sort((i,a)=>i.y-a.y),r=[];let n=null;for(let i=0;i<e.length;i++){const a=e[i];!n||a.y-n.y>n.height/2?r.push([a]):r[r.length-1].push(a),n=a}return r.map(i=>Ev(Qoe(i)))}const lGe=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:r,elements:n,rects:i,platform:a,strategy:o}=e,{padding:s=2,x:l,y:u}=Cu(t,e),c=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(n.reference))||[]),f=sGe(c),d=Ev(Qoe(c)),h=i5(s);function p(){if(f.length===2&&f[0].left>f[1].right&&l!=null&&u!=null)return f.find(g=>l>g.left-h.left&&l<g.right+h.right&&u>g.top-h.top&&u<g.bottom+h.bottom)||d;if(f.length>=2){if(Ys(r)==="y"){const I=f[0],L=f[f.length-1],V=Fo(r)==="top",H=I.top,Y=L.bottom,te=V?I.left:L.left,Q=V?I.right:L.right,ue=Q-te,ie=Y-H;return{top:H,bottom:Y,left:te,right:Q,width:ue,height:ie,x:te,y:H}}const g=Fo(r)==="left",m=ha(...f.map(I=>I.right)),y=vl(...f.map(I=>I.left)),b=f.filter(I=>g?I.left===y:I.right===m),x=b[0].top,w=b[b.length-1].bottom,_=y,C=m,D=C-_,O=w-x;return{top:x,bottom:w,left:_,right:C,width:D,height:O,x:_,y:x}}return d}const v=await a.getElementRects({reference:{getBoundingClientRect:p},floating:n.floating,strategy:o});return i.reference.x!==v.reference.x||i.reference.y!==v.reference.y||i.reference.width!==v.reference.width||i.reference.height!==v.reference.height?{reset:{rects:v}}:{}}}},uGe=new Set(["left","top"]);async function cGe(t,e){const{placement:r,platform:n,elements:i}=t,a=await(n.isRTL==null?void 0:n.isRTL(i.floating)),o=Fo(r),s=ss(r),l=Ys(r)==="y",u=uGe.has(o)?-1:1,c=a&&l?-1:1,f=Cu(e,t);let{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return s&&typeof p=="number"&&(h=s==="end"?p*-1:p),l?{x:h*c,y:d*u}:{x:d*u,y:h*c}}const fGe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:i,y:a,placement:o,middlewareData:s}=e,l=await cGe(e,t);return o===((r=s.offset)==null?void 0:r.placement)&&(n=s.arrow)!=null&&n.alignmentOffset?{}:{x:i+l.x,y:a+l.y,data:{...l,placement:o}}}}},dGe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:i}=e,{mainAxis:a=!0,crossAxis:o=!1,limiter:s={fn:g=>{let{x:m,y}=g;return{x:m,y}}},...l}=Cu(t,e),u={x:r,y:n},c=await Mv(e,l),f=Ys(Fo(i)),d=Zoe(f);let h=u[d],p=u[f];if(a){const g=d==="y"?"top":"left",m=d==="y"?"bottom":"right",y=h+c[g],b=h-c[m];h=zI(y,h,b)}if(o){const g=f==="y"?"top":"left",m=f==="y"?"bottom":"right",y=p+c[g],b=p-c[m];p=zI(y,p,b)}const v=s.fn({...e,[d]:h,[f]:p});return{...v,data:{x:v.x-r,y:v.y-n,enabled:{[d]:a,[f]:o}}}}}},hGe=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var r,n;const{placement:i,rects:a,platform:o,elements:s}=e,{apply:l=()=>{},...u}=Cu(t,e),c=await Mv(e,u),f=Fo(i),d=ss(i),h=Ys(i)==="y",{width:p,height:v}=a.floating;let g,m;f==="top"||f==="bottom"?(g=f,m=d===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(m=f,g=d==="end"?"top":"bottom");const y=v-c.top-c.bottom,b=p-c.left-c.right,x=vl(v-c[g],y),w=vl(p-c[m],b),_=!e.middlewareData.shift;let C=x,D=w;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(D=b),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(C=y),_&&!d){const I=ha(c.left,0),L=ha(c.right,0),V=ha(c.top,0),H=ha(c.bottom,0);h?D=p-2*(I!==0||L!==0?I+L:ha(c.left,c.right)):C=v-2*(V!==0||H!==0?V+H:ha(c.top,c.bottom))}await l({...e,availableWidth:D,availableHeight:C});const O=await o.getDimensions(s.floating);return p!==O.width||v!==O.height?{reset:{rects:!0}}:{}}}};function z2(){return typeof window<"u"}function ig(t){return ese(t)?(t.nodeName||"").toLowerCase():"#document"}function Qa(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Eu(t){var e;return(e=(ese(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function ese(t){return z2()?t instanceof Node||t instanceof Qa(t).Node:!1}function ds(t){return z2()?t instanceof Element||t instanceof Qa(t).Element:!1}function gl(t){return z2()?t instanceof HTMLElement||t instanceof Qa(t).HTMLElement:!1}function Hq(t){return!z2()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Qa(t).ShadowRoot}const pGe=new Set(["inline","contents"]);function W0(t){const{overflow:e,overflowX:r,overflowY:n,display:i}=hs(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!pGe.has(i)}const vGe=new Set(["table","td","th"]);function gGe(t){return vGe.has(ig(t))}const mGe=[":popover-open",":modal"];function F2(t){return mGe.some(e=>{try{return t.matches(e)}catch{return!1}})}const yGe=["transform","translate","scale","rotate","perspective"],bGe=["transform","translate","scale","rotate","perspective","filter"],xGe=["paint","layout","strict","content"];function a5(t){const e=o5(),r=ds(t)?hs(t):t;return yGe.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||bGe.some(n=>(r.willChange||"").includes(n))||xGe.some(n=>(r.contain||"").includes(n))}function wGe(t){let e=$c(t);for(;gl(e)&&!Av(e);){if(a5(e))return e;if(F2(e))return null;e=$c(e)}return null}function o5(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const SGe=new Set(["html","body","#document"]);function Av(t){return SGe.has(ig(t))}function hs(t){return Qa(t).getComputedStyle(t)}function V2(t){return ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $c(t){if(ig(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Hq(t)&&t.host||Eu(t);return Hq(e)?e.host:e}function tse(t){const e=$c(t);return Av(e)?t.ownerDocument?t.ownerDocument.body:t.body:gl(e)&&W0(e)?e:tse(e)}function rse(t,e,r){var n;e===void 0&&(e=[]);const i=tse(t),a=i===((n=t.ownerDocument)==null?void 0:n.body),o=Qa(i);return a?(FI(o),e.concat(o,o.visualViewport||[],W0(i)?i:[],[])):e.concat(i,rse(i,[]))}function FI(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function nse(t){const e=hs(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=gl(t),a=i?t.offsetWidth:r,o=i?t.offsetHeight:n,s=u_(r)!==a||u_(n)!==o;return s&&(r=a,n=o),{width:r,height:n,$:s}}function ise(t){return ds(t)?t:t.contextElement}function Zp(t){const e=ise(t);if(!gl(e))return rl(1);const r=e.getBoundingClientRect(),{width:n,height:i,$:a}=nse(e);let o=(a?u_(r.width):r.width)/n,s=(a?u_(r.height):r.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const _Ge=rl(0);function ase(t){const e=Qa(t);return!o5()||!e.visualViewport?_Ge:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function TGe(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==Qa(t)?!1:e}function p0(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const i=t.getBoundingClientRect(),a=ise(t);let o=rl(1);e&&(n?ds(n)&&(o=Zp(n)):o=Zp(t));const s=TGe(a,r,n)?ase(a):rl(0);let l=(i.left+s.x)/o.x,u=(i.top+s.y)/o.y,c=i.width/o.x,f=i.height/o.y;if(a){const d=Qa(a),h=n&&ds(n)?Qa(n):n;let p=d,v=FI(p);for(;v&&n&&h!==p;){const g=Zp(v),m=v.getBoundingClientRect(),y=hs(v),b=m.left+(v.clientLeft+parseFloat(y.paddingLeft))*g.x,x=m.top+(v.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,u*=g.y,c*=g.x,f*=g.y,l+=b,u+=x,p=Qa(v),v=FI(p)}}return Ev({width:c,height:f,x:l,y:u})}function H2(t,e){const r=V2(t).scrollLeft;return e?e.left+r:p0(Eu(t)).left+r}function ose(t,e){const r=t.getBoundingClientRect(),n=r.left+e.scrollLeft-H2(t,r),i=r.top+e.scrollTop;return{x:n,y:i}}function CGe(t){let{elements:e,rect:r,offsetParent:n,strategy:i}=t;const a=i==="fixed",o=Eu(n),s=e?F2(e.floating):!1;if(n===o||s&&a)return r;let l={scrollLeft:0,scrollTop:0},u=rl(1);const c=rl(0),f=gl(n);if((f||!f&&!a)&&((ig(n)!=="body"||W0(o))&&(l=V2(n)),gl(n))){const h=p0(n);u=Zp(n),c.x=h.x+n.clientLeft,c.y=h.y+n.clientTop}const d=o&&!f&&!a?ose(o,l):rl(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+d.x,y:r.y*u.y-l.scrollTop*u.y+c.y+d.y}}function EGe(t){return Array.from(t.getClientRects())}function MGe(t){const e=Eu(t),r=V2(t),n=t.ownerDocument.body,i=ha(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),a=ha(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+H2(t);const s=-r.scrollTop;return hs(n).direction==="rtl"&&(o+=ha(e.clientWidth,n.clientWidth)-i),{width:i,height:a,x:o,y:s}}const $q=25;function AGe(t,e){const r=Qa(t),n=Eu(t),i=r.visualViewport;let a=n.clientWidth,o=n.clientHeight,s=0,l=0;if(i){a=i.width,o=i.height;const c=o5();(!c||c&&e==="fixed")&&(s=i.offsetLeft,l=i.offsetTop)}const u=H2(n);if(u<=0){const c=n.ownerDocument,f=c.body,d=getComputedStyle(f),h=c.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,p=Math.abs(n.clientWidth-f.clientWidth-h);p<=$q&&(a-=p)}else u<=$q&&(a+=u);return{width:a,height:o,x:s,y:l}}const kGe=new Set(["absolute","fixed"]);function NGe(t,e){const r=p0(t,!0,e==="fixed"),n=r.top+t.clientTop,i=r.left+t.clientLeft,a=gl(t)?Zp(t):rl(1),o=t.clientWidth*a.x,s=t.clientHeight*a.y,l=i*a.x,u=n*a.y;return{width:o,height:s,x:l,y:u}}function Uq(t,e,r){let n;if(e==="viewport")n=AGe(t,r);else if(e==="document")n=MGe(Eu(t));else if(ds(e))n=NGe(e,r);else{const i=ase(t);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Ev(n)}function sse(t,e){const r=$c(t);return r===e||!ds(r)||Av(r)?!1:hs(r).position==="fixed"||sse(r,e)}function DGe(t,e){const r=e.get(t);if(r)return r;let n=rse(t,[]).filter(s=>ds(s)&&ig(s)!=="body"),i=null;const a=hs(t).position==="fixed";let o=a?$c(t):t;for(;ds(o)&&!Av(o);){const s=hs(o),l=a5(o);!l&&s.position==="fixed"&&(i=null),(a?!l&&!i:!l&&s.position==="static"&&!!i&&kGe.has(i.position)||W0(o)&&!l&&sse(t,o))?n=n.filter(c=>c!==o):i=s,o=$c(o)}return e.set(t,n),n}function OGe(t){let{element:e,boundary:r,rootBoundary:n,strategy:i}=t;const o=[...r==="clippingAncestors"?F2(e)?[]:DGe(e,this._c):[].concat(r),n],s=o[0],l=o.reduce((u,c)=>{const f=Uq(e,c,i);return u.top=ha(f.top,u.top),u.right=vl(f.right,u.right),u.bottom=vl(f.bottom,u.bottom),u.left=ha(f.left,u.left),u},Uq(e,s,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function RGe(t){const{width:e,height:r}=nse(t);return{width:e,height:r}}function IGe(t,e,r){const n=gl(e),i=Eu(e),a=r==="fixed",o=p0(t,!0,a,e);let s={scrollLeft:0,scrollTop:0};const l=rl(0);function u(){l.x=H2(i)}if(n||!n&&!a)if((ig(e)!=="body"||W0(i))&&(s=V2(e)),n){const h=p0(e,!0,a,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&u();a&&!n&&i&&u();const c=i&&!n&&!a?ose(i,s):rl(0),f=o.left+s.scrollLeft-l.x-c.x,d=o.top+s.scrollTop-l.y-c.y;return{x:f,y:d,width:o.width,height:o.height}}function hD(t){return hs(t).position==="static"}function jq(t,e){if(!gl(t)||hs(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return Eu(t)===r&&(r=r.ownerDocument.body),r}function lse(t,e){const r=Qa(t);if(F2(t))return r;if(!gl(t)){let i=$c(t);for(;i&&!Av(i);){if(ds(i)&&!hD(i))return i;i=$c(i)}return r}let n=jq(t,e);for(;n&&gGe(n)&&hD(n);)n=jq(n,e);return n&&Av(n)&&hD(n)&&!a5(n)?r:n||wGe(t)||r}const LGe=async function(t){const e=this.getOffsetParent||lse,r=this.getDimensions,n=await r(t.floating);return{reference:IGe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function PGe(t){return hs(t).direction==="rtl"}const BGe={convertOffsetParentRelativeRectToViewportRelativeRect:CGe,getDocumentElement:Eu,getClippingRect:OGe,getOffsetParent:lse,getElementRects:LGe,getClientRects:EGe,getDimensions:RGe,getScale:Zp,isElement:ds,isRTL:PGe},use=fGe,cse=iGe,fse=dGe,dse=aGe,hse=hGe,pse=oGe,vse=rGe,gse=lGe,mse=(t,e,r)=>{const n=new Map,i={platform:BGe,...r},a={...i.platform,_c:n};return tGe(t,e,{...i,platform:a})};function zGe(t,e){const r=Math.min(t.top,e.top),n=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-i,s=n-r,l=i,u=r;return new DOMRect(l,u,o,s)}var FGe=class{constructor({editor:t,element:e,view:r,updateDelay:n=250,resizeDelay:i=60,shouldShow:a,appendTo:o,getReferencedVirtualElement:s,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:f,from:d,to:h})=>{const{doc:p,selection:v}=f,{empty:g}=v,m=!p.textBetween(d,h).length&&xL(f.selection),y=this.element.contains(document.activeElement);return!(!(c.hasFocus()||y)||g||m||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,f)=>{const d=!f?.selection.eq(c.state.selection),h=!f?.doc.eq(c.state.doc);!d&&!h||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,d,h,f)},this.updateDelay))},this.updateHandler=(c,f,d,h)=>{const{composing:p}=c;if(p||!f&&!d)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:c})=>{c.getMeta("bubbleMenu")==="updatePosition"&&this.updatePosition()};var u;this.editor=t,this.element=e,this.view=r,this.updateDelay=n,this.resizeDelay=i,this.appendTo=o,this.scrollTarget=(u=l?.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=s,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(r,r.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(dse(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(fse(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(use(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(vse(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(hse(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(cse(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(pse(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(gse(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t;const{selection:e}=this.editor.state,r=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(r)return r;const n=sX(this.view,e.from,e.to);let i={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof ar){let a=this.view.nodeDOM(e.from);const o=a.dataset.nodeViewWrapper?a:a.querySelector("[data-node-view-wrapper]");o&&(a=o),a&&(i={getBoundingClientRect:()=>a.getBoundingClientRect(),getClientRects:()=>[a.getBoundingClientRect()]})}if(e instanceof Cn){const{$anchorCell:a,$headCell:o}=e,s=a?a.pos:o.pos,l=o?o.pos:a.pos,u=this.view.nodeDOM(s),c=this.view.nodeDOM(l);if(!u||!c)return;const f=u===c?u.getBoundingClientRect():zGe(u.getBoundingClientRect(),c.getBoundingClientRect());i={getBoundingClientRect:()=>f,getClientRects:()=>[f]}}return i}updatePosition(){const t=this.virtualElement;t&&mse(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:r,strategy:n})=>{this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${r}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:r}=t,n=r.selection.from!==r.selection.to;if(this.updateDelay>0&&n){this.handleDebouncedUpdate(t,e);return}const i=!e?.selection.eq(t.state.selection),a=!e?.doc.eq(t.state.doc);this.updateHandler(t,i,a,e)}getShouldShow(t){var e;const{state:r}=this.view,{selection:n}=r,{ranges:i}=n,a=Math.min(...i.map(l=>l.$from.pos)),o=Math.max(...i.map(l=>l.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:r,oldState:t,from:a,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},yse=t=>new en({key:typeof t.pluginKey=="string"?new on(t.pluginKey):t.pluginKey,view:e=>new FGe({view:e,...t})});Vr.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[yse({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var VGe=class{constructor({editor:t,element:e,view:r,options:n,appendTo:i,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:o,state:s})=>{const{selection:l}=s,{$anchor:u,empty:c}=l,f=u.depth===1,d=u.parent.isTextblock&&!u.parent.type.spec.code&&!u.parent.textContent&&u.parent.childCount===0&&!this.getTextContent(u.parent);return!(!o.hasFocus()||!c||!f||!d||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(o,s,l,u)=>{const{composing:c}=o;if(c||!s&&!l)return;if(!this.getShouldShow(u)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var s;if(this.preventHide){this.preventHide=!1;return}o?.relatedTarget&&((s=this.element.parentNode)!=null&&s.contains(o.relatedTarget))||o?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=r,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...n},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(r,r.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return tX(t,{textSerializers:_L(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(dse(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(fse(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(use(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(vse(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(hse(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(cse(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(pse(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(gse(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:r}=this.view,{selection:n}=r,{ranges:i}=n,a=Math.min(...i.map(l=>l.$from.pos)),o=Math.max(...i.map(l=>l.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:r,oldState:t,from:a,to:o})}updatePosition(){const{selection:t}=this.editor.state,e=sX(this.view,t.from,t.to);mse({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:i,strategy:a})=>{this.element.style.width="max-content",this.element.style.position=a,this.element.style.left=`${n}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const r=!e?.selection.eq(t.state.selection),n=!e?.doc.eq(t.state.doc);this.updateHandler(t,r,n,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},bse=t=>new en({key:typeof t.pluginKey=="string"?new on(t.pluginKey):t.pluginKey,view:e=>new VGe({view:e,...t})});Vr.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[bse({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var HGe=j.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:r,resizeDelay:n,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:l,...u},c)=>{const f=j.useRef(document.createElement("div"));typeof c=="function"?c(f.current):c&&(c.current=f.current);const{editor:d}=AX(),h=e||d,p={updateDelay:r,resizeDelay:n,appendTo:i,pluginKey:t,shouldShow:a,getReferencedVirtualElement:o,options:s},v=j.useRef(p);return v.current=p,j.useEffect(()=>{if(h?.isDestroyed)return;if(!h){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const g=f.current;g.style.visibility="hidden",g.style.position="absolute";const m=yse({...v.current,editor:h,element:g});h.registerPlugin(m);const y=v.current.pluginKey;return()=>{h.unregisterPlugin(y),window.requestAnimationFrame(()=>{g.parentNode&&g.parentNode.removeChild(g)})}},[h]),kv.createPortal(F.jsx("div",{...u,children:l}),f.current)});j.forwardRef(({pluginKey:t="floatingMenu",editor:e,appendTo:r,shouldShow:n=null,options:i,children:a,...o},s)=>{const l=j.useRef(document.createElement("div"));typeof s=="function"?s(l.current):s&&(s.current=l.current);const{editor:u}=AX();return j.useEffect(()=>{const c=l.current;if(c.style.visibility="hidden",c.style.position="absolute",e?.isDestroyed||u?.isDestroyed)return;const f=e||u;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=bse({editor:f,element:c,pluginKey:t,appendTo:r,shouldShow:n,options:i});return f.registerPlugin(d),()=>{f.unregisterPlugin(t),window.requestAnimationFrame(()=>{c.parentNode&&c.parentNode.removeChild(c)})}},[e,u,r,t,n,i]),kv.createPortal(F.jsx("div",{...o,children:a}),l.current)});function $Ge(){const{editor:t}=Ot(),[e,r]=j.useReducer(o=>o+1,0);j.useEffect(()=>{if(!t)return;const o=()=>r();return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const n=j.useMemo(()=>{const o=t?au(t):null;return o?.type?.name?t?.getAttributes(o.type.name)?.flipY:!1},[t,e]),i=j.useMemo(()=>{const o=t?au(t):null;return o?.type?.name?t?.getAttributes(o.type.name)?.flipX:!1},[t,e]),a=o=>{const s=t?au(t):null,{flipX:l,flipY:u}=s?.attrs??{};s&&o==="flipX"&&t?.commands.updateAttributes(s.type,{flipX:!l}),s&&o==="flipY"&&t?.commands.updateAttributes(s.type,{flipY:!u})};return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"flip-x",text:"水平翻转",hideText:!0,menuActive:n,onMenuClick:()=>a("flipY")}),F.jsx(Ar,{ico:"flip-y",text:"垂直翻转",hideText:!0,menuActive:i,onMenuClick:()=>a("flipX")})]})}function xse(){const{editor:t}=Ot(),e=()=>{const r=t?au(t):null;r?.attrs.src&&window.open(r.attrs.src)};return F.jsx(Ar,{ico:"open",text:"新窗口打开",shortcut:"Backspace",hideText:!0,onMenuClick:e})}function UGe(){const{editor:t}=Ot(),e=j.useMemo(()=>(t?au(t):null)?.type?.name==="inlineImage"?"转为节点图片":"转为行内图片",[t?.state.selection]),[r,n]=j.useReducer(a=>a+1,0);j.useEffect(()=>{if(!t)return;const a=()=>n();return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]);const i=()=>{const a=t?au(t):null;if(a){const o=a?.type?.name==="inlineImage"?"inlineImage":"image",s=a.attrs??{};!s.error&&s.src&&(t?.chain().focus().deleteSelectionNode().run(),o==="inlineImage"?t?.chain().focus().setImage({...s,equalProportion:!1,inline:!1}).run():t?.chain().focus().setInlineImage({...s,inline:!0,equalProportion:!1}).run())}};return F.jsx(Ar,{ico:"huantu",text:e,hideText:!0,onMenuClick:i})}function dh(){const{editor:t}=Ot();return F.jsx(Ar,{ico:"remove",text:"删除",shortcut:"Backspace",hideText:!0,onMenuClick:()=>t?.chain().focus().deleteSelectionNode().run()})}function jGe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx($Ge,{}),F.jsx(UGe,{}),F.jsx(xse,{}),F.jsx(dh,{})]})}function GGe(){const{editor:t}=Ot(),e=()=>{const r=t?au(t):null;if(!r)return;const n=document.createElement("a");n.href=r.attrs.url,n.download=r.attrs.name,document.body.appendChild(n),n.click(),document.body.removeChild(n)};return t?.getAttributes("file")?.uploaded?F.jsx(Ar,{ico:"down",text:"下载",hideText:!0,onMenuClick:e}):null}function WGe(){const{editor:t}=Ot();return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),(t?.isActive("file")||t?.isActive("video")||t?.isActive("audio"))&&F.jsx(GGe,{}),F.jsx(dh,{})]})}function qGe({defaultColor:t="#007bff"}){const{editor:e}=Ot(),[r,n]=j.useState(!1),[i,a]=j.useState(t),o=l=>{a(l),n(!1);const u=l===""?null:l;e?.chain().focus().setCellAttribute("background",u).run()},s=g0(l=>{a(l);const u=l===""?null:l;e?.chain().focus().setCellAttribute("background",u).run()},200);return F.jsx(xl,{ico:"fill",text:"填充背景",hideText:!0,popupVisible:r,disabled:!e?.can().setCellAttribute("background",""),popupType:"arrow",onMenuClick:()=>o(i),onPopupVisibleChange:n,content:F.jsx("div",{className:"p-2",children:F.jsx("input",{type:"color",value:i,onChange:l=>s(l.target.value),className:"w-full h-8 cursor-pointer",style:{width:"100%",height:"32px",cursor:"pointer",border:"none",background:"transparent"}})}),children:F.jsx("div",{className:"w-[14px] h-[2px] mx-auto",style:{backgroundColor:i}})})}function KGe({hideText:t=!0}){const{editor:e}=Ot();return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"charutop",text:"上方插入一行",hideText:t,disabled:!e?.can().addRowBefore(),onMenuClick:()=>e?.chain().focus().addRowBefore().run()}),F.jsx(Ar,{ico:"charubottom",text:"下方插入一行",hideText:t,disabled:!e?.can().addRowAfter(),onMenuClick:()=>e?.chain().focus().addRowAfter().run()}),F.jsx(Ar,{ico:"charuleft",text:"左方插入一列",hideText:t,disabled:!e?.can().addColumnBefore(),onMenuClick:()=>e?.chain().focus().addColumnBefore().run()}),F.jsx(Ar,{ico:"charuright",text:"右方插入一列",hideText:t,disabled:!e?.can().addColumnAfter(),onMenuClick:()=>e?.chain().focus().addColumnAfter().run()})]})}function YGe({hideText:t=!0}){const{editor:e}=Ot();return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"removehang",text:"删除行",hideText:t,disabled:!e?.can().deleteColumn(),onMenuClick:()=>e?.chain().focus().deleteRow().run()}),F.jsx(Ar,{ico:"removelie",text:"删除列",hideText:t,disabled:!e?.can().deleteColumn(),onMenuClick:()=>e?.chain().focus().deleteColumn().run()})]})}function XGe({hideText:t=!0}){const{editor:e}=Ot();return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"merge-cell",text:"合并单元格",hideText:t,disabled:!e?.can().mergeCells(),onMenuClick:()=>e?.chain().focus().mergeCells().run()}),F.jsx(Ar,{ico:"split-cell",text:"拆分单元格",hideText:t,disabled:!e?.can().splitCell(),onMenuClick:()=>e?.chain().focus().splitCell().run()})]})}function ZGe(){const{editor:t}=Ot();return F.jsx(Ar,{ico:"remove",text:"删除表格",shortcut:"Backspace",hideText:!0,disabled:!t?.can().deleteTable(),onMenuClick:()=>t?.chain().focus().deleteTable().run()})}function JGe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx(qGe,{}),F.jsx(KGe,{}),F.jsx(YGe,{}),F.jsx(XGe,{}),F.jsx(ZGe,{})]})}function QGe(){const{editor:t}=Ot(),[e,r]=j.useState(""),n=()=>{if(e==="")return;t?.state?.selection?.$from?.node()&&t?.commands.updateAttributes("tag",{text:e})},i=()=>{const a=t?.getAttributes("tag");a?.text&&r(a.text)};return j.useEffect(()=>{if(t)return i(),t.on("selectionUpdate",i),()=>{t.off("selectionUpdate",i)}},[t]),F.jsxs(F.Fragment,{children:[F.jsx(jd,{placeholder:"请输入标签",value:e,onChange:a=>r(a),size:"small"}),F.jsx(ts,{type:"primary",size:"small",onClick:n,children:"确认"})]})}function eWe(){const{editor:t}=Ot(),[e,r]=j.useState(!1),n=[{label:"蓝色",color:"#007bff",bgcolor:"rgb(217, 231, 255)"},{label:"红色",color:"rgba(200, 78, 67, 1)",bgcolor:"rgb(252, 223, 220)"},{label:"黄色",color:"rgba(240, 196, 23, 1)",bgcolor:"rgb(255, 245, 210)"},{label:"绿色",color:"rgba(5, 205, 153, 1)",bgcolor:"rgb(205, 245, 235)"},{label:"紫色",color:"#e6afff",bgcolor:"rgb(220, 223, 252)"}],i=o=>{t?.state?.selection?.$from?.node()&&t?.commands.updateAttributes("tag",{type:o.type,color:o.color,backgroundColor:o.bgcolor}),r(!1)},a=()=>{t?.state?.selection?.$from?.node()&&t?.commands.updateAttributes("tag",{type:"default",color:"#999",backgroundColor:"rgba(0, 0, 0, 0.05)"}),r(!1)};return F.jsx(B2,{ico:"fill",text:"高亮填充",hideText:!0,onMenuClick:()=>i(),maxHeight:!1,popupVisible:e,onPopupVisibleChange:r,content:F.jsxs("div",{className:"px-2",children:[n.map((o,s)=>F.jsxs("div",{onClick:()=>i(o),style:{backgroundColor:o.bgcolor},className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer",children:[F.jsx("i",{className:"w-iconfont icon-tumo !text-[14px]"}),o.label]},s)),F.jsxs("div",{className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer border",onClick:a,children:[F.jsx("i",{className:"w-iconfont icon-clear-format !text-[14px]"}),"清除"]})]})})}function tWe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(QGe,{}),F.jsx(eWe,{}),F.jsx(dh,{})]})}function rWe(){const{editor:t,setAssistant:e}=Ot(),r=()=>{e(!0),t?.commands.focus()};return F.jsx(Ar,{ico:"ai-assistant",text:"AI智能助手",hideText:!0,onMenuClick:r})}function nWe(){const{editor:t}=Ot(),[e,r]=j.useState(!1),n=[{label:"默认",bgcolor:"#007bff"},{label:"红色",bgcolor:"#ff8a8a"},{label:"黄色",bgcolor:"#ffff8a"},{label:"绿色",bgcolor:"#a7ffa7"},{label:"紫色",bgcolor:"#e6afff"},{label:"蓝色",bgcolor:"#83d3ff"}],i=o=>{if(!o){t?.chain().focus().setHighlight({color:n[0].bgcolor}).run();return}t?.chain().focus().setHighlight({color:o.bgcolor}).run(),r(!1)},a=()=>{t?.chain().focus().unsetHighlight().run(),r(!1)};return F.jsx(B2,{ico:"fill",text:"高亮填充",hideText:!0,onMenuClick:()=>i(),maxHeight:!1,popupVisible:e,onPopupVisibleChange:r,content:F.jsxs("div",{className:"px-2",children:[n.map((o,s)=>F.jsxs("div",{onClick:()=>i(o),style:{backgroundColor:o.bgcolor},className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer",children:[F.jsx("i",{className:"w-iconfont icon-tumo !text-[14px]"}),o.label]},s)),F.jsxs("div",{className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer border",onClick:a,children:[F.jsx("i",{className:"w-iconfont icon-clear-format !text-[14px]"}),"清除"]})]})})}function iWe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(rWe,{}),F.jsx(DI,{}),F.jsx(OI,{}),F.jsx(RI,{}),F.jsx(II,{}),F.jsx(Koe,{}),F.jsx(nWe,{}),F.jsx(dh,{})]})}function aWe(){const{editor:t}=Ot(),[e,r]=j.useState(""),[n,i]=j.useState(""),a=s=>{i(s)},o=()=>{const s=cq.find(c=>c.value===n),{validate:l,transformURL:u}=s||{};l&&!l(e)||t?.chain().focus().setParagraph().setIframe({type:n,src:u?u(e):e}).run()};return F.jsx("div",{className:"flex items-center gap-2",children:t?.getAttributes("iframe").src===""?F.jsxs("div",{className:"flex items-center gap-2 py-2 px-1",children:[F.jsxs("div",{className:"flex flex-col items-center gap-1 h-[80px]",children:[F.jsx("span",{className:"w-[24px] h-[24px] text-center rounded-full bg-[#007bff] text-[12px] text-[#fff] font-500",style:{lineHeight:"24px"},children:"1"}),F.jsx("div",{className:"w-[1px] flex-1 bg-[#e5e5e5]"}),F.jsx("span",{className:"w-[24px] h-[24px] text-center rounded-full bg-[#007bff] text-[12px] text-[#fff] font-500",style:{lineHeight:"24px"},children:"2"})]}),F.jsxs("div",{className:"flex-1 h-[90px] flex flex-col justify-between gap-1",children:[F.jsx("div",{className:"mb-2",children:F.jsx(ay,{value:n,placeholder:"选择网页类型",options:cq,className:"w-full",onChange:a,renderOption:s=>F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx("span",{dangerouslySetInnerHTML:{__html:s.icon}}),s.label]})})}),F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(jd,{value:e,onChange:s=>r(s.target?s.target.value:s),placeholder:"打开网址复制链接,以http:// 或 https:// 开头",className:"w-[300px]"}),F.jsx(ts,{type:"primary",size:"small",disabled:!e,onClick:o,children:"添加"})]})]})]}):F.jsxs(F.Fragment,{children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx(xse,{}),F.jsx(dh,{})]})})}function oWe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx(BI,{icon:"setting",text:"图表配置",isEdit:!0}),F.jsx(dh,{})]})}const sWe="data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='14'%20cy='14'%20r='11.0833'%20fill='%23258AFF'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11.8581%2011.2155C11.9065%2011.1088%2012.058%2011.1088%2012.1064%2011.2155L14.6199%2016.7534C14.6609%2016.8437%2014.5948%2016.9461%2014.4957%2016.9461H11.6756C11.461%2016.9461%2011.2663%2017.072%2011.1782%2017.2677L10.7355%2018.2514C10.6273%2018.492%2010.8033%2018.7642%2011.0671%2018.7642H16.0477C16.7417%2018.7642%2017.2037%2018.0471%2016.9169%2017.4152L12.8512%208.45725C12.5122%207.71045%2011.4515%207.71057%2011.1127%208.45743L6.67056%2018.2504C6.56136%2018.4911%206.73737%2018.7642%207.00171%2018.7642H8.08241C8.29645%2018.7642%208.49072%2018.639%208.57914%2018.4441L11.8581%2011.2155ZM19.373%2018.4441C19.4614%2018.639%2019.6557%2018.7642%2019.8698%2018.7642H20.9504C21.2147%2018.7642%2021.3907%2018.4911%2021.2816%2018.2504L16.7334%208.22172C16.645%208.02677%2016.4508%207.90156%2016.2367%207.90156L15.156%207.90156C14.8917%207.90156%2014.7157%208.17464%2014.8249%208.41537L19.373%2018.4441Z'%20fill='white'/%3e%3c/svg%3e";function lWe(){const{editor:t,options:e,setAssistant:r}=Ot(),[n,i]=j.useState(""),[a,o]=j.useState({prompt:"",content:"",error:!1,command:""}),[s,l]=j.useState(!1),[u]=j.useState(600),c=j.useRef(null),f=()=>{r(!1),t?.commands.focus()},d=async()=>{if(a.content)try{await navigator.clipboard.writeText(a.content)}catch(b){console.error("Failed to copy: ",b)}},h=()=>{a.command&&(i(a.command),v(a.command))},p=()=>{i(""),o(b=>({...b,prompt:"",content:""}))},v=async b=>{const x=b??n;if(!x)return;l(!0),o(C=>({...C,error:!1,prompt:"",content:""}));const w={lang:"",input:t?Z7e(t):"",command:x},_={html:t?.getHTML()??"",text:t?.getText()??"",json:t?.getJSON()??{}};try{const C=await e.ai?.sendMessage?.(w,_),D=O=>{o(I=>{let L=I.content+O,V=I.error;return L.startsWith("[ERROR]: ")&&(V=!0,L=L.replace("[ERROR]: ","")),{...I,content:L,error:V}})};if(C instanceof ReadableStream){const O=new WritableStream({write(I){D(I)},close(){l(!1),o(I=>({...I,command:x}))}});await C.pipeTo(O)}else Mse(C)?(l(!1),o(O=>{let I=C,L=!1;return I.startsWith("[ERROR]: ")&&(L=!0,I=I.replace("[ERROR]: ","")),{...O,content:I,error:L,command:x}})):(console.error('"ai.assistant.onMessage" method returns data in an incorrect format, it can be a ReadableStream or plain text.'),l(!1))}catch(C){console.error(C),r(!1),l(!1)}},g=()=>{t?.chain().insertContent(a.content).run(),f()},m=()=>{const{to:b}=t?.state.selection??{};b&&t?.chain().insertContentAt(b,a.content).focus().run(),f()},y=()=>{t?.commands.selectParentNode();const{to:b}=t?.state.selection??{};b&&t?.chain().insertContentAt(b,a.content).focus().run(),f()};return F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"relative flex items-center gap-4 h-[50px] border-b px-3 white-ai-wrapper",style:{width:`${u}px`},children:[F.jsx("div",{className:"flex-shrink-0",children:F.jsx("img",{src:sWe,alt:"ai",className:"w-8 h-8"})}),F.jsx("input",{ref:c,value:n,onChange:b=>i(b.target.value),className:`flex-1 outline-none h-full ${s?"input-disabled":""}`,maxLength:e.ai?.maxlength,disabled:s,autoComplete:"false",placeholder:"告诉AI下一步怎么做",onKeyDown:b=>{b.key==="Enter"&&!s&&v()}}),F.jsx("button",{className:"ai-button",disabled:s,onClick:()=>v(),children:s?F.jsx("i",{className:"w-iconfont icon-loading animate-spin"}):F.jsx("i",{className:"w-iconfont icon-send"})})]}),a.content&&F.jsxs("div",{className:"w-full px-3 py-2",style:{width:`${u}px`},children:[F.jsx("div",{className:`w-full min-h-[50px] overflow-y-auto line-clamp-6 result-content ${a.error?"error":""}`,dangerouslySetInnerHTML:{__html:a.content}}),F.jsxs("div",{className:"flex items-center gap-2 text-handle",children:[F.jsx(ts,{type:"primary",size:"small",onClick:g,children:"替换所选"}),F.jsx(ts,{size:"small",onClick:y,children:"插入下方"}),F.jsx(ts,{size:"small",onClick:m,children:"插入后方"}),F.jsx(ts,{size:"small",onClick:p,children:"放弃"}),F.jsx("i",{className:"w-iconfont icon-copy-text cursor-pointer",title:"复制",onClick:d}),F.jsx("i",{className:"w-iconfont icon-refresh cursor-pointer",title:"重新生成",onClick:h})]})]})]})}function uWe(){const{editor:t,assistant:e,setAssistant:r}=Ot(),n=j.useMemo(()=>({placement:e?"bottom":"top",onHide(){r(!1)}}),[e,r]);return t?F.jsx(HGe,{className:`white-editor-bubble-menu rounded-md ${e?"":"px-3 py-2"}`,editor:t,pluginKey:"bubbleMenu",style:{maxWidth:600},options:n,ref:i=>{i&&(i.style.zIndex="200")},children:e?F.jsx(lWe,{}):F.jsx(F.Fragment,{children:t.isActive("toc")||t.isActive("pageBreak")||t.isActive("horizontalRule")||t.isActive("codeBlock")||t.getAttributes("image").error?F.jsx(dh,{}):t.isActive("image")&&!t.getAttributes("image").error||t.isActive("inlineImage")&&!t.getAttributes("inlineImage").error?F.jsx(jGe,{}):t.isActive("video")||t.isActive("audio")||t.isActive("file")?F.jsx(WGe,{}):t.isActive("iframe")?F.jsx(aWe,{}):t.isActive("table")?F.jsx(JGe,{}):t.isActive("tag")?F.jsx(tWe,{}):t.isActive("echarts")?F.jsx(oWe,{}):F.jsx(iWe,{})})}):null}const cWe=()=>{const{editor:t,page:e}=Ot(),[r,n]=j.useReducer(s=>s+1,0);j.useEffect(()=>{if(!t)return;const s=()=>n();return t.on("transaction",s),t.on("selectionUpdate",s),t.on("update",s),()=>{t.off("transaction",s),t.off("selectionUpdate",s),t.off("update",s)}},[t]);const i=j.useMemo(()=>{const{width:s,height:l}=e.size??{width:0,height:0};return{width:s,height:l}},[e.size]),a=j.useMemo(()=>e.layout==="web"?"100%":`calc(${i.width}cm * 1)`,[e.layout,i.width]),o=j.useMemo(()=>{const s=["white-editor-content","flex-1","flex","flex-col"];return t&&(t.isEmpty&&t.state.doc.childCount<=1&&s.push("is-empty"),t.isEditable&&s.push("is-readonly"),t.view?.painter?.enabled&&s.push("format-painter")),s.join(" ")},[t,r,t?.isEmpty,t?.isEditable]);return F.jsxs("div",{className:`white-editor-container min-h-full mx-auto overflow-hidden relative flex flex-col ${e.layout==="page"?"shadow-[0_0_10px_rgba(0,0,0,0.1)] bg-white":""}`,style:{width:a},children:[e.layout==="page"&&F.jsx("div",{className:"w-full h-[4rem]"}),F.jsx(Fme,{editor:t,className:o}),e.layout==="page"&&F.jsx("div",{className:"w-full h-[4rem]"}),t&&F.jsx(uWe,{})]})},fWe=()=>{const{page:t,container:e,options:r,uploadFileMap:n,setEditor:i}=Ot(),a=cVe({container:e,options:r,uploadFileMap:n}),o=Gme({extensions:a,editable:!r?.editor?.readOnly,autofocus:r?.editor?.autofocus,content:Zme(r.document?.content),enableInputRules:NU(r),enablePasteRules:NU(r),editorProps:{attributes:{class:"white-editor"}},parseOptions:r?.editor?.parseOptions});return j.useEffect(()=>{o&&(o.storage.container=e,o.storage.options=r,i(o))},[o,e,r,i]),console.log(r,e),F.jsx("div",{className:"white-editor-namespace white-give-editor-wrapper",children:F.jsxs("div",{className:"flex flex-col ",children:[r.layout?.toolbar?.show&&F.jsx("div",{className:"w-full flex-none border-b border-[#d9d9d9]",children:F.jsx(Ije,{})}),F.jsxs("div",{className:"w-full flex-1 min-h-0 flex overflow-hidden",id:e,children:[t.showToc&&r.layout.toc.show&&F.jsx(Gje,{}),F.jsx("div",{className:`flex-1 h-full overflow-y-auto py-[20px] ${t.layout==="page"?"bg-[#f4f6fa]":""}`,children:F.jsx(cWe,{})})]}),r.layout.foot.show&&F.jsx("div",{className:"w-full h-[40px] flex-none border-t border-[#d9d9d9] px-[2rem]",children:F.jsx(Uje,{})})]})})},dWe=t=>F.jsx(pK,{...t,children:F.jsx(fWe,{})});exports.EditorProvider=pK;exports.WhiteEditor=dWe;exports.useEditorContext=Ot;
456
+ </html>`},u=()=>{const c=l();Vje(c,()=>{console.log("打印完成")})};return F.jsxs("div",{className:"px-[12px] py-[5px] flex items-center gap-[0.4rem] cursor-pointer hover:bg-[rgb(242,243,245)]",onClick:u,children:[F.jsx("i",{className:"w-iconfont icon-export-pdf"}),"导出为PDF"]})}function $je(){const{editor:t,options:e}=Ot(),[r,n]=j.useState(!1),i=async()=>{if(!t)return;const o=t.getHTML();try{await navigator.clipboard.writeText(o)}catch(s){console.error("Failed to copy: ",s)}},a=()=>{if(!t)return;const o=new Blob([t.getText()],{type:"text/plain;charset=utf-8"}),{title:s}=e.document??{},l=s!==""?e.document?.title:"无标题文档";zje.saveAs(o,`${l}.txt`),n(!1)};return F.jsxs("div",{className:"flex items-center gap-[20px] text-[#333] foot-action",children:[e.layout.foot.copy&&F.jsxs("span",{className:"cursor-pointer flex items-center gap-[0.4rem] text-[14px] hover:text-[#007aff]",onClick:i,children:[F.jsx("i",{className:"w-iconfont icon-copy-content"}),"复制全文"]}),F.jsx(ol,{trigger:"click",placement:"top",value:r,onVisibleChange:n,contentStyle:{padding:"6px 0",boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08)"},content:F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"px-[12px] py-[5px] flex items-center gap-[0.4rem] cursor-pointer hover:bg-[rgb(242,243,245)]",onClick:a,children:[F.jsx("i",{className:"w-iconfont icon-text"}),"导出为文本"]}),F.jsx(Hje,{})]}),children:e.layout.foot.download&&F.jsxs("span",{className:"cursor-pointer flex items-center gap-[0.4rem] text-[14px] hover:text-[#007aff]",children:[F.jsx("i",{className:"w-iconfont icon-down"}),"下载"]})})]})}function Uje(){return F.jsxs("div",{className:"w-full h-full flex items-center justify-between",children:[F.jsx(Lje,{}),F.jsx($je,{})]})}const jje=({size:t="1em",top:e="30%",title:r="暂无数据"})=>F.jsxs("div",{className:"flex items-center justify-center flex-col gap-2",style:{paddingTop:e},children:[F.jsxs("svg",{className:"icon",viewBox:"0 0 1030 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,children:[F.jsx("path",{d:"M927.053254 896q0 1.254249-0.496852 2.508497t-1.484497 2.508497q-0.993704 1.248189-2.48426 2.49032-1.478438 1.248189-3.453728 2.48426-1.969231 1.230012-4.429254 2.447905-2.453964 1.217893-5.392663 2.423669-2.938698 1.199716-6.343953 2.381254-3.405254 1.187598-7.277065 2.3449-3.87787 1.163361-8.198059 2.302485-4.320189 1.133065-9.088757 2.241893t-9.967338 2.181302q-5.210888 1.084592-10.82168 2.126769-5.616852 1.048237-11.645728 2.060119-6.022817 1.005822-12.439479 1.97529-6.422722 0.969467-13.208994 1.90258-6.792331 0.933112-13.948213 1.817751-7.149822 0.890698-14.645018 1.738982-7.495195 0.842225-15.311527 1.635977-7.822391 0.799811-15.94168 1.551148-8.125349 0.745278-16.541539 1.442082-8.404071 0.702864-17.086863 1.345137-8.670675 0.648331-17.589776 1.24213-8.919101 0.593799-18.068449 1.127006-9.14329 0.539266-18.480474 1.01794-9.349302 0.484734-18.874319 0.908876-9.518959 0.424142-19.201515 0.787693-9.676497 0.36355-19.492355 0.666508-9.809799 0.302959-19.728663 0.551385-9.918864 0.242367-19.928615 0.430201-9.997633 0.181775-20.067977 0.302959-10.064284 0.127243-20.170982 0.187834-10.100639 0.060592-20.213396 0.060592-10.118817 0-20.219456-0.060592-10.100639-0.060592-20.164923-0.181775-10.070343-0.121183-20.074035-0.302959-10.003692-0.187834-19.922557-0.43626-9.924923-0.242367-19.734722-0.545325-9.815858-0.309018-19.492355-0.672568-9.676497-0.36355-19.201514-0.787693-9.518959-0.424142-18.868261-0.908876-9.343243-0.478675-18.486532-1.01794-9.14329-0.533207-18.062391-1.127006t-17.595834-1.24213q-8.676734-0.642272-17.086864-1.345137-8.41013-0.696805-16.535479-1.442082-8.11929-0.751337-15.935622-1.551148-7.822391-0.793751-15.317585-1.635977-7.495195-0.848284-14.651077-1.732923-7.149822-0.890698-13.936095-1.817751-6.798391-0.933112-13.208994-1.908639-6.422722-0.969467-12.445539-1.981349-6.028876-1.005822-11.645727-2.05406-5.622911-1.042178-10.821681-2.12071t-9.967337-2.187361q-4.768568-1.108828-9.088757-2.241893-4.326249-1.139124-8.19806-2.302485-3.871811-1.163361-7.277065-2.3449-3.405254-1.181538-6.343953-2.381254-2.938698-1.205775-5.392663-2.423669-2.460024-1.217893-4.429254-2.447905-1.97529-1.236071-3.453728-2.48426-1.490556-1.24213-2.48426-2.49032-0.987645-1.254249-1.484497-2.508497t-0.496852-2.508497z",fill:"#007bff",opacity:".1"}),F.jsx("path",{d:"M117.426746 376.832c0 8.70703 6.695385 15.36 15.450887 15.36 8.755503 0 15.450888-6.65297 15.450888-15.36 0-8.70097-6.695385-15.36-15.450888-15.36-8.240473 0-15.450888 7.168-15.450887 15.36z m814.776804 455.16497c-19.571124 5.12-23.691361 9.222059-28.326627 28.16303-5.150296-19.449941-9.270533-23.552-28.326627-28.16303 19.056095-5.12 23.691361-9.209941 28.326627-28.15697 4.635266 18.94703 8.755503 23.552 28.326627 28.15697zM203.436686 323.07503c-25.23645 6.65297-30.386746 11.77297-37.08213 36.864-6.695385-25.08497-11.84568-30.21103-37.08213-36.864 25.23645-6.65903 30.386746-12.288 37.08213-36.864 6.180355 25.08497 11.84568 30.20497 37.08213 36.864z m618.035503-88.064c-15.450888 4.096-18.541065 7.168-22.661301 22.528-4.120237-15.36-7.210414-18.432-22.661302-22.528 15.450888-4.096 18.541065-7.168 22.661302-22.528 3.605207 15.36 7.210414 18.432 22.661301 22.528z m66.438817-78.848c-40.172308 10.24-48.412781 18.94097-59.228402 58.87697-10.300592-39.929941-19.056095-48.128-59.228403-58.87697 40.172308-10.24 48.412781-18.94703 59.228403-58.88303 10.300592 39.42703 19.056095 48.128 59.228402 58.88303z",fill:"#007bff",opacity:".5"}),F.jsx("path",{d:"M422.32426 713.21297v4.096l33.991953 31.23503 130.302485-62.97903-117.941775 75.26703v36.864l19.056095-18.432v-0.51503 0.51503l19.056094 18.432 100.945799-122.88v-4.096l-185.410651 42.49297z",fill:"#007bff",opacity:".2"}),F.jsx("path",{d:"M865.249704 551.936v-1.024c0-1.024-0.51503-1.53297-0.515029-2.55697v-0.51503L754.003314 260.61103c-15.965917-48.64303-61.288521-81.41103-112.79148-81.41103H389.362367c-51.502959 0-96.825562 32.768-112.791479 81.41103L165.839527 547.84v0.51503c-0.51503 1.024-0.51503 1.53297-0.51503 2.55697v206.848c0 65.02097 53.048047 117.76 118.456805 117.76h463.526627c65.408757 0 118.456805-52.73903 118.456805-117.76v-204.8c-0.51503-0.50897-0.51503-0.50897-0.51503-1.024zM305.412544 271.36q0-0.50897 0.51503-0.50897c11.330651-36.864 45.322604-60.93103 83.434793-60.93103h251.334438c38.112189 0 72.104142 24.06703 83.949822 60.416q0 0.51503 0.51503 0.51503l102.490887 266.24H592.284024c-8.755503 0-15.450888 6.65297-15.450888 15.36 0 33.792-27.811598 61.44-61.80355 61.44-33.991953 0-61.80355-27.648-61.80355-61.44 0-8.70703-6.695385-15.36-15.450888-15.36H202.921657l102.490887-265.73103zM834.347929 757.76c0 48.128-39.142249 87.04-87.55503 87.04h-463.526627c-48.412781 0-87.55503-38.912-87.555029-87.04V568.32h228.158106c7.210414 43.52303 45.322604 76.8 91.160237 76.8 45.837633 0 83.949822-33.27697 91.160236-76.8H834.347929v189.44z",fill:"#007bff",opacity:".5"}),F.jsx("path",{d:"M515.029586 578.566059c-14.420828 0-25.751479-11.264-25.751479-25.6v-51.2H254.939645l84.464852-219.136 0.51503-1.024c7.210414-21.504 26.781538-35.84 49.44284-35.84h251.334438c22.661302 0 42.232426 14.336 49.44284 35.84l0.51503 1.024 84.464852 219.136H540.781065v51.2c0 14.336-11.330651 25.6-25.751479 25.6z",fill:"#007bff",opacity:".2"})]}),F.jsx("p",{className:"text-[#666]",children:r})]}),Gje=()=>{const{editor:t,options:e,setPage:r}=Ot(),[n,i]=j.useState([]),[a,o]=j.useState(""),s=j.useMemo(()=>dK(()=>{if(t){const u=t.storage.tableOfContents?.content;u&&i(u)}},200),[t]);j.useEffect(()=>{if(!t)return;s();const u=()=>{s()};return t.on("update",u),()=>{t.off("update",u)}},[t,s]);const l=u=>{if(!t)return;o(u.id);const c=t.view.dom.querySelector(`[data-toc-id="${u.id}"]`);if(!c)return;c.scrollIntoView({behavior:"smooth"});const f=t.view.posAtDOM(c,0),{tr:d}=t.view.state,h=d.doc.nodeAt(f);if(h){const p=f+h.nodeSize;d.setSelection(ir.create(d.doc,p))}else d.setSelection(new ir(d.doc.resolve(f)));t.view.dispatch(d),t.view.focus()};return F.jsxs("div",{className:"w-[260px] h-full flex flex-col overflow-hidden",children:[e?.layout?.foot?.show&&F.jsx("div",{className:"h-[50px] flex-none flex items-center px-4 text-[15px] text-[#666] hover:text-[#333]",children:F.jsxs("span",{className:"flex items-center gap-2 cursor-pointer",onClick:()=>r(u=>({...u,showToc:!1})),children:[F.jsx("i",{className:"w-iconfont icon-left !text-[12px]"}),"收起大纲"]})}),F.jsx("div",{className:"overflow-y-auto min-h-0",children:n?.length>0?F.jsx("ul",{className:"flex-1 px-4 py-2 space-y-[0.3rem]",children:n.map(u=>F.jsx("li",{className:`cursor-pointer text-[#333] text-[14px] h-[34px] block leading-[34px] pr-2 hover:text-[#101219] rounded text-ellipsis overflow-hidden whitespace-nowrap ${a===u.id?"font-bold bg-[#f5f5f5]":""}`,style:{textIndent:`${u.level}rem`},onClick:()=>l(u),children:u.textContent},u.id))}):F.jsx(jje,{size:"120px"})})]})},Xoe=["top","right","bottom","left"],Iq=["start","end"],Lq=Xoe.reduce((t,e)=>t.concat(e,e+"-"+Iq[0],e+"-"+Iq[1]),[]),vl=Math.min,ha=Math.max,u_=Math.round,rl=t=>({x:t,y:t}),Wje={left:"right",right:"left",bottom:"top",top:"bottom"},qje={start:"end",end:"start"};function zI(t,e,r){return ha(t,vl(e,r))}function Cu(t,e){return typeof t=="function"?t(e):t}function Fo(t){return t.split("-")[0]}function ss(t){return t.split("-")[1]}function Zoe(t){return t==="x"?"y":"x"}function r5(t){return t==="y"?"height":"width"}const Kje=new Set(["top","bottom"]);function Ys(t){return Kje.has(Fo(t))?"y":"x"}function n5(t){return Zoe(Ys(t))}function Joe(t,e,r){r===void 0&&(r=!1);const n=ss(t),i=n5(t),a=r5(i);let o=i==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=f_(o)),[o,f_(o)]}function Yje(t){const e=f_(t);return[c_(t),e,c_(e)]}function c_(t){return t.replace(/start|end/g,e=>qje[e])}const Pq=["left","right"],Bq=["right","left"],Xje=["top","bottom"],Zje=["bottom","top"];function Jje(t,e,r){switch(t){case"top":case"bottom":return r?e?Bq:Pq:e?Pq:Bq;case"left":case"right":return e?Xje:Zje;default:return[]}}function Qje(t,e,r,n){const i=ss(t);let a=Jje(Fo(t),r==="start",n);return i&&(a=a.map(o=>o+"-"+i),e&&(a=a.concat(a.map(c_)))),a}function f_(t){return t.replace(/left|right|bottom|top/g,e=>Wje[e])}function eGe(t){return{top:0,right:0,bottom:0,left:0,...t}}function i5(t){return typeof t!="number"?eGe(t):{top:t,right:t,bottom:t,left:t}}function Ev(t){const{x:e,y:r,width:n,height:i}=t;return{width:n,height:i,top:r,left:e,right:e+n,bottom:r+i,x:e,y:r}}function zq(t,e,r){let{reference:n,floating:i}=t;const a=Ys(e),o=n5(e),s=r5(o),l=Fo(e),u=a==="y",c=n.x+n.width/2-i.width/2,f=n.y+n.height/2-i.height/2,d=n[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:n.y-i.height};break;case"bottom":h={x:c,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:f};break;case"left":h={x:n.x-i.width,y:f};break;default:h={x:n.x,y:n.y}}switch(ss(e)){case"start":h[o]-=d*(r&&u?-1:1);break;case"end":h[o]+=d*(r&&u?-1:1);break}return h}const tGe=async(t,e,r)=>{const{placement:n="bottom",strategy:i="absolute",middleware:a=[],platform:o}=r,s=a.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:c,y:f}=zq(u,n,l),d=n,h={},p=0;for(let v=0;v<s.length;v++){const{name:g,fn:m}=s[v],{x:y,y:b,data:x,reset:w}=await m({x:c,y:f,initialPlacement:n,placement:d,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:t,floating:e}});c=y??c,f=b??f,h={...h,[g]:{...h[g],...x}},w&&p<=50&&(p++,typeof w=="object"&&(w.placement&&(d=w.placement),w.rects&&(u=w.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):w.rects),{x:c,y:f}=zq(u,d,l)),v=-1)}return{x:c,y:f,placement:d,strategy:i,middlewareData:h}};async function Mv(t,e){var r;e===void 0&&(e={});const{x:n,y:i,platform:a,rects:o,elements:s,strategy:l}=t,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=Cu(e,t),p=i5(h),g=s[d?f==="floating"?"reference":"floating":f],m=Ev(await a.getClippingRect({element:(r=await(a.isElement==null?void 0:a.isElement(g)))==null||r?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),y=f==="floating"?{x:n,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),x=await(a.isElement==null?void 0:a.isElement(b))?await(a.getScale==null?void 0:a.getScale(b))||{x:1,y:1}:{x:1,y:1},w=Ev(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:y,offsetParent:b,strategy:l}):y);return{top:(m.top-w.top+p.top)/x.y,bottom:(w.bottom-m.bottom+p.bottom)/x.y,left:(m.left-w.left+p.left)/x.x,right:(w.right-m.right+p.right)/x.x}}const rGe=t=>({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:i,rects:a,platform:o,elements:s,middlewareData:l}=e,{element:u,padding:c=0}=Cu(t,e)||{};if(u==null)return{};const f=i5(c),d={x:r,y:n},h=n5(i),p=r5(h),v=await o.getDimensions(u),g=h==="y",m=g?"top":"left",y=g?"bottom":"right",b=g?"clientHeight":"clientWidth",x=a.reference[p]+a.reference[h]-d[h]-a.floating[p],w=d[h]-a.reference[h],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let C=_?_[b]:0;(!C||!await(o.isElement==null?void 0:o.isElement(_)))&&(C=s.floating[b]||a.floating[p]);const D=x/2-w/2,O=C/2-v[p]/2-1,I=vl(f[m],O),L=vl(f[y],O),V=I,H=C-v[p]-L,Y=C/2-v[p]/2+D,te=zI(V,Y,H),Q=!l.arrow&&ss(i)!=null&&Y!==te&&a.reference[p]/2-(Y<V?I:L)-v[p]/2<0,ue=Q?Y<V?Y-V:Y-H:0;return{[h]:d[h]+ue,data:{[h]:te,centerOffset:Y-te-ue,...Q&&{alignmentOffset:ue}},reset:Q}}});function nGe(t,e,r){return(t?[...r.filter(i=>ss(i)===t),...r.filter(i=>ss(i)!==t)]:r.filter(i=>Fo(i)===i)).filter(i=>t?ss(i)===t||(e?c_(i)!==i:!1):!0)}const iGe=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,n,i;const{rects:a,middlewareData:o,placement:s,platform:l,elements:u}=e,{crossAxis:c=!1,alignment:f,allowedPlacements:d=Lq,autoAlignment:h=!0,...p}=Cu(t,e),v=f!==void 0||d===Lq?nGe(f||null,h,d):d,g=await Mv(e,p),m=((r=o.autoPlacement)==null?void 0:r.index)||0,y=v[m];if(y==null)return{};const b=Joe(y,a,await(l.isRTL==null?void 0:l.isRTL(u.floating)));if(s!==y)return{reset:{placement:v[0]}};const x=[g[Fo(y)],g[b[0]],g[b[1]]],w=[...((n=o.autoPlacement)==null?void 0:n.overflows)||[],{placement:y,overflows:x}],_=v[m+1];if(_)return{data:{index:m+1,overflows:w},reset:{placement:_}};const C=w.map(I=>{const L=ss(I.placement);return[I.placement,L&&c?I.overflows.slice(0,2).reduce((V,H)=>V+H,0):I.overflows[0],I.overflows]}).sort((I,L)=>I[1]-L[1]),O=((i=C.filter(I=>I[2].slice(0,ss(I[0])?2:3).every(L=>L<=0))[0])==null?void 0:i[0])||C[0][0];return O!==s?{data:{index:m+1,overflows:w},reset:{placement:O}}:{}}}},aGe=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r,n;const{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:l,elements:u}=e,{mainAxis:c=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:v=!0,...g}=Cu(t,e);if((r=a.arrow)!=null&&r.alignmentOffset)return{};const m=Fo(i),y=Ys(s),b=Fo(s)===s,x=await(l.isRTL==null?void 0:l.isRTL(u.floating)),w=d||(b||!v?[f_(s)]:Yje(s)),_=p!=="none";!d&&_&&w.push(...Qje(s,v,p,x));const C=[s,...w],D=await Mv(e,g),O=[];let I=((n=a.flip)==null?void 0:n.overflows)||[];if(c&&O.push(D[m]),f){const Y=Joe(i,o,x);O.push(D[Y[0]],D[Y[1]])}if(I=[...I,{placement:i,overflows:O}],!O.every(Y=>Y<=0)){var L,V;const Y=(((L=a.flip)==null?void 0:L.index)||0)+1,te=C[Y];if(te&&(!(f==="alignment"?y!==Ys(te):!1)||I.every(ie=>Ys(ie.placement)===y?ie.overflows[0]>0:!0)))return{data:{index:Y,overflows:I},reset:{placement:te}};let Q=(V=I.filter(ue=>ue.overflows[0]<=0).sort((ue,ie)=>ue.overflows[1]-ie.overflows[1])[0])==null?void 0:V.placement;if(!Q)switch(h){case"bestFit":{var H;const ue=(H=I.filter(ie=>{if(_){const Se=Ys(ie.placement);return Se===y||Se==="y"}return!0}).map(ie=>[ie.placement,ie.overflows.filter(Se=>Se>0).reduce((Se,me)=>Se+me,0)]).sort((ie,Se)=>ie[1]-Se[1])[0])==null?void 0:H[0];ue&&(Q=ue);break}case"initialPlacement":Q=s;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};function Fq(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Vq(t){return Xoe.some(e=>t[e]>=0)}const oGe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...i}=Cu(t,e);switch(n){case"referenceHidden":{const a=await Mv(e,{...i,elementContext:"reference"}),o=Fq(a,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Vq(o)}}}case"escaped":{const a=await Mv(e,{...i,altBoundary:!0}),o=Fq(a,r.floating);return{data:{escapedOffsets:o,escaped:Vq(o)}}}default:return{}}}}};function Qoe(t){const e=vl(...t.map(a=>a.left)),r=vl(...t.map(a=>a.top)),n=ha(...t.map(a=>a.right)),i=ha(...t.map(a=>a.bottom));return{x:e,y:r,width:n-e,height:i-r}}function sGe(t){const e=t.slice().sort((i,a)=>i.y-a.y),r=[];let n=null;for(let i=0;i<e.length;i++){const a=e[i];!n||a.y-n.y>n.height/2?r.push([a]):r[r.length-1].push(a),n=a}return r.map(i=>Ev(Qoe(i)))}const lGe=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:r,elements:n,rects:i,platform:a,strategy:o}=e,{padding:s=2,x:l,y:u}=Cu(t,e),c=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(n.reference))||[]),f=sGe(c),d=Ev(Qoe(c)),h=i5(s);function p(){if(f.length===2&&f[0].left>f[1].right&&l!=null&&u!=null)return f.find(g=>l>g.left-h.left&&l<g.right+h.right&&u>g.top-h.top&&u<g.bottom+h.bottom)||d;if(f.length>=2){if(Ys(r)==="y"){const I=f[0],L=f[f.length-1],V=Fo(r)==="top",H=I.top,Y=L.bottom,te=V?I.left:L.left,Q=V?I.right:L.right,ue=Q-te,ie=Y-H;return{top:H,bottom:Y,left:te,right:Q,width:ue,height:ie,x:te,y:H}}const g=Fo(r)==="left",m=ha(...f.map(I=>I.right)),y=vl(...f.map(I=>I.left)),b=f.filter(I=>g?I.left===y:I.right===m),x=b[0].top,w=b[b.length-1].bottom,_=y,C=m,D=C-_,O=w-x;return{top:x,bottom:w,left:_,right:C,width:D,height:O,x:_,y:x}}return d}const v=await a.getElementRects({reference:{getBoundingClientRect:p},floating:n.floating,strategy:o});return i.reference.x!==v.reference.x||i.reference.y!==v.reference.y||i.reference.width!==v.reference.width||i.reference.height!==v.reference.height?{reset:{rects:v}}:{}}}},uGe=new Set(["left","top"]);async function cGe(t,e){const{placement:r,platform:n,elements:i}=t,a=await(n.isRTL==null?void 0:n.isRTL(i.floating)),o=Fo(r),s=ss(r),l=Ys(r)==="y",u=uGe.has(o)?-1:1,c=a&&l?-1:1,f=Cu(e,t);let{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return s&&typeof p=="number"&&(h=s==="end"?p*-1:p),l?{x:h*c,y:d*u}:{x:d*u,y:h*c}}const fGe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:i,y:a,placement:o,middlewareData:s}=e,l=await cGe(e,t);return o===((r=s.offset)==null?void 0:r.placement)&&(n=s.arrow)!=null&&n.alignmentOffset?{}:{x:i+l.x,y:a+l.y,data:{...l,placement:o}}}}},dGe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:i}=e,{mainAxis:a=!0,crossAxis:o=!1,limiter:s={fn:g=>{let{x:m,y}=g;return{x:m,y}}},...l}=Cu(t,e),u={x:r,y:n},c=await Mv(e,l),f=Ys(Fo(i)),d=Zoe(f);let h=u[d],p=u[f];if(a){const g=d==="y"?"top":"left",m=d==="y"?"bottom":"right",y=h+c[g],b=h-c[m];h=zI(y,h,b)}if(o){const g=f==="y"?"top":"left",m=f==="y"?"bottom":"right",y=p+c[g],b=p-c[m];p=zI(y,p,b)}const v=s.fn({...e,[d]:h,[f]:p});return{...v,data:{x:v.x-r,y:v.y-n,enabled:{[d]:a,[f]:o}}}}}},hGe=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var r,n;const{placement:i,rects:a,platform:o,elements:s}=e,{apply:l=()=>{},...u}=Cu(t,e),c=await Mv(e,u),f=Fo(i),d=ss(i),h=Ys(i)==="y",{width:p,height:v}=a.floating;let g,m;f==="top"||f==="bottom"?(g=f,m=d===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(m=f,g=d==="end"?"top":"bottom");const y=v-c.top-c.bottom,b=p-c.left-c.right,x=vl(v-c[g],y),w=vl(p-c[m],b),_=!e.middlewareData.shift;let C=x,D=w;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(D=b),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(C=y),_&&!d){const I=ha(c.left,0),L=ha(c.right,0),V=ha(c.top,0),H=ha(c.bottom,0);h?D=p-2*(I!==0||L!==0?I+L:ha(c.left,c.right)):C=v-2*(V!==0||H!==0?V+H:ha(c.top,c.bottom))}await l({...e,availableWidth:D,availableHeight:C});const O=await o.getDimensions(s.floating);return p!==O.width||v!==O.height?{reset:{rects:!0}}:{}}}};function z2(){return typeof window<"u"}function ig(t){return ese(t)?(t.nodeName||"").toLowerCase():"#document"}function Qa(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Eu(t){var e;return(e=(ese(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function ese(t){return z2()?t instanceof Node||t instanceof Qa(t).Node:!1}function ds(t){return z2()?t instanceof Element||t instanceof Qa(t).Element:!1}function gl(t){return z2()?t instanceof HTMLElement||t instanceof Qa(t).HTMLElement:!1}function Hq(t){return!z2()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Qa(t).ShadowRoot}const pGe=new Set(["inline","contents"]);function W0(t){const{overflow:e,overflowX:r,overflowY:n,display:i}=hs(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!pGe.has(i)}const vGe=new Set(["table","td","th"]);function gGe(t){return vGe.has(ig(t))}const mGe=[":popover-open",":modal"];function F2(t){return mGe.some(e=>{try{return t.matches(e)}catch{return!1}})}const yGe=["transform","translate","scale","rotate","perspective"],bGe=["transform","translate","scale","rotate","perspective","filter"],xGe=["paint","layout","strict","content"];function a5(t){const e=o5(),r=ds(t)?hs(t):t;return yGe.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||bGe.some(n=>(r.willChange||"").includes(n))||xGe.some(n=>(r.contain||"").includes(n))}function wGe(t){let e=$c(t);for(;gl(e)&&!Av(e);){if(a5(e))return e;if(F2(e))return null;e=$c(e)}return null}function o5(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const SGe=new Set(["html","body","#document"]);function Av(t){return SGe.has(ig(t))}function hs(t){return Qa(t).getComputedStyle(t)}function V2(t){return ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $c(t){if(ig(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Hq(t)&&t.host||Eu(t);return Hq(e)?e.host:e}function tse(t){const e=$c(t);return Av(e)?t.ownerDocument?t.ownerDocument.body:t.body:gl(e)&&W0(e)?e:tse(e)}function rse(t,e,r){var n;e===void 0&&(e=[]);const i=tse(t),a=i===((n=t.ownerDocument)==null?void 0:n.body),o=Qa(i);return a?(FI(o),e.concat(o,o.visualViewport||[],W0(i)?i:[],[])):e.concat(i,rse(i,[]))}function FI(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function nse(t){const e=hs(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=gl(t),a=i?t.offsetWidth:r,o=i?t.offsetHeight:n,s=u_(r)!==a||u_(n)!==o;return s&&(r=a,n=o),{width:r,height:n,$:s}}function ise(t){return ds(t)?t:t.contextElement}function Zp(t){const e=ise(t);if(!gl(e))return rl(1);const r=e.getBoundingClientRect(),{width:n,height:i,$:a}=nse(e);let o=(a?u_(r.width):r.width)/n,s=(a?u_(r.height):r.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const _Ge=rl(0);function ase(t){const e=Qa(t);return!o5()||!e.visualViewport?_Ge:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function TGe(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==Qa(t)?!1:e}function p0(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const i=t.getBoundingClientRect(),a=ise(t);let o=rl(1);e&&(n?ds(n)&&(o=Zp(n)):o=Zp(t));const s=TGe(a,r,n)?ase(a):rl(0);let l=(i.left+s.x)/o.x,u=(i.top+s.y)/o.y,c=i.width/o.x,f=i.height/o.y;if(a){const d=Qa(a),h=n&&ds(n)?Qa(n):n;let p=d,v=FI(p);for(;v&&n&&h!==p;){const g=Zp(v),m=v.getBoundingClientRect(),y=hs(v),b=m.left+(v.clientLeft+parseFloat(y.paddingLeft))*g.x,x=m.top+(v.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,u*=g.y,c*=g.x,f*=g.y,l+=b,u+=x,p=Qa(v),v=FI(p)}}return Ev({width:c,height:f,x:l,y:u})}function H2(t,e){const r=V2(t).scrollLeft;return e?e.left+r:p0(Eu(t)).left+r}function ose(t,e){const r=t.getBoundingClientRect(),n=r.left+e.scrollLeft-H2(t,r),i=r.top+e.scrollTop;return{x:n,y:i}}function CGe(t){let{elements:e,rect:r,offsetParent:n,strategy:i}=t;const a=i==="fixed",o=Eu(n),s=e?F2(e.floating):!1;if(n===o||s&&a)return r;let l={scrollLeft:0,scrollTop:0},u=rl(1);const c=rl(0),f=gl(n);if((f||!f&&!a)&&((ig(n)!=="body"||W0(o))&&(l=V2(n)),gl(n))){const h=p0(n);u=Zp(n),c.x=h.x+n.clientLeft,c.y=h.y+n.clientTop}const d=o&&!f&&!a?ose(o,l):rl(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+d.x,y:r.y*u.y-l.scrollTop*u.y+c.y+d.y}}function EGe(t){return Array.from(t.getClientRects())}function MGe(t){const e=Eu(t),r=V2(t),n=t.ownerDocument.body,i=ha(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),a=ha(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+H2(t);const s=-r.scrollTop;return hs(n).direction==="rtl"&&(o+=ha(e.clientWidth,n.clientWidth)-i),{width:i,height:a,x:o,y:s}}const $q=25;function AGe(t,e){const r=Qa(t),n=Eu(t),i=r.visualViewport;let a=n.clientWidth,o=n.clientHeight,s=0,l=0;if(i){a=i.width,o=i.height;const c=o5();(!c||c&&e==="fixed")&&(s=i.offsetLeft,l=i.offsetTop)}const u=H2(n);if(u<=0){const c=n.ownerDocument,f=c.body,d=getComputedStyle(f),h=c.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,p=Math.abs(n.clientWidth-f.clientWidth-h);p<=$q&&(a-=p)}else u<=$q&&(a+=u);return{width:a,height:o,x:s,y:l}}const kGe=new Set(["absolute","fixed"]);function NGe(t,e){const r=p0(t,!0,e==="fixed"),n=r.top+t.clientTop,i=r.left+t.clientLeft,a=gl(t)?Zp(t):rl(1),o=t.clientWidth*a.x,s=t.clientHeight*a.y,l=i*a.x,u=n*a.y;return{width:o,height:s,x:l,y:u}}function Uq(t,e,r){let n;if(e==="viewport")n=AGe(t,r);else if(e==="document")n=MGe(Eu(t));else if(ds(e))n=NGe(e,r);else{const i=ase(t);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Ev(n)}function sse(t,e){const r=$c(t);return r===e||!ds(r)||Av(r)?!1:hs(r).position==="fixed"||sse(r,e)}function DGe(t,e){const r=e.get(t);if(r)return r;let n=rse(t,[]).filter(s=>ds(s)&&ig(s)!=="body"),i=null;const a=hs(t).position==="fixed";let o=a?$c(t):t;for(;ds(o)&&!Av(o);){const s=hs(o),l=a5(o);!l&&s.position==="fixed"&&(i=null),(a?!l&&!i:!l&&s.position==="static"&&!!i&&kGe.has(i.position)||W0(o)&&!l&&sse(t,o))?n=n.filter(c=>c!==o):i=s,o=$c(o)}return e.set(t,n),n}function OGe(t){let{element:e,boundary:r,rootBoundary:n,strategy:i}=t;const o=[...r==="clippingAncestors"?F2(e)?[]:DGe(e,this._c):[].concat(r),n],s=o[0],l=o.reduce((u,c)=>{const f=Uq(e,c,i);return u.top=ha(f.top,u.top),u.right=vl(f.right,u.right),u.bottom=vl(f.bottom,u.bottom),u.left=ha(f.left,u.left),u},Uq(e,s,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function RGe(t){const{width:e,height:r}=nse(t);return{width:e,height:r}}function IGe(t,e,r){const n=gl(e),i=Eu(e),a=r==="fixed",o=p0(t,!0,a,e);let s={scrollLeft:0,scrollTop:0};const l=rl(0);function u(){l.x=H2(i)}if(n||!n&&!a)if((ig(e)!=="body"||W0(i))&&(s=V2(e)),n){const h=p0(e,!0,a,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&u();a&&!n&&i&&u();const c=i&&!n&&!a?ose(i,s):rl(0),f=o.left+s.scrollLeft-l.x-c.x,d=o.top+s.scrollTop-l.y-c.y;return{x:f,y:d,width:o.width,height:o.height}}function hD(t){return hs(t).position==="static"}function jq(t,e){if(!gl(t)||hs(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return Eu(t)===r&&(r=r.ownerDocument.body),r}function lse(t,e){const r=Qa(t);if(F2(t))return r;if(!gl(t)){let i=$c(t);for(;i&&!Av(i);){if(ds(i)&&!hD(i))return i;i=$c(i)}return r}let n=jq(t,e);for(;n&&gGe(n)&&hD(n);)n=jq(n,e);return n&&Av(n)&&hD(n)&&!a5(n)?r:n||wGe(t)||r}const LGe=async function(t){const e=this.getOffsetParent||lse,r=this.getDimensions,n=await r(t.floating);return{reference:IGe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function PGe(t){return hs(t).direction==="rtl"}const BGe={convertOffsetParentRelativeRectToViewportRelativeRect:CGe,getDocumentElement:Eu,getClippingRect:OGe,getOffsetParent:lse,getElementRects:LGe,getClientRects:EGe,getDimensions:RGe,getScale:Zp,isElement:ds,isRTL:PGe},use=fGe,cse=iGe,fse=dGe,dse=aGe,hse=hGe,pse=oGe,vse=rGe,gse=lGe,mse=(t,e,r)=>{const n=new Map,i={platform:BGe,...r},a={...i.platform,_c:n};return tGe(t,e,{...i,platform:a})};function zGe(t,e){const r=Math.min(t.top,e.top),n=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-i,s=n-r,l=i,u=r;return new DOMRect(l,u,o,s)}var FGe=class{constructor({editor:t,element:e,view:r,updateDelay:n=250,resizeDelay:i=60,shouldShow:a,appendTo:o,getReferencedVirtualElement:s,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:f,from:d,to:h})=>{const{doc:p,selection:v}=f,{empty:g}=v,m=!p.textBetween(d,h).length&&xL(f.selection),y=this.element.contains(document.activeElement);return!(!(c.hasFocus()||y)||g||m||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,f)=>{const d=!f?.selection.eq(c.state.selection),h=!f?.doc.eq(c.state.doc);!d&&!h||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,d,h,f)},this.updateDelay))},this.updateHandler=(c,f,d,h)=>{const{composing:p}=c;if(p||!f&&!d)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:c})=>{c.getMeta("bubbleMenu")==="updatePosition"&&this.updatePosition()};var u;this.editor=t,this.element=e,this.view=r,this.updateDelay=n,this.resizeDelay=i,this.appendTo=o,this.scrollTarget=(u=l?.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=s,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(r,r.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(dse(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(fse(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(use(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(vse(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(hse(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(cse(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(pse(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(gse(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t;const{selection:e}=this.editor.state,r=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(r)return r;const n=sX(this.view,e.from,e.to);let i={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof ar){let a=this.view.nodeDOM(e.from);const o=a.dataset.nodeViewWrapper?a:a.querySelector("[data-node-view-wrapper]");o&&(a=o),a&&(i={getBoundingClientRect:()=>a.getBoundingClientRect(),getClientRects:()=>[a.getBoundingClientRect()]})}if(e instanceof Cn){const{$anchorCell:a,$headCell:o}=e,s=a?a.pos:o.pos,l=o?o.pos:a.pos,u=this.view.nodeDOM(s),c=this.view.nodeDOM(l);if(!u||!c)return;const f=u===c?u.getBoundingClientRect():zGe(u.getBoundingClientRect(),c.getBoundingClientRect());i={getBoundingClientRect:()=>f,getClientRects:()=>[f]}}return i}updatePosition(){const t=this.virtualElement;t&&mse(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:r,strategy:n})=>{this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${r}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:r}=t,n=r.selection.from!==r.selection.to;if(this.updateDelay>0&&n){this.handleDebouncedUpdate(t,e);return}const i=!e?.selection.eq(t.state.selection),a=!e?.doc.eq(t.state.doc);this.updateHandler(t,i,a,e)}getShouldShow(t){var e;const{state:r}=this.view,{selection:n}=r,{ranges:i}=n,a=Math.min(...i.map(l=>l.$from.pos)),o=Math.max(...i.map(l=>l.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:r,oldState:t,from:a,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},yse=t=>new en({key:typeof t.pluginKey=="string"?new on(t.pluginKey):t.pluginKey,view:e=>new FGe({view:e,...t})});Vr.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[yse({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var VGe=class{constructor({editor:t,element:e,view:r,options:n,appendTo:i,shouldShow:a}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:o,state:s})=>{const{selection:l}=s,{$anchor:u,empty:c}=l,f=u.depth===1,d=u.parent.isTextblock&&!u.parent.type.spec.code&&!u.parent.textContent&&u.parent.childCount===0&&!this.getTextContent(u.parent);return!(!o.hasFocus()||!c||!f||!d||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(o,s,l,u)=>{const{composing:c}=o;if(c||!s&&!l)return;if(!this.getShouldShow(u)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var s;if(this.preventHide){this.preventHide=!1;return}o?.relatedTarget&&((s=this.element.parentNode)!=null&&s.contains(o.relatedTarget))||o?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=r,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...n},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(r,r.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return tX(t,{textSerializers:_L(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(dse(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(fse(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(use(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(vse(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(hse(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(cse(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(pse(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(gse(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:r}=this.view,{selection:n}=r,{ranges:i}=n,a=Math.min(...i.map(l=>l.$from.pos)),o=Math.max(...i.map(l=>l.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:r,oldState:t,from:a,to:o})}updatePosition(){const{selection:t}=this.editor.state,e=sX(this.view,t.from,t.to);mse({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:i,strategy:a})=>{this.element.style.width="max-content",this.element.style.position=a,this.element.style.left=`${n}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const r=!e?.selection.eq(t.state.selection),n=!e?.doc.eq(t.state.doc);this.updateHandler(t,r,n,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},bse=t=>new en({key:typeof t.pluginKey=="string"?new on(t.pluginKey):t.pluginKey,view:e=>new VGe({view:e,...t})});Vr.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[bse({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var HGe=j.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:r,resizeDelay:n,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:l,...u},c)=>{const f=j.useRef(document.createElement("div"));typeof c=="function"?c(f.current):c&&(c.current=f.current);const{editor:d}=AX(),h=e||d,p={updateDelay:r,resizeDelay:n,appendTo:i,pluginKey:t,shouldShow:a,getReferencedVirtualElement:o,options:s},v=j.useRef(p);return v.current=p,j.useEffect(()=>{if(h?.isDestroyed)return;if(!h){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const g=f.current;g.style.visibility="hidden",g.style.position="absolute";const m=yse({...v.current,editor:h,element:g});h.registerPlugin(m);const y=v.current.pluginKey;return()=>{h.unregisterPlugin(y),window.requestAnimationFrame(()=>{g.parentNode&&g.parentNode.removeChild(g)})}},[h]),kv.createPortal(F.jsx("div",{...u,children:l}),f.current)});j.forwardRef(({pluginKey:t="floatingMenu",editor:e,appendTo:r,shouldShow:n=null,options:i,children:a,...o},s)=>{const l=j.useRef(document.createElement("div"));typeof s=="function"?s(l.current):s&&(s.current=l.current);const{editor:u}=AX();return j.useEffect(()=>{const c=l.current;if(c.style.visibility="hidden",c.style.position="absolute",e?.isDestroyed||u?.isDestroyed)return;const f=e||u;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=bse({editor:f,element:c,pluginKey:t,appendTo:r,shouldShow:n,options:i});return f.registerPlugin(d),()=>{f.unregisterPlugin(t),window.requestAnimationFrame(()=>{c.parentNode&&c.parentNode.removeChild(c)})}},[e,u,r,t,n,i]),kv.createPortal(F.jsx("div",{...o,children:a}),l.current)});function $Ge(){const{editor:t}=Ot(),[e,r]=j.useReducer(o=>o+1,0);j.useEffect(()=>{if(!t)return;const o=()=>r();return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const n=j.useMemo(()=>{const o=t?au(t):null;return o?.type?.name?t?.getAttributes(o.type.name)?.flipY:!1},[t,e]),i=j.useMemo(()=>{const o=t?au(t):null;return o?.type?.name?t?.getAttributes(o.type.name)?.flipX:!1},[t,e]),a=o=>{const s=t?au(t):null,{flipX:l,flipY:u}=s?.attrs??{};s&&o==="flipX"&&t?.commands.updateAttributes(s.type,{flipX:!l}),s&&o==="flipY"&&t?.commands.updateAttributes(s.type,{flipY:!u})};return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"flip-x",text:"水平翻转",hideText:!0,menuActive:n,onMenuClick:()=>a("flipY")}),F.jsx(Ar,{ico:"flip-y",text:"垂直翻转",hideText:!0,menuActive:i,onMenuClick:()=>a("flipX")})]})}function xse(){const{editor:t}=Ot(),e=()=>{const r=t?au(t):null;r?.attrs.src&&window.open(r.attrs.src)};return F.jsx(Ar,{ico:"open",text:"新窗口打开",shortcut:"Backspace",hideText:!0,onMenuClick:e})}function UGe(){const{editor:t}=Ot(),e=j.useMemo(()=>(t?au(t):null)?.type?.name==="inlineImage"?"转为节点图片":"转为行内图片",[t?.state.selection]),[r,n]=j.useReducer(a=>a+1,0);j.useEffect(()=>{if(!t)return;const a=()=>n();return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]);const i=()=>{const a=t?au(t):null;if(a){const o=a?.type?.name==="inlineImage"?"inlineImage":"image",s=a.attrs??{};!s.error&&s.src&&(t?.chain().focus().deleteSelectionNode().run(),o==="inlineImage"?t?.chain().focus().setImage({...s,equalProportion:!1,inline:!1}).run():t?.chain().focus().setInlineImage({...s,inline:!0,equalProportion:!1}).run())}};return F.jsx(Ar,{ico:"huantu",text:e,hideText:!0,onMenuClick:i})}function dh(){const{editor:t}=Ot();return F.jsx(Ar,{ico:"remove",text:"删除",shortcut:"Backspace",hideText:!0,onMenuClick:()=>t?.chain().focus().deleteSelectionNode().run()})}function jGe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx($Ge,{}),F.jsx(UGe,{}),F.jsx(xse,{}),F.jsx(dh,{})]})}function GGe(){const{editor:t}=Ot(),e=()=>{const r=t?au(t):null;if(!r)return;const n=document.createElement("a");n.href=r.attrs.url,n.download=r.attrs.name,document.body.appendChild(n),n.click(),document.body.removeChild(n)};return t?.getAttributes("file")?.uploaded?F.jsx(Ar,{ico:"down",text:"下载",hideText:!0,onMenuClick:e}):null}function WGe(){const{editor:t}=Ot();return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),(t?.isActive("file")||t?.isActive("video")||t?.isActive("audio"))&&F.jsx(GGe,{}),F.jsx(dh,{})]})}function qGe({defaultColor:t="#007bff"}){const{editor:e}=Ot(),[r,n]=j.useState(!1),[i,a]=j.useState(t),o=l=>{a(l),n(!1);const u=l===""?null:l;e?.chain().focus().setCellAttribute("background",u).run()},s=g0(l=>{a(l);const u=l===""?null:l;e?.chain().focus().setCellAttribute("background",u).run()},200);return F.jsx(xl,{ico:"fill",text:"填充背景",hideText:!0,popupVisible:r,disabled:!e?.can().setCellAttribute("background",""),popupType:"arrow",onMenuClick:()=>o(i),onPopupVisibleChange:n,content:F.jsx("div",{className:"p-2",children:F.jsx("input",{type:"color",value:i,onChange:l=>s(l.target.value),className:"w-full h-8 cursor-pointer",style:{width:"100%",height:"32px",cursor:"pointer",border:"none",background:"transparent"}})}),children:F.jsx("div",{className:"w-[14px] h-[2px] mx-auto",style:{backgroundColor:i}})})}function KGe({hideText:t=!0}){const{editor:e}=Ot();return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"charutop",text:"上方插入一行",hideText:t,disabled:!e?.can().addRowBefore(),onMenuClick:()=>e?.chain().focus().addRowBefore().run()}),F.jsx(Ar,{ico:"charubottom",text:"下方插入一行",hideText:t,disabled:!e?.can().addRowAfter(),onMenuClick:()=>e?.chain().focus().addRowAfter().run()}),F.jsx(Ar,{ico:"charuleft",text:"左方插入一列",hideText:t,disabled:!e?.can().addColumnBefore(),onMenuClick:()=>e?.chain().focus().addColumnBefore().run()}),F.jsx(Ar,{ico:"charuright",text:"右方插入一列",hideText:t,disabled:!e?.can().addColumnAfter(),onMenuClick:()=>e?.chain().focus().addColumnAfter().run()})]})}function YGe({hideText:t=!0}){const{editor:e}=Ot();return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"removehang",text:"删除行",hideText:t,disabled:!e?.can().deleteColumn(),onMenuClick:()=>e?.chain().focus().deleteRow().run()}),F.jsx(Ar,{ico:"removelie",text:"删除列",hideText:t,disabled:!e?.can().deleteColumn(),onMenuClick:()=>e?.chain().focus().deleteColumn().run()})]})}function XGe({hideText:t=!0}){const{editor:e}=Ot();return F.jsxs(F.Fragment,{children:[F.jsx(Ar,{ico:"merge-cell",text:"合并单元格",hideText:t,disabled:!e?.can().mergeCells(),onMenuClick:()=>e?.chain().focus().mergeCells().run()}),F.jsx(Ar,{ico:"split-cell",text:"拆分单元格",hideText:t,disabled:!e?.can().splitCell(),onMenuClick:()=>e?.chain().focus().splitCell().run()})]})}function ZGe(){const{editor:t}=Ot();return F.jsx(Ar,{ico:"remove",text:"删除表格",shortcut:"Backspace",hideText:!0,disabled:!t?.can().deleteTable(),onMenuClick:()=>t?.chain().focus().deleteTable().run()})}function JGe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx(qGe,{}),F.jsx(KGe,{}),F.jsx(YGe,{}),F.jsx(XGe,{}),F.jsx(ZGe,{})]})}function QGe(){const{editor:t}=Ot(),[e,r]=j.useState(""),n=()=>{if(e==="")return;t?.state?.selection?.$from?.node()&&t?.commands.updateAttributes("tag",{text:e})},i=()=>{const a=t?.getAttributes("tag");a?.text&&r(a.text)};return j.useEffect(()=>{if(t)return i(),t.on("selectionUpdate",i),()=>{t.off("selectionUpdate",i)}},[t]),F.jsxs(F.Fragment,{children:[F.jsx(jd,{placeholder:"请输入标签",value:e,onChange:a=>r(a),size:"small"}),F.jsx(ts,{type:"primary",size:"small",onClick:n,children:"确认"})]})}function eWe(){const{editor:t}=Ot(),[e,r]=j.useState(!1),n=[{label:"蓝色",color:"#007bff",bgcolor:"rgb(217, 231, 255)"},{label:"红色",color:"rgba(200, 78, 67, 1)",bgcolor:"rgb(252, 223, 220)"},{label:"黄色",color:"rgba(240, 196, 23, 1)",bgcolor:"rgb(255, 245, 210)"},{label:"绿色",color:"rgba(5, 205, 153, 1)",bgcolor:"rgb(205, 245, 235)"},{label:"紫色",color:"#e6afff",bgcolor:"rgb(220, 223, 252)"}],i=o=>{t?.state?.selection?.$from?.node()&&t?.commands.updateAttributes("tag",{type:o.type,color:o.color,backgroundColor:o.bgcolor}),r(!1)},a=()=>{t?.state?.selection?.$from?.node()&&t?.commands.updateAttributes("tag",{type:"default",color:"#999",backgroundColor:"rgba(0, 0, 0, 0.05)"}),r(!1)};return F.jsx(B2,{ico:"fill",text:"高亮填充",hideText:!0,onMenuClick:()=>i(),maxHeight:!1,popupVisible:e,onPopupVisibleChange:r,content:F.jsxs("div",{className:"px-2",children:[n.map((o,s)=>F.jsxs("div",{onClick:()=>i(o),style:{backgroundColor:o.bgcolor},className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer",children:[F.jsx("i",{className:"w-iconfont icon-tumo !text-[14px]"}),o.label]},s)),F.jsxs("div",{className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer border",onClick:a,children:[F.jsx("i",{className:"w-iconfont icon-clear-format !text-[14px]"}),"清除"]})]})})}function tWe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(QGe,{}),F.jsx(eWe,{}),F.jsx(dh,{})]})}function rWe(){const{editor:t,setAssistant:e}=Ot(),r=()=>{e(!0),t?.commands.focus()};return F.jsx(Ar,{ico:"ai-assistant",text:"AI智能助手",hideText:!0,onMenuClick:r})}function nWe(){const{editor:t}=Ot(),[e,r]=j.useState(!1),n=[{label:"默认",bgcolor:"#007bff"},{label:"红色",bgcolor:"#ff8a8a"},{label:"黄色",bgcolor:"#ffff8a"},{label:"绿色",bgcolor:"#a7ffa7"},{label:"紫色",bgcolor:"#e6afff"},{label:"蓝色",bgcolor:"#83d3ff"}],i=o=>{if(!o){t?.chain().focus().setHighlight({color:n[0].bgcolor}).run();return}t?.chain().focus().setHighlight({color:o.bgcolor}).run(),r(!1)},a=()=>{t?.chain().focus().unsetHighlight().run(),r(!1)};return F.jsx(B2,{ico:"fill",text:"高亮填充",hideText:!0,onMenuClick:()=>i(),maxHeight:!1,popupVisible:e,onPopupVisibleChange:r,content:F.jsxs("div",{className:"px-2",children:[n.map((o,s)=>F.jsxs("div",{onClick:()=>i(o),style:{backgroundColor:o.bgcolor},className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer",children:[F.jsx("i",{className:"w-iconfont icon-tumo !text-[14px]"}),o.label]},s)),F.jsxs("div",{className:"h-[30px] w-[90px] flex items-center justify-center gap-2 mb-2 rounded-[3px] cursor-pointer border",onClick:a,children:[F.jsx("i",{className:"w-iconfont icon-clear-format !text-[14px]"}),"清除"]})]})})}function iWe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(rWe,{}),F.jsx(DI,{}),F.jsx(OI,{}),F.jsx(RI,{}),F.jsx(II,{}),F.jsx(Koe,{}),F.jsx(nWe,{}),F.jsx(dh,{})]})}function aWe(){const{editor:t}=Ot(),[e,r]=j.useState(""),[n,i]=j.useState(""),a=s=>{i(s)},o=()=>{const s=cq.find(c=>c.value===n),{validate:l,transformURL:u}=s||{};l&&!l(e)||t?.chain().focus().setParagraph().setIframe({type:n,src:u?u(e):e}).run()};return F.jsx("div",{className:"flex items-center gap-2",children:t?.getAttributes("iframe").src===""?F.jsxs("div",{className:"flex items-center gap-2 py-2 px-1",children:[F.jsxs("div",{className:"flex flex-col items-center gap-1 h-[80px]",children:[F.jsx("span",{className:"w-[24px] h-[24px] text-center rounded-full bg-[#007bff] text-[12px] text-[#fff] font-500",style:{lineHeight:"24px"},children:"1"}),F.jsx("div",{className:"w-[1px] flex-1 bg-[#e5e5e5]"}),F.jsx("span",{className:"w-[24px] h-[24px] text-center rounded-full bg-[#007bff] text-[12px] text-[#fff] font-500",style:{lineHeight:"24px"},children:"2"})]}),F.jsxs("div",{className:"flex-1 h-[90px] flex flex-col justify-between gap-1",children:[F.jsx("div",{className:"mb-2",children:F.jsx(ay,{value:n,placeholder:"选择网页类型",options:cq,className:"w-full",onChange:a,renderOption:s=>F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx("span",{dangerouslySetInnerHTML:{__html:s.icon}}),s.label]})})}),F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(jd,{value:e,onChange:s=>r(s.target?s.target.value:s),placeholder:"打开网址复制链接,以http:// 或 https:// 开头",className:"w-[300px]"}),F.jsx(ts,{type:"primary",size:"small",disabled:!e,onClick:o,children:"添加"})]})]})]}):F.jsxs(F.Fragment,{children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx(xse,{}),F.jsx(dh,{})]})})}function oWe(){return F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx(ng,{}),F.jsx(tg,{}),F.jsx(rg,{}),F.jsx(BI,{icon:"setting",text:"图表配置",isEdit:!0}),F.jsx(dh,{})]})}const sWe="data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='14'%20cy='14'%20r='11.0833'%20fill='%23258AFF'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11.8581%2011.2155C11.9065%2011.1088%2012.058%2011.1088%2012.1064%2011.2155L14.6199%2016.7534C14.6609%2016.8437%2014.5948%2016.9461%2014.4957%2016.9461H11.6756C11.461%2016.9461%2011.2663%2017.072%2011.1782%2017.2677L10.7355%2018.2514C10.6273%2018.492%2010.8033%2018.7642%2011.0671%2018.7642H16.0477C16.7417%2018.7642%2017.2037%2018.0471%2016.9169%2017.4152L12.8512%208.45725C12.5122%207.71045%2011.4515%207.71057%2011.1127%208.45743L6.67056%2018.2504C6.56136%2018.4911%206.73737%2018.7642%207.00171%2018.7642H8.08241C8.29645%2018.7642%208.49072%2018.639%208.57914%2018.4441L11.8581%2011.2155ZM19.373%2018.4441C19.4614%2018.639%2019.6557%2018.7642%2019.8698%2018.7642H20.9504C21.2147%2018.7642%2021.3907%2018.4911%2021.2816%2018.2504L16.7334%208.22172C16.645%208.02677%2016.4508%207.90156%2016.2367%207.90156L15.156%207.90156C14.8917%207.90156%2014.7157%208.17464%2014.8249%208.41537L19.373%2018.4441Z'%20fill='white'/%3e%3c/svg%3e";function lWe(){const{editor:t,options:e,setAssistant:r}=Ot(),[n,i]=j.useState(""),[a,o]=j.useState({prompt:"",content:"",error:!1,command:""}),[s,l]=j.useState(!1),[u]=j.useState(600),c=j.useRef(null),f=()=>{r(!1),t?.commands.focus()},d=async()=>{if(a.content)try{await navigator.clipboard.writeText(a.content)}catch(b){console.error("Failed to copy: ",b)}},h=()=>{a.command&&(i(a.command),v(a.command))},p=()=>{i(""),o(b=>({...b,prompt:"",content:""}))},v=async b=>{const x=b??n;if(!x)return;l(!0),o(C=>({...C,error:!1,prompt:"",content:""}));const w={lang:"",input:t?Z7e(t):"",command:x},_={html:t?.getHTML()??"",text:t?.getText()??"",json:t?.getJSON()??{}};try{const C=await e.ai?.sendMessage?.(w,_),D=O=>{o(I=>{let L=I.content+O,V=I.error;return L.startsWith("[ERROR]: ")&&(V=!0,L=L.replace("[ERROR]: ","")),{...I,content:L,error:V}})};if(C instanceof ReadableStream){const O=new WritableStream({write(I){D(I)},close(){l(!1),o(I=>({...I,command:x}))}});await C.pipeTo(O)}else Mse(C)?(l(!1),o(O=>{let I=C,L=!1;return I.startsWith("[ERROR]: ")&&(L=!0,I=I.replace("[ERROR]: ","")),{...O,content:I,error:L,command:x}})):(console.error('"ai.assistant.onMessage" method returns data in an incorrect format, it can be a ReadableStream or plain text.'),l(!1))}catch(C){console.error(C),r(!1),l(!1)}},g=()=>{t?.chain().insertContent(a.content).run(),f()},m=()=>{const{to:b}=t?.state.selection??{};b&&t?.chain().insertContentAt(b,a.content).focus().run(),f()},y=()=>{t?.commands.selectParentNode();const{to:b}=t?.state.selection??{};b&&t?.chain().insertContentAt(b,a.content).focus().run(),f()};return F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"relative flex items-center gap-4 h-[50px] border-b px-3 white-ai-wrapper",style:{width:`${u}px`},children:[F.jsx("div",{className:"flex-shrink-0",children:F.jsx("img",{src:sWe,alt:"ai",className:"w-8 h-8"})}),F.jsx("input",{ref:c,value:n,onChange:b=>i(b.target.value),className:`flex-1 outline-none h-full ${s?"input-disabled":""}`,maxLength:e.ai?.maxlength,disabled:s,autoComplete:"false",placeholder:"告诉AI下一步怎么做",onKeyDown:b=>{b.key==="Enter"&&!s&&v()}}),F.jsx("button",{className:"ai-button",disabled:s,onClick:()=>v(),children:s?F.jsx("i",{className:"w-iconfont icon-loading animate-spin"}):F.jsx("i",{className:"w-iconfont icon-send"})})]}),a.content&&F.jsxs("div",{className:"w-full px-3 py-2",style:{width:`${u}px`},children:[F.jsx("div",{className:`w-full min-h-[50px] overflow-y-auto line-clamp-6 result-content ${a.error?"error":""}`,dangerouslySetInnerHTML:{__html:a.content}}),F.jsxs("div",{className:"flex items-center gap-2 text-handle",children:[F.jsx(ts,{type:"primary",size:"small",onClick:g,children:"替换所选"}),F.jsx(ts,{size:"small",onClick:y,children:"插入下方"}),F.jsx(ts,{size:"small",onClick:m,children:"插入后方"}),F.jsx(ts,{size:"small",onClick:p,children:"放弃"}),F.jsx("i",{className:"w-iconfont icon-copy-text cursor-pointer",title:"复制",onClick:d}),F.jsx("i",{className:"w-iconfont icon-refresh cursor-pointer",title:"重新生成",onClick:h})]})]})]})}function uWe(){const{editor:t,assistant:e,setAssistant:r}=Ot(),n=j.useMemo(()=>({placement:e?"bottom":"top",onHide(){r(!1)}}),[e,r]);return t?F.jsx(HGe,{className:`white-editor-bubble-menu rounded-md ${e?"":"px-3 py-2"}`,editor:t,pluginKey:"bubbleMenu",style:{maxWidth:600},options:n,ref:i=>{i&&(i.style.zIndex="200")},children:e?F.jsx(lWe,{}):F.jsx(F.Fragment,{children:t.isActive("toc")||t.isActive("pageBreak")||t.isActive("horizontalRule")||t.isActive("codeBlock")||t.getAttributes("image").error?F.jsx(dh,{}):t.isActive("image")&&!t.getAttributes("image").error||t.isActive("inlineImage")&&!t.getAttributes("inlineImage").error?F.jsx(jGe,{}):t.isActive("video")||t.isActive("audio")||t.isActive("file")?F.jsx(WGe,{}):t.isActive("iframe")?F.jsx(aWe,{}):t.isActive("table")?F.jsx(JGe,{}):t.isActive("tag")?F.jsx(tWe,{}):t.isActive("echarts")?F.jsx(oWe,{}):F.jsx(iWe,{})})}):null}const cWe=()=>{const{editor:t,page:e}=Ot(),[r,n]=j.useReducer(s=>s+1,0);j.useEffect(()=>{if(!t)return;const s=()=>n();return t.on("transaction",s),t.on("selectionUpdate",s),t.on("update",s),()=>{t.off("transaction",s),t.off("selectionUpdate",s),t.off("update",s)}},[t]);const i=j.useMemo(()=>{const{width:s,height:l}=e.size??{width:0,height:0};return{width:s,height:l}},[e.size]),a=j.useMemo(()=>e.layout==="web"?"100%":`calc(${i.width}cm * 1)`,[e.layout,i.width]),o=j.useMemo(()=>{const s=["white-editor-content","flex-1","flex","flex-col"];return t&&(t.isEmpty&&t.state.doc.childCount<=1&&s.push("is-empty"),t.isEditable&&s.push("is-readonly"),t.view?.painter?.enabled&&s.push("format-painter")),s.join(" ")},[t,r,t?.isEmpty,t?.isEditable]);return F.jsxs("div",{className:`white-editor-container min-h-full mx-auto overflow-hidden relative flex flex-col ${e.layout==="page"?"shadow-[0_0_10px_rgba(0,0,0,0.1)] bg-white":""}`,style:{width:a},children:[e.layout==="page"&&F.jsx("div",{className:"w-full h-[4rem]"}),F.jsx(Fme,{editor:t,className:o}),e.layout==="page"&&F.jsx("div",{className:"w-full h-[4rem]"}),t&&F.jsx(uWe,{})]})},fWe=()=>{const{page:t,container:e,options:r,uploadFileMap:n,setEditor:i}=Ot(),a=cVe({container:e,options:r,uploadFileMap:n}),o=Gme({extensions:a,editable:!r?.editor?.readOnly,autofocus:r?.editor?.autofocus,content:Zme(r.document?.content),enableInputRules:NU(r),enablePasteRules:NU(r),editorProps:{attributes:{class:"white-editor"}},parseOptions:r?.editor?.parseOptions});return j.useEffect(()=>{o&&(o.storage.container=e,o.storage.options=r,i(o))},[o,e,r,i]),console.log(r,e),F.jsx("div",{className:"white-editor-namespace white-give-editor-wrapper",children:F.jsxs("div",{className:"flex flex-col w-full h-full",children:[r.layout?.toolbar?.show&&F.jsx("div",{className:"w-full flex-none border-b border-[#d9d9d9]",children:F.jsx(Ije,{})}),F.jsxs("div",{className:"w-full flex-1 min-h-0 flex overflow-hidden",id:e,children:[t.showToc&&r.layout.toc.show&&F.jsx(Gje,{}),F.jsx("div",{className:`flex-1 h-full overflow-y-auto py-[20px] ${t.layout==="page"?"bg-[#f4f6fa]":""}`,children:F.jsx(cWe,{})})]}),r.layout.foot.show&&F.jsx("div",{className:"w-full h-[40px] flex-none border-t border-[#d9d9d9] px-[2rem]",children:F.jsx(Uje,{})})]})})},dWe=t=>F.jsx(pK,{...t,children:F.jsx(fWe,{})});exports.EditorProvider=pK;exports.WhiteEditor=dWe;exports.useEditorContext=Ot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@white-give/editor-react",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "author": "white-give",
5
5
  "private": false,
6
6
  "type": "module",