@sovann72-dev/lynqify-ui 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/components/RichTextEditor/Extension/Image/ImageResize/constants/index.d.ts +22 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/controllers/image-node-view.d.ts +38 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/controllers/position-controller.d.ts +12 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/controllers/resize-controller.d.ts +13 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/image-resize.d.ts +22 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/index.d.ts +4 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/types/index.d.ts +20 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/attribute-parser.d.ts +4 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/clamp-width.d.ts +6 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/index.d.ts +7 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/resize-handler.d.ts +12 -0
- package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/style-manager.d.ts +6 -0
- package/dist/index.d.ts +5 -1
- package/dist/lynqify-ui.js +1527 -985
- package/dist/lynqify-ui.umd.cjs +33 -10
- package/package.json +1 -1
package/dist/lynqify-ui.umd.cjs
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
(function(h,Y){typeof exports=="object"&&typeof module<"u"?Y(exports,require("@tiptap/extension-bold"),require("@tiptap/extension-color"),require("@tiptap/extension-document"),require("@tiptap/extension-file-handler"),require("@tiptap/extension-hard-break"),require("@tiptap/extension-heading"),require("@tiptap/extension-highlight"),require("@tiptap/extension-image"),require("@tiptap/extension-italic"),require("@tiptap/extension-link"),require("@tiptap/extension-list"),require("@tiptap/extension-mention"),require("@tiptap/extension-paragraph"),require("@tiptap/extension-table"),require("@tiptap/extension-text"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/extensions"),require("@tiptap/react"),require("@tiptap/core"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","@tiptap/extension-bold","@tiptap/extension-color","@tiptap/extension-document","@tiptap/extension-file-handler","@tiptap/extension-hard-break","@tiptap/extension-heading","@tiptap/extension-highlight","@tiptap/extension-image","@tiptap/extension-italic","@tiptap/extension-link","@tiptap/extension-list","@tiptap/extension-mention","@tiptap/extension-paragraph","@tiptap/extension-table","@tiptap/extension-text","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/extensions","@tiptap/react","@tiptap/core","react","react-dom"],Y):(h=typeof globalThis<"u"?globalThis:h||self,Y(h.LynqifyUI={},h.Bold,h.Color,h.Document,h.FileHandler,h.HardBreak,h.Heading,h.Highlight,h.Image,h.Italic,h.Link,h.extensionList,h.Mention,h.Paragraph,h.extensionTable,h.Text,h.TextAlign,h.extensionTextStyle,h.Underline,h.extensions,h.TipTapReact,h.TipTapCore,h.React,h.ReactDOM))})(this,(function(h,Y,Ne,Ae,at,Ce,lt,ut,ct,Le,dt,P,ft,Me,W,Pe,De,ze,_e,K,hr,te,Je,pr){"use strict";function mr(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const Fe=mr(Je),ht=Me.extend({addNodeView(){return({node:n})=>{const e=n.attrs.indent||0,t=document.createElement("p");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}},addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0"),renderHTML:e=>e.indent?{"data-indent":e.indent,style:`--indent-level: ${e.indent};`}:{}}}}});function pt(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let l=0;i.text[l]==s.text[l];l++)t++;return t}if(i.content.size||s.content.size){let l=pt(i.content,s.content,t+1);if(l!=null)return l}t+=i.nodeSize}}function mt(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let l=n.child(--i),a=e.child(--s),u=l.nodeSize;if(l==a){t-=u,r-=u;continue}if(!l.sameMarkup(a))return{a:t,b:r};if(l.isText&&l.text!=a.text){let f=0,d=Math.min(l.text.length,a.text.length);for(;f<d&&l.text[l.text.length-f-1]==a.text[a.text.length-f-1];)f++,t--,r--;return{a:t,b:r}}if(l.content.size||a.content.size){let f=mt(l.content,a.content,t-1,r-1);if(f)return f}t-=u,r-=u}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let l=0,a=0;a<t;l++){let u=this.content[l],f=a+u.nodeSize;if(f>e&&r(u,i+a,s||null,l)!==!1&&u.content.size){let d=a+1;u.nodesBetween(Math.max(0,e-d),Math.min(u.content.size,t-d),r,i+d)}a=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",l=!0;return this.nodesBetween(e,t,(a,u)=>{let f=a.isText?a.text.slice(Math.max(e,u)-u,t-u):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&f||a.isTextblock)&&r&&(l?l=!1:s+=r),s+=f},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new k(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,l=0;l<t;s++){let a=this.content[s],u=l+a.nodeSize;u>e&&((l<e||u>t)&&(a.isText?a=a.cut(Math.max(0,e-l),Math.min(a.text.length,t-l)):a=a.cut(Math.max(0,e-l-1),Math.min(a.content.size,t-l-1))),r.push(a),i+=a.nodeSize),l=u}return new k(r,i)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new k(i,s)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return pt(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return mt(this,e,t,r)}findIndex(e){if(e==0)return ve(0,e);if(e==this.size)return ve(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?ve(t+1,s):ve(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new k(t||e,r)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const He={index:0,offset:0};function ve(n,e){return He.index=n,He.offset=e,He}class gr extends Error{}class E{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=yt(this.content,e+this.openStart,t);return r&&new E(r,this.openStart,this.openEnd)}removeBetween(e,t){return new E(gt(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return E.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new E(k.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new E(e,r,i)}}E.empty=new E(k.empty,0,0);function gt(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:l,offset:a}=n.findIndex(t);if(i==e||s.isText){if(a!=t&&!n.child(l).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=l)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(gt(s.content,e-i-1,t-i-1)))}function yt(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),l=n.maybeChild(i);if(s==e||l.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=yt(l.content,e-s-1,t,l);return a&&n.replaceChild(i,l.copy(a))}class vt{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const It=65535,bt=Math.pow(2,16);function yr(n,e){return n+e*bt}function St(n){return n&It}function vr(n){return(n-(n&It))/bt}const wt=1,Tt=2,Ie=4,xt=8;class Et{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&xt)>0}get deletedBefore(){return(this.delInfo&(wt|Ie))>0}get deletedAfter(){return(this.delInfo&(Tt|Ie))>0}get deletedAcross(){return(this.delInfo&Ie)>0}}class B{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&B.empty)return B.empty}recover(e){let t=0,r=St(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+vr(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let u=this.ranges[a]-(this.inverted?i:0);if(u>e)break;let f=this.ranges[a+s],d=this.ranges[a+l],m=u+f;if(e<=m){let v=f?e==u?-1:e==m?1:t:t,S=u+i+(v<0?0:d);if(r)return S;let g=e==(t<0?u:m)?null:yr(a/3,e-u),T=e==u?Tt:e==m?wt:Ie;return(t<0?e!=u:e!=m)&&(T|=xt),new Et(S,T,g)}i+=d-f}return r?e+i:new Et(e+i,0,null)}touches(e,t){let r=0,i=St(t),s=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let u=this.ranges[a]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[a+s],d=u+f;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+l]-f}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let l=this.ranges[i],a=l-(this.inverted?s:0),u=l+(this.inverted?0:s),f=this.ranges[i+t],d=this.ranges[i+r];e(a,a+f,u,u+d),s+=d-f}}invert(){return new B(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?B.empty:new B(e<0?[0,-e,0]:[0,0,e])}}B.empty=new B([]);const Be=Object.create(null);class D{getMap(){return B.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Be[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Be)throw new RangeError("Duplicate use of step JSON ID "+e);return Be[e]=t,t.prototype.jsonID=e,t}}class N{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new N(e,null)}static fail(e){return new N(null,e)}static fromReplace(e,t,r,i){try{return N.ok(e.replace(t,r,i))}catch(s){if(s instanceof gr)return N.fail(s.message);throw s}}}function je(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(je(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return k.fromArray(r)}class G extends D{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new E(je(t.content,(l,a)=>!l.isAtom||!a.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,s)}invert(){return new X(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new G(t.pos,r.pos,this.mark)}merge(e){return e instanceof G&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new G(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new G(t.from,t.to,e.markFromJSON(t.mark))}}D.jsonID("addMark",G);class X extends D{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new E(je(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,r)}invert(){return new G(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new X(t.pos,r.pos,this.mark)}merge(e){return e instanceof X&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new X(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new X(t.from,t.to,e.markFromJSON(t.mark))}}D.jsonID("removeMark",X);class Z extends D{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new E(k.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Z(this.pos,t.marks[i]);return new Z(this.pos,this.mark)}}return new ae(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Z(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Z(t.pos,e.markFromJSON(t.mark))}}D.jsonID("addNodeMark",Z);class ae extends D{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new E(k.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Z(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ae(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ae(t.pos,e.markFromJSON(t.mark))}}D.jsonID("removeNodeMark",ae);class q extends D{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&qe(e,this.from,this.to)?N.fail("Structure replace would overwrite content"):N.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new B([this.from,this.to-this.from,this.slice.size])}invert(e){return new q(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&q.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new q(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof q)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new q(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new q(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new q(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}q.MAP_BIAS=1,D.jsonID("replace",q);class re extends D{constructor(e,t,r,i,s,l,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=l,this.structure=a}apply(e){if(this.structure&&(qe(e,this.from,this.gapFrom)||qe(e,this.gapTo,this.to)))return N.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return N.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?N.fromReplace(e,this.from,this.to,r):N.fail("Content does not fit in gap")}getMap(){return new B([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new re(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new re(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new re(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}D.jsonID("replaceAround",re);function qe(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let l=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function Ir(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function kt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let l=n.$from.node(r),a=n.$from.index(r)+i,u=n.$to.indexAfter(r)-s;if(r<n.depth&&l.canReplace(a,u,t))return r;if(r==0||l.type.spec.isolating||!Ir(l,a,u))break;a&&(i=1),u<l.childCount&&(s=1)}return null}class le extends D{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return N.fromReplace(e,this.pos,this.pos+1,new E(k.from(i),0,t.isLeaf?0:1))}getMap(){return B.empty}invert(e){return new le(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new le(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new le(t.pos,t.attr,t.value)}}D.jsonID("attr",le);class be extends D{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return N.ok(r)}getMap(){return B.empty}invert(e){return new be(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new be(t.attr,t.value)}}D.jsonID("docAttr",be);let ue=class extends Error{};ue=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},ue.prototype=Object.create(Error.prototype),ue.prototype.constructor=ue,ue.prototype.name="TransformError";const $e=Object.create(null);class L{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new br(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=E.empty){let r=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=r,r=r.lastChild;let s=e.steps.length,l=this.ranges;for(let a=0;a<l.length;a++){let{$from:u,$to:f}=l[a],d=e.mapping.slice(s);e.replaceRange(d.map(u.pos),d.map(f.pos),a?E.empty:t),a==0&&Nt(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],u=e.mapping.slice(r),f=u.map(l.pos),d=u.map(a.pos);s?e.deleteRange(f,d):(e.replaceRangeWith(f,d,t),Nt(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new z(e):ne(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let l=t<0?ne(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):ne(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new V(e.node(0))}static atStart(e){return ne(e,e,0,0,1)||new V(e)}static atEnd(e){return ne(e,e,e.content.size,e.childCount,-1)||new V(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$e[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in $e)throw new RangeError("Duplicate use of selection JSON ID "+e);return $e[e]=t,t.prototype.jsonID=e,t}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}}L.prototype.visible=!0;class br{constructor(e,t){this.$from=e,this.$to=t}}let Rt=!1;function Ot(n){!Rt&&!n.parent.inlineContent&&(Rt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class z extends L{constructor(e,t=e){Ot(e),Ot(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return L.near(r);let i=e.resolve(t.map(this.anchor));return new z(i.parent.inlineContent?i:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Se(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new z(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=L.findFrom(t,r,!0)||L.findFrom(t,-r,!0);if(s)t=s.$head;else return L.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(L.findFrom(e,-r,!0)||L.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new z(e,t)}}L.jsonID("text",z);class Se{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Se(e.map(this.anchor),e.map(this.head))}resolve(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))}}class _ extends L{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?L.near(s):new _(s)}content(){return new E(k.from(this.node),0,0)}eq(e){return e instanceof _&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ve(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new _(e.resolve(t.anchor))}static create(e,t){return new _(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}_.prototype.visible=!1,L.jsonID("node",_);class Ve{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Se(r,r):new Ve(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&_.isSelectable(r)?new _(t):L.near(t)}}class V extends L{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let r=L.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new V(e)}map(e){return new V(e)}eq(e){return e instanceof V}getBookmark(){return Sr}}L.jsonID("all",V);const Sr={map(){return this},resolve(n){return new V(n)}};function ne(n,e,t,r,i,s=!1){if(e.inlineContent)return z.create(n,t);for(let l=r-(i>0?0:1);i>0?l<e.childCount:l>=0;l+=i){let a=e.child(l);if(a.isAtom){if(!s&&_.isSelectable(a))return _.create(n,t-(i<0?a.nodeSize:0))}else{let u=ne(n,a,t+i,i<0?a.childCount:0,i,s);if(u)return u}t+=a.nodeSize*i}return null}function Nt(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof q||i instanceof re))return;let s=n.mapping.maps[r],l;s.forEach((a,u,f,d)=>{l==null&&(l=d)}),n.setSelection(L.near(n.doc.resolve(l),t))}function At(n,e){return!e||!n?n:n.bind(e)}class we{constructor(e,t,r){this.name=e,this.init=At(t.init,r),this.apply=At(t.apply,r)}}new we("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new we("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new we("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new we("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Ct(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Ct(i,e,{})),t[r]=i}return t}class ce{constructor(e){this.spec=e,this.props={},e.props&&Ct(e.props,this,this.props),this.key=e.key?e.key.key:Lt("plugin")}getState(e){return e[this.key]}}const We=Object.create(null);function Lt(n){return n in We?n+"$"+ ++We[n]:(We[n]=0,n+"$")}class wr{constructor(e="key"){this.key=Lt(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const $=n=>n==="bulletList"||n==="orderedList",Te=n=>n==="listItem",J=n=>n==="paragraph"||n==="heading";function Ue(n,e){for(const t of n)if(t(e))return!0;return!1}function Tr(n,e){for(const t of n)if(t(e))return!0;return!1}const Mt=({state:n,view:e,$from:t,$to:r,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(n.doc.nodesBetween(t.pos,r.pos,m=>{(Te(m.type.name)||J(m.type.name))&&s++}),!(s>1))return!1;const{tr:a,doc:u}=n;let f=!1;const d=new Set;return u.nodesBetween(t.pos,r.pos,(m,v)=>{if($(m.type.name)&&(m.attrs.indent??0)>0){if(!d.has(v)){d.add(v);const S=m.attrs.indent??0;a.setNodeAttribute(v,"indent",Math.max(0,S-1)),f=!0;const g=n.doc.resolve(v),T=n.doc.resolve(v+m.nodeSize),M=new vt(g,T,g.depth),C=kt(M);C!=null&&(a.lift(M,C),f=!0)}return!1}if(J(m.type.name)&&(m.attrs.indent??0)>0){const S=m.attrs.indent??0;a.setNodeAttribute(v,"indent",Math.max(0,S-1)),f=!0}return!0}),f?(a.setMeta("addToHistory",!0),e.dispatch(a),!0):!1},xr=({editor:n,$from:e,currentNode:t})=>{const r=e.pos===e.start(),i=t.attrs.indent>0;return J(t.type.name)&&i&&r?n.commands.outdent():!1},Er=({state:n,view:e,$from:t,currentNode:r})=>{const i=r.content.size===0,s=r.attrs.indent>0;if(!(J(r.type.name)&&s&&i))return!1;const a=t.before(t.depth),u=n.tr;return u.delete(a,a+r.nodeSize),e.dispatch(u),!0},kr=({state:n,view:e,$from:t,currentNode:r})=>{const i=t.pos===t.start(),s=r.content.size===0,l=r.attrs.indent>0,a=t.before(t.depth),u=n.doc.resolve(a).nodeBefore,f=u!=null&&$(u.type.name);if(J(r.type.name)&&!l&&s&&i&&f){const m=n.tr;return m.delete(a,a+r.nodeSize),e.dispatch(m),!0}return!1},Rr=n=>{const{tr:e,state:t,dispatch:r}=n,{selection:i}=t,{$from:s,$to:l}=i;if(i.empty)return!1;let a=0;if(t.doc.nodesBetween(s.pos,l.pos,d=>{($(d.type.name)||J(d.type.name))&&a++}),a<=1)return!1;const u=new Set;let f=!1;return t.doc.nodesBetween(s.pos,l.pos,(d,m)=>{var S;return!($(d.type.name)||J(d.type.name))||u.has(m)?!0:(u.add(m),e.setNodeAttribute(m,"indent",(((S=d.attrs)==null?void 0:S.indent)??0)+1),f=!0,!1)}),f?(e.setMeta("addToHistory",!0),r==null||r(e),!0):!1},Or=n=>{var f;const{tr:e,state:t,dispatch:r}=n,{selection:i}=t,{$from:s}=i;let l=null,a=null;for(let d=s.depth;d>0;d--){const m=s.node(d);if($(m.type.name)){l={...m,pos:s.before(d)},a={...s.node(d+1),pos:s.before(d+1)};break}}if(!l||!a)return!1;if(((f=l.content)==null?void 0:f.childCount)===1&&i instanceof z){const d=l.attrs.indent??0;return e.setNodeAttribute(l.pos,"indent",d+1),e.setMeta("addToHistory",!1),r==null||r(e),!0}return n.chain().focus().sinkListItem("listItem").updateAttributes("bulletList",{indent:1}).updateAttributes("orderedList",{indent:1}).run(),!0},Nr=n=>{const{tr:e,state:t,dispatch:r}=n,{selection:i}=t,{$from:s}=i,l=s.node();if(!(J(l.type.name)&&i instanceof z))return!1;const u=l.attrs.indent??0;return e.setNodeAttribute(s.before(s.depth),"indent",u+1),e.setMeta("addToHistory",!1),r==null||r(e),!0},Ar=({state:n,view:e,$from:t,$to:r,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(n.doc.nodesBetween(t.pos,r.pos,m=>{(Te(m.type.name)||J(m.type.name))&&s++}),!(s>1))return!1;const{tr:a,doc:u}=n;let f=!1;const d=new Set;return u.nodesBetween(t.pos,r.pos,(m,v)=>{if($(m.type.name)&&(m.attrs.indent??0)>0){if(!d.has(v)){d.add(v);const S=m.attrs.indent??0;a.setNodeAttribute(v,"indent",Math.max(0,S-1)),f=!0;const g=n.doc.resolve(v),T=n.doc.resolve(v+m.nodeSize),M=new vt(g,T,g.depth),C=kt(M);C!=null&&(a.lift(M,C),f=!0)}return!1}if(J(m.type.name)&&(m.attrs.indent??0)>0){const S=m.attrs.indent??0;a.setNodeAttribute(v,"indent",Math.max(0,S-1)),f=!0}return!0}),f?(a.setMeta("addToHistory",!0),e.dispatch(a),!0):!1},Cr=({$from:n,selectionIsEmpty:e})=>{var l;if(!e)return!1;let t=!1,r=!1,i=0;for(let a=n.depth;a>0;a--){const u=n.node(a);if($(u.type.name))if(!t)t=!0,i=((l=u.attrs)==null?void 0:l.indent)??0;else{r=!0;break}}return t&&!r?i===0:!1},Lr=({state:n,view:e,$from:t,currentNode:r,selectionIsEmpty:i})=>{if(!i||!(r.type.name==="paragraph"&&r.content.size===0))return!1;const l=t.before(t.depth),a=n.doc.resolve(l).nodeBefore;if(!(a!=null&&$(a.type.name)))return!1;const f=n.doc.resolve(l-1),d=n.tr.setSelection(z.near(f,-1));return e.dispatch(d),!0},Mr=({state:n,view:e,$from:t,$to:r,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(n.doc.nodesBetween(t.pos,r.pos,m=>{(Te(m.type.name)||J(m.type.name))&&s++}),!(s>1))return!1;const{tr:a,doc:u}=n;let f=!1;const d=new Set;return u.nodesBetween(t.pos,r.pos,(m,v)=>{if(($(m.type.name)||J(m.type.name))&&!d.has(v)){d.add(v);const g=m.attrs.indent??0;return a.setNodeAttribute(v,"indent",g+1),f=!0,!1}return!0}),f?(a.setMeta("addToHistory",!0),e.dispatch(a),!0):!1},Pr=({state:n,view:e,$from:t,selectionIsEmpty:r})=>r||t.path.some(s=>{var l;return((l=s==null?void 0:s.type)==null?void 0:l.name)==="listItem"})?!1:(e.dispatch(n.tr.insertText(" ")),!0),Dr=({editor:n,currentNode:e,$from:t})=>{const r=e.content.size===0,i=t.node(t.depth-1);return i&&Te(i.type.name)&&!r?(n.chain().focus().indent().focus().run(),!0):!1},zr=({state:n,view:e,$from:t,currentNode:r})=>{const i=t.pos===t.start(),s=r.content.size===0;return!i&&!s?(e.dispatch(n.tr.insertText(" ")),!0):!1};function Ye(n){const{state:e,view:t}=n,{$from:r,$to:i,empty:s}=e.selection;return{editor:n,state:e,view:t,$from:r,$to:i,selectionIsEmpty:s,currentNode:r.node()}}const Pt=hr.Extension.create({name:"indent",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands._handleEnterKeyDown(),Tab:()=>{const n=Ye(this.editor);return Ue([Mr,Pr,Dr,zr],n)||this.editor.commands.indent()},Backspace:()=>{const n=Ye(this.editor);return Ue([xr,Er,kr],n)},"Shift-Tab":()=>{const n=Ye(this.editor);return Ue([Ar,Lr,Cr],n)||this.editor.chain().outdentShiftTab().run()},Space:()=>this.editor.commands._handleSpaceKeyDown()}},addProseMirrorPlugins(){return[new ce({appendTransaction:(n,e,t)=>{if(!n.some(s=>s.docChanged))return null;let i=null;return t.doc.descendants((s,l)=>{var v;if(!(J(s.type.name)&&(((v=s==null?void 0:s.attrs)==null?void 0:v.indent)??0)>0))return;const u=t.doc.resolve(l);if(!(u.parent.type.name==="listItem"))return;let d=null;for(let S=u.depth-1;S>0;S--)if($(u.node(S).type.name)){d=u.start(S)-1;break}if(d===null||d<0)return;i||(i=t.tr);const m=s.attrs.indent;i.setNodeAttribute(l,"indent",0),i.setNodeAttribute(d,"indent",m)}),i}})]},addGlobalAttributes(){return[{types:this.options.types??["orderedList","bulletList","paragraph","heading"],attributes:{indent:{default:1,parseHTML:n=>parseInt(n.getAttribute("data-indent")||"1",10),renderHTML:n=>n!=null&&n.indent?{style:`padding-left: ${n.indent*20}px`}:{}}}}]},addCommands(){return{_handleEnterKeyDown:()=>n=>{var u;const{tr:e,state:t,dispatch:r}=n,{$from:i}=t.selection,s=i.node();if(!(((u=s==null?void 0:s.type)==null?void 0:u.name)==="paragraph"&&s.attrs.indent))return!1;const a=s.attrs.indent;return e.split(i.pos),e.setNodeAttribute(e.selection.$from.before(),"indent",a),e.scrollIntoView(),e.setMeta("addToHistory",!1),r==null||r(e),!0},_handleSpaceKeyDown:()=>()=>!1,indent:()=>n=>Tr([Rr,Or,Nr],n),outdent:()=>n=>{const{state:e,view:t,tr:r,dispatch:i}=n,{$from:s,$to:l,empty:a}=e.selection,u={editor:n.editor,state:e,view:t,$from:s,$to:l,selectionIsEmpty:a,currentNode:s.node()};if(Mt(u))return!0;const f=s.node();if(!(J(f.type.name)&&f.attrs.indent>0)||!(s.pos===s.start()))return!1;const v=Math.max(0,f.attrs.indent-1);return r.setNodeAttribute(s.before(s.depth),"indent",v),r.setMeta("addToHistory",!1),i==null||i(r),!0},outdentShiftTab:()=>n=>{const{state:e,tr:t,dispatch:r}=n,{$from:i}=e.selection,s=i.node();if(!(J(s.type.name)&&s.attrs.indent>0))return!1;const a=Math.max(0,s.attrs.indent-1);return t.setNodeAttribute(i.before(i.depth),"indent",a),t.setMeta("addToHistory",!1),r==null||r(t),!0},increaseIndent:()=>({commands:n})=>n.indent(),decreaseIndent:()=>n=>{const{state:e,view:t}=n,{$from:r,$to:i,empty:s}=e.selection,l={editor:n.editor,state:e,view:t,$from:r,$to:i,selectionIsEmpty:s,currentNode:r.node()};return Mt(l)?!0:n.chain().outdentShiftTab().run()}}}});var _r=P.BulletList,Jr=P.ListItem,Fr=P.OrderedList;const Dt=_r.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}},addNodeView(){return({node:n})=>{const e=n.attrs.indent||0,t=document.createElement("ul");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}}}),zt=Fr.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}},addNodeView(){return({node:n})=>{const e=n.attrs.indent||0,t=document.createElement("ol");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}}}),Ke=Jr.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),class:{default:null,parseHTML:e=>e.getAttribute("class"),renderHTML:e=>e.class?{class:e.class,...e}:{}},indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}}}),Ge=te.Extension.create({name:"dynamicBulletStyling",addProseMirrorPlugins(){return[new ce({key:new wr("dynamicBulletStyling"),appendTransaction:(n,e,t)=>{const r=t.tr;let i=!1;return t.doc.descendants((s,l)=>{if(s.type.name==="listItem"){let a=0;const u=t.doc.resolve(l);for(let f=u.depth;f>0;f--)if(u.node(f).type.name==="bulletList"){a=1;break}a>0&&(r.setNodeAttribute(u.pos,"[data-style]","line-height: inherit"),i=!0)}}),i?r:null}})]}}),Hr=n=>n==="bulletList"||n==="orderedList",Br=n=>n==="paragraph"||n==="heading",_t=te.Extension.create({name:"listIndentIntegration",addProseMirrorPlugins(){return[new ce({appendTransaction:(n,e,t)=>{if(!n.find(i=>i.docChanged))return null;let r=null;return t.doc.descendants((i,s)=>{var l;if(Br(i.type.name)&&(((l=i==null?void 0:i.attrs)==null?void 0:l.indent)??0)>0){const a=t.doc.resolve(s);if(a.parent.type.name==="listItem"){let f=null;for(let d=a.depth-1;d>0;d--){const m=a.node(d);if(Hr(m.type.name)){f=a.start(d)-1;break}}if(f!==null&&f>=0){r||(r=t.tr);const d=i.attrs.indent;r.setNodeAttribute(s,"indent",0),r.setNodeAttribute(f,"indent",d)}}}}),r}}),new ce({props:{transformPastedHTML(n){const e=/<p[^>]*style="[^"]*(?:padding|margin)-left:\s*(\d+)(?:px|pt|em)[^"]*"[^>]*>/gi;n=n.replace(e,(i,s)=>`<p data-indent="${Math.floor(parseInt(s,10)/40)}">`);const t=/<ol[^>]*style="[^"]*list-style-type:\s*(upper-roman|lower-roman|upper-alpha|lower-alpha)[^"]*"[^>]*>/gi;n=n.replace(t,()=>"<ol>");const r=/<li[^>]*style="[^"]*list-style-type:\s*[^;"\s]+[^"]*"[^>]*>/gi;return n=n.replace(r,i=>i.replace(/list-style-type:\s*[^;"\s]+;?/gi,"")),n}}})]}}),Xe=te.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"],getStyle:n=>`font-size: ${n}`}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize.replace(/['"]+/g,""),renderHTML:n=>n.fontSize?{style:this.options.getStyle(n.fontSize)}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Ze=te.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"],getStyle:n=>`line-height: ${n};`}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight.replace(/['"]+/g,""),renderHTML:n=>n.lineHeight?{style:this.options.getStyle(n.lineHeight)}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),jr=[Y,K.CharacterCount,Ne,Ae,at,lt,ut,ct,dt,P.ListItem,P.ListKeymap,ft,P.OrderedList,K.Placeholder,W.Table,W.TableCell,W.TableHeader,W.TableRow,P.TaskItem,P.TaskList,De,ze.TextStyle,_e,Me,Pe,Le,Ce,K.UndoRedo,Ke,Xe,Ze,P.BulletList,Ge],qr=[ht,ze.TextStyle,Ne,K.UndoRedo.configure({newGroupDelay:500,depth:100}),Ce,_e,Y,Le,P.TaskItem,Ke,Ae,Pe,Xe,Ze,Dt,Ge,_t,De.configure({types:["heading","paragraph"]}),zt.configure({itemTypeName:"listItem",keepMarks:!0,keepAttributes:!0}),Pt],$r=te.Extension.create({name:"MentionStorage",addStorage(){return{suggestions:[]}}});var ie={},Jt;function Vr(){if(Jt)return ie;Jt=1;var n=pr;if(process.env.NODE_ENV==="production")ie.createRoot=n.createRoot,ie.hydrateRoot=n.hydrateRoot;else{var e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;ie.createRoot=function(t,r){e.usingClientEntryPoint=!0;try{return n.createRoot(t,r)}finally{e.usingClientEntryPoint=!1}},ie.hydrateRoot=function(t,r,i){e.usingClientEntryPoint=!0;try{return n.hydrateRoot(t,r,i)}finally{e.usingClientEntryPoint=!1}}}return ie}var Wr=Vr(),xe={exports:{}},de={};/**
|
|
1
|
+
(function(h,$){typeof exports=="object"&&typeof module<"u"?$(exports,require("@tiptap/extension-bold"),require("@tiptap/extension-color"),require("@tiptap/extension-document"),require("@tiptap/extension-file-handler"),require("@tiptap/extension-hard-break"),require("@tiptap/extension-heading"),require("@tiptap/extension-highlight"),require("@tiptap/extension-image"),require("@tiptap/extension-italic"),require("@tiptap/extension-link"),require("@tiptap/extension-list"),require("@tiptap/extension-mention"),require("@tiptap/extension-paragraph"),require("@tiptap/extension-table"),require("@tiptap/extension-text"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/extensions"),require("@tiptap/core"),require("@tiptap/react"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","@tiptap/extension-bold","@tiptap/extension-color","@tiptap/extension-document","@tiptap/extension-file-handler","@tiptap/extension-hard-break","@tiptap/extension-heading","@tiptap/extension-highlight","@tiptap/extension-image","@tiptap/extension-italic","@tiptap/extension-link","@tiptap/extension-list","@tiptap/extension-mention","@tiptap/extension-paragraph","@tiptap/extension-table","@tiptap/extension-text","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/extensions","@tiptap/core","@tiptap/react","react","react-dom"],$):(h=typeof globalThis<"u"?globalThis:h||self,$(h.LynqifyUI={},h.Bold,h.Color,h.Document,h.FileHandler,h.HardBreak,h.Heading,h.Highlight,h.Image,h.Italic,h.Link,h.extensionList,h.Mention,h.Paragraph,h.extensionTable,h.Text,h.TextAlign,h.extensionTextStyle,h.Underline,h.extensions,h.TipTapCore,h.TipTapReact,h.React,h.ReactDOM))})(this,(function(h,$,X,Pe,gt,De,yt,vt,wt,_e,St,D,It,Be,Y,$e,Fe,Je,We,Z,se,Ee,He,xn){"use strict";var Kr=Object.defineProperty;var Xr=(h,$,X)=>$ in h?Kr(h,$,{enumerable:!0,configurable:!0,writable:!0,value:X}):h[$]=X;var R=(h,$,X)=>Xr(h,typeof $!="symbol"?$+"":$,X);function Tn(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const je=Tn(He);function bt(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let l=0;i.text[l]==s.text[l];l++)t++;return t}if(i.content.size||s.content.size){let l=bt(i.content,s.content,t+1);if(l!=null)return l}t+=i.nodeSize}}function Et(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let l=r.child(--i),a=e.child(--s),c=l.nodeSize;if(l==a){t-=c,n-=c;continue}if(!l.sameMarkup(a))return{a:t,b:n};if(l.isText&&l.text!=a.text){let f=0,u=Math.min(l.text.length,a.text.length);for(;f<u&&l.text[l.text.length-f-1]==a.text[a.text.length-f-1];)f++,t--,n--;return{a:t,b:n}}if(l.content.size||a.content.size){let f=Et(l.content,a.content,t-1,n-1);if(f)return f}t-=c,n-=c}}class O{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let l=0,a=0;a<t;l++){let c=this.content[l],f=a+c.nodeSize;if(f>e&&n(c,i+a,s||null,l)!==!1&&c.content.size){let u=a+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),n,i+u)}a=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",l=!0;return this.nodesBetween(e,t,(a,c)=>{let f=a.isText?a.text.slice(Math.max(e,c)-c,t-c):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&f||a.isTextblock)&&n&&(l?l=!1:s+=n),s+=f},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new O(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;c>e&&((l<e||c>t)&&(a.isText?a=a.cut(Math.max(0,e-l),Math.min(a.text.length,t-l)):a=a.cut(Math.max(0,e-l-1),Math.min(a.content.size,t-l-1))),n.push(a),i+=a.nodeSize),l=c}return new O(n,i)}cutByIndex(e,t){return e==t?O.empty:e==0&&t==this.content.length?this:new O(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new O(i,s)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return bt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Et(this,e,t,n)}findIndex(e){if(e==0)return xe(0,e);if(e==this.size)return xe(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?xe(t+1,s):xe(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return O.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new O(t||e,n)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const qe={index:0,offset:0};function xe(r,e){return qe.index=r,qe.offset=e,qe}class Rn extends Error{}class T{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Tt(this.content,e+this.openStart,t);return n&&new T(n,this.openStart,this.openEnd)}removeBetween(e,t){return new T(xt(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return T.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new T(O.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new T(e,n,i)}}T.empty=new T(O.empty,0,0);function xt(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:l,offset:a}=r.findIndex(t);if(i==e||s.isText){if(a!=t&&!r.child(l).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=l)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(xt(s.content,e-i-1,t-i-1)))}function Tt(r,e,t,n){let{index:i,offset:s}=r.findIndex(e),l=r.maybeChild(i);if(s==e||l.isText)return n&&!n.canReplace(i,i,t)?null:r.cut(0,e).append(t).append(r.cut(e));let a=Tt(l.content,e-s-1,t,l);return a&&r.replaceChild(i,l.copy(a))}class Rt{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ot=65535,Ct=Math.pow(2,16);function On(r,e){return r+e*Ct}function kt(r){return r&Ot}function Cn(r){return(r-(r&Ot))/Ct}const Nt=1,Lt=2,Te=4,At=8;class zt{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&At)>0}get deletedBefore(){return(this.delInfo&(Nt|Te))>0}get deletedAfter(){return(this.delInfo&(Lt|Te))>0}get deletedAcross(){return(this.delInfo&Te)>0}}class j{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&j.empty)return j.empty}recover(e){let t=0,n=kt(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Cn(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?i:0);if(c>e)break;let f=this.ranges[a+s],u=this.ranges[a+l],p=c+f;if(e<=p){let y=f?e==c?-1:e==p?1:t:t,w=c+i+(y<0?0:u);if(n)return w;let g=e==(t<0?c:p)?null:On(a/3,e-c),b=e==c?Lt:e==p?Nt:Te;return(t<0?e!=c:e!=p)&&(b|=At),new zt(w,b,g)}i+=u-f}return n?e+i:new zt(e+i,0,null)}touches(e,t){let n=0,i=kt(t),s=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?n:0);if(c>e)break;let f=this.ranges[a+s],u=c+f;if(e<=u&&a==i*3)return!0;n+=this.ranges[a+l]-f}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let l=this.ranges[i],a=l-(this.inverted?s:0),c=l+(this.inverted?0:s),f=this.ranges[i+t],u=this.ranges[i+n];e(a,a+f,c,c+u),s+=u-f}}invert(){return new j(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?j.empty:new j(e<0?[0,-e,0]:[0,0,e])}}j.empty=new j([]);const Ve=Object.create(null);class _{getMap(){return j.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Ve[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ve)throw new RangeError("Duplicate use of step JSON ID "+e);return Ve[e]=t,t.prototype.jsonID=e,t}}class N{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new N(e,null)}static fail(e){return new N(null,e)}static fromReplace(e,t,n,i){try{return N.ok(e.replace(t,n,i))}catch(s){if(s instanceof Rn)return N.fail(s.message);throw s}}}function Ue(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(Ue(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return O.fromArray(n)}class Q extends _{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new T(Ue(t.content,(l,a)=>!l.isAtom||!a.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,s)}invert(){return new ee(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Q(t.pos,n.pos,this.mark)}merge(e){return e instanceof Q&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Q(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Q(t.from,t.to,e.markFromJSON(t.mark))}}_.jsonID("addMark",Q);class ee extends _{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new T(Ue(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,n)}invert(){return new Q(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ee(t.pos,n.pos,this.mark)}merge(e){return e instanceof ee&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ee(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ee(t.from,t.to,e.markFromJSON(t.mark))}}_.jsonID("removeMark",ee);class te extends _{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new T(O.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new te(this.pos,t.marks[i]);return new te(this.pos,this.mark)}}return new he(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new te(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new te(t.pos,e.markFromJSON(t.mark))}}_.jsonID("addNodeMark",te);class he extends _{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new T(O.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new te(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new he(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new he(t.pos,e.markFromJSON(t.mark))}}_.jsonID("removeNodeMark",he);class V extends _{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Ke(e,this.from,this.to)?N.fail("Structure replace would overwrite content"):N.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new j([this.from,this.to-this.from,this.slice.size])}invert(e){return new V(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&V.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new V(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof V)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?T.empty:new T(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new V(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?T.empty:new T(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new V(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new V(t.from,t.to,T.fromJSON(e,t.slice),!!t.structure)}}V.MAP_BIAS=1,_.jsonID("replace",V);class oe extends _{constructor(e,t,n,i,s,l,a=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=l,this.structure=a}apply(e){if(this.structure&&(Ke(e,this.from,this.gapFrom)||Ke(e,this.gapTo,this.to)))return N.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return N.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?N.fromReplace(e,this.from,this.to,n):N.fail("Content does not fit in gap")}getMap(){return new j([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new oe(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new oe(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new oe(t.from,t.to,t.gapFrom,t.gapTo,T.fromJSON(e,t.slice),t.insert,!!t.structure)}}_.jsonID("replaceAround",oe);function Ke(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let l=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function kn(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Mt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let l=r.$from.node(n),a=r.$from.index(n)+i,c=r.$to.indexAfter(n)-s;if(n<r.depth&&l.canReplace(a,c,t))return n;if(n==0||l.type.spec.isolating||!kn(l,a,c))break;a&&(i=1),c<l.childCount&&(s=1)}return null}class pe extends _{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return N.fromReplace(e,this.pos,this.pos+1,new T(O.from(i),0,t.isLeaf?0:1))}getMap(){return j.empty}invert(e){return new pe(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pe(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new pe(t.pos,t.attr,t.value)}}_.jsonID("attr",pe);class Re extends _{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return N.ok(n)}getMap(){return j.empty}invert(e){return new Re(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Re(t.attr,t.value)}}_.jsonID("docAttr",Re);let me=class extends Error{};me=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t},me.prototype=Object.create(Error.prototype),me.prototype.constructor=me,me.prototype.name="TransformError";const Xe=Object.create(null);class z{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Nn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=T.empty){let n=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=n,n=n.lastChild;let s=e.steps.length,l=this.ranges;for(let a=0;a<l.length;a++){let{$from:c,$to:f}=l[a],u=e.mapping.slice(s);e.replaceRange(u.map(c.pos),u.map(f.pos),a?T.empty:t),a==0&&_t(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(n),f=c.map(l.pos),u=c.map(a.pos);s?e.deleteRange(f,u):(e.replaceRangeWith(f,u,t),_t(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new F(e):ae(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let l=t<0?ae(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):ae(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(l)return l}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new K(e.node(0))}static atStart(e){return ae(e,e,0,0,1)||new K(e)}static atEnd(e){return ae(e,e,e.content.size,e.childCount,-1)||new K(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Xe[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Xe)throw new RangeError("Duplicate use of selection JSON ID "+e);return Xe[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}z.prototype.visible=!0;class Nn{constructor(e,t){this.$from=e,this.$to=t}}let Pt=!1;function Dt(r){!Pt&&!r.parent.inlineContent&&(Pt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class F extends z{constructor(e,t=e){Dt(e),Dt(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return z.near(n);let i=e.resolve(t.map(this.anchor));return new F(i.parent.inlineContent?i:n,n)}replace(e,t=T.empty){if(super.replace(e,t),t==T.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Oe(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=z.findFrom(t,n,!0)||z.findFrom(t,-n,!0);if(s)t=s.$head;else return z.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(z.findFrom(e,-n,!0)||z.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new F(e,t)}}z.jsonID("text",F);class Oe{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Oe(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class B extends z{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?z.near(s):new B(s)}content(){return new T(O.from(this.node),0,0)}eq(e){return e instanceof B&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ye(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new B(e.resolve(t.anchor))}static create(e,t){return new B(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}B.prototype.visible=!1,z.jsonID("node",B);class Ye{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Oe(n,n):new Ye(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&B.isSelectable(n)?new B(t):z.near(t)}}class K extends z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=T.empty){if(t==T.empty){e.delete(0,e.doc.content.size);let n=z.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new K(e)}map(e){return new K(e)}eq(e){return e instanceof K}getBookmark(){return Ln}}z.jsonID("all",K);const Ln={map(){return this},resolve(r){return new K(r)}};function ae(r,e,t,n,i,s=!1){if(e.inlineContent)return F.create(r,t);for(let l=n-(i>0?0:1);i>0?l<e.childCount:l>=0;l+=i){let a=e.child(l);if(a.isAtom){if(!s&&B.isSelectable(a))return B.create(r,t-(i<0?a.nodeSize:0))}else{let c=ae(r,a,t+i,i<0?a.childCount:0,i,s);if(c)return c}t+=a.nodeSize*i}return null}function _t(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof V||i instanceof oe))return;let s=r.mapping.maps[n],l;s.forEach((a,c,f,u)=>{l==null&&(l=u)}),r.setSelection(z.near(r.doc.resolve(l),t))}function Bt(r,e){return!e||!r?r:r.bind(e)}class Ce{constructor(e,t,n){this.name=e,this.init=Bt(t.init,n),this.apply=Bt(t.apply,n)}}new Ce("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Ce("selection",{init(r,e){return r.selection||z.atStart(e.doc)},apply(r){return r.selection}}),new Ce("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Ce("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}});function $t(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=$t(i,e,{})),t[n]=i}return t}class le{constructor(e){this.spec=e,this.props={},e.props&&$t(e.props,this,this.props),this.key=e.key?e.key.key:Ft("plugin")}getState(e){return e[this.key]}}const Ge=Object.create(null);function Ft(r){return r in Ge?r+"$"+ ++Ge[r]:(Ge[r]=0,r+"$")}class An{constructor(e="key"){this.key=Ft(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ze=St.extend({addAttributes(){var r;return{...(r=this.parent)==null?void 0:r.call(this),"data-note-file-id":{default:null,parseHTML:e=>e.getAttribute("data-note-file-id"),renderHTML:e=>e["data-note-file-id"]?{"data-note-file-id":e["data-note-file-id"]}:{}}}},addProseMirrorPlugins(){return[new le({appendTransaction(r,e,t){if(!r.some(p=>p.docChanged))return null;const{selection:n}=t;if(!n.empty)return null;const{$from:i}=n;if(i.parent.type.name!=="paragraph"||i.parent.content.size!==0)return null;const s=i.before(i.depth),l=e.selection.$from;if(l.depth<1)return null;const a=l.before(l.depth);if(s!==a)return null;const c=e.doc.nodeAt(s);if(!c||c.type.name!=="paragraph")return null;let f=!1;if(c.forEach(p=>{p.marks.some(y=>y.type.name==="link")&&(f=!0)}),!f)return null;const u=t.tr;try{u.join(s)}catch{}return u.setStoredMarks([])}})]}}),Jt=Be.extend({addNodeView(){return({node:r})=>{const e=r.attrs.indent||0,t=document.createElement("p");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}},addAttributes(){var r;return{...(r=this.parent)==null?void 0:r.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0"),renderHTML:e=>e.indent?{"data-indent":e.indent,style:`--indent-level: ${e.indent};`}:{}}}}}),P={MOBILE_BREAKPOINT:768,ICON_SIZE:"24px",CONTROLLER_HEIGHT:"25px",DOT_SIZE:{MOBILE:16,DESKTOP:9},DOT_POSITION:{MOBILE:"-8px",DESKTOP:"-4px"},COLORS:{BORDER:"#6C6C6C",BACKGROUND:"rgba(255, 255, 255, 1)"},ICONS:{LEFT:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg",CENTER:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg",RIGHT:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg"}},ne={isMobile(){return document.documentElement.clientWidth<P.MOBILE_BREAKPOINT},getDotPosition(){return ne.isMobile()?P.DOT_POSITION.MOBILE:P.DOT_POSITION.DESKTOP},getDotSize(){return ne.isMobile()?P.DOT_SIZE.MOBILE:P.DOT_SIZE.DESKTOP},clearContainerBorder(r){const e=r.getAttribute("style"),t=e==null?void 0:e.replace("border: 1px dashed #6C6C6C;","").replace("border: 1px dashed rgb(108, 108, 108)","");r.setAttribute("style",t)},removeResizeElements(r){if(r.childElementCount>3)for(let e=0;e<5;e++)r.removeChild(r.lastChild)}};class Qe{static parseImageAttributes(e,t){Object.entries(e).forEach(([n,i])=>{if(!(i==null||n==="wrapperStyle")){if(n==="containerStyle"){const s=i.match(/width:\s*([0-9.]+)px/);s&&t.setAttribute("width",s[1]);return}t.setAttribute(n,i)}})}static extractWidthFromStyle(e){const t=e.match(/width:\s*([0-9.]+)px/);return t?(t==null?void 0:t.at(1))??null:null}}function et(r,e){const{minWidth:t,maxWidth:n}=e,i=t!==void 0?Math.max(0,t):0;let s=Math.max(i,r);return n!==void 0&&s>n&&(s=n),s}class ce{static getContainerStyle(e,t){return`${`width: ${t&&t!=="0px"&&t!=="0"?t:"100%"}; height: auto; cursor: pointer;`} ${e?"display: inline-block;":""}`}static getWrapperStyle(e){return e?"display: inline-block; float: left; padding-right: 8px;":"display: flex"}static getPositionControllerStyle(e){return`
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 0%;
|
|
4
|
+
left: 50%;
|
|
5
|
+
width: ${e?"66px":"100px"};
|
|
6
|
+
height: ${P.CONTROLLER_HEIGHT};
|
|
7
|
+
z-index: 999;
|
|
8
|
+
background-color: ${P.COLORS.BACKGROUND};
|
|
9
|
+
border-radius: 3px;
|
|
10
|
+
border: 1px solid ${P.COLORS.BORDER};
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
transform: translate(-50%, -50%);
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: center;
|
|
15
|
+
padding: 0 6px;
|
|
16
|
+
display: none;
|
|
17
|
+
`.replace(/\s+/g," ").trim()}static getDotStyle(e){const t=ne.getDotPosition(),n=ne.getDotSize(),i=[`top: ${t}; left: ${t}; cursor: nwse-resize;`,`top: ${t}; right: ${t}; cursor: nesw-resize;`,`bottom: ${t}; left: ${t}; cursor: nesw-resize;`,`bottom: ${t}; right: ${t}; cursor: nwse-resize;`];return`
|
|
18
|
+
position: absolute;
|
|
19
|
+
width: ${n}px;
|
|
20
|
+
height: ${n}px;
|
|
21
|
+
border: 1.5px solid ${P.COLORS.BORDER};
|
|
22
|
+
border-radius: 50%;
|
|
23
|
+
${i[e]}
|
|
24
|
+
`.replace(/\s+/g," ").trim()}}class zn{constructor(e,t,n){R(this,"elements");R(this,"inline");R(this,"dispatchNodeView");this.elements=e,this.inline=t,this.dispatchNodeView=n}createControllerIcon(e){const t=document.createElement("img");return t.setAttribute("src",e),t.setAttribute("style",`width: ${P.ICON_SIZE}; height: ${P.ICON_SIZE}; cursor: pointer;`),t.addEventListener("mouseover",n=>{n.target.style.opacity="0.6"}),t.addEventListener("mouseout",n=>{n.target.style.opacity="1"}),t}handleLeftClick(){if(!this.inline)this.elements.container.setAttribute("style",`${this.elements.container.style.cssText} margin: 0 auto 0 0;`);else{const e="display: inline-block; float: left; padding-right: 8px;";this.elements.wrapper.setAttribute("style",e),this.elements.container.setAttribute("style",e)}this.dispatchNodeView()}handleCenterClick(){this.elements.container.setAttribute("style",`${this.elements.container.style.cssText} margin: 0 auto;`),this.dispatchNodeView()}handleRightClick(){if(!this.inline)this.elements.container.setAttribute("style",`${this.elements.container.style.cssText} margin: 0 0 0 auto;`);else{const e="display: inline-block; float: right; padding-left: 8px;";this.elements.wrapper.setAttribute("style",e),this.elements.container.setAttribute("style",e)}this.dispatchNodeView()}createPositionControls(){const e=document.createElement("div");e.setAttribute("style",ce.getPositionControllerStyle(this.inline));const t=this.createControllerIcon(P.ICONS.LEFT);if(t.addEventListener("click",()=>this.handleLeftClick()),e.appendChild(t),!this.inline){const i=this.createControllerIcon(P.ICONS.CENTER);i.addEventListener("click",()=>this.handleCenterClick()),e.appendChild(i)}const n=this.createControllerIcon(P.ICONS.RIGHT);return n.addEventListener("click",()=>this.handleRightClick()),e.appendChild(n),this.elements.container.appendChild(e),this}}class Mn{constructor(e,t,n=()=>({})){R(this,"elements");R(this,"dispatchNodeView");R(this,"getResizeLimits");R(this,"state",{isResizing:!1,startX:0,startWidth:0});R(this,"handleMouseMove",(e,t)=>{if(!this.state.isResizing)return;const n=t%2===0?-(e.clientX-this.state.startX):e.clientX-this.state.startX,i=et(this.state.startWidth+n,this.getResizeLimits());this.elements.container.style.width=i+"px",this.elements.img.style.width=i+"px"});R(this,"handleMouseUp",()=>{this.state.isResizing&&(this.state.isResizing=!1),this.dispatchNodeView()});R(this,"handleTouchMove",(e,t)=>{if(!this.state.isResizing)return;const n=t%2===0?-(e.touches[0].clientX-this.state.startX):e.touches[0].clientX-this.state.startX,i=et(this.state.startWidth+n,this.getResizeLimits());this.elements.container.style.width=i+"px",this.elements.img.style.width=i+"px"});R(this,"handleTouchEnd",()=>{this.state.isResizing&&(this.state.isResizing=!1),this.dispatchNodeView()});this.elements=e,this.dispatchNodeView=t,this.getResizeLimits=n}createResizeHandle(e){const t=document.createElement("div");return t.setAttribute("style",ce.getDotStyle(e)),t.addEventListener("mousedown",n=>{n.preventDefault(),this.state.isResizing=!0,this.state.startX=n.clientX,this.state.startWidth=this.elements.container.offsetWidth;const i=l=>this.handleMouseMove(l,e),s=()=>{this.handleMouseUp(),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)}),t.addEventListener("touchstart",n=>{n.cancelable&&n.preventDefault(),this.state.isResizing=!0,this.state.startX=n.touches[0].clientX,this.state.startWidth=this.elements.container.offsetWidth;const i=l=>this.handleTouchMove(l,e),s=()=>{this.handleTouchEnd(),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",s)};document.addEventListener("touchmove",i),document.addEventListener("touchend",s)},{passive:!1}),t}}class Pn{constructor(e={}){R(this,"limits");this.limits=e}update(e){this.limits={...this.limits,...e}}get(){return this.limits}}class Dn{constructor(e,t,n={},i){R(this,"context");R(this,"elements");R(this,"inline");R(this,"resizeLimitsRef");R(this,"resizeEventName");R(this,"handleResizeEvent");R(this,"clearContainerBorder",()=>{ne.clearContainerBorder(this.elements.container)});R(this,"dispatchNodeView",()=>{const{view:e,getPos:t}=this.context;if(typeof t=="function"){this.clearContainerBorder();const n={...this.context.node.attrs,width:Qe.extractWidthFromStyle(this.elements.container.style.cssText)??this.context.node.attrs.width,containerStyle:`${this.elements.container.style.cssText}`,wrapperStyle:`${this.elements.wrapper.style.cssText}`};e.dispatch(e.state.tr.setNodeMarkup(t(),null,n))}});R(this,"removeResizeElements",()=>{ne.removeResizeElements(this.elements.container)});this.context=e,this.inline=t,this.resizeLimitsRef=new Pn(n),this.resizeEventName=i,this.elements=this.createElements(),i&&(this.handleResizeEvent=(s=>{const l=s;l.detail&&this.updateResizeLimits({maxWidth:l.detail.maxWidth})}),window.addEventListener(i,this.handleResizeEvent))}destroy(){this.resizeEventName&&this.handleResizeEvent&&window.removeEventListener(this.resizeEventName,this.handleResizeEvent)}updateResizeLimits(e){this.resizeLimitsRef.update(e)}createElements(){return{wrapper:document.createElement("div"),container:document.createElement("div"),img:document.createElement("img")}}setupImageAttributes(){Qe.parseImageAttributes(this.context.node.attrs,this.elements.img)}setupDOMStructure(){const{wrapperStyle:e,containerStyle:t}=this.context.node.attrs;this.elements.wrapper.setAttribute("style",e),this.elements.wrapper.appendChild(this.elements.container),this.elements.container.setAttribute("style",t),this.elements.container.appendChild(this.elements.img)}applyResizeLimits(){const e=this.resizeLimitsRef.get();let t=Qe.extractWidthFromStyle(this.elements.container.style.cssText);if(t===null){const l=e.maxWidth;if(!l)return;t=l.toString()}const n=Number(t);if(Number.isNaN(n))return;const i=et(n,e),s=`${i}px`;this.elements.container.style.width=s,this.elements.img.style.width=s,this.elements.img.setAttribute("width",String(i))}createPositionController(){new zn(this.elements,this.inline,this.dispatchNodeView).createPositionControls()}createResizeHandler(){const e=new Mn(this.elements,this.dispatchNodeView,()=>this.resizeLimitsRef.get());Array.from({length:4},(t,n)=>{const i=e.createResizeHandle(n);this.elements.container.appendChild(i)})}setupContainerClick(){this.elements.container.addEventListener("click",()=>{var t;ne.isMobile()&&((t=document.querySelector(".ProseMirror-focused"))==null||t.blur()),this.removeResizeElements(),this.createPositionController(),this.elements.container.setAttribute("style",`position: relative; border: 1px dashed ${P.COLORS.BORDER}; ${this.context.node.attrs.containerStyle}`),this.applyResizeLimits(),this.createResizeHandler()})}setupContentClick(){document.addEventListener("click",e=>{const t=e.target;this.elements.container.contains(t)||t.style.cssText===`width: ${P.ICON_SIZE}; height: ${P.ICON_SIZE}; cursor: pointer;`||(this.clearContainerBorder(),this.removeResizeElements())})}initialize(){this.setupDOMStructure(),this.setupImageAttributes(),this.applyResizeLimits();const{editable:e}=this.context.editor.options;return e?(this.setupContainerClick(),this.setupContentClick(),{dom:this.elements.wrapper,destroy:()=>this.destroy()}):{dom:this.elements.container,destroy:()=>this.destroy()}}}const Wt="image-resize-limit-update";class _n{constructor(e){R(this,"currentMaxWidth");R(this,"resizeTimeout");R(this,"rafId");R(this,"handleResize",()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>{const e=this.measureContainerWidth();if(e!==this.currentMaxWidth){this.currentMaxWidth=e;const t=new CustomEvent(Wt,{detail:{maxWidth:e}});window.dispatchEvent(t)}})},150)});this.editorElement=e,this.currentMaxWidth=this.measureContainerWidth(),window.addEventListener("resize",this.handleResize)}measureContainerWidth(){return this.editorElement.clientWidth}getCurrentMaxWidth(){return this.currentMaxWidth}destroy(){window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.rafId&&cancelAnimationFrame(this.rafId)}}const tt=wt.extend({name:"imageResize",addOptions(){var r;return{...(r=this.parent)==null?void 0:r.call(this),inline:!1,minWidth:void 0,maxWidth:void 0,allowBase64:!1}},onCreate(){const r=new _n(this.editor.view.dom);return this.resizeHandler=r,()=>{r.destroy()}},renderHTML({HTMLAttributes:r}){const e={...r};if(r!=null&&r.id&&(e["data-id"]=r.id),!(r!=null&&r.wrapperStyle))return["img",e];const t=(r==null?void 0:r.width)??this.options.maxWidth??0,n=this.options.inline,i=(r==null?void 0:r.containerStyle)??ce.getContainerStyle(n,`${t}px`),s=(r==null?void 0:r.wrapperStyle)??ce.getWrapperStyle(n);return["div",{style:i},["div",{style:s},["img",e]]]},addAttributes(){var e;const r=this.options.inline;return{...(e=this.parent)==null?void 0:e.call(this),id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id,style:"margin-block: 10px;"}:{}},width:{renderHTML:t=>t.width?{width:t.width}:{}},containerStyle:{default:null,parseHTML:t=>{const n=t.getAttribute("containerstyle");if(n)return n;const i=t.getAttribute("width");return i?ce.getContainerStyle(r,`${i}px`):`${t.style.cssText}`},renderHTML:t=>t.width?{width:t.width}:{}},wrapperStyle:{default:ce.getWrapperStyle(r)}}},addNodeView(){return({node:r,editor:e,getPos:t})=>{var u;if(r.type.name!=="imageResize"){const p=document.createElement("img");return p.src=r.attrs.src,p.alt=r.attrs.alt||"",r.attrs.width&&(p.width=r.attrs.width),r.attrs.height&&(p.height=r.attrs.height),{dom:p}}const{inline:n,minWidth:i,maxWidth:s}=this.options,l={node:r,editor:e,view:e.view,getPos:typeof t=="function"?t:void 0},a={minWidth:i,maxWidth:s??((u=this.resizeHandler)==null?void 0:u.getCurrentMaxWidth())},f=new Dn(l,n,a,Wt).initialize();return f.dom.addEventListener("click",p=>{p.preventDefault();const y=t();if(y!==void 0){const{state:w,view:g}=e,b=w.tr.setSelection(B.create(w.doc,y));g.dispatch(b)}}),f}},addCommands(){var r;return{...(r=this.parent)==null?void 0:r.call(this),setResizableImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addKeyboardShortcuts(){return{Backspace:()=>Bn(this.editor)}}}),Bn=r=>{var t,n;const e=[];return r.state.doc.nodesBetween(r.state.selection.$from.pos,r.state.selection.$to.pos,i=>{e==null||e.push(i)}),e.length!==1||((n=(t=e.at(0))==null?void 0:t.type)==null?void 0:n.name)!=="imageResize"?(console.log("trace 1: handled?"),!1):(r.commands.deleteSelection(),!0)},U=r=>r==="bulletList"||r==="orderedList",ke=r=>r==="listItem",J=r=>r==="paragraph"||r==="heading";function nt(r,e){for(const t of r)if(t(e))return!0;return!1}function $n(r,e){for(const t of r)if(t(e))return!0;return!1}const Fn=({editor:r,$from:e,currentNode:t})=>{const n=e.pos===e.start(),i=t.attrs.indent>0;return J(t.type.name)&&i&&n?r.commands.outdent():!1},Jn=({state:r,view:e,$from:t,currentNode:n})=>{const i=n.content.size===0,s=n.attrs.indent>0;if(!(J(n.type.name)&&s&&i))return!1;const a=t.before(t.depth),c=r.tr;return c.delete(a,a+n.nodeSize),e.dispatch(c),!0},Wn=({state:r,view:e,$from:t,currentNode:n})=>{const i=t.pos===t.start(),s=n.content.size===0,l=n.attrs.indent>0,a=t.before(t.depth),c=r.doc.resolve(a).nodeBefore,f=c!=null&&U(c.type.name);if(J(n.type.name)&&!l&&s&&i&&f){const p=r.tr;return p.delete(a,a+n.nodeSize),e.dispatch(p),!0}return!1},Hn=r=>{const{tr:e,state:t,dispatch:n}=r,{selection:i}=t,{$from:s,$to:l}=i;if(i.empty)return!1;let a=0;if(t.doc.nodesBetween(s.pos,l.pos,u=>{(U(u.type.name)||J(u.type.name))&&a++}),a<=1)return!1;const c=new Set;let f=!1;return t.doc.nodesBetween(s.pos,l.pos,(u,p)=>{var w;return!(U(u.type.name)||J(u.type.name))||c.has(p)?!0:(c.add(p),e.setNodeAttribute(p,"indent",(((w=u.attrs)==null?void 0:w.indent)??0)+1),f=!0,!1)}),f?(e.setMeta("addToHistory",!0),n==null||n(e),!0):!1},jn=r=>{var f;const{tr:e,state:t,dispatch:n}=r,{selection:i}=t,{$from:s}=i;let l=null,a=null;for(let u=s.depth;u>0;u--){const p=s.node(u);if(U(p.type.name)){l={...p,pos:s.before(u)},a={...s.node(u+1),pos:s.before(u+1)};break}}if(!l||!a)return!1;if(((f=l.content)==null?void 0:f.childCount)===1&&i instanceof F){const u=l.attrs.indent??0;return e.setNodeAttribute(l.pos,"indent",u+1),e.setMeta("addToHistory",!1),n==null||n(e),!0}return r.chain().focus().sinkListItem("listItem").updateAttributes("bulletList",{indent:1}).updateAttributes("orderedList",{indent:1}).run(),!0},qn=r=>{const{tr:e,state:t,dispatch:n}=r,{selection:i}=t,{$from:s}=i,l=s.node();if(!(J(l.type.name)&&i instanceof F))return!1;const c=l.attrs.indent??0;return e.setNodeAttribute(s.before(s.depth),"indent",c+1),e.setMeta("addToHistory",!1),n==null||n(e),!0},Ht=({state:r,view:e,$from:t,$to:n,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(r.doc.nodesBetween(t.pos,n.pos,p=>{(ke(p.type.name)||J(p.type.name))&&s++}),!(s>1))return!1;const{tr:a,doc:c}=r;let f=!1;const u=new Set;return c.nodesBetween(t.pos,n.pos,(p,y)=>{if(U(p.type.name)&&(p.attrs.indent??0)>0){if(!u.has(y)){u.add(y);const w=p.attrs.indent??0;a.setNodeAttribute(y,"indent",Math.max(0,w-1)),f=!0;const g=r.doc.resolve(y),b=r.doc.resolve(y+p.nodeSize),M=new Rt(g,b,g.depth),A=Mt(M);A!=null&&(a.lift(M,A),f=!0)}return!1}if(J(p.type.name)&&(p.attrs.indent??0)>0){const w=p.attrs.indent??0;a.setNodeAttribute(y,"indent",Math.max(0,w-1)),f=!0}return!0}),f?(a.setMeta("addToHistory",!0),e.dispatch(a),!0):!1},Vn=({state:r,view:e,$from:t,$to:n,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(r.doc.nodesBetween(t.pos,n.pos,p=>{(ke(p.type.name)||J(p.type.name))&&s++}),!(s>1))return!1;const{tr:a,doc:c}=r;let f=!1;const u=new Set;return c.nodesBetween(t.pos,n.pos,(p,y)=>{if(U(p.type.name)&&(p.attrs.indent??0)>0){if(!u.has(y)){u.add(y);const w=p.attrs.indent??0;a.setNodeAttribute(y,"indent",Math.max(0,w-1)),f=!0;const g=r.doc.resolve(y),b=r.doc.resolve(y+p.nodeSize),M=new Rt(g,b,g.depth),A=Mt(M);A!=null&&(a.lift(M,A),f=!0)}return!1}if(J(p.type.name)&&(p.attrs.indent??0)>0){const w=p.attrs.indent??0;a.setNodeAttribute(y,"indent",Math.max(0,w-1)),f=!0}return!0}),f?(a.setMeta("addToHistory",!0),e.dispatch(a),!0):!1},Un=({$from:r,selectionIsEmpty:e})=>{var l;if(!e)return!1;let t=!1,n=!1,i=0;for(let a=r.depth;a>0;a--){const c=r.node(a);if(U(c.type.name))if(!t)t=!0,i=((l=c.attrs)==null?void 0:l.indent)??0;else{n=!0;break}}return t&&!n?i===0:!1},Kn=({state:r,view:e,$from:t,currentNode:n,selectionIsEmpty:i})=>{if(!i||!(n.type.name==="paragraph"&&n.content.size===0))return!1;const l=t.before(t.depth),a=r.doc.resolve(l).nodeBefore;if(!(a!=null&&U(a.type.name)))return!1;const f=r.doc.resolve(l-1),u=r.tr.setSelection(F.near(f,-1));return e.dispatch(u),!0},Xn=({state:r,view:e,$from:t,$to:n,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(r.doc.nodesBetween(t.pos,n.pos,p=>{(ke(p.type.name)||J(p.type.name))&&s++}),!(s>1))return!1;const{tr:a,doc:c}=r;let f=!1;const u=new Set;return c.nodesBetween(t.pos,n.pos,(p,y)=>{if((U(p.type.name)||J(p.type.name))&&!u.has(y)){u.add(y);const g=p.attrs.indent??0;return a.setNodeAttribute(y,"indent",g+1),f=!0,!1}return!0}),f?(a.setMeta("addToHistory",!0),e.dispatch(a),!0):!1},Yn=({state:r,view:e,$from:t,selectionIsEmpty:n})=>n||t.path.some(s=>{var l;return((l=s==null?void 0:s.type)==null?void 0:l.name)==="listItem"})?!1:(e.dispatch(r.tr.insertText(" ")),!0),Gn=({editor:r,currentNode:e,$from:t})=>{const n=e.content.size===0,i=t.node(t.depth-1);return i&&ke(i.type.name)&&!n?(r.chain().focus().indent().focus().run(),!0):!1},Zn=({state:r,view:e,$from:t,currentNode:n})=>{const i=t.pos===t.start(),s=n.content.size===0;return!i&&!s?(e.dispatch(r.tr.insertText(" ")),!0):!1};function rt(r){const{state:e,view:t}=r,{$from:n,$to:i,empty:s}=e.selection;return{editor:r,state:e,view:t,$from:n,$to:i,selectionIsEmpty:s,currentNode:n.node()}}const jt=Ee.Extension.create({name:"indent",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands._handleEnterKeyDown(),Tab:()=>{const r=rt(this.editor);return nt([Xn,Yn,Gn,Zn],r)||this.editor.commands.indent()},Backspace:()=>{const r=rt(this.editor);return nt([Fn,Jn,Wn],r)},"Shift-Tab":()=>{const r=rt(this.editor);return nt([Vn,Kn,Un],r)||this.editor.chain().outdentShiftTab().run()},Space:()=>this.editor.commands._handleSpaceKeyDown()}},addProseMirrorPlugins(){return[new le({appendTransaction:(r,e,t)=>{if(!r.some(s=>s.docChanged))return null;let i=null;return t.doc.descendants((s,l)=>{var y;if(!(J(s.type.name)&&(((y=s==null?void 0:s.attrs)==null?void 0:y.indent)??0)>0))return;const c=t.doc.resolve(l);if(!(c.parent.type.name==="listItem"))return;let u=null;for(let w=c.depth-1;w>0;w--)if(U(c.node(w).type.name)){u=c.start(w)-1;break}if(u===null||u<0)return;i||(i=t.tr);const p=s.attrs.indent;i.setNodeAttribute(l,"indent",0),i.setNodeAttribute(u,"indent",p)}),i}})]},addGlobalAttributes(){return[{types:this.options.types??["orderedList","bulletList","paragraph","heading"],attributes:{indent:{default:1,parseHTML:r=>parseInt(r.getAttribute("data-indent")||"1",10),renderHTML:r=>r!=null&&r.indent?{style:`padding-left: ${r.indent*20}px`}:{}}}}]},addCommands(){return{_handleEnterKeyDown:()=>r=>{var c;const{tr:e,state:t,dispatch:n}=r,{$from:i}=t.selection,s=i.node();if(!(((c=s==null?void 0:s.type)==null?void 0:c.name)==="paragraph"&&s.attrs.indent))return!1;const a=s.attrs.indent;return e.split(i.pos),e.setNodeAttribute(e.selection.$from.before(),"indent",a),e.scrollIntoView(),e.setMeta("addToHistory",!1),n==null||n(e),!0},_handleSpaceKeyDown:()=>()=>!1,indent:()=>r=>$n([Hn,jn,qn],r),outdent:()=>r=>{const{state:e,view:t,tr:n,dispatch:i}=r,{$from:s,$to:l,empty:a}=e.selection,c={editor:r.editor,state:e,view:t,$from:s,$to:l,selectionIsEmpty:a,currentNode:s.node()};if(Ht(c))return!0;const f=s.node();if(!(J(f.type.name)&&f.attrs.indent>0)||!(s.pos===s.start()))return!1;const y=Math.max(0,f.attrs.indent-1);return n.setNodeAttribute(s.before(s.depth),"indent",y),n.setMeta("addToHistory",!1),i==null||i(n),!0},outdentShiftTab:()=>r=>{const{state:e,tr:t,dispatch:n}=r,{$from:i}=e.selection,s=i.node();if(!(J(s.type.name)&&s.attrs.indent>0))return!1;const a=Math.max(0,s.attrs.indent-1);return t.setNodeAttribute(i.before(i.depth),"indent",a),t.setMeta("addToHistory",!1),n==null||n(t),!0},increaseIndent:()=>({commands:r})=>r.indent(),decreaseIndent:()=>r=>{const{state:e,view:t}=r,{$from:n,$to:i,empty:s}=e.selection,l={editor:r.editor,state:e,view:t,$from:n,$to:i,selectionIsEmpty:s,currentNode:n.node()};return Ht(l)?!0:r.chain().outdentShiftTab().run()}}}});var Qn=D.BulletList,er=D.ListItem,tr=D.OrderedList;const qt=Qn.extend({addAttributes(){var r;return{...(r=this.parent)==null?void 0:r.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}},addNodeView(){return({node:r})=>{const e=r.attrs.indent||0,t=document.createElement("ul");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}}}),Vt=tr.extend({addAttributes(){var r;return{...(r=this.parent)==null?void 0:r.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}},addNodeView(){return({node:r})=>{const e=r.attrs.indent||0,t=document.createElement("ol");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}}}),it=er.extend({addAttributes(){var r;return{...(r=this.parent)==null?void 0:r.call(this),class:{default:null,parseHTML:e=>e.getAttribute("class"),renderHTML:e=>e.class?{class:e.class,...e}:{}},indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}}}),st=se.Extension.create({name:"dynamicBulletStyling",addProseMirrorPlugins(){return[new le({key:new An("dynamicBulletStyling"),appendTransaction:(r,e,t)=>{const n=t.tr;let i=!1;return t.doc.descendants((s,l)=>{if(s.type.name==="listItem"){let a=0;const c=t.doc.resolve(l);for(let f=c.depth;f>0;f--)if(c.node(f).type.name==="bulletList"){a=1;break}a>0&&(n.setNodeAttribute(c.pos,"[data-style]","line-height: inherit"),i=!0)}}),i?n:null}})]}}),nr=r=>r==="bulletList"||r==="orderedList",rr=r=>r==="paragraph"||r==="heading",Ut=se.Extension.create({name:"listIndentIntegration",addProseMirrorPlugins(){return[new le({appendTransaction:(r,e,t)=>{if(!r.find(i=>i.docChanged))return null;let n=null;return t.doc.descendants((i,s)=>{var l;if(rr(i.type.name)&&(((l=i==null?void 0:i.attrs)==null?void 0:l.indent)??0)>0){const a=t.doc.resolve(s);if(a.parent.type.name==="listItem"){let f=null;for(let u=a.depth-1;u>0;u--){const p=a.node(u);if(nr(p.type.name)){f=a.start(u)-1;break}}if(f!==null&&f>=0){n||(n=t.tr);const u=i.attrs.indent;n.setNodeAttribute(s,"indent",0),n.setNodeAttribute(f,"indent",u)}}}}),n}}),new le({props:{transformPastedHTML(r){const e=/<p[^>]*style="[^"]*(?:padding|margin)-left:\s*(\d+)(?:px|pt|em)[^"]*"[^>]*>/gi;r=r.replace(e,(i,s)=>`<p data-indent="${Math.floor(parseInt(s,10)/40)}">`);const t=/<ol[^>]*style="[^"]*list-style-type:\s*(upper-roman|lower-roman|upper-alpha|lower-alpha)[^"]*"[^>]*>/gi;r=r.replace(t,()=>"<ol>");const n=/<li[^>]*style="[^"]*list-style-type:\s*[^;"\s]+[^"]*"[^>]*>/gi;return r=r.replace(n,i=>i.replace(/list-style-type:\s*[^;"\s]+;?/gi,"")),r}}})]}}),ot=se.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"],getStyle:r=>`font-size: ${r}`}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:r=>r.style.fontSize.replace(/['"]+/g,""),renderHTML:r=>r.fontSize?{style:this.options.getStyle(r.fontSize)}:{}}}}]},addCommands(){return{setFontSize:r=>({chain:e})=>e().setMark("textStyle",{fontSize:r}).run(),unsetFontSize:()=>({chain:r})=>r().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),at=se.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"],getStyle:r=>`line-height: ${r};`}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:r=>r.style.lineHeight.replace(/['"]+/g,""),renderHTML:r=>r.lineHeight?{style:this.options.getStyle(r.lineHeight)}:{}}}}]},addCommands(){return{setLineHeight:r=>({chain:e})=>e().setMark("textStyle",{lineHeight:r}).run(),unsetLineHeight:()=>({chain:r})=>r().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),ir=[$,Z.CharacterCount,X,Pe,gt,yt,vt,tt,Ze,D.ListItem,D.ListKeymap,It,D.OrderedList,Z.Placeholder,Y.Table,Y.TableCell,Y.TableHeader,Y.TableRow,D.TaskItem,D.TaskList,Fe,Je.TextStyle,We,Be,$e,_e,De,Z.UndoRedo,it,ot,at,D.BulletList,st],sr=[Jt,Je.TextStyle,X,Z.UndoRedo.configure({newGroupDelay:500,depth:100}),De,We,$,_e,D.TaskItem,it,Pe,$e,ot,at,qt,st,tt,Ut,Fe.configure({types:["heading","paragraph"]}),Vt.configure({itemTypeName:"listItem",keepMarks:!0,keepAttributes:!0}),Ze,jt],or=se.Extension.create({name:"MentionStorage",addStorage(){return{suggestions:[]}}});var ue={},Kt;function ar(){if(Kt)return ue;Kt=1;var r=xn;if(process.env.NODE_ENV==="production")ue.createRoot=r.createRoot,ue.hydrateRoot=r.hydrateRoot;else{var e=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;ue.createRoot=function(t,n){e.usingClientEntryPoint=!0;try{return r.createRoot(t,n)}finally{e.usingClientEntryPoint=!1}},ue.hydrateRoot=function(t,n,i){e.usingClientEntryPoint=!0;try{return r.hydrateRoot(t,n,i)}finally{e.usingClientEntryPoint=!1}}}return ue}var lr=ar(),Ne={exports:{}},ge={};/**
|
|
2
25
|
* @license React
|
|
3
26
|
* react-jsx-runtime.production.min.js
|
|
4
27
|
*
|
|
@@ -6,7 +29,7 @@
|
|
|
6
29
|
*
|
|
7
30
|
* This source code is licensed under the MIT license found in the
|
|
8
31
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
32
|
+
*/var Xt;function cr(){if(Xt)return ge;Xt=1;var r=He,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function l(a,c,f){var u,p={},y=null,w=null;f!==void 0&&(y=""+f),c.key!==void 0&&(y=""+c.key),c.ref!==void 0&&(w=c.ref);for(u in c)n.call(c,u)&&!s.hasOwnProperty(u)&&(p[u]=c[u]);if(a&&a.defaultProps)for(u in c=a.defaultProps,c)p[u]===void 0&&(p[u]=c[u]);return{$$typeof:e,type:a,key:y,ref:w,props:p,_owner:i.current}}return ge.Fragment=t,ge.jsx=l,ge.jsxs=l,ge}var ye={};/**
|
|
10
33
|
* @license React
|
|
11
34
|
* react-jsx-runtime.development.js
|
|
12
35
|
*
|
|
@@ -14,17 +37,17 @@
|
|
|
14
37
|
*
|
|
15
38
|
* This source code is licensed under the MIT license found in the
|
|
16
39
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
40
|
+
*/var Yt;function ur(){return Yt||(Yt=1,process.env.NODE_ENV!=="production"&&(function(){var r=He,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),g=Symbol.iterator,b="@@iterator";function M(o){if(o===null||typeof o!="object")return null;var d=g&&o[g]||o[b];return typeof d=="function"?d:null}var A=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(o){{for(var d=arguments.length,m=new Array(d>1?d-1:0),v=1;v<d;v++)m[v-1]=arguments[v];Se("error",o,m)}}function Se(o,d,m){{var v=A.ReactDebugCurrentFrame,E=v.getStackAddendum();E!==""&&(d+="%s",m=m.concat([E]));var x=m.map(function(I){return String(I)});x.unshift("Warning: "+d),Function.prototype.apply.call(console[o],console,x)}}var pr=!1,mr=!1,gr=!1,yr=!1,vr=!1,Zt;Zt=Symbol.for("react.module.reference");function wr(o){return!!(typeof o=="string"||typeof o=="function"||o===n||o===s||vr||o===i||o===f||o===u||yr||o===w||pr||mr||gr||typeof o=="object"&&o!==null&&(o.$$typeof===y||o.$$typeof===p||o.$$typeof===l||o.$$typeof===a||o.$$typeof===c||o.$$typeof===Zt||o.getModuleId!==void 0))}function Sr(o,d,m){var v=o.displayName;if(v)return v;var E=d.displayName||d.name||"";return E!==""?m+"("+E+")":m}function Qt(o){return o.displayName||"Context"}function G(o){if(o==null)return null;if(typeof o.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case n:return"Fragment";case t:return"Portal";case s:return"Profiler";case i:return"StrictMode";case f:return"Suspense";case u:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case a:var d=o;return Qt(d)+".Consumer";case l:var m=o;return Qt(m._context)+".Provider";case c:return Sr(o,o.render,"ForwardRef");case p:var v=o.displayName||null;return v!==null?v:G(o.type)||"Memo";case y:{var E=o,x=E._payload,I=E._init;try{return G(I(x))}catch{return null}}}return null}var re=Object.assign,Ie=0,en,tn,nn,rn,sn,on,an;function ln(){}ln.__reactDisabledLog=!0;function Ir(){{if(Ie===0){en=console.log,tn=console.info,nn=console.warn,rn=console.error,sn=console.group,on=console.groupCollapsed,an=console.groupEnd;var o={configurable:!0,enumerable:!0,value:ln,writable:!0};Object.defineProperties(console,{info:o,log:o,warn:o,error:o,group:o,groupCollapsed:o,groupEnd:o})}Ie++}}function br(){{if(Ie--,Ie===0){var o={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:re({},o,{value:en}),info:re({},o,{value:tn}),warn:re({},o,{value:nn}),error:re({},o,{value:rn}),group:re({},o,{value:sn}),groupCollapsed:re({},o,{value:on}),groupEnd:re({},o,{value:an})})}Ie<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var lt=A.ReactCurrentDispatcher,ct;function Le(o,d,m){{if(ct===void 0)try{throw Error()}catch(E){var v=E.stack.trim().match(/\n( *(at )?)/);ct=v&&v[1]||""}return`
|
|
41
|
+
`+ct+o}}var ut=!1,Ae;{var Er=typeof WeakMap=="function"?WeakMap:Map;Ae=new Er}function cn(o,d){if(!o||ut)return"";{var m=Ae.get(o);if(m!==void 0)return m}var v;ut=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var x;x=lt.current,lt.current=null,Ir();try{if(d){var I=function(){throw Error()};if(Object.defineProperty(I.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(I,[])}catch(H){v=H}Reflect.construct(o,[],I)}else{try{I.call()}catch(H){v=H}o.call(I.prototype)}}else{try{throw Error()}catch(H){v=H}o()}}catch(H){if(H&&v&&typeof H.stack=="string"){for(var S=H.stack.split(`
|
|
42
|
+
`),W=v.stack.split(`
|
|
43
|
+
`),k=S.length-1,L=W.length-1;k>=1&&L>=0&&S[k]!==W[L];)L--;for(;k>=1&&L>=0;k--,L--)if(S[k]!==W[L]){if(k!==1||L!==1)do if(k--,L--,L<0||S[k]!==W[L]){var q=`
|
|
44
|
+
`+S[k].replace(" at new "," at ");return o.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",o.displayName)),typeof o=="function"&&Ae.set(o,q),q}while(k>=1&&L>=0);break}}}finally{ut=!1,lt.current=x,br(),Error.prepareStackTrace=E}var fe=o?o.displayName||o.name:"",ie=fe?Le(fe):"";return typeof o=="function"&&Ae.set(o,ie),ie}function xr(o,d,m){return cn(o,!1)}function Tr(o){var d=o.prototype;return!!(d&&d.isReactComponent)}function ze(o,d,m){if(o==null)return"";if(typeof o=="function")return cn(o,Tr(o));if(typeof o=="string")return Le(o);switch(o){case f:return Le("Suspense");case u:return Le("SuspenseList")}if(typeof o=="object")switch(o.$$typeof){case c:return xr(o.render);case p:return ze(o.type,d,m);case y:{var v=o,E=v._payload,x=v._init;try{return ze(x(E),d,m)}catch{}}}return""}var be=Object.prototype.hasOwnProperty,un={},dn=A.ReactDebugCurrentFrame;function Me(o){if(o){var d=o._owner,m=ze(o.type,o._source,d?d.type:null);dn.setExtraStackFrame(m)}else dn.setExtraStackFrame(null)}function Rr(o,d,m,v,E){{var x=Function.call.bind(be);for(var I in o)if(x(o,I)){var S=void 0;try{if(typeof o[I]!="function"){var W=Error((v||"React class")+": "+m+" type `"+I+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[I]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}S=o[I](d,I,v,m,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(k){S=k}S&&!(S instanceof Error)&&(Me(E),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",v||"React class",m,I,typeof S),Me(null)),S instanceof Error&&!(S.message in un)&&(un[S.message]=!0,Me(E),C("Failed %s type: %s",m,S.message),Me(null))}}}var Or=Array.isArray;function dt(o){return Or(o)}function Cr(o){{var d=typeof Symbol=="function"&&Symbol.toStringTag,m=d&&o[Symbol.toStringTag]||o.constructor.name||"Object";return m}}function kr(o){try{return fn(o),!1}catch{return!0}}function fn(o){return""+o}function hn(o){if(kr(o))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Cr(o)),fn(o)}var pn=A.ReactCurrentOwner,Nr={key:!0,ref:!0,__self:!0,__source:!0},mn,gn;function Lr(o){if(be.call(o,"ref")){var d=Object.getOwnPropertyDescriptor(o,"ref").get;if(d&&d.isReactWarning)return!1}return o.ref!==void 0}function Ar(o){if(be.call(o,"key")){var d=Object.getOwnPropertyDescriptor(o,"key").get;if(d&&d.isReactWarning)return!1}return o.key!==void 0}function zr(o,d){typeof o.ref=="string"&&pn.current}function Mr(o,d){{var m=function(){mn||(mn=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};m.isReactWarning=!0,Object.defineProperty(o,"key",{get:m,configurable:!0})}}function Pr(o,d){{var m=function(){gn||(gn=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};m.isReactWarning=!0,Object.defineProperty(o,"ref",{get:m,configurable:!0})}}var Dr=function(o,d,m,v,E,x,I){var S={$$typeof:e,type:o,key:d,ref:m,props:I,_owner:x};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function _r(o,d,m,v,E){{var x,I={},S=null,W=null;m!==void 0&&(hn(m),S=""+m),Ar(d)&&(hn(d.key),S=""+d.key),Lr(d)&&(W=d.ref,zr(d,E));for(x in d)be.call(d,x)&&!Nr.hasOwnProperty(x)&&(I[x]=d[x]);if(o&&o.defaultProps){var k=o.defaultProps;for(x in k)I[x]===void 0&&(I[x]=k[x])}if(S||W){var L=typeof o=="function"?o.displayName||o.name||"Unknown":o;S&&Mr(I,L),W&&Pr(I,L)}return Dr(o,S,W,E,v,pn.current,I)}}var ft=A.ReactCurrentOwner,yn=A.ReactDebugCurrentFrame;function de(o){if(o){var d=o._owner,m=ze(o.type,o._source,d?d.type:null);yn.setExtraStackFrame(m)}else yn.setExtraStackFrame(null)}var ht;ht=!1;function pt(o){return typeof o=="object"&&o!==null&&o.$$typeof===e}function vn(){{if(ft.current){var o=G(ft.current.type);if(o)return`
|
|
22
45
|
|
|
23
|
-
Check the render method of \``+o+"`."}return""}}function
|
|
46
|
+
Check the render method of \``+o+"`."}return""}}function Br(o){return""}var wn={};function $r(o){{var d=vn();if(!d){var m=typeof o=="string"?o:o.displayName||o.name;m&&(d=`
|
|
24
47
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
48
|
+
Check the top-level render call using <`+m+">.")}return d}}function Sn(o,d){{if(!o._store||o._store.validated||o.key!=null)return;o._store.validated=!0;var m=$r(d);if(wn[m])return;wn[m]=!0;var v="";o&&o._owner&&o._owner!==ft.current&&(v=" It was passed a child from "+G(o._owner.type)+"."),de(o),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,v),de(null)}}function In(o,d){{if(typeof o!="object")return;if(dt(o))for(var m=0;m<o.length;m++){var v=o[m];pt(v)&&Sn(v,d)}else if(pt(o))o._store&&(o._store.validated=!0);else if(o){var E=M(o);if(typeof E=="function"&&E!==o.entries)for(var x=E.call(o),I;!(I=x.next()).done;)pt(I.value)&&Sn(I.value,d)}}}function Fr(o){{var d=o.type;if(d==null||typeof d=="string")return;var m;if(typeof d=="function")m=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===c||d.$$typeof===p))m=d.propTypes;else return;if(m){var v=G(d);Rr(m,o.props,"prop",v,o)}else if(d.PropTypes!==void 0&&!ht){ht=!0;var E=G(d);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Jr(o){{for(var d=Object.keys(o.props),m=0;m<d.length;m++){var v=d[m];if(v!=="children"&&v!=="key"){de(o),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),de(null);break}}o.ref!==null&&(de(o),C("Invalid attribute `ref` supplied to `React.Fragment`."),de(null))}}var bn={};function En(o,d,m,v,E,x){{var I=wr(o);if(!I){var S="";(o===void 0||typeof o=="object"&&o!==null&&Object.keys(o).length===0)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var W=Br();W?S+=W:S+=vn();var k;o===null?k="null":dt(o)?k="array":o!==void 0&&o.$$typeof===e?(k="<"+(G(o.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):k=typeof o,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",k,S)}var L=_r(o,d,m,E,x);if(L==null)return L;if(I){var q=d.children;if(q!==void 0)if(v)if(dt(q)){for(var fe=0;fe<q.length;fe++)In(q[fe],o);Object.freeze&&Object.freeze(q)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else In(q,o)}if(be.call(d,"key")){var ie=G(o),H=Object.keys(d).filter(function(Ur){return Ur!=="key"}),mt=H.length>0?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}";if(!bn[ie+mt]){var Vr=H.length>0?"{"+H.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
|
|
26
49
|
let props = %s;
|
|
27
50
|
<%s {...props} />
|
|
28
51
|
React keys must be passed directly to JSX without using spread:
|
|
29
52
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
53
|
+
<%s key={someKey} {...props} />`,mt,ie,Vr,ie),bn[ie+mt]=!0}}return o===n?Jr(L):Fr(L),L}}function Wr(o,d,m){return En(o,d,m,!0)}function Hr(o,d,m){return En(o,d,m,!1)}var jr=Hr,qr=Wr;ye.Fragment=n,ye.jsx=jr,ye.jsxs=qr})()),ye}var Gt;function dr(){return Gt||(Gt=1,process.env.NODE_ENV==="production"?Ne.exports=cr():Ne.exports=ur()),Ne.exports}var ve=dr();const fr=({images:r,onAdd:e,onDelete:t,onImageClick:n,focusedImageIndex:i})=>ve.jsxs("div",{className:"batch-image-gallery",style:{display:"flex",gap:"8px",overflowX:"auto",padding:"8px"},children:[r.map((s,l)=>ve.jsxs("div",{style:{position:"relative",border:i===l?"2px solid blue":"2px solid transparent",cursor:"pointer"},onClick:()=>n(s),children:[ve.jsx("img",{src:s.src,alt:s.alt,style:{width:"80px",height:"80px",objectFit:"cover"}}),ve.jsx("button",{onClick:a=>{a.stopPropagation(),t(l)},style:{position:"absolute",top:0,right:0},children:"×"})]},s.id)),ve.jsx("button",{onClick:e,style:{width:"80px",height:"80px"},children:"+"})]});let we=null;const hr=se.Node.create({name:"batchSegmentImages",group:"block",inline:!1,atom:!0,addOptions(){return{maxImageAmount:void 0,height:void 0,onAdd:void 0,onRemove:void 0,onImageClick:void 0,initialImageRegistry:void 0}},addStorage(){return{imageRegistry:new Map(this.options.initialImageRegistry)}},addAttributes(){return{batchId:{default:null,parseHTML:r=>r.getAttribute("data-batch-id"),renderHTML:r=>({"data-batch-id":r.batchId})},id:{default:null,parseHTML:r=>r.getAttribute("data-id"),renderHTML:r=>({"data-id":r.id})},images:{default:[],parseHTML:r=>{const e=r.querySelectorAll("img"),t=[];return e.forEach(n=>{const i=n.getAttribute("data-id"),s=n.getAttribute("src"),l=n.getAttribute("alt"),a=n.getAttribute("title");i&&s&&t.push({id:i,src:s,alt:l??void 0,title:a??void 0})}),t},renderHTML:()=>({})},imageVersion:{default:0,parseHTML:()=>0,renderHTML:()=>({})},focusedImageIndex:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},addProseMirrorPlugins(){return[new le({props:{handleKeyDown(r,e){return e.key==="ArrowLeft"||e.key==="ArrowUp"?we="left":e.key==="ArrowRight"||e.key==="ArrowDown"?we="right":we=null,!1}}})]},addKeyboardShortcuts(){const r=(n,i)=>{const s=this.editor.state.tr.setNodeMarkup(n,void 0,{...i.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1);s.setSelection(F.near(s.doc.resolve(n))),this.editor.view.dispatch(s)},e=(n,i)=>{const s=n+i.nodeSize,l=this.editor.state.tr.setNodeMarkup(n,void 0,{...i.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1);l.setSelection(F.near(l.doc.resolve(s))),this.editor.view.dispatch(l)},t=n=>{var p,y;const{selection:i}=this.editor.state;if(!(i instanceof B))return!1;const s=i.node;if(s.type.name!=="batchSegmentImages")return!1;const l=((y=(p=this.editor.storage.batchSegmentImages)==null?void 0:p.imageRegistry)==null?void 0:y.get(s.attrs.batchId))??s.attrs.images;if(!l.length)return!1;const a=i.from,c=s.attrs.focusedImageIndex,f=!!this.options.onAdd;let u;if(n==="right"){if(c===null)return e(a,s),!0;if(c<l.length-1)u=c+1;else if(c===l.length-1&&f)u=null;else return e(a,s),!0}else if(c===null)u=l.length-1;else if(c>0)u=c-1;else return r(a,s),!0;if(this.editor.view.dispatch(this.editor.state.tr.setNodeMarkup(a,void 0,{...s.attrs,focusedImageIndex:u}).setMeta("addToHistory",!1)),u!==null&&u>=0&&u<l.length){const w=this.editor.view.nodeDOM(a);w instanceof HTMLElement&&requestAnimationFrame(()=>{var b;(b=w.querySelectorAll("img")[u])==null||b.scrollIntoView({block:"nearest",inline:"nearest"})})}return!0};return{ArrowLeft:()=>t("left"),ArrowRight:()=>t("right"),Space:()=>{var c,f,u,p,y,w;const{selection:n}=this.editor.state;if(!(n instanceof B))return!1;const i=n.node;if(i.type.name!=="batchSegmentImages")return!1;const s=((f=(c=this.editor.storage.batchSegmentImages)==null?void 0:c.imageRegistry)==null?void 0:f.get(i.attrs.batchId))??i.attrs.images,l=i.attrs.focusedImageIndex,a=n.from;if(l===null)return(p=(u=this.options).onAdd)==null||p.call(u,{position:"last",batchId:i.attrs.batchId,currentImages:s,getPos:()=>a,editor:this.editor}),!0;if(l>=0&&l<s.length){const g=s[l];return(w=(y=this.options).onImageClick)==null||w.call(y,{imageId:g.id,batchId:i.attrs.batchId,src:g.src,getPos:()=>a,editor:this.editor}),!0}return!1}}},renderHTML({node:r}){const e=r.attrs.images??[];return["div",{"data-batch-id":r.attrs.batchId,style:"display: flex; overflow-x: auto; gap: 10px; white-space: nowrap; padding: 10px 0;"},...e.map(t=>["img",{"data-id":t.id,src:t.src,alt:t.alt??"",title:t.title??"",style:"width: 80px; height: 80px; object-fit: cover; flex-shrink: 0;"}])]},addNodeView(){return({node:r,getPos:e,editor:t})=>{const n=this.options,i=this.storage,s=document.createElement("div");s.style.width="100%",s.classList.add("batch-segment-gallery"),i.imageRegistry.has(r.attrs.batchId)||i.imageRegistry.set(r.attrs.batchId,r.attrs.images??[]);const l=lr.createRoot(s),a={current:r};let c=null;const f=()=>{var g;(g=n.onAdd)==null||g.call(n,{position:"last",batchId:a.current.attrs.batchId,currentImages:i.imageRegistry.get(a.current.attrs.batchId)??[],getPos:e,editor:t})},u=g=>{var b,M;(M=n.onRemove)==null||M.call(n,{index:g,imageId:(b=(i.imageRegistry.get(a.current.attrs.batchId)??[])[g])==null?void 0:b.id,batchId:a.current.attrs.batchId,getPos:e,editor:t})},p=g=>{var M;const b=e();if(b!==void 0){const A=(i.imageRegistry.get(a.current.attrs.batchId)??[]).findIndex(C=>C.id===g.id);t.view.dispatch(t.state.tr.setNodeMarkup(b,void 0,{...a.current.attrs,focusedImageIndex:A}).setMeta("addToHistory",!1))}(M=n.onImageClick)==null||M.call(n,{imageId:g.id,batchId:a.current.attrs.batchId,src:g.src,getPos:e,editor:t})},y=()=>{const[g,b]=je.useState({images:i.imageRegistry.get(r.attrs.batchId)??[],focusedImageIndex:r.attrs.focusedImageIndex,batchId:r.attrs.batchId});return c=b,je.createElement(fr,{batchId:g.batchId,images:g.images,maxImageAmount:n.maxImageAmount,height:n.height,focusedImageIndex:g.focusedImageIndex,onAdd:f,onDelete:u,onImageClick:p})};l.render(je.createElement(y));let w=r;return s.addEventListener("click",()=>{const g=e();if(g!==void 0){const{state:b,view:M}=t,A=b.doc.nodeAt(g);if(!A)return;const C=b.tr.setNodeMarkup(g,void 0,{...A.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1);M.dispatch(C.setSelection(B.create(C.doc,g)))}}),{dom:s,update:g=>g.type!==r.type?!1:(g===w||(w=g,a.current=g,c==null||c({images:i.imageRegistry.get(g.attrs.batchId)??[],focusedImageIndex:g.attrs.focusedImageIndex,batchId:g.attrs.batchId})),!0),selectNode:()=>{const g=we;we=null;const b=e();if(b===void 0)return;const M=t.state.doc.nodeAt(b);if(!M||M.attrs.focusedImageIndex!==null)return;const A=g==="left"?null:0;queueMicrotask(()=>{const C=e();if(C===void 0)return;const Se=t.state.doc.nodeAt(C);!Se||Se.attrs.focusedImageIndex!==null||t.state.selection instanceof B&&t.view.dispatch(t.state.tr.setNodeMarkup(C,void 0,{...Se.attrs,focusedImageIndex:A}).setMeta("addToHistory",!1))})},deselectNode:()=>{const g=e();if(g===void 0)return;const b=t.state.doc.nodeAt(g);!b||b.attrs.focusedImageIndex===null||t.view.dispatch(t.state.tr.setNodeMarkup(g,void 0,{...b.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1))},destroy:()=>{i.imageRegistry.delete(r.attrs.batchId),queueMicrotask(()=>l.unmount())}}}},addCommands(){return{insertBatchImages:({batchId:r,images:e})=>t=>(t.editor.storage.batchSegmentImages.imageRegistry.set(r,e),t.chain().insertContent({type:"batchSegmentImages",attrs:{batchId:r,images:e,id:crypto.randomUUID()}}).run())}},parseHTML(){return[{tag:"div[data-batch-id]"}]}});h.Bold=$,h.Color=X,h.Document=Pe,h.FileHandler=gt,h.HardBreak=De,h.Heading=yt,h.Highlight=vt,h.Image=wt,h.Italic=_e,h.Link=St,Object.defineProperty(h,"BulletList",{enumerable:!0,get:()=>D.BulletList}),Object.defineProperty(h,"ListItem",{enumerable:!0,get:()=>D.ListItem}),Object.defineProperty(h,"ListKeymap",{enumerable:!0,get:()=>D.ListKeymap}),Object.defineProperty(h,"OrderedList",{enumerable:!0,get:()=>D.OrderedList}),Object.defineProperty(h,"TaskItem",{enumerable:!0,get:()=>D.TaskItem}),Object.defineProperty(h,"TaskList",{enumerable:!0,get:()=>D.TaskList}),h.Mention=It,h.Paragraph=Be,Object.defineProperty(h,"Table",{enumerable:!0,get:()=>Y.Table}),Object.defineProperty(h,"TableCell",{enumerable:!0,get:()=>Y.TableCell}),Object.defineProperty(h,"TableHeader",{enumerable:!0,get:()=>Y.TableHeader}),Object.defineProperty(h,"TableRow",{enumerable:!0,get:()=>Y.TableRow}),h.Text=$e,h.TextAlign=Fe,Object.defineProperty(h,"TextStyle",{enumerable:!0,get:()=>Je.TextStyle}),h.Underline=We,Object.defineProperty(h,"CharacterCount",{enumerable:!0,get:()=>Z.CharacterCount}),Object.defineProperty(h,"History",{enumerable:!0,get:()=>Z.UndoRedo}),Object.defineProperty(h,"Placeholder",{enumerable:!0,get:()=>Z.Placeholder}),Object.defineProperty(h,"Editor",{enumerable:!0,get:()=>Ee.Editor}),Object.defineProperty(h,"EditorContent",{enumerable:!0,get:()=>Ee.EditorContent}),Object.defineProperty(h,"useEditor",{enumerable:!0,get:()=>Ee.useEditor}),h.ALL_EXTENSIONS=ir,h.BASE_EXTENSIONS=sr,h.BatchSegmentImagesExtension=hr,h.CustomBulletList=qt,h.CustomLink=Ze,h.CustomListItem=it,h.CustomOrderedList=Vt,h.CustomParagraph=Jt,h.DynamicBulletStyling=st,h.FontSize=ot,h.ImageResize=tt,h.IndentExtension=jt,h.LineHeight=at,h.ListIndentIntegration=Ut,h.MentionStorage=or,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|