1import{s as Y,E as k,P as F,D as P,e as _,t as $,M as B,m as I,v as R,N as U,w as K,n as G,x as V}from"./index-BeBi6N00.js";import{k as q}from"./katex-Dc8nsIP1.js";import{j as x,r as E}from"./index-59gKS5K7.js";var At=Y;const J=(t,e)=>t.doc.resolve(e).parent.type.name!=="codeBlock",Q="display: inline-block; height: 0; opacity: 0; overflow: hidden; position: absolute; width: 0;",Z=t=>{const{regex:e,katexOptions:r={},editor:n,shouldRender:a}=t;return new F({key:new _("mathematics"),state:{init:()=>P.empty,apply(o,p,f,m){const{selection:u}=m,g=[];return m.doc.descendants((y,b)=>{if(!y.isText||!y.text||!a(m,b,y))return;let w;for(;(w=e.exec(y.text))!==null;){const v=b+w.index,M=v+w[0].length,L=w.slice(1).find(Boolean);if(!L)continue;const s=u.$from.pos-u.$to.pos===0,d=u.$anchor.pos>=v&&u.$anchor.pos<=M,i=u.$from.pos>=v&&u.$to.pos<=M,S=(s&&d||i)&&n.isEditable;S||g.push($.widget(v,()=>{const l=document.createElement("span");l.classList.add("Tiptap-mathematics-render"),n.isEditable&&l.classList.add("Tiptap-mathematics-render--editable");try{q.render(L,l,r)}catch{l.innerHTML=L}return l})),g.push($.inline(v,M,S?{class:"Tiptap-mathematics-editor"}:{class:"Tiptap-mathematics-editor Tiptap-mathematics-editor--hidden",style:Q}))}}),g.length>0?P.create(m.doc,g):P.empty}},props:{decorations(o){return this.getState(o)}}})},Lt=k.create({name:"Mathematics",addOptions(){return{regex:/\$([^$]*)\$/gi,katexOptions:void 0,shouldRender:J}},addProseMirrorPlugins(){return[Z({...this.options,editor:this.editor})]}});var tt=20,X=(t,e=0)=>{const r=[];return!t.children.length||e>tt||Array.from(t.children).forEach(n=>{n.tagName==="SPAN"?r.push(n):n.children.length&&r.push(...X(n,e+1))}),r},et=t=>
vendor: 4,955 bytes, line 1
1{if(!t.children.length)return;const e=X(t);e&&e.forEach(r=>{var n,a;const o=r.getAttribute("style"),p=(a=(n=r.parentElement)==null?void 0:n.closest("span"))==null?void 0:a.getAttribute("style");r.setAttribute("style",`${p};${o}`)})},rt=B.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&et(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",I(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(r,n)=>{if(r.isTextblock)return!0;r.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(o=>!!o))||t.removeMark(n,n+r.nodeSize,this.type)}),!0}}}}),nt=k.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const r=(e=R(t,"background-color"))!=null?e:t.style.backgroundColor;return r==null?void 0:r.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),it=k.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const r=(e=R(t,"color"))!=null?e:t.style.color;return r==null?void 0:r.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),st=k.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=R(t,"font-family"))!=null?e:t.style.fontFamily},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),at=k.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=R(t,"font-size"))!=null?e:t.style.fontSize},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),ot=k.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=R(t,"line-height"))!=null?e:t.style.lineHeight},renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});k.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(nt.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(it.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(st.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(at.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(ot.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(rt.configure(this.options.textStyle)),t}});var lt=k.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(r=>e.updateAttributes(r,{textAlign:t})).some(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:r})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}}
1,addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),kt=lt,dt=Object.defineProperty,ut=Object.defineProperties,ct=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,D=(t,e,r)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,A=(t,e)=>{for(var r in e||(e={}))ht.call(e,r)&&D(t,r,e[r]);if(N)for(var r of N(e))pt.call(e,r)&&D(t,r,e[r]);return t},C=(t,e)=>ut(t,ct(e)),mt=(t,e,r)=>new Promise((n,a)=>{var o=m=>{try{f(r.next(m))}catch(u){a(u)}},p=m=>{try{f(r.throw(m))}catch(u){a(u)}},f=m=>m.done?n(m.value):Promise.resolve(m.value).then(o,p);f((r=r.apply(t,e)).next())}),gt=t=>{let{updateAttributes:e,node:{attrs:r},editor:n,extension:a}=t,{captionProps:o}=a.options,p=E.useRef(null);E.useEffect(()=>{var g;a.options.withCaption||r.caption===""&&((g=p.current)==null||g.focus())},[r.caption,a.options.withCaption]);let f=g=>{if(!p.current)return;let{innerText:y,innerHTML:b}=g.target,w=(y==null?void 0:y.replaceAll(` 2`,""))==="",v=b.replaceAll("<div>",` 3`).replaceAll("</div>","").replaceAll("<br>",""),M=w?"":v;p.current.innerHTML=M,e({caption:M})},m=g=>{g.preventDefault();let y=g.clipboardData.getData("text/plain"),b=window.getSelection();if(b&&y){let w=b.getRangeAt(0);b.deleteFromDocument(),w.insertNode(document.createTextNode(y)),w.setStart(w.endContainer,w.endOffset)}},u=g=>{if((g.ctrlKey||g.metaKey)&&g.key==="a"){g.preventDefault();let y=window.getSelection();if(y){let b=y.getRangeAt(0);b.selectNodeContents(g.currentTarget),y.addRange(b)}}};return x.jsx("span",C(A({},o),{ref:p,className:`caption ${(o==null?void 0:o.className)||""}`,contentEditable:n.isEditable,onBlur:f,onPaste:m,onKeyDown:u,dangerouslySetInnerHTML:{__html:r.caption||""}}))},W=gt;function z(t,e,r){return Math.min(Math.max(t,e),r)}var c={east:1,north:8,south:2,west:4};function ft({editor:t,imageRef:e,minWidth:r,maxWidth:n,minHeight:a,maxHeight:o,keepRatio:p,onResizeEnd:f,onResizeStart:m}){let u=E.useRef(null),g=E.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),y=t.view.dom,b=s=>{let d=s===c.east||s===c.west,i=s===c.north||s===c.south,T=s&c.north&&s&c.west||s&c.south&&s&c.east,S=d?"ew":i?"ns":T?"nwse":"nesw";y!==null&&y.style.setProperty("cursor",`${S}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${S}-resize`,"important"),document.body.style.setProperty("-webkit-user-select","none","important"))},w=()=>{y!==null&&y.style.removeProperty("cursor"),document.body!==null&&(document.body.style.removeProperty("cursor"),document.body.style.removeProperty("-webkit-user-select"))},v=(s,d)=>{if(!t.isEditable)return;let i=e.current,T=u.current;if(i!==null&&T!==null){s.preventDefault();let{width:S,height:l}=i.getBoundingClientRect(),h=g.current;h.startWidth=S,h.startHeight=l,h.ratio=S/l,h.currentWidth=S,h.currentHeight=l,h.startX=s.clientX,h.startY=s.clientY,h.isResizing=!0,h.direction=d,b(d),m==null||m(),T.classList.add("image-control-wrapper--resizing"),i.style.height=`${l}px`,i.style.width=`${S}px`,document.addEventListener("pointermove",M),document.addEventListener("pointerup",L)}},M=s=>{let d=e.current,i=g.current,T=i.direction&(c.east|c.west),S=i.direction&(c.south|c.north);if(!(d===null||!i.isResizing)){if(p){let l=0,h=0;if(T){let H=Math.floor(i.startX-s.clientX);H=i.direction&c.east?-H:H,l=z(i.startWidth+H,r,n),h=l/i.ratio}else{let H=Math.floor(i.startY-s.clientY);H=i.direction&c.south?-H:H,h=z(i.startHeight+H,a,o),l=h*i.ratio}if(l<r||l>n||h<a||h>o)return;d.style.width=`${l}px`,d.style.height=`${h}px`,d.style.maxWidth=`${l}px`,i.currentHeight=h,i.currentWidth=l;return}if(T&&S){let l=Math.floor(i.startX-s.clientX);l=i.direction&c.east?-l:l;let h=Math.floor(i.startY-s.clientY);h=i.direction&c.south?-h:h;let H=z(i.startWidth+l,r,n),j=z(i.startHeight+h,a,o);d.style.width=`${H}px`,d.style.height=`${j}px`,d.style.maxWidth=`${H}px`,i.currentHeight=j,i.currentWidth=H}else if(S){let l=Math.floor(i.startY-s.clientY);l=i.direction&c.south?-l:l;let h=z(i.startHeight+l,a,o);d.style.height=`${h}px`,i.currentHeight=h}else{let l=Math.floor(i.startX-s.clientX);l=i.direction&c.east?-l:l;let h=z(i.startWidth+l,r,n);d.style.width=`${h}px`,d.style.maxWidth=`${h}px`,i.currentWidth=h}}},L=()=>{let s=e.current,d=g.current,i=u.current;if(s!==null&&i!==null&&d.isResizing){let T=d.currentWidth,S=d.currentHeight;d.startWidth=0,d.startHeight=0,d.ratio=0,d.startX=0,d.startY=0,d.currentWidth=0,d.currentHeight=0,d.isResizing=!1,i.classList.remove("image-control-wrapper--resizing"),w(),f(T,S),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",L)}};return x.jsxs("div",{ref:u,children:[x.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:s=>{v(s,c.north)}}),x.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:s=>{v(s,c.north|c.east)}}),x.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:s=>{v(s,c.east)}}),x.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:s=>{v(s,c.south|c.east)}}),x.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:s=>{v(s,c.south)}}),x.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:s=>{v(s,c.south|c.west)}}),x.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:s=>{v(s,c.west)}}),x.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:s=>{v(s,c.north|c.west)}})]})}var yt=t=>{let{updateAttributes:e,node:r,extension:n,editor:a}=t,o=E.useRef(null),p=r.attrs,f=n.options,m=!a.isEditable,{width:u,height:g,caption:y}=p,b=p["data-keep-ratio"],w=f.withCaption||typeof y=="string",v=!b&&{width:u,height:g},M=C(A({},p),{style:C(A({},v||{}),{maxWidth:u})}),L=(d,i)=>{b&&o.current&&(o.current.style.width="",o.current.style.height=""),e({width:d,height:i})},s=d=>{var i;(i=f.onContextMenu)==null||i.call(f,d,t)};return m?x.jsxs(x.Fragment,{children:[x.jsx("img",A({},M)),w&&y&&x.jsx(W,A({},t))]}):x.jsxs(x.Fragment,{children:[x.jsx("img",C(A({},M),{ref:o,onContextMenu:s})),w&&x.jsx(W,A({},t)),x.jsx(ft,{editor:a,imageRef:o,minWidth:f.minWidth,maxWidth:f.maxWidth,minHeight:f.minHeight,maxHeight:f.maxHeight,keepRatio:b,onResizeEnd:L})]})},xt=yt,vt=t=>x.jsx(V,{className:"image-component","data-drag-handle":!0,children:x.jsx(xt,A({},t))}),bt=vt,wt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,St=t=>new Promise((e,r)=>{let n=new Image,a=URL.createObjectURL(t);n.onload=()=>{e({width:n.width,height:n.height}),URL.revokeObjectURL(a)},n.onerror=()=>{URL.revokeObjectURL(a),r(new Error("Failed to load image"))},n.src=a}),O=(t,e,r)=>mt(null,null,function*(){var n;if(!t["data-keep-ratio"])return Promise.resolve(t);let{width:a,height:o}=yield St(e),p=(n=t.width)!=null?n:r.defaultWidth,f=o/a;return C(A({},t),{width:p,height:p*f})}),zt=U.create({name:"image",group:"inline",inline:!0,draggable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},defaultHeight:500,defaultWidth:500,minWidth:100,maxWidth:16384,minHeight:100,maxHeight:1/0,allowBase64:!0}},addAttributes(){return{src:{default:""},alt:{default:""},title:{default:""},width:{default:this.options.defaultWidth},height:{default:this.options.defaultHeight},"data-keep-ratio":{parseHTML:t=>t.getAttribute("data-keep-ratio")!=="false",renderHTML(t){return t["data-keep-ratio"]?{style:[`max-width: ${t.width}px`].join(";"),"data-keep-ratio":"true"}:{}},default:!0},className:{parseHTML:t=>t.getAttribute("class"),renderHTML:t=>({class:t.className}),default:""},caption:{parseHTML:t=>{var e,r;return(r=(e=t.parentElement)==null?void 0:e.querySelector("span"))==null?void 0:r.textContent},renderHTML(){return null},default:void 0}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'},{tag:"span > img + span",ignore:!0}]}
3,renderHTML({HTMLAttributes:t,node:e}){var r,n;let a=document.createElement("span");a.classList.add("node-image");let o=document.createElement("span");o.classList.add("image-component");let p=document.createElement("img"),f=I(this.options.HTMLAttributes,t);Object.keys(f).forEach(u=>{u!=="caption"&&p.setAttribute(u,f[u])}),o.appendChild(p);let m=e.attrs;if(m.caption){let u=document.createElement("span");u.classList.add("caption",...((n=(r=this.options.captionProps)==null?void 0:r.className)==null?void 0:n.split(" "))||""),u.innerHTML=m.caption,o.appendChild(u)}return a.appendChild(o),a},addCommands(){return{setResizableImage:(t,e,r)=>({commands:n})=>n.insertContentAt(e||this.editor.state.selection.head,{type:this.name,attrs:t},r)}},addInputRules(){return[G({find:wt,type:this.type,getAttributes:t=>{let[,,e,r,n]=t;return{src:r,alt:e,title:n}}})]},addProseMirrorPlugins(){return[new F({key:new _(this.name),props:{handlePaste:(t,e,r)=>{var n,a,o;let p=(n=e.clipboardData)==null?void 0:n.files;if(((a=r.content.firstChild)==null?void 0:a.type.name)===this.name)return this.editor.commands.setResizableImage(A({},r.content.firstChild.attrs)),!0;let f=!((o=e.clipboardData)!=null&&o.getData("text/html"));if(!p||p.length===0||!this.options.onUpload||!f)return!1;let m=this.editor.state.selection.head;for(let u of p)this.options.onUpload(u).then(g=>O(g,u,this.options)).then(g=>{this.editor.chain().focus().setResizableImage(g,m,{updateSelection:!1}).run()});return!0},handleDrop:(t,e)=>{var r,n;e.preventDefault();let a=(r=e.dataTransfer)==null?void 0:r.files,o=!((n=e.dataTransfer)!=null&&n.getData("text/html"));if(!a||a.length===0||!this.options.onUpload||!o)return!1;let p=t.posAtCoords({left:e.clientX,top:e.clientY});for(let f of a)this.options.onUpload(f).then(m=>O(m,f,this.options)).then(m=>{this.editor.chain().focus().setResizableImage(m,p==null?void 0:p.pos,{updateSelection:!1}).run()})}}})]},addNodeView(){return K(t=>bt(t),{className:"node-image"})}});export{it as C,at as F,ot as L,Lt as M,rt as T,lt as a,kt as b,At as i,zt as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.