@zipify/wysiwyg 4.12.0-beta.0 → 4.12.0-beta.1

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/cli.js CHANGED
@@ -61,4 +61,4 @@ __p += '`),me&&(B+=`' +
61
61
  function print() { __p += __j.call(arguments, '') }
62
62
  `:`;
63
63
  `)+B+`return __p
64
- }`;var se=tm(function(){return be(x,j+"return "+B).apply(t,C)});if(se.source=B,Zu(se))throw se;return se}function $x(o){return _e(o).toLowerCase()}function Hx(o){return _e(o).toUpperCase()}function Wx(o,l,f){if(o=_e(o),o&&(f||l===t))return cd(o);if(!o||!(l=kt(l)))return o;var d=en(o),b=en(l),x=fd(d,b),C=hd(d,b)+1;return ir(d,x,C).join("")}function Vx(o,l,f){if(o=_e(o),o&&(f||l===t))return o.slice(0,pd(o)+1);if(!o||!(l=kt(l)))return o;var d=en(o),b=hd(d,en(l))+1;return ir(d,0,b).join("")}function Ux(o,l,f){if(o=_e(o),o&&(f||l===t))return o.replace(Zl,"");if(!o||!(l=kt(l)))return o;var d=en(o),b=fd(d,en(l));return ir(d,b).join("")}function qx(o,l){var f=te,d=Se;if(Oe(l)){var b="separator"in l?l.separator:b;f="length"in l?ie(l.length):f,d="omission"in l?kt(l.omission):d}o=_e(o);var x=o.length;if(ni(o)){var C=en(o);x=C.length}if(f>=x)return o;var M=f-ri(d);if(M<1)return d;var I=C?ir(C,0,M).join(""):o.slice(0,M);if(b===t)return I+d;if(C&&(M+=I.length-M),Qu(b)){if(o.slice(M).search(b)){var P,D=I;for(b.global||(b=mu(b.source,_e(Nh.exec(b))+"g")),b.lastIndex=0;P=b.exec(D);)var B=P.index;I=I.slice(0,B===t?M:B)}}else if(o.indexOf(kt(b),M)!=M){var q=I.lastIndexOf(b);q>-1&&(I=I.slice(0,q))}return I+d}function Kx(o){return o=_e(o),o&&rb.test(o)?o.replace(Mh,v2):o}var Gx=ci(function(o,l,f){return o+(f?" ":"")+l.toUpperCase()}),nc=np("toUpperCase");function em(o,l,f){return o=_e(o),l=f?t:l,l===t?g2(o)?C2(o):a2(o):o.match(l)||[]}var tm=ue(function(o,l){try{return Ct(o,t,l)}catch(f){return Zu(f)?f:new ne(f)}}),Jx=Mn(function(o,l){return zt(l,function(f){f=dn(f),Tn(o,f,Yu(o[f],o))}),o});function jx(o){var l=o==null?0:o.length,f=Y();return o=l?Ae(o,function(d){if(typeof d[1]!="function")throw new $t(a);return[f(d[0]),d[1]]}):[],ue(function(d){for(var b=-1;++b<l;){var x=o[b];if(Ct(x[0],this,d))return Ct(x[1],this,d)}})}function Yx(o){return v_(Wt(o,m))}function rc(o){return function(){return o}}function Xx(o,l){return o==null||o!==o?l:o}var Zx=ip(),Qx=ip(!0);function mt(o){return o}function ic(o){return Ld(typeof o=="function"?o:Wt(o,m))}function eC(o){return Dd(Wt(o,m))}function tC(o,l){return Fd(o,Wt(l,m))}var nC=ue(function(o,l){return function(f){return ts(f,o,l)}}),rC=ue(function(o,l){return function(f){return ts(o,f,l)}});function sc(o,l,f){var d=Ve(l),b=vo(l,d);f==null&&!(Oe(l)&&(b.length||!d.length))&&(f=l,l=o,o=this,b=vo(l,Ve(l)));var x=!(Oe(f)&&"chain"in f)||!!f.chain,C=In(o);return zt(b,function(M){var I=l[M];o[M]=I,C&&(o.prototype[M]=function(){var P=this.__chain__;if(x||P){var D=o(this.__wrapped__),B=D.__actions__=ht(this.__actions__);return B.push({func:I,args:arguments,thisArg:o}),D.__chain__=P,D}return I.apply(o,Zn([this.value()],arguments))})}),o}function iC(){return Xe._===this&&(Xe._=O2),this}function oc(){}function sC(o){return o=ie(o),ue(function(l){return Bd(l,o)})}var oC=Fu(Ae),aC=Fu(sd),lC=Fu(lu);function nm(o){return Uu(o)?uu(dn(o)):B_(o)}function uC(o){return function(l){return o==null?t:Rr(o,l)}}var cC=op(),fC=op(!0);function ac(){return[]}function lc(){return!1}function hC(){return{}}function dC(){return""}function pC(){return!0}function mC(o,l){if(o=ie(o),o<1||o>Yn)return[];var f=xt,d=nt(o,xt);l=Y(l),o-=xt;for(var b=hu(d,l);++f<o;)l(f);return b}function gC(o){return re(o)?Ae(o,dn):Tt(o)?[o]:ht(Sp(_e(o)))}function yC(o){var l=++A2;return _e(o)+l}var bC=To(function(o,l){return o+l},0),_C=Bu("ceil"),wC=To(function(o,l){return o/l},1),vC=Bu("floor");function SC(o){return o&&o.length?wo(o,mt,xu):t}function xC(o,l){return o&&o.length?wo(o,Y(l,2),xu):t}function CC(o){return ld(o,mt)}function EC(o,l){return ld(o,Y(l,2))}function kC(o){return o&&o.length?wo(o,mt,Tu):t}function TC(o,l){return o&&o.length?wo(o,Y(l,2),Tu):t}var AC=To(function(o,l){return o*l},1),MC=Bu("round"),OC=To(function(o,l){return o-l},0);function IC(o){return o&&o.length?fu(o,mt):0}function NC(o,l){return o&&o.length?fu(o,Y(l,2)):0}return w.after=eS,w.ary=Rp,w.assign=HS,w.assignIn=Gp,w.assignInWith=$o,w.assignWith=WS,w.at=VS,w.before=Lp,w.bind=Yu,w.bindAll=Jx,w.bindKey=Pp,w.castArray=hS,w.chain=Op,w.chunk=vw,w.compact=Sw,w.concat=xw,w.cond=jx,w.conforms=Yx,w.constant=rc,w.countBy=Iv,w.create=US,w.curry=Dp,w.curryRight=Fp,w.debounce=Bp,w.defaults=qS,w.defaultsDeep=KS,w.defer=tS,w.delay=nS,w.difference=Cw,w.differenceBy=Ew,w.differenceWith=kw,w.drop=Tw,w.dropRight=Aw,w.dropRightWhile=Mw,w.dropWhile=Ow,w.fill=Iw,w.filter=Rv,w.flatMap=Dv,w.flatMapDeep=Fv,w.flatMapDepth=Bv,w.flatten=kp,w.flattenDeep=Nw,w.flattenDepth=Rw,w.flip=rS,w.flow=Zx,w.flowRight=Qx,w.fromPairs=Lw,w.functions=QS,w.functionsIn=ex,w.groupBy=zv,w.initial=Dw,w.intersection=Fw,w.intersectionBy=Bw,w.intersectionWith=zw,w.invert=nx,w.invertBy=rx,w.invokeMap=Hv,w.iteratee=ic,w.keyBy=Wv,w.keys=Ve,w.keysIn=pt,w.map=Lo,w.mapKeys=sx,w.mapValues=ox,w.matches=eC,w.matchesProperty=tC,w.memoize=Do,w.merge=ax,w.mergeWith=Jp,w.method=nC,w.methodOf=rC,w.mixin=sc,w.negate=Fo,w.nthArg=sC,w.omit=lx,w.omitBy=ux,w.once=iS,w.orderBy=Vv,w.over=oC,w.overArgs=sS,w.overEvery=aC,w.overSome=lC,w.partial=Xu,w.partialRight=zp,w.partition=Uv,w.pick=cx,w.pickBy=jp,w.property=nm,w.propertyOf=uC,w.pull=Vw,w.pullAll=Ap,w.pullAllBy=Uw,w.pullAllWith=qw,w.pullAt=Kw,w.range=cC,w.rangeRight=fC,w.rearg=oS,w.reject=Gv,w.remove=Gw,w.rest=aS,w.reverse=Ju,w.sampleSize=jv,w.set=hx,w.setWith=dx,w.shuffle=Yv,w.slice=Jw,w.sortBy=Qv,w.sortedUniq=tv,w.sortedUniqBy=nv,w.split=Dx,w.spread=lS,w.tail=rv,w.take=iv,w.takeRight=sv,w.takeRightWhile=ov,w.takeWhile=av,w.tap=Sv,w.throttle=uS,w.thru=Ro,w.toArray=Up,w.toPairs=Yp,w.toPairsIn=Xp,w.toPath=gC,w.toPlainObject=Kp,w.transform=px,w.unary=cS,w.union=lv,w.unionBy=uv,w.unionWith=cv,w.uniq=fv,w.uniqBy=hv,w.uniqWith=dv,w.unset=mx,w.unzip=ju,w.unzipWith=Mp,w.update=gx,w.updateWith=yx,w.values=di,w.valuesIn=bx,w.without=pv,w.words=em,w.wrap=fS,w.xor=mv,w.xorBy=gv,w.xorWith=yv,w.zip=bv,w.zipObject=_v,w.zipObjectDeep=wv,w.zipWith=vv,w.entries=Yp,w.entriesIn=Xp,w.extend=Gp,w.extendWith=$o,sc(w,w),w.add=bC,w.attempt=tm,w.camelCase=Sx,w.capitalize=Zp,w.ceil=_C,w.clamp=_x,w.clone=dS,w.cloneDeep=mS,w.cloneDeepWith=gS,w.cloneWith=pS,w.conformsTo=yS,w.deburr=Qp,w.defaultTo=Xx,w.divide=wC,w.endsWith=xx,w.eq=nn,w.escape=Cx,w.escapeRegExp=Ex,w.every=Nv,w.find=Lv,w.findIndex=Cp,w.findKey=GS,w.findLast=Pv,w.findLastIndex=Ep,w.findLastKey=JS,w.floor=vC,w.forEach=Ip,w.forEachRight=Np,w.forIn=jS,w.forInRight=YS,w.forOwn=XS,w.forOwnRight=ZS,w.get=ec,w.gt=bS,w.gte=_S,w.has=tx,w.hasIn=tc,w.head=Tp,w.identity=mt,w.includes=$v,w.indexOf=Pw,w.inRange=wx,w.invoke=ix,w.isArguments=Dr,w.isArray=re,w.isArrayBuffer=wS,w.isArrayLike=dt,w.isArrayLikeObject=Le,w.isBoolean=vS,w.isBuffer=sr,w.isDate=SS,w.isElement=xS,w.isEmpty=CS,w.isEqual=ES,w.isEqualWith=kS,w.isError=Zu,w.isFinite=TS,w.isFunction=In,w.isInteger=$p,w.isLength=Bo,w.isMap=Hp,w.isMatch=AS,w.isMatchWith=MS,w.isNaN=OS,w.isNative=IS,w.isNil=RS,w.isNull=NS,w.isNumber=Wp,w.isObject=Oe,w.isObjectLike=Ie,w.isPlainObject=ls,w.isRegExp=Qu,w.isSafeInteger=LS,w.isSet=Vp,w.isString=zo,w.isSymbol=Tt,w.isTypedArray=hi,w.isUndefined=PS,w.isWeakMap=DS,w.isWeakSet=FS,w.join=$w,w.kebabCase=kx,w.last=Ut,w.lastIndexOf=Hw,w.lowerCase=Tx,w.lowerFirst=Ax,w.lt=BS,w.lte=zS,w.max=SC,w.maxBy=xC,w.mean=CC,w.meanBy=EC,w.min=kC,w.minBy=TC,w.stubArray=ac,w.stubFalse=lc,w.stubObject=hC,w.stubString=dC,w.stubTrue=pC,w.multiply=AC,w.nth=Ww,w.noConflict=iC,w.noop=oc,w.now=Po,w.pad=Mx,w.padEnd=Ox,w.padStart=Ix,w.parseInt=Nx,w.random=vx,w.reduce=qv,w.reduceRight=Kv,w.repeat=Rx,w.replace=Lx,w.result=fx,w.round=MC,w.runInContext=O,w.sample=Jv,w.size=Xv,w.snakeCase=Px,w.some=Zv,w.sortedIndex=jw,w.sortedIndexBy=Yw,w.sortedIndexOf=Xw,w.sortedLastIndex=Zw,w.sortedLastIndexBy=Qw,w.sortedLastIndexOf=ev,w.startCase=Fx,w.startsWith=Bx,w.subtract=OC,w.sum=IC,w.sumBy=NC,w.template=zx,w.times=mC,w.toFinite=Nn,w.toInteger=ie,w.toLength=qp,w.toLower=$x,w.toNumber=qt,w.toSafeInteger=$S,w.toString=_e,w.toUpper=Hx,w.trim=Wx,w.trimEnd=Vx,w.trimStart=Ux,w.truncate=qx,w.unescape=Kx,w.uniqueId=yC,w.upperCase=Gx,w.upperFirst=nc,w.each=Ip,w.eachRight=Np,w.first=Tp,sc(w,function(){var o={};return fn(w,function(l,f){ve.call(w.prototype,f)||(o[f]=l)}),o}(),{chain:!1}),w.VERSION=r,zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){w[o].placeholder=w}),zt(["drop","take"],function(o,l){fe.prototype[o]=function(f){f=f===t?1:ze(ie(f),0);var d=this.__filtered__&&!l?new fe(this):this.clone();return d.__filtered__?d.__takeCount__=nt(f,d.__takeCount__):d.__views__.push({size:nt(f,xt),type:o+(d.__dir__<0?"Right":"")}),d},fe.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),zt(["filter","map","takeWhile"],function(o,l){var f=l+1,d=f==Ft||f==We;fe.prototype[o]=function(b){var x=this.clone();return x.__iteratees__.push({iteratee:Y(b,3),type:f}),x.__filtered__=x.__filtered__||d,x}}),zt(["head","last"],function(o,l){var f="take"+(l?"Right":"");fe.prototype[o]=function(){return this[f](1).value()[0]}}),zt(["initial","tail"],function(o,l){var f="drop"+(l?"":"Right");fe.prototype[o]=function(){return this.__filtered__?new fe(this):this[f](1)}}),fe.prototype.compact=function(){return this.filter(mt)},fe.prototype.find=function(o){return this.filter(o).head()},fe.prototype.findLast=function(o){return this.reverse().find(o)},fe.prototype.invokeMap=ue(function(o,l){return typeof o=="function"?new fe(this):this.map(function(f){return ts(f,o,l)})}),fe.prototype.reject=function(o){return this.filter(Fo(Y(o)))},fe.prototype.slice=function(o,l){o=ie(o);var f=this;return f.__filtered__&&(o>0||l<0)?new fe(f):(o<0?f=f.takeRight(-o):o&&(f=f.drop(o)),l!==t&&(l=ie(l),f=l<0?f.dropRight(-l):f.take(l-o)),f)},fe.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},fe.prototype.toArray=function(){return this.take(xt)},fn(fe.prototype,function(o,l){var f=/^(?:filter|find|map|reject)|While$/.test(l),d=/^(?:head|last)$/.test(l),b=w[d?"take"+(l=="last"?"Right":""):l],x=d||/^find/.test(l);b&&(w.prototype[l]=function(){var C=this.__wrapped__,M=d?[1]:arguments,I=C instanceof fe,P=M[0],D=I||re(C),B=function(ce){var me=b.apply(w,Zn([ce],M));return d&&q?me[0]:me};D&&f&&typeof P=="function"&&P.length!=1&&(I=D=!1);var q=this.__chain__,j=!!this.__actions__.length,X=x&&!q,se=I&&!j;if(!x&&D){C=se?C:new fe(this);var Z=o.apply(C,M);return Z.__actions__.push({func:Ro,args:[B],thisArg:t}),new Ht(Z,q)}return X&&se?o.apply(this,M):(Z=this.thru(B),X?d?Z.value()[0]:Z.value():Z)})}),zt(["pop","push","shift","sort","splice","unshift"],function(o){var l=io[o],f=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",d=/^(?:pop|shift)$/.test(o);w.prototype[o]=function(){var b=arguments;if(d&&!this.__chain__){var x=this.value();return l.apply(re(x)?x:[],b)}return this[f](function(C){return l.apply(re(C)?C:[],b)})}}),fn(fe.prototype,function(o,l){var f=w[l];if(f){var d=f.name+"";ve.call(ai,d)||(ai[d]=[]),ai[d].push({name:l,func:f})}}),ai[ko(t,g).name]=[{name:"wrapper",func:t}],fe.prototype.clone=K2,fe.prototype.reverse=G2,fe.prototype.value=J2,w.prototype.at=xv,w.prototype.chain=Cv,w.prototype.commit=Ev,w.prototype.next=kv,w.prototype.plant=Av,w.prototype.reverse=Mv,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=Ov,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=Tv),w},ii=E2();Ar?((Ar.exports=ii)._=ii,iu._=ii):Xe._=ii}).call(RI)}(Ws,Ws.exports)),Ws.exports}var By=LI();function bh(n){return n.type.create(By.cloneDeep(n.attrs))}function _h({tr:n,node:e,position:t,mark:r}){return e.isText?n.removeMark(t,t+e.nodeSize,r):n.removeNodeMark(t,r)}const PI=Re.create({name:"node_processor",addCommands(){return{setBlockAttributes:W(({commands:n,state:e},t,r,i={})=>{const s=H(n.getBlockAttributes(t))??{},{doc:a,tr:u}=e,{from:c,to:h}=u.selection;a.nodesBetween(c,h,(p,m)=>{Nf.includes(p.type.name)&&u.setNodeAttribute(m,t,{...i,...s,...r})})}),getBlockAttributes:W(({editor:n},e,t)=>ge(()=>{let r=Object.assign({},t||{});for(const i of Nf)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:W(({commands:n},e)=>{for(const t of Nf)n.resetAttributes(t,e)}),applyMark:W(({state:n,commands:e},t,r,i={})=>{const{tr:s,doc:a,schema:u}=n,{$from:c,$to:h}=s.selection,p=mn(ke.LINK,u),m=mn(t,u);if(!(m.spec.group||"").includes(Rt.SETTINGS))return e.setMark(t,r);if(c.pos===h.pos)return;const _=S=>{if(!i.onAppliedToParent||i.onAppliedToParent(S)===!1){const{tr:E,node:N,position:g,mark:v}=S;_h({tr:E,node:N,position:g,mark:v.type})}};a.nodesBetween(c.pos,h.pos,(S,E)=>{if(S.type.name===oe.LIST)return;const N=NI(S.marks,t),g=m.create({...N?.attrs||{},...r}),v=Py(c,h,S,E);if(!p.isInSet(S.marks)&&II(s.doc,E,g,i.isAppliedToParent))return _({tr:s,node:S,position:E,mark:g});if(S.isText){s.addMark(v.from,v.to,g);return}MI(s.doc,s.selection,S,E)&&s.addNodeMark(E,g)})}),getMarks:W(({editor:n},e)=>{const t=yi(n,"state");return ge(()=>{const{selection:r,doc:i}=H(t),{from:s,to:a}=H(r),u=[];return i.nodesBetween(s,a,c=>{for(const h of c.marks)h.type.name===e&&u.unshift(h.attrs)}),u})}),getMark:W(({commands:n},e)=>{const t=n.getMarks(e);return ge(()=>H(t)[0]??null)}),hasMark:W(({commands:n},e)=>{const t=n.getMark(e);return ge(()=>!!H(t))}),getCommonSettingMark:W(({commands:n},e,t)=>{const r=n.getMark(e);return ge(()=>H(r)?.value??H(t))}),getDeviceSettingMark:W(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return ge(()=>{for(const s of H(r)){const a=s[H(i)];if(a)return a}return H(t)})}),removeAllMarks:W(({state:n})=>{const{tr:e,doc:t}=n,{from:r,to:i}=e.selection;t.nodesBetween(r,i,(s,a)=>{for(const u of s.marks)_h({tr:e,node:s,position:a,mark:u})})}),removeMarks:W(({state:n},e)=>{const{tr:t,doc:r}=n,{from:i,to:s}=t.selection;r.nodesBetween(i,s,(a,u)=>{const c=a.marks.filter(h=>e.includes(h.type.name));for(const h of c)_h({tr:t,node:a,position:u,mark:h})})})}}}),DI=Re.create({name:"text_processor",addCommands(){return{getSelectedText:W(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:W(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,s)=>{if(!i.isText)return;const a=Py(t,r,i,s),u=Math.max(0,t.pos-s),c=Math.max(0,r.pos-s),h=e({text:i.textContent.substring(u,c)}),p=n.schema.text(h,i.marks);n.tr.replaceWith(a.from,a.to,p)})})}}}),FI=Re.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:W(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:W(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:W(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;return n.doc.nodesBetween(r,i,(s,a,u)=>{if(t({node:s,parent:u})){const c=s.isText?0:Dy(n.doc,a);r=Math.min(r,a+c),i=Math.max(i,a+s.nodeSize-c)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:W(({commands:n})=>n.expandSelection(({parent:e})=>e.type.name===oe.DOCUMENT))}}}),BI=jn.create({name:"doc",topNode:!0,content:"block+"});class Ks extends Ue{constructor(e,t,r,i="SetDocAttr"){super(),this.key=e,this.value=t,this.schema=r,this.stepType=i}apply(e){this.prevValue=e.attrs.meta[this.key];const t=fr.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,De.ok(t)}invert(){return new Ks(this.key,this.prevValue,this.schema,"revertSetDocAttr")}map(){return null}toJSON(){return{stepType:this.stepType,key:this.key,value:this.value}}static fromJSON(e){return new Ks(e.key,e.value,e.stepType)}}Ue.jsonID("setDocAttr",Ks);const zI=BI.extend({marks:Rt.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:W(({state:n},e,t)=>{n.tr.step(new Ks(e,t,n.schema))})}}}),$I=jn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Mi(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),HI=$I.extend({marks:Rt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),WI=jn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Mi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>mM({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),VI=WI.extend({marks:Rt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),UI=Re.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[RM.create(this.editor),LM.create(this.editor)]}}),qI=()=>[zI,HI,VI,bM,AM,PI,DI,FI,UI],KI=wt.create({name:ke.FONT_FAMILY,group:Rt.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:W(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=H(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ke.FONT_STYLE).value;t.isItalicOnly?n.applyItalic():!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:W(({commands:n})=>{const e=H(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return ge(()=>n.findFontByName(H(r))||t)}),findFontByName:W((n,e)=>H(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:W(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:W(({commands:n})=>{const e=n.getPreset();return ge(()=>H(e).common.font_family)})}},parseHTML(){const n=e=>({value:e.replace(/["']/g,"")});return[{style:"--zw-font-family",getAttrs:n},{style:"font-family",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.value?`"${n.value}"`:null;return xr({font_family:e})}}),GI=Re.create({name:ke.STYLE_PRESET,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{preset:{isRequired:!1,default:{id:H(this.options.defaultId)},parseHTML:n=>{const e=H(this.options.presets);if(n.parentElement.tagName==="LI")return null;for(const{id:t,node:r,fallbackClass:i}of e){if(i&&n.classList.contains(i))return{id:t};const s=H(this.options.styleRenderer).makePresetCssClass({id:t});if(n.matches(s))return{id:t};if(n.tagName===`H${r?.level}`)return{id:t}}return n.tagName==="P"?{id:H(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:H(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const s of Object.keys(t)){const a=t[s],u=r[s],c=!u||u.toLowerCase()==="inherit";i[s]=c?a:u}return i}return{getPresetList:W(()=>ge(()=>H(this.options.presets).filter(t=>!t.hidden))),getPreset:W(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:H(this.options.defaultId)}),i=t.getPresetList(),s=t.isLink(),a=t.getLinkPreset();return ge(()=>{const u=n(H(i),H(r).id);if(!H(s))return u;const c=H(a);return{id:u.id,common:e(u.common,c.common),mobile:e(u.mobile,c.mobile),tablet:e(u.tablet,c.tablet),desktop:e(u.desktop,c.desktop)}})}),applyPreset:W(({commands:t,chain:r},i)=>{const s=H(t.getPresetList()),a=n(s,i),u=a.node?.type??oe.PARAGRAPH,c={preset:{id:i}};a.node&&(c.level=a.node.level);for(const h of p1)c[h]=H(t.getBlockAttributes(h));r().removeList().setNode(u,c).run()}),applyDefaultPreset:W(({commands:t})=>{t.applyPreset(H(this.options.defaultId))}),removePreset:W(({commands:t})=>{t.setNode(oe.PARAGRAPH,{preset:null})}),getPresetCustomization:W(({editor:t,commands:r})=>{const i=yi(t,"state");return ge(()=>{const{selection:s,doc:a}=H(i),{from:u,to:c}=s;return r._getSettingCustomization(a,u,c)})}),isSettingCustomized:W(({commands:t},r)=>{const i=t.getPresetCustomization(),s=qa.includes(r)?"attributes":"marks";return ge(()=>H(i)[s]?.includes(r)??!1)}),getContentCustomization:W(({editor:t,commands:r})=>{const i=yi(t,"state");return ge(()=>{const{doc:s}=H(i);return r._getSettingCustomization(s,0,s.content.size)})}),_getSettingCustomization:W((t,r,i,s)=>{const a=new Set,u=new Set;return r.nodesBetween(i,s,c=>{for(const[h,p]of Object.entries(c.attrs))qa.includes(h)&&p&&u.add(h);for(const{type:h}of c.marks)g1.includes(h.name)&&a.add(h.name)}),{attributes:Array.from(u),marks:Array.from(a)}}),removePresetCustomization:W(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(g1).resetAttributes(oe.PARAGRAPH,qa).resetAttributes(oe.HEADING,qa).restoreSelection().run()}),removeFormat:W(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Pi.head,H(this.options.presets))}}),JI=wt.create({name:ke.FONT_WEIGHT,group:Rt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:W(({commands:n},e)=>{n.applyMark(this.name,{value:e}),H(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:W(({commands:n})=>{const e=H(n.getFontWeight()),t=H(n.getFont()),i=Number(e)>=600?"400":"700",s=t.findClosestWeight(i);n.applyFontWeight(s)}),getFontWeight:W(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return ge(()=>{const r=H(e),i=H(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:W(({commands:n})=>{const e=n.getPreset();return ge(()=>H(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Yt("toggleBold"),"Mod-B":Yt("toggleBold")}),parseHTML(){const n=e=>e==="bold"?{value:"700"}:Number(e)?{value:e}:!1;return[{style:"--zw-font-weight",getAttrs:n},{style:"font-weight",getAttrs:n},{tag:"b",attrs:{value:"700"}},{tag:"strong",attrs:{value:"700"}}]},renderHTML({HTMLAttributes:n}){return xr({font_weight:n.value})}}),jI=wt.create({name:ke.FONT_SIZE,group:Rt.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:W(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].font_size.replace("px",""))}),applyFontSize:W(({commands:n},e)=>{const t=H(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:s,mark:a})=>{const u={...a.attrs,[t]:null};if(!Object.values(u).some(p=>!!p))return!1;const h=a.type.create(u);if(i.isText){r.addMark(s,s+i.nodeSize,h);return}r.addNodeMark(s,h)}})}),increaseFontSize:W(({commands:n})=>{const e=Number(H(n.getFontSize())),t=Math.min(e+1,H(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:W(({commands:n})=>{const e=Number(H(n.getFontSize())),t=Math.max(e-1,H(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Yt("increaseFontSize"),"Mod-Shift--":Yt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=H(this.options.wrapperRef),r=Ly(e,t);return String(r)};return[{tag:'[style*="--zw-font-size"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-font-size-mobile")),tablet:n(e.getPropertyValue("--zw-font-size-tablet")),desktop:n(e.getPropertyValue("--zw-font-size-desktop"))})},{style:"font-size",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:null}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return xr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),YI=wt.create({name:ke.FONT_COLOR,group:Rt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:W(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:W(({commands:n})=>{const e=n.getPreset();return ge(()=>H(e).common.color)}),applyFontColor:W(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:Ny(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return xr({font_color:n.value})}}),XI=wt.create({name:ke.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:W(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:W(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:Ny(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return xr({background_color:n.value})}}),ZI=Re.create({name:"device_manager",addCommands(){return{getDevice:W(()=>yi(this.options,"device"))}}}),QI=wt.create({name:ke.FONT_STYLE,group:Rt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return ge(()=>H(e)?.italic??H(t).italic)}),isItalicAvailable:W(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return ge(()=>{const r=H(e),i=H(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:W(({commands:n})=>{const e=n.getPreset();return ge(()=>({italic:H(e).common.font_style==="italic"}))}),toggleItalic:W(({commands:n})=>{H(n.isItalicAvailable())&&(H(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:W(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:W(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Yt("toggleItalic"),"Mod-I":Yt("toggleItalic")}),parseHTML(){const n=e=>({italic:e.includes("italic")});return[{tag:"i",attrs:{italic:!0}},{style:"--zw-font-style",getAttrs:n},{style:"font-style",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.italic?"italic":"normal";return xr({font_style:e})}}),eN=wt.create({name:ke.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>H(e).underline)}),isStrikeThrough:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>H(e).strike_through)}),getTextDecoration:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return ge(()=>{const r=H(e)??{},i=H(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:W(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return ge(()=>H(e)!==H(t).underline)}),getDefaultTextDecoration:W(({commands:n})=>{const e=n.getPreset();return ge(()=>{const{text_decoration:t}=H(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:W(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:W(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:W(({commands:n},e,t=null)=>{const r=H(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:W(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:W(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Yt("toggleUnderline"),"Mod-U":Yt("toggleUnderline")}),parseHTML(){const n=e=>{const t=e.includes("underline"),r=e.includes("line-through");return!t&&!r?!1:{underline:t,strike_through:r}};return[{style:"--zw-text-decoration",getAttrs:n},{style:"text-decoration-line",getAttrs:n},{style:"text-decoration",getAttrs:n},{tag:"s",attrs:{underline:!1,strike_through:!0}},{tag:"u",attrs:{underline:!0,strike_through:!1}}]},renderHTML({HTMLAttributes:n}){const e=[];return n.underline&&e.push("underline"),n.strike_through&&e.push("line-through"),e.length||e.push("none"),xr({text_decoration:e.join(" ")})}}),tN=Re.create({name:"case_style",addCommands(){return{applyCaseStyle:W(({commands:n},e)=>{switch(e){case Ua.CAPITALIZE:return n.applyCapitalize();case Ua.LOWERCASE:return n.applyLowerCase();case Ua.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:W(({commands:n})=>{n.transformText(({text:e})=>eO(e))}),applyLowerCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),zy={mobile:null,tablet:null,desktop:null},nN=Re.create({name:ke.ALIGNMENT,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[ke.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=AI(n.textAlign);if(e)return{desktop:e,tablet:e,mobile:e};const t=n.getPropertyValue("--zw-alignment-mobile")||null,r=n.getPropertyValue("--zw-alignment-tablet")||null,i=n.getPropertyValue("--zw-alignment-desktop")||null;return!t&&!r&&!i?null:{desktop:i,tablet:r,mobile:t}},renderHTML(n){return n.alignment?Cl({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:W(({commands:n},e)=>{const t=H(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},zy)}),removeAlignment:W(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:W(({commands:n})=>{const e=n.getBlockAttributes(this.name,zy),t=n.getDevice(),r=n.getDefaultAlignment();return ge(()=>H(e)?.[H(t)]??H(r))}),getDefaultAlignment:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].alignment??_r.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Yt("applyAlignment",_r.LEFT),"Mod-Shift-e":Yt("applyAlignment",_r.CENTER),"Mod-Shift-r":Yt("applyAlignment",_r.RIGHT),"Mod-Shift-j":Yt("applyAlignment",_r.JUSTIFY)})}),$y={mobile:null,tablet:null,desktop:null},rN=Re.create({name:ke.LINE_HEIGHT,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[ke.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const s=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:s,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=H(this.options.wrapperRef),r=EI(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?Cl({line_height_mobile:n.line_height.mobile,line_height_tablet:n.line_height.tablet,line_height_desktop:n.line_height.desktop}):null}}}}]},addCommands(){return{getLineHeight:W(({commands:n})=>{const e=n.getBlockAttributes(this.name,$y),t=n.getDevice(),r=n.getDefaultLineHeight();return ge(()=>H(e)?.[H(t)]??H(r))}),getDefaultLineHeight:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].line_height)}),applyLineHeight:W(({commands:n},e)=>{const t=H(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},$y)})}}}),iN=wt.create({name:ke.LETTER_SPACING,group:Rt.SETTINGS,addAttributes:()=>({mobile:{default:null},tablet:{default:null},desktop:{default:null}}),addCommands(){return{getLetterSpacing:W(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultLetterSpacing())),getDefaultLetterSpacing:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].letter_spacing||null)}),applyLetterSpacing:W(({commands:n},e)=>{const t=H(n.getDevice());n.applyMark(this.name,{[t]:e})})}},parseHTML(){const n=e=>{if(!e)return null;const t=H(this.options.wrapperRef);return`${kI(e,t)}px`};return[{tag:'[style*="--zw-letter-spacing"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-letter-spacing-mobile")),tablet:n(e.getPropertyValue("--zw-letter-spacing-tablet")),desktop:n(e.getPropertyValue("--zw-letter-spacing-desktop"))})},{style:"letter-spacing",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:t}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return xr({letter_spacing_mobile:e(n.mobile),letter_spacing_tablet:e(n.tablet),letter_spacing_desktop:e(n.desktop)})}}),sN=jn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Mi(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),oN=sN.extend({name:oe.LIST_ITEM,marks:Rt.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:W(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const s=n(t);for(const a of r.marks)t.addNodeMark(s,bh(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===oe.LIST))return t.listItemNewline()}})});function aN(n,e){if(m1.includes(e.type)||e.type.isInSet(n.marks))return!1;for(const t of n.content.content)if(t.childCount&&(!t.marks||!e.isInSet(t.marks)))return!1;return!0}function lN(n){const e=n.selection.$from.start(),t=n.selection.$to.end();n.doc.nodesBetween(e,t,(r,i)=>{if(r.type.name===oe.LIST)return;if(r.type.name!==oe.LIST_ITEM)return!1;const s=[];return r.forEach(a=>{for(const u of a.marks){if(u.isInSet(s)){n.removeNodeMark(i+1,u);continue}aN(r,u)&&(n.removeNodeMark(i+1,u),n.addNodeMark(i,bh(u)),s.push(u))}}),!1})}const uN=jn.create({name:oe.LIST,content:`${oe.LIST_ITEM}+`,group:"block list",marks:Rt.SETTINGS,addExtensions:()=>[oN],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:an.DISC}}}),parseHTML(){const n={a:an.ROMAN,i:an.LATIN,1:an.DECIMAL},e=t=>{for(const r of IM){const i=`.${H(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||an.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||an.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[H(this.options.baseClass)+n.bullet.type,H(this.options.presetClass)];return[NM.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:W(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return ge(()=>H(e).type??null)}),applyList:W(({commands:n,chain:e},t)=>H(n.getListType())===t?n.removeList():e().applyDefaultPreset().toggleList(oe.LIST,oe.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({tr:i})=>lN(i)).run()),removeList:W(({chain:n})=>n().expandSelection(({parent:e})=>e.type.name===oe.LIST).command(({tr:e})=>{const t=e.selection.$from.start(),r=e.selection.$to.end();return e.doc.nodesBetween(t,r,(i,s,a)=>{if([oe.LIST,oe.LIST_ITEM].includes(i.type.name))return;if(a.type.name!==oe.LIST_ITEM)return!1;const u=a.marks.filter(c=>!c.type.isInSet(i.marks));for(const c of u)e.addNodeMark(s,bh(c));return!1}),!0}).liftListItem(oe.LIST_ITEM).run())}},addInputRules(){const n=(e,t)=>gM({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(an.DISC,/^\s*([-+*])\s$/),n(an.DECIMAL,/^(\d+)\.\s$/),n(an.LATIN,/^([ivx]{1,3})\.\s$/i),n(an.ROMAN,/^([a-z])\.\s$/i)]}});function cN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function fN(n){return new ct({key:new It("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(h=>h.docChanged)&&!t.doc.eq(r.doc),s=e.some(h=>h.getMeta("preventAutolink"));if(!i||s)return;const{tr:a}=r,u=BA(t.doc,[...e]);if(GA(u).forEach(({newRange:h})=>{const p=$A(r.doc,h,_=>_.isTextblock);let m,y;if(p.length>1?(m=p[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ")):p.length&&r.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(m=p[0],y=r.doc.textBetween(m.pos,h.to,void 0," ")),m&&y){const _=y.split(" ").filter(g=>g!=="");if(_.length<=0)return!1;const S=_[_.length-1],E=m.pos+y.lastIndexOf(S);if(!S)return!1;const N=xl(S).map(g=>g.toObject(n.defaultProtocol));if(!cN(N))return!1;N.filter(g=>g.isLink).map(g=>({...g,from:E+g.start+1,to:E+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).filter(g=>n.shouldAutoLink(g.value)).forEach(g=>{i1(g.from,g.to,r.doc).some(v=>v.mark.type===n.type)||a.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!a.steps.length)return a}})}function hN(n){return new ct({key:new It("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let a=r.target;const u=[];for(;a.nodeName!=="DIV";)u.push(a),a=a.parentNode;if(!u.find(y=>y.nodeName==="A"))return!1;const c=UA(e.state,n.type.name),h=r.target,p=(i=h?.href)!==null&&i!==void 0?i:c.href,m=(s=h?.target)!==null&&s!==void 0?s:c.target;return h&&p?(window.open(p,m),!0):!1}}})}function dN(n){return new ct({key:new It("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:s}=i,{empty:a}=s;if(a)return!1;let u="";r.content.forEach(h=>{u+=h.textContent});const c=N1(u,{defaultProtocol:n.defaultProtocol}).find(h=>h.isLink&&h.value===u);return!u||!c?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}const pN=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function Yr(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(pN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const mN=wt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){I1(n);return}I1(n.scheme,n.optionalSlashes)})},onDestroy(){YM()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Yr(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Yr(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Yr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Mi(this.options.HTMLAttributes,n),0]:["a",Mi(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Yr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Yr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[yM({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=N1(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!Yr(a,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>e.push({text:s.value,data:{href:s.href},index:s.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(fN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Yr(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(hN({type:this.type})),this.options.linkOnPaste&&n.push(dN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),gN=mN.extend({name:ke.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:Rf.SELF,parseHTML:n=>n.getAttribute("target")||Rf.SELF},destination:{default:Oi.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Oi.URL;const t=e.replace("#","");return H(this.options.pageBlocks).find(s=>s.id===parseInt(t))?Oi.BLOCK:Oi.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:W(({commands:e,chain:t},r)=>(e.setMeta("preventAutolink",!0),e.getSelectedText()?t().applyMark(this.name,r).expandSelectionToLink().command(({tr:i})=>(r.text&&i.insertText(r.text,i.selection.from,i.selection.to),!0)).run():e.insertContent(Wy.text(r.text,[Wy.mark(ke.LINK,r)])))),expandSelectionToLink:W(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:W(({commands:e})=>e.hasMark(this.name)),getLinkPreset:W(()=>ge(()=>H(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),QM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Oi.BLOCK?`#${n.href}`:n.href,t=H(this.options.basePresetClass)+H(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),yN=wt.create({name:ke.SUPERSCRIPT,addCommands(){return{applySuperscript:W(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:W(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:W(({commands:n})=>{H(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:W(({commands:n})=>{const e=n.getMark(this.name);return ge(()=>!!H(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),bN=Re.create({name:ke.MARGIN,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[ke.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:s}=n.style;return[e,t,r,i,s].some(c=>!!c)?e?{value:e}:{value:[t||0,r||0,i||0,s||0].join(" ")}:null},renderHTML(n){return n.margin?Cl({margin:n.margin.value}):null}}}}]});function _N(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=kc({default:null,link:null});return r5(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),qI().concat([GI.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new CN({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),uN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),ZI.configure({device:n.deviceRef}),jI.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),KI.configure({fonts:n.fonts,defaultPreset:yi(t,"default"),defaultFont:n.defaultFont}),JI,YI,XI,QI,eN,tN,yN,nN,rN.configure({wrapperRef:n.wrapperRef}),iN,gN.configure({preset:yi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),bN])}class wN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class Hy{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class _n extends Hy{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=_n.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=s=>s.tagName!=="BODY"&&t.call(this,s),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:s=>r(s)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,s;const a=u=>{this._assignElementProperties(u,e,_n.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,_n.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){a(u),i=null,s=u;continue}if(u.tagName==="BR"&&s&&s?.tagName!=="BR"){u.remove(),s=u;continue}if(u.tagName==="BR"){const c=this.dom.createElement("p");c.append(u),a(c),i=null,s=u;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(u),s=u}e.append(t),this._removeStyleProperties(e,_n.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,_n.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return _n.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return _n.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const s=t.style.getPropertyValue(i);s&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,s)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let s=i.cloneNode();const a=u=>{this._assignElementProperties(u,e,_n.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){a(s),s=i.cloneNode();continue}s.append(u)}t.append(s),e.replaceWith(t)}_normalizeBlockTextDecoration(){const e=this.dom.querySelectorAll('[style*="text-decoration"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveTextDecorationToChildren(t)}_moveTextDecorationToChildren(e){const t=this._parseTextDecoration(e);if(e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration"),e.style.cssText||e.removeAttribute("style"),!t.none)for(const r of e.childNodes){const i=this._wrapTextNode(e,r),s=this._parseTextDecoration(i),a={underline:s.underline||t.underline,line_through:s.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,u])=>u).map(([u])=>u.replace("_","-")).join(" ")}}_parseTextDecoration(e){const{textDecoration:t,textDecorationLine:r}=e.style,i=t||r||"";return{none:i.includes("none"),underline:i.includes("underline"),line_through:i.includes("line-through")}}_normalizeBlockBackgroundColor(){const e=this.dom.querySelectorAll('[style*="background-color"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveBackgroundColorToChildren(t)}_moveBackgroundColorToChildren(e){const t=e.style.backgroundColor;e.style.removeProperty("background-color"),e.style.cssText||e.removeAttribute("style");for(const r of e.childNodes){const i=this._wrapTextNode(e,r),s=i.style.backgroundColor||t;i.style.backgroundColor=s}}_wrapTextNode(e,t){if(t.nodeType!==this._Node.TEXT_NODE)return t;const r=this.dom.createElement("span");return r.append(t.cloneNode()),e.replaceChild(r,t),r}}class vN extends Hy{normalize(){return this._iterateNodes(this._bubbleMarks),this.content}_iterateNodes(e){this._iterateChildNodes(this.content,e)}_iterateChildNodes(e,t){for(const r of e.content)r.content&&this._iterateChildNodes(r,t),t.call(this,r)}_bubbleMarks(e){if(e.content&&e.type!==oe.LIST){for(const t of e.content)if(!this._isLink(t)&&t.marks)for(const r of t.marks.slice()){if(this._includesMark(e,r)){this._removeMark(t,r);continue}this._canBubbleMark(e,r)&&(this._removeMark(t,r),this._addMark(e,r))}}}_canBubbleMark(e,t){if(m1.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===oe.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>By.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===oe.TEXT&&this._includesMarkType(e,ke.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Bl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new _n({content:e,parser:t.parser||new wN})}static _buildJson(e){return new vN({content:e})}static normalize(e,t={}){return Bl.build(e,t).normalize()}}class Pi{static window=globalThis.window;static use(e){this.window=e}static get document(){return this.window.document}static get body(){return this.document.body}static get head(){return this.document.head}static getComputedStyle(e){return this.window.getComputedStyle(e)}}class Eh{static build({config:e,nodeDomParser:t}){const r=_N({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:na(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:na(If.DESKTOP),pageBlocksRef:na([]),wrapperRef:Pi.document.createElement("p")}),i=WA(r);return new Eh({schema:i,domParser:_s.fromSchema(i),nodeDomParser:t})}_schema;_domParser;_nodeDomParser;constructor({schema:e,domParser:t,nodeDomParser:r}){this._schema=e,this._domParser=t,this._nodeDomParser=r}toJSON(e){const t=Bl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}function SN(n,e){return n.type===e}function xN(n){return typeof n=="string"}class Wy{static doc(e){return{type:oe.DOCUMENT,content:e}}static list(e,t){return{type:oe.LIST,attrs:{bullet:{type:e}},content:t.map(r=>SN(r,oe.LIST_ITEM)?r:this.listItem([r].flat()))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{type:oe.LIST_ITEM,...t?{attrs:t}:{},...i?{marks:i}:{},content:[r].flat().map(s=>xN(s)?this.paragraph(s):s)}}static heading(e,...t){const r=this.textBlock(t);return r.attrs??={},r.attrs.level=e,{type:oe.HEADING,...r}}static paragraph(...e){return{type:oe.PARAGRAPH,...this.textBlock(e)}}static textBlock(e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{content:typeof r=="string"?[this.text(r)]:[r].flat(),...t?{attrs:t}:{},...i?{marks:i}:{}}}static normalizeTextBlockArgs(e){return e.length===1?{attrs:null,marks:null,content:e[0]}:e.length===2?{attrs:e[0],marks:null,content:e[1]}:{attrs:e[0],marks:e[1],content:e[2]}}static text(e,t){return{type:oe.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ke.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class CN{_baseClass;_makeVariable;_linkPresetId;constructor({baseClass:e,makeVariable:t,linkPresetId:r}){this._baseClass=e,this._makeVariable=t,this._linkPresetId=r}inject(e,t){let r=e.querySelector("[data-zw-styles]");r||(r=Pi.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,s=this.makePresetCssClass(r);t+=` ${s} {`;for(const a of MM)for(const u of Object.keys(r[a])){const c=this._makeVariable({device:a,preset:r,property:u}),h=this._makeInternalVariableName(u,a);if(t+=`${h}: var(${c}, inherit);`,i&&!p1.includes(u)){const p=h.replace("preset-","");t+=`${p}: var(${h});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===If.COMMON?"":`-${t}`;return`--zw-preset-${r}${i}`}makePresetHtmlClass(e){return this._baseClass+e.id}makePresetCssClass(e){return this.makePresetHtmlClass(e).split(" ").map(t=>`.${t}`).join("")}}class kh{static _instance;static get instance(){return this._instance??=new kh,this._instance}static query(e,t){return this.instance.query(e,t)}query(e,t){let r=null;return e.descendants(i=>{if(r)return!1;if(this.matchNode(i,t))return r=i,!1}),r?t.getMark?this.getMark(r,t.getMark):r:null}matchNode(e,t){return!(t.typeName&&t.typeName!==e.type.name||t.mark&&!this.getMark(e,t.mark))}getMark(e,t){return e.marks.find(r=>this.matchMark(r,t))||null}matchMark(e,t){return e.type.name===t.typeName}}class Vy{static createWindow(){return new sm.JSDOM().window}types;parse(e){const{window:t}=new sm.JSDOM(e);return this.types=t,t.document}}class Uy{name;description;argument;options=[];doCommand(){throw new Error('Command "doCommand" is required')}install(e){if(!this.name)throw new Error('Command "name" is required');let t=e.command(this.name);if(this.description&&(t=t.description(this.description)),this.argument&&(t=t.argument(this.argument)),this.options.length)for(const r of this.options)t=t.option(r.flags,r.description,r.default);t.action(this.doCommand.bind(this))}output(e){}}class EN extends Uy{name="to-json";description="migrate html to json";argument="<html...>";options=[{flags:"-c, --config <path>",description:"Generator config",default:im.resolve(__dirname,"../bin/zp.config.json")},{flags:"-f, --format <type>",description:"Set output format",default:"rb"}];doCommand(e,{config:t,format:r}){Pi.use(Vy.createWindow());const i=im.resolve(process.cwd(),t),s=Eh.build({config:require(i).editor,nodeDomParser:new Vy}),a=e.map(h=>s.toJSON(this._formatInputHtml(h))),u=a.length===1?a[0]:a,c=this._stringifyContent(u);this.output(r==="rb"?this._formatOutputRb(c):c)}_formatInputHtml(e){return e.replace(/\\(["'])/g,"$1").replace(/rgba\(\d{1,3}, ?\d{1,3}, ?\d{1,3}, (\d{1,2}%)\)/g,(t,r)=>t.replace(r,parseFloat(r)/100))}_stringifyContent(e){return JSON.stringify(e,(r,i)=>i===null?void 0:i,2)}_formatOutputRb(e){return e.replace(/\\"/g,'"').replace(/font-family: ?'(.+)'/g,'font-family: "$1"').replace(/'/g,"\\'").replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm,t=>t.replace(/"/g,"")).replace(/: "(.+)"([,\n])/g,": '$1'$2")}}var kN="4.12.0-beta.0";class TN extends Uy{name="version";description="display cli version";doCommand(){this.output(kN)}}const qy=new UC,AN=[EN,TN];for(const n of AN)new n().install(qy);qy.parse();
64
+ }`;var se=tm(function(){return be(x,j+"return "+B).apply(t,C)});if(se.source=B,Zu(se))throw se;return se}function $x(o){return _e(o).toLowerCase()}function Hx(o){return _e(o).toUpperCase()}function Wx(o,l,f){if(o=_e(o),o&&(f||l===t))return cd(o);if(!o||!(l=kt(l)))return o;var d=en(o),b=en(l),x=fd(d,b),C=hd(d,b)+1;return ir(d,x,C).join("")}function Vx(o,l,f){if(o=_e(o),o&&(f||l===t))return o.slice(0,pd(o)+1);if(!o||!(l=kt(l)))return o;var d=en(o),b=hd(d,en(l))+1;return ir(d,0,b).join("")}function Ux(o,l,f){if(o=_e(o),o&&(f||l===t))return o.replace(Zl,"");if(!o||!(l=kt(l)))return o;var d=en(o),b=fd(d,en(l));return ir(d,b).join("")}function qx(o,l){var f=te,d=Se;if(Oe(l)){var b="separator"in l?l.separator:b;f="length"in l?ie(l.length):f,d="omission"in l?kt(l.omission):d}o=_e(o);var x=o.length;if(ni(o)){var C=en(o);x=C.length}if(f>=x)return o;var M=f-ri(d);if(M<1)return d;var I=C?ir(C,0,M).join(""):o.slice(0,M);if(b===t)return I+d;if(C&&(M+=I.length-M),Qu(b)){if(o.slice(M).search(b)){var P,D=I;for(b.global||(b=mu(b.source,_e(Nh.exec(b))+"g")),b.lastIndex=0;P=b.exec(D);)var B=P.index;I=I.slice(0,B===t?M:B)}}else if(o.indexOf(kt(b),M)!=M){var q=I.lastIndexOf(b);q>-1&&(I=I.slice(0,q))}return I+d}function Kx(o){return o=_e(o),o&&rb.test(o)?o.replace(Mh,v2):o}var Gx=ci(function(o,l,f){return o+(f?" ":"")+l.toUpperCase()}),nc=np("toUpperCase");function em(o,l,f){return o=_e(o),l=f?t:l,l===t?g2(o)?C2(o):a2(o):o.match(l)||[]}var tm=ue(function(o,l){try{return Ct(o,t,l)}catch(f){return Zu(f)?f:new ne(f)}}),Jx=Mn(function(o,l){return zt(l,function(f){f=dn(f),Tn(o,f,Yu(o[f],o))}),o});function jx(o){var l=o==null?0:o.length,f=Y();return o=l?Ae(o,function(d){if(typeof d[1]!="function")throw new $t(a);return[f(d[0]),d[1]]}):[],ue(function(d){for(var b=-1;++b<l;){var x=o[b];if(Ct(x[0],this,d))return Ct(x[1],this,d)}})}function Yx(o){return v_(Wt(o,m))}function rc(o){return function(){return o}}function Xx(o,l){return o==null||o!==o?l:o}var Zx=ip(),Qx=ip(!0);function mt(o){return o}function ic(o){return Ld(typeof o=="function"?o:Wt(o,m))}function eC(o){return Dd(Wt(o,m))}function tC(o,l){return Fd(o,Wt(l,m))}var nC=ue(function(o,l){return function(f){return ts(f,o,l)}}),rC=ue(function(o,l){return function(f){return ts(o,f,l)}});function sc(o,l,f){var d=Ve(l),b=vo(l,d);f==null&&!(Oe(l)&&(b.length||!d.length))&&(f=l,l=o,o=this,b=vo(l,Ve(l)));var x=!(Oe(f)&&"chain"in f)||!!f.chain,C=In(o);return zt(b,function(M){var I=l[M];o[M]=I,C&&(o.prototype[M]=function(){var P=this.__chain__;if(x||P){var D=o(this.__wrapped__),B=D.__actions__=ht(this.__actions__);return B.push({func:I,args:arguments,thisArg:o}),D.__chain__=P,D}return I.apply(o,Zn([this.value()],arguments))})}),o}function iC(){return Xe._===this&&(Xe._=O2),this}function oc(){}function sC(o){return o=ie(o),ue(function(l){return Bd(l,o)})}var oC=Fu(Ae),aC=Fu(sd),lC=Fu(lu);function nm(o){return Uu(o)?uu(dn(o)):B_(o)}function uC(o){return function(l){return o==null?t:Rr(o,l)}}var cC=op(),fC=op(!0);function ac(){return[]}function lc(){return!1}function hC(){return{}}function dC(){return""}function pC(){return!0}function mC(o,l){if(o=ie(o),o<1||o>Yn)return[];var f=xt,d=nt(o,xt);l=Y(l),o-=xt;for(var b=hu(d,l);++f<o;)l(f);return b}function gC(o){return re(o)?Ae(o,dn):Tt(o)?[o]:ht(Sp(_e(o)))}function yC(o){var l=++A2;return _e(o)+l}var bC=To(function(o,l){return o+l},0),_C=Bu("ceil"),wC=To(function(o,l){return o/l},1),vC=Bu("floor");function SC(o){return o&&o.length?wo(o,mt,xu):t}function xC(o,l){return o&&o.length?wo(o,Y(l,2),xu):t}function CC(o){return ld(o,mt)}function EC(o,l){return ld(o,Y(l,2))}function kC(o){return o&&o.length?wo(o,mt,Tu):t}function TC(o,l){return o&&o.length?wo(o,Y(l,2),Tu):t}var AC=To(function(o,l){return o*l},1),MC=Bu("round"),OC=To(function(o,l){return o-l},0);function IC(o){return o&&o.length?fu(o,mt):0}function NC(o,l){return o&&o.length?fu(o,Y(l,2)):0}return w.after=eS,w.ary=Rp,w.assign=HS,w.assignIn=Gp,w.assignInWith=$o,w.assignWith=WS,w.at=VS,w.before=Lp,w.bind=Yu,w.bindAll=Jx,w.bindKey=Pp,w.castArray=hS,w.chain=Op,w.chunk=vw,w.compact=Sw,w.concat=xw,w.cond=jx,w.conforms=Yx,w.constant=rc,w.countBy=Iv,w.create=US,w.curry=Dp,w.curryRight=Fp,w.debounce=Bp,w.defaults=qS,w.defaultsDeep=KS,w.defer=tS,w.delay=nS,w.difference=Cw,w.differenceBy=Ew,w.differenceWith=kw,w.drop=Tw,w.dropRight=Aw,w.dropRightWhile=Mw,w.dropWhile=Ow,w.fill=Iw,w.filter=Rv,w.flatMap=Dv,w.flatMapDeep=Fv,w.flatMapDepth=Bv,w.flatten=kp,w.flattenDeep=Nw,w.flattenDepth=Rw,w.flip=rS,w.flow=Zx,w.flowRight=Qx,w.fromPairs=Lw,w.functions=QS,w.functionsIn=ex,w.groupBy=zv,w.initial=Dw,w.intersection=Fw,w.intersectionBy=Bw,w.intersectionWith=zw,w.invert=nx,w.invertBy=rx,w.invokeMap=Hv,w.iteratee=ic,w.keyBy=Wv,w.keys=Ve,w.keysIn=pt,w.map=Lo,w.mapKeys=sx,w.mapValues=ox,w.matches=eC,w.matchesProperty=tC,w.memoize=Do,w.merge=ax,w.mergeWith=Jp,w.method=nC,w.methodOf=rC,w.mixin=sc,w.negate=Fo,w.nthArg=sC,w.omit=lx,w.omitBy=ux,w.once=iS,w.orderBy=Vv,w.over=oC,w.overArgs=sS,w.overEvery=aC,w.overSome=lC,w.partial=Xu,w.partialRight=zp,w.partition=Uv,w.pick=cx,w.pickBy=jp,w.property=nm,w.propertyOf=uC,w.pull=Vw,w.pullAll=Ap,w.pullAllBy=Uw,w.pullAllWith=qw,w.pullAt=Kw,w.range=cC,w.rangeRight=fC,w.rearg=oS,w.reject=Gv,w.remove=Gw,w.rest=aS,w.reverse=Ju,w.sampleSize=jv,w.set=hx,w.setWith=dx,w.shuffle=Yv,w.slice=Jw,w.sortBy=Qv,w.sortedUniq=tv,w.sortedUniqBy=nv,w.split=Dx,w.spread=lS,w.tail=rv,w.take=iv,w.takeRight=sv,w.takeRightWhile=ov,w.takeWhile=av,w.tap=Sv,w.throttle=uS,w.thru=Ro,w.toArray=Up,w.toPairs=Yp,w.toPairsIn=Xp,w.toPath=gC,w.toPlainObject=Kp,w.transform=px,w.unary=cS,w.union=lv,w.unionBy=uv,w.unionWith=cv,w.uniq=fv,w.uniqBy=hv,w.uniqWith=dv,w.unset=mx,w.unzip=ju,w.unzipWith=Mp,w.update=gx,w.updateWith=yx,w.values=di,w.valuesIn=bx,w.without=pv,w.words=em,w.wrap=fS,w.xor=mv,w.xorBy=gv,w.xorWith=yv,w.zip=bv,w.zipObject=_v,w.zipObjectDeep=wv,w.zipWith=vv,w.entries=Yp,w.entriesIn=Xp,w.extend=Gp,w.extendWith=$o,sc(w,w),w.add=bC,w.attempt=tm,w.camelCase=Sx,w.capitalize=Zp,w.ceil=_C,w.clamp=_x,w.clone=dS,w.cloneDeep=mS,w.cloneDeepWith=gS,w.cloneWith=pS,w.conformsTo=yS,w.deburr=Qp,w.defaultTo=Xx,w.divide=wC,w.endsWith=xx,w.eq=nn,w.escape=Cx,w.escapeRegExp=Ex,w.every=Nv,w.find=Lv,w.findIndex=Cp,w.findKey=GS,w.findLast=Pv,w.findLastIndex=Ep,w.findLastKey=JS,w.floor=vC,w.forEach=Ip,w.forEachRight=Np,w.forIn=jS,w.forInRight=YS,w.forOwn=XS,w.forOwnRight=ZS,w.get=ec,w.gt=bS,w.gte=_S,w.has=tx,w.hasIn=tc,w.head=Tp,w.identity=mt,w.includes=$v,w.indexOf=Pw,w.inRange=wx,w.invoke=ix,w.isArguments=Dr,w.isArray=re,w.isArrayBuffer=wS,w.isArrayLike=dt,w.isArrayLikeObject=Le,w.isBoolean=vS,w.isBuffer=sr,w.isDate=SS,w.isElement=xS,w.isEmpty=CS,w.isEqual=ES,w.isEqualWith=kS,w.isError=Zu,w.isFinite=TS,w.isFunction=In,w.isInteger=$p,w.isLength=Bo,w.isMap=Hp,w.isMatch=AS,w.isMatchWith=MS,w.isNaN=OS,w.isNative=IS,w.isNil=RS,w.isNull=NS,w.isNumber=Wp,w.isObject=Oe,w.isObjectLike=Ie,w.isPlainObject=ls,w.isRegExp=Qu,w.isSafeInteger=LS,w.isSet=Vp,w.isString=zo,w.isSymbol=Tt,w.isTypedArray=hi,w.isUndefined=PS,w.isWeakMap=DS,w.isWeakSet=FS,w.join=$w,w.kebabCase=kx,w.last=Ut,w.lastIndexOf=Hw,w.lowerCase=Tx,w.lowerFirst=Ax,w.lt=BS,w.lte=zS,w.max=SC,w.maxBy=xC,w.mean=CC,w.meanBy=EC,w.min=kC,w.minBy=TC,w.stubArray=ac,w.stubFalse=lc,w.stubObject=hC,w.stubString=dC,w.stubTrue=pC,w.multiply=AC,w.nth=Ww,w.noConflict=iC,w.noop=oc,w.now=Po,w.pad=Mx,w.padEnd=Ox,w.padStart=Ix,w.parseInt=Nx,w.random=vx,w.reduce=qv,w.reduceRight=Kv,w.repeat=Rx,w.replace=Lx,w.result=fx,w.round=MC,w.runInContext=O,w.sample=Jv,w.size=Xv,w.snakeCase=Px,w.some=Zv,w.sortedIndex=jw,w.sortedIndexBy=Yw,w.sortedIndexOf=Xw,w.sortedLastIndex=Zw,w.sortedLastIndexBy=Qw,w.sortedLastIndexOf=ev,w.startCase=Fx,w.startsWith=Bx,w.subtract=OC,w.sum=IC,w.sumBy=NC,w.template=zx,w.times=mC,w.toFinite=Nn,w.toInteger=ie,w.toLength=qp,w.toLower=$x,w.toNumber=qt,w.toSafeInteger=$S,w.toString=_e,w.toUpper=Hx,w.trim=Wx,w.trimEnd=Vx,w.trimStart=Ux,w.truncate=qx,w.unescape=Kx,w.uniqueId=yC,w.upperCase=Gx,w.upperFirst=nc,w.each=Ip,w.eachRight=Np,w.first=Tp,sc(w,function(){var o={};return fn(w,function(l,f){ve.call(w.prototype,f)||(o[f]=l)}),o}(),{chain:!1}),w.VERSION=r,zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){w[o].placeholder=w}),zt(["drop","take"],function(o,l){fe.prototype[o]=function(f){f=f===t?1:ze(ie(f),0);var d=this.__filtered__&&!l?new fe(this):this.clone();return d.__filtered__?d.__takeCount__=nt(f,d.__takeCount__):d.__views__.push({size:nt(f,xt),type:o+(d.__dir__<0?"Right":"")}),d},fe.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),zt(["filter","map","takeWhile"],function(o,l){var f=l+1,d=f==Ft||f==We;fe.prototype[o]=function(b){var x=this.clone();return x.__iteratees__.push({iteratee:Y(b,3),type:f}),x.__filtered__=x.__filtered__||d,x}}),zt(["head","last"],function(o,l){var f="take"+(l?"Right":"");fe.prototype[o]=function(){return this[f](1).value()[0]}}),zt(["initial","tail"],function(o,l){var f="drop"+(l?"":"Right");fe.prototype[o]=function(){return this.__filtered__?new fe(this):this[f](1)}}),fe.prototype.compact=function(){return this.filter(mt)},fe.prototype.find=function(o){return this.filter(o).head()},fe.prototype.findLast=function(o){return this.reverse().find(o)},fe.prototype.invokeMap=ue(function(o,l){return typeof o=="function"?new fe(this):this.map(function(f){return ts(f,o,l)})}),fe.prototype.reject=function(o){return this.filter(Fo(Y(o)))},fe.prototype.slice=function(o,l){o=ie(o);var f=this;return f.__filtered__&&(o>0||l<0)?new fe(f):(o<0?f=f.takeRight(-o):o&&(f=f.drop(o)),l!==t&&(l=ie(l),f=l<0?f.dropRight(-l):f.take(l-o)),f)},fe.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},fe.prototype.toArray=function(){return this.take(xt)},fn(fe.prototype,function(o,l){var f=/^(?:filter|find|map|reject)|While$/.test(l),d=/^(?:head|last)$/.test(l),b=w[d?"take"+(l=="last"?"Right":""):l],x=d||/^find/.test(l);b&&(w.prototype[l]=function(){var C=this.__wrapped__,M=d?[1]:arguments,I=C instanceof fe,P=M[0],D=I||re(C),B=function(ce){var me=b.apply(w,Zn([ce],M));return d&&q?me[0]:me};D&&f&&typeof P=="function"&&P.length!=1&&(I=D=!1);var q=this.__chain__,j=!!this.__actions__.length,X=x&&!q,se=I&&!j;if(!x&&D){C=se?C:new fe(this);var Z=o.apply(C,M);return Z.__actions__.push({func:Ro,args:[B],thisArg:t}),new Ht(Z,q)}return X&&se?o.apply(this,M):(Z=this.thru(B),X?d?Z.value()[0]:Z.value():Z)})}),zt(["pop","push","shift","sort","splice","unshift"],function(o){var l=io[o],f=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",d=/^(?:pop|shift)$/.test(o);w.prototype[o]=function(){var b=arguments;if(d&&!this.__chain__){var x=this.value();return l.apply(re(x)?x:[],b)}return this[f](function(C){return l.apply(re(C)?C:[],b)})}}),fn(fe.prototype,function(o,l){var f=w[l];if(f){var d=f.name+"";ve.call(ai,d)||(ai[d]=[]),ai[d].push({name:l,func:f})}}),ai[ko(t,g).name]=[{name:"wrapper",func:t}],fe.prototype.clone=K2,fe.prototype.reverse=G2,fe.prototype.value=J2,w.prototype.at=xv,w.prototype.chain=Cv,w.prototype.commit=Ev,w.prototype.next=kv,w.prototype.plant=Av,w.prototype.reverse=Mv,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=Ov,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=Tv),w},ii=E2();Ar?((Ar.exports=ii)._=ii,iu._=ii):Xe._=ii}).call(RI)}(Ws,Ws.exports)),Ws.exports}var By=LI();function bh(n){return n.type.create(By.cloneDeep(n.attrs))}function _h({tr:n,node:e,position:t,mark:r}){return e.isText?n.removeMark(t,t+e.nodeSize,r):n.removeNodeMark(t,r)}const PI=Re.create({name:"node_processor",addCommands(){return{setBlockAttributes:W(({commands:n,state:e},t,r,i={})=>{const s=H(n.getBlockAttributes(t))??{},{doc:a,tr:u}=e,{from:c,to:h}=u.selection;a.nodesBetween(c,h,(p,m)=>{Nf.includes(p.type.name)&&u.setNodeAttribute(m,t,{...i,...s,...r})})}),getBlockAttributes:W(({editor:n},e,t)=>ge(()=>{let r=Object.assign({},t||{});for(const i of Nf)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:W(({commands:n},e)=>{for(const t of Nf)n.resetAttributes(t,e)}),applyMark:W(({state:n,commands:e},t,r,i={})=>{const{tr:s,doc:a,schema:u}=n,{$from:c,$to:h}=s.selection,p=mn(ke.LINK,u),m=mn(t,u);if(!(m.spec.group||"").includes(Rt.SETTINGS))return e.setMark(t,r);if(c.pos===h.pos)return;const _=S=>{if(!i.onAppliedToParent||i.onAppliedToParent(S)===!1){const{tr:E,node:N,position:g,mark:v}=S;_h({tr:E,node:N,position:g,mark:v.type})}};a.nodesBetween(c.pos,h.pos,(S,E)=>{if(S.type.name===oe.LIST)return;const N=NI(S.marks,t),g=m.create({...N?.attrs||{},...r}),v=Py(c,h,S,E);if(!p.isInSet(S.marks)&&II(s.doc,E,g,i.isAppliedToParent))return _({tr:s,node:S,position:E,mark:g});if(S.isText){s.addMark(v.from,v.to,g);return}MI(s.doc,s.selection,S,E)&&s.addNodeMark(E,g)})}),getMarks:W(({editor:n},e)=>{const t=yi(n,"state");return ge(()=>{const{selection:r,doc:i}=H(t),{from:s,to:a}=H(r),u=[];return i.nodesBetween(s,a,c=>{for(const h of c.marks)h.type.name===e&&u.unshift(h.attrs)}),u})}),getMark:W(({commands:n},e)=>{const t=n.getMarks(e);return ge(()=>H(t)[0]??null)}),hasMark:W(({commands:n},e)=>{const t=n.getMark(e);return ge(()=>!!H(t))}),getCommonSettingMark:W(({commands:n},e,t)=>{const r=n.getMark(e);return ge(()=>H(r)?.value??H(t))}),getDeviceSettingMark:W(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return ge(()=>{for(const s of H(r)){const a=s[H(i)];if(a)return a}return H(t)})}),removeAllMarks:W(({state:n})=>{const{tr:e,doc:t}=n,{from:r,to:i}=e.selection;t.nodesBetween(r,i,(s,a)=>{for(const u of s.marks)_h({tr:e,node:s,position:a,mark:u})})}),removeMarks:W(({state:n},e)=>{const{tr:t,doc:r}=n,{from:i,to:s}=t.selection;r.nodesBetween(i,s,(a,u)=>{const c=a.marks.filter(h=>e.includes(h.type.name));for(const h of c)_h({tr:t,node:a,position:u,mark:h})})})}}}),DI=Re.create({name:"text_processor",addCommands(){return{getSelectedText:W(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:W(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,s)=>{if(!i.isText)return;const a=Py(t,r,i,s),u=Math.max(0,t.pos-s),c=Math.max(0,r.pos-s),h=e({text:i.textContent.substring(u,c)}),p=n.schema.text(h,i.marks);n.tr.replaceWith(a.from,a.to,p)})})}}}),FI=Re.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:W(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:W(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:W(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;return n.doc.nodesBetween(r,i,(s,a,u)=>{if(t({node:s,parent:u})){const c=s.isText?0:Dy(n.doc,a);r=Math.min(r,a+c),i=Math.max(i,a+s.nodeSize-c)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:W(({commands:n})=>n.expandSelection(({parent:e})=>e.type.name===oe.DOCUMENT))}}}),BI=jn.create({name:"doc",topNode:!0,content:"block+"});class Ks extends Ue{constructor(e,t,r,i="SetDocAttr"){super(),this.key=e,this.value=t,this.schema=r,this.stepType=i}apply(e){this.prevValue=e.attrs.meta[this.key];const t=fr.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,De.ok(t)}invert(){return new Ks(this.key,this.prevValue,this.schema,"revertSetDocAttr")}map(){return null}toJSON(){return{stepType:this.stepType,key:this.key,value:this.value}}static fromJSON(e){return new Ks(e.key,e.value,e.stepType)}}Ue.jsonID("setDocAttr",Ks);const zI=BI.extend({marks:Rt.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:W(({state:n},e,t)=>{n.tr.step(new Ks(e,t,n.schema))})}}}),$I=jn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Mi(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),HI=$I.extend({marks:Rt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),WI=jn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Mi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>mM({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),VI=WI.extend({marks:Rt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),UI=Re.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[RM.create(this.editor),LM.create(this.editor)]}}),qI=()=>[zI,HI,VI,bM,AM,PI,DI,FI,UI],KI=wt.create({name:ke.FONT_FAMILY,group:Rt.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:W(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=H(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ke.FONT_STYLE).value;t.isItalicOnly?n.applyItalic():!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:W(({commands:n})=>{const e=H(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return ge(()=>n.findFontByName(H(r))||t)}),findFontByName:W((n,e)=>H(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:W(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:W(({commands:n})=>{const e=n.getPreset();return ge(()=>H(e).common.font_family)})}},parseHTML(){const n=e=>({value:e.replace(/["']/g,"")});return[{style:"--zw-font-family",getAttrs:n},{style:"font-family",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.value?`"${n.value}"`:null;return xr({font_family:e})}}),GI=Re.create({name:ke.STYLE_PRESET,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{preset:{isRequired:!1,default:{id:H(this.options.defaultId)},parseHTML:n=>{const e=H(this.options.presets);if(n.parentElement.tagName==="LI")return null;for(const{id:t,node:r,fallbackClass:i}of e){if(i&&n.classList.contains(i))return{id:t};const s=H(this.options.styleRenderer).makePresetCssClass({id:t});if(n.matches(s))return{id:t};if(n.tagName===`H${r?.level}`)return{id:t}}return n.tagName==="P"?{id:H(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:H(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const s of Object.keys(t)){const a=t[s],u=r[s],c=!u||u.toLowerCase()==="inherit";i[s]=c?a:u}return i}return{getPresetList:W(()=>ge(()=>H(this.options.presets).filter(t=>!t.hidden))),getPreset:W(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:H(this.options.defaultId)}),i=t.getPresetList(),s=t.isLink(),a=t.getLinkPreset();return ge(()=>{const u=n(H(i),H(r).id);if(!H(s))return u;const c=H(a);return{id:u.id,common:e(u.common,c.common),mobile:e(u.mobile,c.mobile),tablet:e(u.tablet,c.tablet),desktop:e(u.desktop,c.desktop)}})}),applyPreset:W(({commands:t,chain:r},i)=>{const s=H(t.getPresetList()),a=n(s,i),u=a.node?.type??oe.PARAGRAPH,c={preset:{id:i}};a.node&&(c.level=a.node.level);for(const h of p1)c[h]=H(t.getBlockAttributes(h));r().removeList().setNode(u,c).run()}),applyDefaultPreset:W(({commands:t})=>{t.applyPreset(H(this.options.defaultId))}),removePreset:W(({commands:t})=>{t.setNode(oe.PARAGRAPH,{preset:null})}),getPresetCustomization:W(({editor:t,commands:r})=>{const i=yi(t,"state");return ge(()=>{const{selection:s,doc:a}=H(i),{from:u,to:c}=s;return r._getSettingCustomization(a,u,c)})}),isSettingCustomized:W(({commands:t},r)=>{const i=t.getPresetCustomization(),s=qa.includes(r)?"attributes":"marks";return ge(()=>H(i)[s]?.includes(r)??!1)}),getContentCustomization:W(({editor:t,commands:r})=>{const i=yi(t,"state");return ge(()=>{const{doc:s}=H(i);return r._getSettingCustomization(s,0,s.content.size)})}),_getSettingCustomization:W((t,r,i,s)=>{const a=new Set,u=new Set;return r.nodesBetween(i,s,c=>{for(const[h,p]of Object.entries(c.attrs))qa.includes(h)&&p&&u.add(h);for(const{type:h}of c.marks)g1.includes(h.name)&&a.add(h.name)}),{attributes:Array.from(u),marks:Array.from(a)}}),removePresetCustomization:W(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(g1).resetAttributes(oe.PARAGRAPH,qa).resetAttributes(oe.HEADING,qa).restoreSelection().run()}),removeFormat:W(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Pi.head,H(this.options.presets))}}),JI=wt.create({name:ke.FONT_WEIGHT,group:Rt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:W(({commands:n},e)=>{n.applyMark(this.name,{value:e}),H(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:W(({commands:n})=>{const e=H(n.getFontWeight()),t=H(n.getFont()),i=Number(e)>=600?"400":"700",s=t.findClosestWeight(i);n.applyFontWeight(s)}),getFontWeight:W(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return ge(()=>{const r=H(e),i=H(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:W(({commands:n})=>{const e=n.getPreset();return ge(()=>H(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Yt("toggleBold"),"Mod-B":Yt("toggleBold")}),parseHTML(){const n=e=>e==="bold"?{value:"700"}:Number(e)?{value:e}:!1;return[{style:"--zw-font-weight",getAttrs:n},{style:"font-weight",getAttrs:n},{tag:"b",attrs:{value:"700"}},{tag:"strong",attrs:{value:"700"}}]},renderHTML({HTMLAttributes:n}){return xr({font_weight:n.value})}}),jI=wt.create({name:ke.FONT_SIZE,group:Rt.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:W(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].font_size.replace("px",""))}),applyFontSize:W(({commands:n},e)=>{const t=H(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:s,mark:a})=>{const u={...a.attrs,[t]:null};if(!Object.values(u).some(p=>!!p))return!1;const h=a.type.create(u);if(i.isText){r.addMark(s,s+i.nodeSize,h);return}r.addNodeMark(s,h)}})}),increaseFontSize:W(({commands:n})=>{const e=Number(H(n.getFontSize())),t=Math.min(e+1,H(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:W(({commands:n})=>{const e=Number(H(n.getFontSize())),t=Math.max(e-1,H(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Yt("increaseFontSize"),"Mod-Shift--":Yt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=H(this.options.wrapperRef),r=Ly(e,t);return String(r)};return[{tag:'[style*="--zw-font-size"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-font-size-mobile")),tablet:n(e.getPropertyValue("--zw-font-size-tablet")),desktop:n(e.getPropertyValue("--zw-font-size-desktop"))})},{style:"font-size",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:null}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return xr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),YI=wt.create({name:ke.FONT_COLOR,group:Rt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:W(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:W(({commands:n})=>{const e=n.getPreset();return ge(()=>H(e).common.color)}),applyFontColor:W(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:Ny(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return xr({font_color:n.value})}}),XI=wt.create({name:ke.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:W(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:W(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:Ny(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return xr({background_color:n.value})}}),ZI=Re.create({name:"device_manager",addCommands(){return{getDevice:W(()=>yi(this.options,"device"))}}}),QI=wt.create({name:ke.FONT_STYLE,group:Rt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return ge(()=>H(e)?.italic??H(t).italic)}),isItalicAvailable:W(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return ge(()=>{const r=H(e),i=H(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:W(({commands:n})=>{const e=n.getPreset();return ge(()=>({italic:H(e).common.font_style==="italic"}))}),toggleItalic:W(({commands:n})=>{H(n.isItalicAvailable())&&(H(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:W(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:W(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Yt("toggleItalic"),"Mod-I":Yt("toggleItalic")}),parseHTML(){const n=e=>({italic:e.includes("italic")});return[{tag:"i",attrs:{italic:!0}},{style:"--zw-font-style",getAttrs:n},{style:"font-style",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.italic?"italic":"normal";return xr({font_style:e})}}),eN=wt.create({name:ke.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>H(e).underline)}),isStrikeThrough:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>H(e).strike_through)}),getTextDecoration:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return ge(()=>{const r=H(e)??{},i=H(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:W(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return ge(()=>H(e)!==H(t).underline)}),getDefaultTextDecoration:W(({commands:n})=>{const e=n.getPreset();return ge(()=>{const{text_decoration:t}=H(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:W(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:W(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:W(({commands:n},e,t=null)=>{const r=H(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:W(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:W(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Yt("toggleUnderline"),"Mod-U":Yt("toggleUnderline")}),parseHTML(){const n=e=>{const t=e.includes("underline"),r=e.includes("line-through");return!t&&!r?!1:{underline:t,strike_through:r}};return[{style:"--zw-text-decoration",getAttrs:n},{style:"text-decoration-line",getAttrs:n},{style:"text-decoration",getAttrs:n},{tag:"s",attrs:{underline:!1,strike_through:!0}},{tag:"u",attrs:{underline:!0,strike_through:!1}}]},renderHTML({HTMLAttributes:n}){const e=[];return n.underline&&e.push("underline"),n.strike_through&&e.push("line-through"),e.length||e.push("none"),xr({text_decoration:e.join(" ")})}}),tN=Re.create({name:"case_style",addCommands(){return{applyCaseStyle:W(({commands:n},e)=>{switch(e){case Ua.CAPITALIZE:return n.applyCapitalize();case Ua.LOWERCASE:return n.applyLowerCase();case Ua.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:W(({commands:n})=>{n.transformText(({text:e})=>eO(e))}),applyLowerCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),zy={mobile:null,tablet:null,desktop:null},nN=Re.create({name:ke.ALIGNMENT,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[ke.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=AI(n.textAlign);if(e)return{desktop:e,tablet:e,mobile:e};const t=n.getPropertyValue("--zw-alignment-mobile")||null,r=n.getPropertyValue("--zw-alignment-tablet")||null,i=n.getPropertyValue("--zw-alignment-desktop")||null;return!t&&!r&&!i?null:{desktop:i,tablet:r,mobile:t}},renderHTML(n){return n.alignment?Cl({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:W(({commands:n},e)=>{const t=H(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},zy)}),removeAlignment:W(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:W(({commands:n})=>{const e=n.getBlockAttributes(this.name,zy),t=n.getDevice(),r=n.getDefaultAlignment();return ge(()=>H(e)?.[H(t)]??H(r))}),getDefaultAlignment:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].alignment??_r.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Yt("applyAlignment",_r.LEFT),"Mod-Shift-e":Yt("applyAlignment",_r.CENTER),"Mod-Shift-r":Yt("applyAlignment",_r.RIGHT),"Mod-Shift-j":Yt("applyAlignment",_r.JUSTIFY)})}),$y={mobile:null,tablet:null,desktop:null},rN=Re.create({name:ke.LINE_HEIGHT,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[ke.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const s=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:s,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=H(this.options.wrapperRef),r=EI(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?Cl({line_height_mobile:n.line_height.mobile,line_height_tablet:n.line_height.tablet,line_height_desktop:n.line_height.desktop}):null}}}}]},addCommands(){return{getLineHeight:W(({commands:n})=>{const e=n.getBlockAttributes(this.name,$y),t=n.getDevice(),r=n.getDefaultLineHeight();return ge(()=>H(e)?.[H(t)]??H(r))}),getDefaultLineHeight:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].line_height)}),applyLineHeight:W(({commands:n},e)=>{const t=H(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},$y)})}}}),iN=wt.create({name:ke.LETTER_SPACING,group:Rt.SETTINGS,addAttributes:()=>({mobile:{default:null},tablet:{default:null},desktop:{default:null}}),addCommands(){return{getLetterSpacing:W(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultLetterSpacing())),getDefaultLetterSpacing:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>H(t)[H(e)].letter_spacing??null)}),applyLetterSpacing:W(({commands:n},e)=>{const t=H(n.getDevice());n.applyMark(this.name,{[t]:e})})}},parseHTML(){const n=e=>{if(!e)return null;const t=H(this.options.wrapperRef);return`${kI(e,t)}px`};return[{tag:'[style*="--zw-letter-spacing"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-letter-spacing-mobile")),tablet:n(e.getPropertyValue("--zw-letter-spacing-tablet")),desktop:n(e.getPropertyValue("--zw-letter-spacing-desktop"))})},{style:"letter-spacing",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:t}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return xr({letter_spacing_mobile:e(n.mobile),letter_spacing_tablet:e(n.tablet),letter_spacing_desktop:e(n.desktop)})}}),sN=jn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Mi(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),oN=sN.extend({name:oe.LIST_ITEM,marks:Rt.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:W(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const s=n(t);for(const a of r.marks)t.addNodeMark(s,bh(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===oe.LIST))return t.listItemNewline()}})});function aN(n,e){if(m1.includes(e.type)||e.type.isInSet(n.marks))return!1;for(const t of n.content.content)if(t.childCount&&(!t.marks||!e.isInSet(t.marks)))return!1;return!0}function lN(n){const e=n.selection.$from.start(),t=n.selection.$to.end();n.doc.nodesBetween(e,t,(r,i)=>{if(r.type.name===oe.LIST)return;if(r.type.name!==oe.LIST_ITEM)return!1;const s=[];return r.forEach(a=>{for(const u of a.marks){if(u.isInSet(s)){n.removeNodeMark(i+1,u);continue}aN(r,u)&&(n.removeNodeMark(i+1,u),n.addNodeMark(i,bh(u)),s.push(u))}}),!1})}const uN=jn.create({name:oe.LIST,content:`${oe.LIST_ITEM}+`,group:"block list",marks:Rt.SETTINGS,addExtensions:()=>[oN],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:an.DISC}}}),parseHTML(){const n={a:an.ROMAN,i:an.LATIN,1:an.DECIMAL},e=t=>{for(const r of IM){const i=`.${H(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||an.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||an.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[H(this.options.baseClass)+n.bullet.type,H(this.options.presetClass)];return[NM.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:W(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return ge(()=>H(e).type??null)}),applyList:W(({commands:n,chain:e},t)=>H(n.getListType())===t?n.removeList():e().applyDefaultPreset().toggleList(oe.LIST,oe.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({tr:i})=>lN(i)).run()),removeList:W(({chain:n})=>n().expandSelection(({parent:e})=>e.type.name===oe.LIST).command(({tr:e})=>{const t=e.selection.$from.start(),r=e.selection.$to.end();return e.doc.nodesBetween(t,r,(i,s,a)=>{if([oe.LIST,oe.LIST_ITEM].includes(i.type.name))return;if(a.type.name!==oe.LIST_ITEM)return!1;const u=a.marks.filter(c=>!c.type.isInSet(i.marks));for(const c of u)e.addNodeMark(s,bh(c));return!1}),!0}).liftListItem(oe.LIST_ITEM).run())}},addInputRules(){const n=(e,t)=>gM({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(an.DISC,/^\s*([-+*])\s$/),n(an.DECIMAL,/^(\d+)\.\s$/),n(an.LATIN,/^([ivx]{1,3})\.\s$/i),n(an.ROMAN,/^([a-z])\.\s$/i)]}});function cN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function fN(n){return new ct({key:new It("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(h=>h.docChanged)&&!t.doc.eq(r.doc),s=e.some(h=>h.getMeta("preventAutolink"));if(!i||s)return;const{tr:a}=r,u=BA(t.doc,[...e]);if(GA(u).forEach(({newRange:h})=>{const p=$A(r.doc,h,_=>_.isTextblock);let m,y;if(p.length>1?(m=p[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ")):p.length&&r.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(m=p[0],y=r.doc.textBetween(m.pos,h.to,void 0," ")),m&&y){const _=y.split(" ").filter(g=>g!=="");if(_.length<=0)return!1;const S=_[_.length-1],E=m.pos+y.lastIndexOf(S);if(!S)return!1;const N=xl(S).map(g=>g.toObject(n.defaultProtocol));if(!cN(N))return!1;N.filter(g=>g.isLink).map(g=>({...g,from:E+g.start+1,to:E+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).filter(g=>n.shouldAutoLink(g.value)).forEach(g=>{i1(g.from,g.to,r.doc).some(v=>v.mark.type===n.type)||a.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!a.steps.length)return a}})}function hN(n){return new ct({key:new It("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let a=r.target;const u=[];for(;a.nodeName!=="DIV";)u.push(a),a=a.parentNode;if(!u.find(y=>y.nodeName==="A"))return!1;const c=UA(e.state,n.type.name),h=r.target,p=(i=h?.href)!==null&&i!==void 0?i:c.href,m=(s=h?.target)!==null&&s!==void 0?s:c.target;return h&&p?(window.open(p,m),!0):!1}}})}function dN(n){return new ct({key:new It("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:s}=i,{empty:a}=s;if(a)return!1;let u="";r.content.forEach(h=>{u+=h.textContent});const c=N1(u,{defaultProtocol:n.defaultProtocol}).find(h=>h.isLink&&h.value===u);return!u||!c?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}const pN=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function Yr(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(pN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const mN=wt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){I1(n);return}I1(n.scheme,n.optionalSlashes)})},onDestroy(){YM()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Yr(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Yr(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Yr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Mi(this.options.HTMLAttributes,n),0]:["a",Mi(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Yr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Yr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[yM({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=N1(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!Yr(a,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>e.push({text:s.value,data:{href:s.href},index:s.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(fN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Yr(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(hN({type:this.type})),this.options.linkOnPaste&&n.push(dN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),gN=mN.extend({name:ke.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:Rf.SELF,parseHTML:n=>n.getAttribute("target")||Rf.SELF},destination:{default:Oi.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Oi.URL;const t=e.replace("#","");return H(this.options.pageBlocks).find(s=>s.id===parseInt(t))?Oi.BLOCK:Oi.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:W(({commands:e,chain:t},r)=>(e.setMeta("preventAutolink",!0),e.getSelectedText()?t().applyMark(this.name,r).expandSelectionToLink().command(({tr:i})=>(r.text&&i.insertText(r.text,i.selection.from,i.selection.to),!0)).run():e.insertContent(Wy.text(r.text,[Wy.mark(ke.LINK,r)])))),expandSelectionToLink:W(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:W(({commands:e})=>e.hasMark(this.name)),getLinkPreset:W(()=>ge(()=>H(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),QM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Oi.BLOCK?`#${n.href}`:n.href,t=H(this.options.basePresetClass)+H(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),yN=wt.create({name:ke.SUPERSCRIPT,addCommands(){return{applySuperscript:W(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:W(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:W(({commands:n})=>{H(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:W(({commands:n})=>{const e=n.getMark(this.name);return ge(()=>!!H(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),bN=Re.create({name:ke.MARGIN,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[ke.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:s}=n.style;return[e,t,r,i,s].some(c=>!!c)?e?{value:e}:{value:[t||0,r||0,i||0,s||0].join(" ")}:null},renderHTML(n){return n.margin?Cl({margin:n.margin.value}):null}}}}]});function _N(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=kc({default:null,link:null});return r5(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),qI().concat([GI.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new CN({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),uN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),ZI.configure({device:n.deviceRef}),jI.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),KI.configure({fonts:n.fonts,defaultPreset:yi(t,"default"),defaultFont:n.defaultFont}),JI,YI,XI,QI,eN,tN,yN,nN,rN.configure({wrapperRef:n.wrapperRef}),iN,gN.configure({preset:yi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),bN])}class wN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class Hy{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class _n extends Hy{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=_n.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=s=>s.tagName!=="BODY"&&t.call(this,s),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:s=>r(s)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,s;const a=u=>{this._assignElementProperties(u,e,_n.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,_n.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){a(u),i=null,s=u;continue}if(u.tagName==="BR"&&s&&s?.tagName!=="BR"){u.remove(),s=u;continue}if(u.tagName==="BR"){const c=this.dom.createElement("p");c.append(u),a(c),i=null,s=u;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(u),s=u}e.append(t),this._removeStyleProperties(e,_n.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,_n.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return _n.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return _n.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const s=t.style.getPropertyValue(i);s&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,s)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let s=i.cloneNode();const a=u=>{this._assignElementProperties(u,e,_n.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){a(s),s=i.cloneNode();continue}s.append(u)}t.append(s),e.replaceWith(t)}_normalizeBlockTextDecoration(){const e=this.dom.querySelectorAll('[style*="text-decoration"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveTextDecorationToChildren(t)}_moveTextDecorationToChildren(e){const t=this._parseTextDecoration(e);if(e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration"),e.style.cssText||e.removeAttribute("style"),!t.none)for(const r of e.childNodes){const i=this._wrapTextNode(e,r),s=this._parseTextDecoration(i),a={underline:s.underline||t.underline,line_through:s.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,u])=>u).map(([u])=>u.replace("_","-")).join(" ")}}_parseTextDecoration(e){const{textDecoration:t,textDecorationLine:r}=e.style,i=t||r||"";return{none:i.includes("none"),underline:i.includes("underline"),line_through:i.includes("line-through")}}_normalizeBlockBackgroundColor(){const e=this.dom.querySelectorAll('[style*="background-color"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveBackgroundColorToChildren(t)}_moveBackgroundColorToChildren(e){const t=e.style.backgroundColor;e.style.removeProperty("background-color"),e.style.cssText||e.removeAttribute("style");for(const r of e.childNodes){const i=this._wrapTextNode(e,r),s=i.style.backgroundColor||t;i.style.backgroundColor=s}}_wrapTextNode(e,t){if(t.nodeType!==this._Node.TEXT_NODE)return t;const r=this.dom.createElement("span");return r.append(t.cloneNode()),e.replaceChild(r,t),r}}class vN extends Hy{normalize(){return this._iterateNodes(this._bubbleMarks),this.content}_iterateNodes(e){this._iterateChildNodes(this.content,e)}_iterateChildNodes(e,t){for(const r of e.content)r.content&&this._iterateChildNodes(r,t),t.call(this,r)}_bubbleMarks(e){if(e.content&&e.type!==oe.LIST){for(const t of e.content)if(!this._isLink(t)&&t.marks)for(const r of t.marks.slice()){if(this._includesMark(e,r)){this._removeMark(t,r);continue}this._canBubbleMark(e,r)&&(this._removeMark(t,r),this._addMark(e,r))}}}_canBubbleMark(e,t){if(m1.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===oe.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>By.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===oe.TEXT&&this._includesMarkType(e,ke.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Bl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new _n({content:e,parser:t.parser||new wN})}static _buildJson(e){return new vN({content:e})}static normalize(e,t={}){return Bl.build(e,t).normalize()}}class Pi{static window=globalThis.window;static use(e){this.window=e}static get document(){return this.window.document}static get body(){return this.document.body}static get head(){return this.document.head}static getComputedStyle(e){return this.window.getComputedStyle(e)}}class Eh{static build({config:e,nodeDomParser:t}){const r=_N({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:na(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:na(If.DESKTOP),pageBlocksRef:na([]),wrapperRef:Pi.document.createElement("p")}),i=WA(r);return new Eh({schema:i,domParser:_s.fromSchema(i),nodeDomParser:t})}_schema;_domParser;_nodeDomParser;constructor({schema:e,domParser:t,nodeDomParser:r}){this._schema=e,this._domParser=t,this._nodeDomParser=r}toJSON(e){const t=Bl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}function SN(n,e){return n.type===e}function xN(n){return typeof n=="string"}class Wy{static doc(e){return{type:oe.DOCUMENT,content:e}}static list(e,t){return{type:oe.LIST,attrs:{bullet:{type:e}},content:t.map(r=>SN(r,oe.LIST_ITEM)?r:this.listItem([r].flat()))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{type:oe.LIST_ITEM,...t?{attrs:t}:{},...i?{marks:i}:{},content:[r].flat().map(s=>xN(s)?this.paragraph(s):s)}}static heading(e,...t){const r=this.textBlock(t);return r.attrs??={},r.attrs.level=e,{type:oe.HEADING,...r}}static paragraph(...e){return{type:oe.PARAGRAPH,...this.textBlock(e)}}static textBlock(e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{content:typeof r=="string"?[this.text(r)]:[r].flat(),...t?{attrs:t}:{},...i?{marks:i}:{}}}static normalizeTextBlockArgs(e){return e.length===1?{attrs:null,marks:null,content:e[0]}:e.length===2?{attrs:e[0],marks:null,content:e[1]}:{attrs:e[0],marks:e[1],content:e[2]}}static text(e,t){return{type:oe.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ke.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class CN{_baseClass;_makeVariable;_linkPresetId;constructor({baseClass:e,makeVariable:t,linkPresetId:r}){this._baseClass=e,this._makeVariable=t,this._linkPresetId=r}inject(e,t){let r=e.querySelector("[data-zw-styles]");r||(r=Pi.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,s=this.makePresetCssClass(r);t+=` ${s} {`;for(const a of MM)for(const u of Object.keys(r[a])){const c=this._makeVariable({device:a,preset:r,property:u}),h=this._makeInternalVariableName(u,a);if(t+=`${h}: var(${c}, inherit);`,i&&!p1.includes(u)){const p=h.replace("preset-","");t+=`${p}: var(${h});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===If.COMMON?"":`-${t}`;return`--zw-preset-${r}${i}`}makePresetHtmlClass(e){return this._baseClass+e.id}makePresetCssClass(e){return this.makePresetHtmlClass(e).split(" ").map(t=>`.${t}`).join("")}}class kh{static _instance;static get instance(){return this._instance??=new kh,this._instance}static query(e,t){return this.instance.query(e,t)}query(e,t){let r=null;return e.descendants(i=>{if(r)return!1;if(this.matchNode(i,t))return r=i,!1}),r?t.getMark?this.getMark(r,t.getMark):r:null}matchNode(e,t){return!(t.typeName&&t.typeName!==e.type.name||t.mark&&!this.getMark(e,t.mark))}getMark(e,t){return e.marks.find(r=>this.matchMark(r,t))||null}matchMark(e,t){return e.type.name===t.typeName}}class Vy{static createWindow(){return new sm.JSDOM().window}types;parse(e){const{window:t}=new sm.JSDOM(e);return this.types=t,t.document}}class Uy{name;description;argument;options=[];doCommand(){throw new Error('Command "doCommand" is required')}install(e){if(!this.name)throw new Error('Command "name" is required');let t=e.command(this.name);if(this.description&&(t=t.description(this.description)),this.argument&&(t=t.argument(this.argument)),this.options.length)for(const r of this.options)t=t.option(r.flags,r.description,r.default);t.action(this.doCommand.bind(this))}output(e){}}class EN extends Uy{name="to-json";description="migrate html to json";argument="<html...>";options=[{flags:"-c, --config <path>",description:"Generator config",default:im.resolve(__dirname,"../bin/zp.config.json")},{flags:"-f, --format <type>",description:"Set output format",default:"rb"}];doCommand(e,{config:t,format:r}){Pi.use(Vy.createWindow());const i=im.resolve(process.cwd(),t),s=Eh.build({config:require(i).editor,nodeDomParser:new Vy}),a=e.map(h=>s.toJSON(this._formatInputHtml(h))),u=a.length===1?a[0]:a,c=this._stringifyContent(u);this.output(r==="rb"?this._formatOutputRb(c):c)}_formatInputHtml(e){return e.replace(/\\(["'])/g,"$1").replace(/rgba\(\d{1,3}, ?\d{1,3}, ?\d{1,3}, (\d{1,2}%)\)/g,(t,r)=>t.replace(r,parseFloat(r)/100))}_stringifyContent(e){return JSON.stringify(e,(r,i)=>i===null?void 0:i,2)}_formatOutputRb(e){return e.replace(/\\"/g,'"').replace(/font-family: ?'(.+)'/g,'font-family: "$1"').replace(/'/g,"\\'").replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm,t=>t.replace(/"/g,"")).replace(/: "(.+)"([,\n])/g,": '$1'$2")}}var kN="4.12.0-beta.1";class TN extends Uy{name="version";description="display cli version";doCommand(){this.output(kN)}}const qy=new UC,AN=[EN,TN];for(const n of AN)new n().install(qy);qy.parse();
package/dist/node.js CHANGED
@@ -36,4 +36,4 @@ __p += '`),fe&&(R+=`' +
36
36
  function print() { __p += __j.call(arguments, '') }
37
37
  `:`;
38
38
  `)+R+`return __p
39
- }`;var ee=Gp(function(){return me(v,G+"return "+R).apply(t,x)});if(ee.source=R,Kc(ee))throw ee;return ee}function bx(s){return ge(s).toLowerCase()}function wx(s){return ge(s).toUpperCase()}function vx(s,l,u){if(s=ge(s),s&&(u||l===t))return td(s);if(!s||!(l=kt(l)))return s;var d=jt(s),y=jt(l),v=nd(d,y),x=rd(d,y)+1;return nr(d,v,x).join("")}function Sx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.slice(0,sd(s)+1);if(!s||!(l=kt(l)))return s;var d=jt(s),y=rd(d,jt(l))+1;return nr(d,0,y).join("")}function xx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.replace(Ka,"");if(!s||!(l=kt(l)))return s;var d=jt(s),y=nd(d,jt(l));return nr(d,y).join("")}function kx(s,l){var u=Gn,d=sn;if(Ce(l)){var y="separator"in l?l.separator:y;u="length"in l?Q(l.length):u,d="omission"in l?kt(l.omission):d}s=ge(s);var v=s.length;if(ti(s)){var x=jt(s);v=x.length}if(u>=v)return s;var E=u-ni(d);if(E<1)return d;var T=x?nr(x,0,E).join(""):s.slice(0,E);if(y===t)return T+d;if(x&&(E+=T.length-E),Gc(y)){if(s.slice(E).search(y)){var N,O=T;for(y.global||(y=ac(y.source,ge(kh.exec(y))+"g")),y.lastIndex=0;N=y.exec(O);)var R=N.index;T=T.slice(0,R===t?E:R)}}else if(s.indexOf(kt(y),E)!=E){var H=T.lastIndexOf(y);H>-1&&(T=T.slice(0,H))}return T+d}function Ex(s){return s=ge(s),s&&Py.test(s)?s.replace(vh,Qb):s}var _x=ci(function(s,l,u){return s+(u?" ":"")+l.toUpperCase()}),jc=Jd("toUpperCase");function Kp(s,l,u){return s=ge(s),l=u?t:l,l===t?qb(s)?n2(s):Fb(s):s.match(l)||[]}var Gp=ie(function(s,l){try{return St(s,t,l)}catch(u){return Kc(u)?u:new X(u)}}),Tx=_n(function(s,l){return Lt(l,function(u){u=un(u),kn(s,u,Uc(s[u],s))}),s});function Cx(s){var l=s==null?0:s.length,u=J();return s=l?_e(s,function(d){if(typeof d[1]!="function")throw new Pt(a);return[u(d[0]),d[1]]}):[],ie(function(d){for(var y=-1;++y<l;){var v=s[y];if(St(v[0],this,d))return St(v[1],this,d)}})}function Mx(s){return Q2(zt(s,p))}function Yc(s){return function(){return s}}function Ax(s,l){return s==null||s!==s?l:s}var Ix=jd(),Nx=jd(!0);function ht(s){return s}function Xc(s){return _d(typeof s=="function"?s:zt(s,p))}function Ox(s){return Cd(zt(s,p))}function Rx(s,l){return Md(s,zt(l,p))}var Lx=ie(function(s,l){return function(u){return es(u,s,l)}}),Px=ie(function(s,l){return function(u){return es(s,u,l)}});function Zc(s,l,u){var d=He(l),y=vo(l,d);u==null&&!(Ce(l)&&(y.length||!d.length))&&(u=l,l=s,s=this,y=vo(l,He(l)));var v=!(Ce(u)&&"chain"in u)||!!u.chain,x=Cn(s);return Lt(y,function(E){var T=l[E];s[E]=T,x&&(s.prototype[E]=function(){var N=this.__chain__;if(v||N){var O=s(this.__wrapped__),R=O.__actions__=ct(this.__actions__);return R.push({func:T,args:arguments,thisArg:s}),O.__chain__=N,O}return T.apply(s,Yn([this.value()],arguments))})}),s}function Dx(){return qe._===this&&(qe._=a2),this}function Qc(){}function zx(s){return s=Q(s),ie(function(l){return Ad(l,s)})}var Bx=Ic(_e),Fx=Ic(Yh),Hx=Ic(tc);function Jp(s){return zc(s)?nc(un(s)):gw(s)}function $x(s){return function(l){return s==null?t:Nr(s,l)}}var Wx=Xd(),Ux=Xd(!0);function eu(){return[]}function tu(){return!1}function Vx(){return{}}function Kx(){return""}function Gx(){return!0}function Jx(s,l){if(s=Q(s),s<1||s>qn)return[];var u=vt,d=Qe(s,vt);l=J(l),s-=vt;for(var y=sc(d,l);++u<s;)l(u);return y}function qx(s){return Z(s)?_e(s,un):Et(s)?[s]:ct(dp(ge(s)))}function jx(s){var l=++o2;return ge(s)+l}var Yx=To(function(s,l){return s+l},0),Xx=Nc("ceil"),Zx=To(function(s,l){return s/l},1),Qx=Nc("floor");function ek(s){return s&&s.length?wo(s,ht,gc):t}function tk(s,l){return s&&s.length?wo(s,J(l,2),gc):t}function nk(s){return Qh(s,ht)}function rk(s,l){return Qh(s,J(l,2))}function ik(s){return s&&s.length?wo(s,ht,vc):t}function sk(s,l){return s&&s.length?wo(s,J(l,2),vc):t}var ok=To(function(s,l){return s*l},1),lk=Nc("round"),ak=To(function(s,l){return s-l},0);function ck(s){return s&&s.length?ic(s,ht):0}function uk(s,l){return s&&s.length?ic(s,J(l,2)):0}return w.after=OS,w.ary=Ep,w.assign=w5,w.assignIn=Bp,w.assignInWith=Fo,w.assignWith=v5,w.at=S5,w.before=_p,w.bind=Uc,w.bindAll=Tx,w.bindKey=Tp,w.castArray=VS,w.chain=Sp,w.chunk=Qw,w.compact=ev,w.concat=tv,w.cond=Cx,w.conforms=Mx,w.constant=Yc,w.countBy=cS,w.create=x5,w.curry=Cp,w.curryRight=Mp,w.debounce=Ap,w.defaults=k5,w.defaultsDeep=E5,w.defer=RS,w.delay=LS,w.difference=nv,w.differenceBy=rv,w.differenceWith=iv,w.drop=sv,w.dropRight=ov,w.dropRightWhile=lv,w.dropWhile=av,w.fill=cv,w.filter=fS,w.flatMap=pS,w.flatMapDeep=mS,w.flatMapDepth=gS,w.flatten=yp,w.flattenDeep=uv,w.flattenDepth=fv,w.flip=PS,w.flow=Ix,w.flowRight=Nx,w.fromPairs=hv,w.functions=N5,w.functionsIn=O5,w.groupBy=yS,w.initial=pv,w.intersection=mv,w.intersectionBy=gv,w.intersectionWith=yv,w.invert=L5,w.invertBy=P5,w.invokeMap=wS,w.iteratee=Xc,w.keyBy=vS,w.keys=He,w.keysIn=ft,w.map=Ro,w.mapKeys=z5,w.mapValues=B5,w.matches=Ox,w.matchesProperty=Rx,w.memoize=Po,w.merge=F5,w.mergeWith=Fp,w.method=Lx,w.methodOf=Px,w.mixin=Zc,w.negate=Do,w.nthArg=zx,w.omit=H5,w.omitBy=$5,w.once=DS,w.orderBy=SS,w.over=Bx,w.overArgs=zS,w.overEvery=Fx,w.overSome=Hx,w.partial=Vc,w.partialRight=Ip,w.partition=xS,w.pick=W5,w.pickBy=Hp,w.property=Jp,w.propertyOf=$x,w.pull=Sv,w.pullAll=wp,w.pullAllBy=xv,w.pullAllWith=kv,w.pullAt=Ev,w.range=Wx,w.rangeRight=Ux,w.rearg=BS,w.reject=_S,w.remove=_v,w.rest=FS,w.reverse=$c,w.sampleSize=CS,w.set=V5,w.setWith=K5,w.shuffle=MS,w.slice=Tv,w.sortBy=NS,w.sortedUniq=Rv,w.sortedUniqBy=Lv,w.split=px,w.spread=HS,w.tail=Pv,w.take=Dv,w.takeRight=zv,w.takeRightWhile=Bv,w.takeWhile=Fv,w.tap=eS,w.throttle=$S,w.thru=Oo,w.toArray=Pp,w.toPairs=$p,w.toPairsIn=Wp,w.toPath=qx,w.toPlainObject=zp,w.transform=G5,w.unary=WS,w.union=Hv,w.unionBy=$v,w.unionWith=Wv,w.uniq=Uv,w.uniqBy=Vv,w.uniqWith=Kv,w.unset=J5,w.unzip=Wc,w.unzipWith=vp,w.update=q5,w.updateWith=j5,w.values=hi,w.valuesIn=Y5,w.without=Gv,w.words=Kp,w.wrap=US,w.xor=Jv,w.xorBy=qv,w.xorWith=jv,w.zip=Yv,w.zipObject=Xv,w.zipObjectDeep=Zv,w.zipWith=Qv,w.entries=$p,w.entriesIn=Wp,w.extend=Bp,w.extendWith=Fo,Zc(w,w),w.add=Yx,w.attempt=Gp,w.camelCase=ex,w.capitalize=Up,w.ceil=Xx,w.clamp=X5,w.clone=KS,w.cloneDeep=JS,w.cloneDeepWith=qS,w.cloneWith=GS,w.conformsTo=jS,w.deburr=Vp,w.defaultTo=Ax,w.divide=Zx,w.endsWith=tx,w.eq=Xt,w.escape=nx,w.escapeRegExp=rx,w.every=uS,w.find=hS,w.findIndex=mp,w.findKey=_5,w.findLast=dS,w.findLastIndex=gp,w.findLastKey=T5,w.floor=Qx,w.forEach=xp,w.forEachRight=kp,w.forIn=C5,w.forInRight=M5,w.forOwn=A5,w.forOwnRight=I5,w.get=Jc,w.gt=YS,w.gte=XS,w.has=R5,w.hasIn=qc,w.head=bp,w.identity=ht,w.includes=bS,w.indexOf=dv,w.inRange=Z5,w.invoke=D5,w.isArguments=Lr,w.isArray=Z,w.isArrayBuffer=ZS,w.isArrayLike=ut,w.isArrayLikeObject=Ne,w.isBoolean=QS,w.isBuffer=rr,w.isDate=e5,w.isElement=t5,w.isEmpty=n5,w.isEqual=r5,w.isEqualWith=i5,w.isError=Kc,w.isFinite=s5,w.isFunction=Cn,w.isInteger=Np,w.isLength=zo,w.isMap=Op,w.isMatch=o5,w.isMatchWith=l5,w.isNaN=a5,w.isNative=c5,w.isNil=f5,w.isNull=u5,w.isNumber=Rp,w.isObject=Ce,w.isObjectLike=Me,w.isPlainObject=ls,w.isRegExp=Gc,w.isSafeInteger=h5,w.isSet=Lp,w.isString=Bo,w.isSymbol=Et,w.isTypedArray=fi,w.isUndefined=d5,w.isWeakMap=p5,w.isWeakSet=m5,w.join=bv,w.kebabCase=ix,w.last=Ft,w.lastIndexOf=wv,w.lowerCase=sx,w.lowerFirst=ox,w.lt=g5,w.lte=y5,w.max=ek,w.maxBy=tk,w.mean=nk,w.meanBy=rk,w.min=ik,w.minBy=sk,w.stubArray=eu,w.stubFalse=tu,w.stubObject=Vx,w.stubString=Kx,w.stubTrue=Gx,w.multiply=ok,w.nth=vv,w.noConflict=Dx,w.noop=Qc,w.now=Lo,w.pad=lx,w.padEnd=ax,w.padStart=cx,w.parseInt=ux,w.random=Q5,w.reduce=kS,w.reduceRight=ES,w.repeat=fx,w.replace=hx,w.result=U5,w.round=lk,w.runInContext=_,w.sample=TS,w.size=AS,w.snakeCase=dx,w.some=IS,w.sortedIndex=Cv,w.sortedIndexBy=Mv,w.sortedIndexOf=Av,w.sortedLastIndex=Iv,w.sortedLastIndexBy=Nv,w.sortedLastIndexOf=Ov,w.startCase=mx,w.startsWith=gx,w.subtract=ak,w.sum=ck,w.sumBy=uk,w.template=yx,w.times=Jx,w.toFinite=Mn,w.toInteger=Q,w.toLength=Dp,w.toLower=bx,w.toNumber=Ht,w.toSafeInteger=b5,w.toString=ge,w.toUpper=wx,w.trim=vx,w.trimEnd=Sx,w.trimStart=xx,w.truncate=kx,w.unescape=Ex,w.uniqueId=jx,w.upperCase=_x,w.upperFirst=jc,w.each=xp,w.eachRight=kp,w.first=bp,Zc(w,function(){var s={};return an(w,function(l,u){we.call(w.prototype,u)||(s[u]=l)}),s}(),{chain:!1}),w.VERSION=r,Lt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){w[s].placeholder=w}),Lt(["drop","take"],function(s,l){oe.prototype[s]=function(u){u=u===t?1:De(Q(u),0);var d=this.__filtered__&&!l?new oe(this):this.clone();return d.__filtered__?d.__takeCount__=Qe(u,d.__takeCount__):d.__views__.push({size:Qe(u,vt),type:s+(d.__dir__<0?"Right":"")}),d},oe.prototype[s+"Right"]=function(u){return this.reverse()[s](u).reverse()}}),Lt(["filter","map","takeWhile"],function(s,l){var u=l+1,d=u==on||u==Fe;oe.prototype[s]=function(y){var v=this.clone();return v.__iteratees__.push({iteratee:J(y,3),type:u}),v.__filtered__=v.__filtered__||d,v}}),Lt(["head","last"],function(s,l){var u="take"+(l?"Right":"");oe.prototype[s]=function(){return this[u](1).value()[0]}}),Lt(["initial","tail"],function(s,l){var u="drop"+(l?"":"Right");oe.prototype[s]=function(){return this.__filtered__?new oe(this):this[u](1)}}),oe.prototype.compact=function(){return this.filter(ht)},oe.prototype.find=function(s){return this.filter(s).head()},oe.prototype.findLast=function(s){return this.reverse().find(s)},oe.prototype.invokeMap=ie(function(s,l){return typeof s=="function"?new oe(this):this.map(function(u){return es(u,s,l)})}),oe.prototype.reject=function(s){return this.filter(Do(J(s)))},oe.prototype.slice=function(s,l){s=Q(s);var u=this;return u.__filtered__&&(s>0||l<0)?new oe(u):(s<0?u=u.takeRight(-s):s&&(u=u.drop(s)),l!==t&&(l=Q(l),u=l<0?u.dropRight(-l):u.take(l-s)),u)},oe.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},oe.prototype.toArray=function(){return this.take(vt)},an(oe.prototype,function(s,l){var u=/^(?:filter|find|map|reject)|While$/.test(l),d=/^(?:head|last)$/.test(l),y=w[d?"take"+(l=="last"?"Right":""):l],v=d||/^find/.test(l);y&&(w.prototype[l]=function(){var x=this.__wrapped__,E=d?[1]:arguments,T=x instanceof oe,N=E[0],O=T||Z(x),R=function(se){var fe=y.apply(w,Yn([se],E));return d&&H?fe[0]:fe};O&&u&&typeof N=="function"&&N.length!=1&&(T=O=!1);var H=this.__chain__,G=!!this.__actions__.length,q=v&&!H,ee=T&&!G;if(!v&&O){x=ee?x:new oe(this);var j=s.apply(x,E);return j.__actions__.push({func:Oo,args:[R],thisArg:t}),new Dt(j,H)}return q&&ee?s.apply(this,E):(j=this.thru(R),q?d?j.value()[0]:j.value():j)})}),Lt(["pop","push","shift","sort","splice","unshift"],function(s){var l=ro[s],u=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",d=/^(?:pop|shift)$/.test(s);w.prototype[s]=function(){var y=arguments;if(d&&!this.__chain__){var v=this.value();return l.apply(Z(v)?v:[],y)}return this[u](function(x){return l.apply(Z(x)?x:[],y)})}}),an(oe.prototype,function(s,l){var u=w[l];if(u){var d=u.name+"";we.call(oi,d)||(oi[d]=[]),oi[d].push({name:l,func:u})}}),oi[_o(t,M).name]=[{name:"wrapper",func:t}],oe.prototype.clone=E2,oe.prototype.reverse=_2,oe.prototype.value=T2,w.prototype.at=tS,w.prototype.chain=nS,w.prototype.commit=rS,w.prototype.next=iS,w.prototype.plant=oS,w.prototype.reverse=lS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=aS,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=sS),w},ri=r2();Tr?((Tr.exports=ri)._=ri,Xa._=ri):qe._=ri}).call(QI)}($s,$s.exports)),$s.exports}var wy=eN();function ch(n){return n.type.create(wy.cloneDeep(n.attrs))}function uh({tr:n,node:e,position:t,mark:r}){return e.isText?n.removeMark(t,t+e.nodeSize,r):n.removeNodeMark(t,r)}const tN=Ie.create({name:"node_processor",addCommands(){return{setBlockAttributes:B(({commands:n,state:e},t,r,i={})=>{const o=z(n.getBlockAttributes(t))??{},{doc:a,tr:c}=e,{from:f,to:h}=c.selection;a.nodesBetween(f,h,(m,p)=>{kf.includes(m.type.name)&&c.setNodeAttribute(p,t,{...i,...o,...r})})}),getBlockAttributes:B(({editor:n},e,t)=>de(()=>{let r=Object.assign({},t||{});for(const i of kf)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:B(({commands:n},e)=>{for(const t of kf)n.resetAttributes(t,e)}),applyMark:B(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:a,schema:c}=n,{$from:f,$to:h}=o.selection,m=hn(ke.LINK,c),p=hn(t,c);if(!(p.spec.group||"").includes(At.SETTINGS))return e.setMark(t,r);if(f.pos===h.pos)return;const b=S=>{if(!i.onAppliedToParent||i.onAppliedToParent(S)===!1){const{tr:k,node:C,position:M,mark:P}=S;uh({tr:k,node:C,position:M,mark:P.type})}};a.nodesBetween(f.pos,h.pos,(S,k)=>{if(S.type.name===te.LIST)return;const C=ZI(S.marks,t),M=p.create({...C?.attrs||{},...r}),P=gy(f,h,S,k);if(!m.isInSet(S.marks)&&XI(o.doc,k,M,i.isAppliedToParent))return b({tr:o,node:S,position:k,mark:M});if(S.isText){o.addMark(P.from,P.to,M);return}jI(o.doc,o.selection,S,k)&&o.addNodeMark(k,M)})}),getMarks:B(({editor:n},e)=>{const t=gi(n,"state");return de(()=>{const{selection:r,doc:i}=z(t),{from:o,to:a}=z(r),c=[];return i.nodesBetween(o,a,f=>{for(const h of f.marks)h.type.name===e&&c.unshift(h.attrs)}),c})}),getMark:B(({commands:n},e)=>{const t=n.getMarks(e);return de(()=>z(t)[0]??null)}),hasMark:B(({commands:n},e)=>{const t=n.getMark(e);return de(()=>!!z(t))}),getCommonSettingMark:B(({commands:n},e,t)=>{const r=n.getMark(e);return de(()=>z(r)?.value??z(t))}),getDeviceSettingMark:B(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return de(()=>{for(const o of z(r)){const a=o[z(i)];if(a)return a}return z(t)})}),removeAllMarks:B(({state:n})=>{const{tr:e,doc:t}=n,{from:r,to:i}=e.selection;t.nodesBetween(r,i,(o,a)=>{for(const c of o.marks)uh({tr:e,node:o,position:a,mark:c})})}),removeMarks:B(({state:n},e)=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(a,c)=>{const f=a.marks.filter(h=>e.includes(h.type.name));for(const h of f)uh({tr:t,node:a,position:c,mark:h})})})}}}),nN=Ie.create({name:"text_processor",addCommands(){return{getSelectedText:B(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:B(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const a=gy(t,r,i,o),c=Math.max(0,t.pos-o),f=Math.max(0,r.pos-o),h=e({text:i.textContent.substring(c,f)}),m=n.schema.text(h,i.marks);n.tr.replaceWith(a.from,a.to,m)})})}}}),rN=Ie.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:B(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:B(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:B(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;return n.doc.nodesBetween(r,i,(o,a,c)=>{if(t({node:o,parent:c})){const f=o.isText?0:yy(n.doc,a);r=Math.min(r,a+f),i=Math.max(i,a+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:B(({commands:n})=>n.expandSelection(({parent:e})=>e.type.name===te.DOCUMENT))}}}),iN=Kn.create({name:"doc",topNode:!0,content:"block+"});class Ks extends $e{constructor(e,t,r,i="SetDocAttr"){super(),this.key=e,this.value=t,this.schema=r,this.stepType=i}apply(e){this.prevValue=e.attrs.meta[this.key];const t=cr.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,Re.ok(t)}invert(){return new Ks(this.key,this.prevValue,this.schema,"revertSetDocAttr")}map(){return null}toJSON(){return{stepType:this.stepType,key:this.key,value:this.value}}static fromJSON(e){return new Ks(e.key,e.value,e.stepType)}}$e.jsonID("setDocAttr",Ks);const sN=iN.extend({marks:At.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:B(({state:n},e,t)=>{n.tr.step(new Ks(e,t,n.schema))})}}}),oN=Kn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Mi(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),lN=oN.extend({marks:At.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),aN=Kn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Mi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>PM({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),cN=aN.extend({marks:At.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),uN=Ie.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[QM.create(this.editor),eA.create(this.editor)]}}),fN=()=>[sN,lN,cN,BM,qM,tN,nN,rN,uN],hN=yt.create({name:ke.FONT_FAMILY,group:At.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:B(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=z(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ke.FONT_STYLE).value;t.isItalicOnly?n.applyItalic():!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:B(({commands:n})=>{const e=z(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return de(()=>n.findFontByName(z(r))||t)}),findFontByName:B((n,e)=>z(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:B(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:B(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_family)})}},parseHTML(){const n=e=>({value:e.replace(/["']/g,"")});return[{style:"--zw-font-family",getAttrs:n},{style:"font-family",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.value?`"${n.value}"`:null;return Sr({font_family:e})}}),dN=Ie.create({name:ke.STYLE_PRESET,addGlobalAttributes(){return[{types:[te.PARAGRAPH,te.HEADING],attributes:{preset:{isRequired:!1,default:{id:z(this.options.defaultId)},parseHTML:n=>{const e=z(this.options.presets);if(n.parentElement.tagName==="LI")return null;for(const{id:t,node:r,fallbackClass:i}of e){if(i&&n.classList.contains(i))return{id:t};const o=z(this.options.styleRenderer).makePresetCssClass({id:t});if(n.matches(o))return{id:t};if(n.tagName===`H${r?.level}`)return{id:t}}return n.tagName==="P"?{id:z(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:z(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const a=t[o],c=r[o],f=!c||c.toLowerCase()==="inherit";i[o]=f?a:c}return i}return{getPresetList:B(()=>de(()=>z(this.options.presets).filter(t=>!t.hidden))),getPreset:B(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:z(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),a=t.getLinkPreset();return de(()=>{const c=n(z(i),z(r).id);if(!z(o))return c;const f=z(a);return{id:c.id,common:e(c.common,f.common),mobile:e(c.mobile,f.mobile),tablet:e(c.tablet,f.tablet),desktop:e(c.desktop,f.desktop)}})}),applyPreset:B(({commands:t,chain:r},i)=>{const o=z(t.getPresetList()),a=n(o,i),c=a.node?.type??te.PARAGRAPH,f={preset:{id:i}};a.node&&(f.level=a.node.level);for(const h of j0)f[h]=z(t.getBlockAttributes(h));r().removeList().setNode(c,f).run()}),applyDefaultPreset:B(({commands:t})=>{t.applyPreset(z(this.options.defaultId))}),removePreset:B(({commands:t})=>{t.setNode(te.PARAGRAPH,{preset:null})}),getPresetCustomization:B(({editor:t,commands:r})=>{const i=gi(t,"state");return de(()=>{const{selection:o,doc:a}=z(i),{from:c,to:f}=o;return r._getSettingCustomization(a,c,f)})}),isSettingCustomized:B(({commands:t},r)=>{const i=t.getPresetCustomization(),o=zl.includes(r)?"attributes":"marks";return de(()=>z(i)[o]?.includes(r)??!1)}),getContentCustomization:B(({editor:t,commands:r})=>{const i=gi(t,"state");return de(()=>{const{doc:o}=z(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:B((t,r,i,o)=>{const a=new Set,c=new Set;return r.nodesBetween(i,o,f=>{for(const[h,m]of Object.entries(f.attrs))zl.includes(h)&&m&&c.add(h);for(const{type:h}of f.marks)X0.includes(h.name)&&a.add(h.name)}),{attributes:Array.from(c),marks:Array.from(a)}}),removePresetCustomization:B(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(X0).resetAttributes(te.PARAGRAPH,zl).resetAttributes(te.HEADING,zl).restoreSelection().run()}),removeFormat:B(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Li.head,z(this.options.presets))}}),pN=yt.create({name:ke.FONT_WEIGHT,group:At.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:B(({commands:n},e)=>{n.applyMark(this.name,{value:e}),z(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:B(({commands:n})=>{const e=z(n.getFontWeight()),t=z(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:B(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return de(()=>{const r=z(e),i=z(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:B(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Kt("toggleBold"),"Mod-B":Kt("toggleBold")}),parseHTML(){const n=e=>e==="bold"?{value:"700"}:Number(e)?{value:e}:!1;return[{style:"--zw-font-weight",getAttrs:n},{style:"font-weight",getAttrs:n},{tag:"b",attrs:{value:"700"}},{tag:"strong",attrs:{value:"700"}}]},renderHTML({HTMLAttributes:n}){return Sr({font_weight:n.value})}}),mN=yt.create({name:ke.FONT_SIZE,group:At.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:B(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].font_size.replace("px",""))}),applyFontSize:B(({commands:n},e)=>{const t=z(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:a})=>{const c={...a.attrs,[t]:null};if(!Object.values(c).some(m=>!!m))return!1;const h=a.type.create(c);if(i.isText){r.addMark(o,o+i.nodeSize,h);return}r.addNodeMark(o,h)}})}),increaseFontSize:B(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.min(e+1,z(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:B(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.max(e-1,z(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Kt("increaseFontSize"),"Mod-Shift--":Kt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=z(this.options.wrapperRef),r=my(e,t);return String(r)};return[{tag:'[style*="--zw-font-size"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-font-size-mobile")),tablet:n(e.getPropertyValue("--zw-font-size-tablet")),desktop:n(e.getPropertyValue("--zw-font-size-desktop"))})},{style:"font-size",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:null}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return Sr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),gN=yt.create({name:ke.FONT_COLOR,group:At.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:B(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:B(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.color)}),applyFontColor:B(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:dy(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Sr({font_color:n.value})}}),yN=yt.create({name:ke.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:B(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:B(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:dy(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Sr({background_color:n.value})}}),bN=Ie.create({name:"device_manager",addCommands(){return{getDevice:B(()=>gi(this.options,"device"))}}}),wN=yt.create({name:ke.FONT_STYLE,group:At.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:B(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return de(()=>z(e)?.italic??z(t).italic)}),isItalicAvailable:B(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return de(()=>{const r=z(e),i=z(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:B(({commands:n})=>{const e=n.getPreset();return de(()=>({italic:z(e).common.font_style==="italic"}))}),toggleItalic:B(({commands:n})=>{z(n.isItalicAvailable())&&(z(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:B(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:B(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Kt("toggleItalic"),"Mod-I":Kt("toggleItalic")}),parseHTML(){const n=e=>({italic:e.includes("italic")});return[{tag:"i",attrs:{italic:!0}},{style:"--zw-font-style",getAttrs:n},{style:"font-style",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.italic?"italic":"normal";return Sr({font_style:e})}}),vN=yt.create({name:ke.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:B(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).underline)}),isStrikeThrough:B(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).strike_through)}),getTextDecoration:B(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return de(()=>{const r=z(e)??{},i=z(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:B(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return de(()=>z(e)!==z(t).underline)}),getDefaultTextDecoration:B(({commands:n})=>{const e=n.getPreset();return de(()=>{const{text_decoration:t}=z(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:B(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:B(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:B(({commands:n},e,t=null)=>{const r=z(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:B(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:B(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Kt("toggleUnderline"),"Mod-U":Kt("toggleUnderline")}),parseHTML(){const n=e=>{const t=e.includes("underline"),r=e.includes("line-through");return!t&&!r?!1:{underline:t,strike_through:r}};return[{style:"--zw-text-decoration",getAttrs:n},{style:"text-decoration-line",getAttrs:n},{style:"text-decoration",getAttrs:n},{tag:"s",attrs:{underline:!1,strike_through:!0}},{tag:"u",attrs:{underline:!0,strike_through:!1}}]},renderHTML({HTMLAttributes:n}){const e=[];return n.underline&&e.push("underline"),n.strike_through&&e.push("line-through"),e.length||e.push("none"),Sr({text_decoration:e.join(" ")})}}),SN=Ie.create({name:"case_style",addCommands(){return{applyCaseStyle:B(({commands:n},e)=>{switch(e){case Dl.CAPITALIZE:return n.applyCapitalize();case Dl.LOWERCASE:return n.applyLowerCase();case Dl.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:B(({commands:n})=>{n.transformText(({text:e})=>vA(e))}),applyLowerCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),vy={mobile:null,tablet:null,desktop:null},xN=Ie.create({name:ke.ALIGNMENT,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[ke.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=qI(n.textAlign);if(e)return{desktop:e,tablet:e,mobile:e};const t=n.getPropertyValue("--zw-alignment-mobile")||null,r=n.getPropertyValue("--zw-alignment-tablet")||null,i=n.getPropertyValue("--zw-alignment-desktop")||null;return!t&&!r&&!i?null:{desktop:i,tablet:r,mobile:t}},renderHTML(n){return n.alignment?ga({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:B(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},vy)}),removeAlignment:B(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:B(({commands:n})=>{const e=n.getBlockAttributes(this.name,vy),t=n.getDevice(),r=n.getDefaultAlignment();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultAlignment:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].alignment??yr.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Kt("applyAlignment",yr.LEFT),"Mod-Shift-e":Kt("applyAlignment",yr.CENTER),"Mod-Shift-r":Kt("applyAlignment",yr.RIGHT),"Mod-Shift-j":Kt("applyAlignment",yr.JUSTIFY)})}),Sy={mobile:null,tablet:null,desktop:null},kN=Ie.create({name:ke.LINE_HEIGHT,addGlobalAttributes(){return[{types:[te.PARAGRAPH,te.HEADING],attributes:{[ke.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=z(this.options.wrapperRef),r=KI(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?ga({line_height_mobile:n.line_height.mobile,line_height_tablet:n.line_height.tablet,line_height_desktop:n.line_height.desktop}):null}}}}]},addCommands(){return{getLineHeight:B(({commands:n})=>{const e=n.getBlockAttributes(this.name,Sy),t=n.getDevice(),r=n.getDefaultLineHeight();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultLineHeight:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].line_height)}),applyLineHeight:B(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},Sy)})}}}),EN=yt.create({name:ke.LETTER_SPACING,group:At.SETTINGS,addAttributes:()=>({mobile:{default:null},tablet:{default:null},desktop:{default:null}}),addCommands(){return{getLetterSpacing:B(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultLetterSpacing())),getDefaultLetterSpacing:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].letter_spacing||null)}),applyLetterSpacing:B(({commands:n},e)=>{const t=z(n.getDevice());n.applyMark(this.name,{[t]:e})})}},parseHTML(){const n=e=>{if(!e)return null;const t=z(this.options.wrapperRef);return`${GI(e,t)}px`};return[{tag:'[style*="--zw-letter-spacing"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-letter-spacing-mobile")),tablet:n(e.getPropertyValue("--zw-letter-spacing-tablet")),desktop:n(e.getPropertyValue("--zw-letter-spacing-desktop"))})},{style:"letter-spacing",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:t}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return Sr({letter_spacing_mobile:e(n.mobile),letter_spacing_tablet:e(n.tablet),letter_spacing_desktop:e(n.desktop)})}}),_N=Kn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Mi(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),TN=_N.extend({name:te.LIST_ITEM,marks:At.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:B(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const a of r.marks)t.addNodeMark(o,ch(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===te.LIST))return t.listItemNewline()}})});function CN(n,e){if(Y0.includes(e.type)||e.type.isInSet(n.marks))return!1;for(const t of n.content.content)if(t.childCount&&(!t.marks||!e.isInSet(t.marks)))return!1;return!0}function MN(n){const e=n.selection.$from.start(),t=n.selection.$to.end();n.doc.nodesBetween(e,t,(r,i)=>{if(r.type.name===te.LIST)return;if(r.type.name!==te.LIST_ITEM)return!1;const o=[];return r.forEach(a=>{for(const c of a.marks){if(c.isInSet(o)){n.removeNodeMark(i+1,c);continue}CN(r,c)&&(n.removeNodeMark(i+1,c),n.addNodeMark(i,ch(c)),o.push(c))}}),!1})}const AN=Kn.create({name:te.LIST,content:`${te.LIST_ITEM}+`,group:"block list",marks:At.SETTINGS,addExtensions:()=>[TN],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:tn.DISC}}}),parseHTML(){const n={a:tn.ROMAN,i:tn.LATIN,1:tn.DECIMAL},e=t=>{for(const r of XM){const i=`.${z(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||tn.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||tn.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[z(this.options.baseClass)+n.bullet.type,z(this.options.presetClass)];return[ZM.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:B(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return de(()=>z(e).type??null)}),applyList:B(({commands:n,chain:e},t)=>z(n.getListType())===t?n.removeList():e().applyDefaultPreset().toggleList(te.LIST,te.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({tr:i})=>MN(i)).run()),removeList:B(({chain:n})=>n().expandSelection(({parent:e})=>e.type.name===te.LIST).command(({tr:e})=>{const t=e.selection.$from.start(),r=e.selection.$to.end();return e.doc.nodesBetween(t,r,(i,o,a)=>{if([te.LIST,te.LIST_ITEM].includes(i.type.name))return;if(a.type.name!==te.LIST_ITEM)return!1;const c=a.marks.filter(f=>!f.type.isInSet(i.marks));for(const f of c)e.addNodeMark(o,ch(f));return!1}),!0}).liftListItem(te.LIST_ITEM).run())}},addInputRules(){const n=(e,t)=>DM({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(tn.DISC,/^\s*([-+*])\s$/),n(tn.DECIMAL,/^(\d+)\.\s$/),n(tn.LATIN,/^([ivx]{1,3})\.\s$/i),n(tn.ROMAN,/^([a-z])\.\s$/i)]}});function IN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function NN(n){return new lt({key:new Ct("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(h=>h.docChanged)&&!t.doc.eq(r.doc),o=e.some(h=>h.getMeta("preventAutolink"));if(!i||o)return;const{tr:a}=r,c=iM(t.doc,[...e]);if(dM(c).forEach(({newRange:h})=>{const m=oM(r.doc,h,b=>b.isTextblock);let p,g;if(m.length>1?(p=m[0],g=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ")):m.length&&r.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(p=m[0],g=r.doc.textBetween(p.pos,h.to,void 0," ")),p&&g){const b=g.split(" ").filter(M=>M!=="");if(b.length<=0)return!1;const S=b[b.length-1],k=p.pos+g.lastIndexOf(S);if(!S)return!1;const C=ma(S).map(M=>M.toObject(n.defaultProtocol));if(!IN(C))return!1;C.filter(M=>M.isLink).map(M=>({...M,from:k+M.start+1,to:k+M.end+1})).filter(M=>r.schema.marks.code?!r.doc.rangeHasMark(M.from,M.to,r.schema.marks.code):!0).filter(M=>n.validate(M.value)).filter(M=>n.shouldAutoLink(M.value)).forEach(M=>{F0(M.from,M.to,r.doc).some(P=>P.mark.type===n.type)||a.addMark(M.from,M.to,n.type.create({href:M.href}))})}}),!!a.steps.length)return a}})}function ON(n){return new lt({key:new Ct("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let a=r.target;const c=[];for(;a.nodeName!=="DIV";)c.push(a),a=a.parentNode;if(!c.find(g=>g.nodeName==="A"))return!1;const f=uM(e.state,n.type.name),h=r.target,m=(i=h?.href)!==null&&i!==void 0?i:f.href,p=(o=h?.target)!==null&&o!==void 0?o:f.target;return h&&m?(window.open(m,p),!0):!1}}})}function RN(n){return new lt({key:new Ct("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let c="";r.content.forEach(h=>{c+=h.textContent});const f=d1(c,{defaultProtocol:n.defaultProtocol}).find(h=>h.isLink&&h.value===c);return!c||!f?!1:n.editor.commands.setMark(n.type,{href:f.href})}}})}const LN=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function qr(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(LN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const PN=yt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){h1(n);return}h1(n.scheme,n.optionalSlashes)})},onDestroy(){gA()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!qr(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!qr(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!qr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Mi(this.options.HTMLAttributes,n),0]:["a",Mi(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!qr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!qr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[zM({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=d1(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:a=>!!qr(a,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(NN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!qr(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(ON({type:this.type})),this.options.linkOnPaste&&n.push(RN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),DN=PN.extend({name:ke.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:Ef.SELF,parseHTML:n=>n.getAttribute("target")||Ef.SELF},destination:{default:Ai.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Ai.URL;const t=e.replace("#","");return z(this.options.pageBlocks).find(o=>o.id===parseInt(t))?Ai.BLOCK:Ai.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:B(({commands:e,chain:t},r)=>(e.setMeta("preventAutolink",!0),e.getSelectedText()?t().applyMark(this.name,r).expandSelectionToLink().command(({tr:i})=>(r.text&&i.insertText(r.text,i.selection.from,i.selection.to),!0)).run():e.insertContent(ky.text(r.text,[ky.mark(ke.LINK,r)])))),expandSelectionToLink:B(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:B(({commands:e})=>e.hasMark(this.name)),getLinkPreset:B(()=>de(()=>z(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),wA.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Ai.BLOCK?`#${n.href}`:n.href,t=z(this.options.basePresetClass)+z(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),zN=yt.create({name:ke.SUPERSCRIPT,addCommands(){return{applySuperscript:B(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:B(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:B(({commands:n})=>{z(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:B(({commands:n})=>{const e=n.getMark(this.name);return de(()=>!!z(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),BN=Ie.create({name:ke.MARGIN,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[ke.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?ga({margin:n.margin.value}):null}}}}]});function FN(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=yu({default:null,link:null});return kE(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),fN().concat([dN.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new VN({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),AN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),bN.configure({device:n.deviceRef}),mN.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),hN.configure({fonts:n.fonts,defaultPreset:gi(t,"default"),defaultFont:n.defaultFont}),pN,gN,yN,wN,vN,SN,zN,xN,kN.configure({wrapperRef:n.wrapperRef}),EN,DN.configure({preset:gi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),BN])}class HN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class xy{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class gn extends xy{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=gn.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const a=c=>{this._assignElementProperties(c,e,gn.BLOCK_STYLES),t.append(c)};this._assignElementProperties(e,e.parentElement,gn.BLOCK_STYLES);for(const c of r){if(this._isBlockNode(c)){a(c),i=null,o=c;continue}if(c.tagName==="BR"&&o&&o?.tagName!=="BR"){c.remove(),o=c;continue}if(c.tagName==="BR"){const f=this.dom.createElement("p");f.append(c),a(f),i=null,o=c;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(c),o=c}e.append(t),this._removeStyleProperties(e,gn.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,gn.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return gn.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return gn.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const a=c=>{this._assignElementProperties(c,e,gn.BLOCK_STYLES),t.append(c)};for(const c of r){if(c.tagName==="BR"){a(o),o=i.cloneNode();continue}o.append(c)}t.append(o),e.replaceWith(t)}_normalizeBlockTextDecoration(){const e=this.dom.querySelectorAll('[style*="text-decoration"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveTextDecorationToChildren(t)}_moveTextDecorationToChildren(e){const t=this._parseTextDecoration(e);if(e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration"),e.style.cssText||e.removeAttribute("style"),!t.none)for(const r of e.childNodes){const i=this._wrapTextNode(e,r),o=this._parseTextDecoration(i),a={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,c])=>c).map(([c])=>c.replace("_","-")).join(" ")}}_parseTextDecoration(e){const{textDecoration:t,textDecorationLine:r}=e.style,i=t||r||"";return{none:i.includes("none"),underline:i.includes("underline"),line_through:i.includes("line-through")}}_normalizeBlockBackgroundColor(){const e=this.dom.querySelectorAll('[style*="background-color"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveBackgroundColorToChildren(t)}_moveBackgroundColorToChildren(e){const t=e.style.backgroundColor;e.style.removeProperty("background-color"),e.style.cssText||e.removeAttribute("style");for(const r of e.childNodes){const i=this._wrapTextNode(e,r),o=i.style.backgroundColor||t;i.style.backgroundColor=o}}_wrapTextNode(e,t){if(t.nodeType!==this._Node.TEXT_NODE)return t;const r=this.dom.createElement("span");return r.append(t.cloneNode()),e.replaceChild(r,t),r}}class $N extends xy{normalize(){return this._iterateNodes(this._bubbleMarks),this.content}_iterateNodes(e){this._iterateChildNodes(this.content,e)}_iterateChildNodes(e,t){for(const r of e.content)r.content&&this._iterateChildNodes(r,t),t.call(this,r)}_bubbleMarks(e){if(e.content&&e.type!==te.LIST){for(const t of e.content)if(!this._isLink(t)&&t.marks)for(const r of t.marks.slice()){if(this._includesMark(e,r)){this._removeMark(t,r);continue}this._canBubbleMark(e,r)&&(this._removeMark(t,r),this._addMark(e,r))}}}_canBubbleMark(e,t){if(Y0.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===te.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>wy.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===te.TEXT&&this._includesMarkType(e,ke.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Na{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new gn({content:e,parser:t.parser||new HN})}static _buildJson(e){return new $N({content:e})}static normalize(e,t={}){return Na.build(e,t).normalize()}}class Li{static window=globalThis.window;static use(e){this.window=e}static get document(){return this.window.document}static get body(){return this.document.body}static get head(){return this.document.head}static getComputedStyle(e){return this.window.getComputedStyle(e)}}class gh{static build({config:e,nodeDomParser:t}){const r=FN({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:qo(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:qo(xf.DESKTOP),pageBlocksRef:qo([]),wrapperRef:Li.document.createElement("p")}),i=aM(r);return new gh({schema:i,domParser:bs.fromSchema(i),nodeDomParser:t})}_schema;_domParser;_nodeDomParser;constructor({schema:e,domParser:t,nodeDomParser:r}){this._schema=e,this._domParser=t,this._nodeDomParser=r}toJSON(e){const t=Na.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}function WN(n,e){return n.type===e}function UN(n){return typeof n=="string"}class ky{static doc(e){return{type:te.DOCUMENT,content:e}}static list(e,t){return{type:te.LIST,attrs:{bullet:{type:e}},content:t.map(r=>WN(r,te.LIST_ITEM)?r:this.listItem([r].flat()))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{type:te.LIST_ITEM,...t?{attrs:t}:{},...i?{marks:i}:{},content:[r].flat().map(o=>UN(o)?this.paragraph(o):o)}}static heading(e,...t){const r=this.textBlock(t);return r.attrs??={},r.attrs.level=e,{type:te.HEADING,...r}}static paragraph(...e){return{type:te.PARAGRAPH,...this.textBlock(e)}}static textBlock(e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{content:typeof r=="string"?[this.text(r)]:[r].flat(),...t?{attrs:t}:{},...i?{marks:i}:{}}}static normalizeTextBlockArgs(e){return e.length===1?{attrs:null,marks:null,content:e[0]}:e.length===2?{attrs:e[0],marks:null,content:e[1]}:{attrs:e[0],marks:e[1],content:e[2]}}static text(e,t){return{type:te.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ke.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class VN{_baseClass;_makeVariable;_linkPresetId;constructor({baseClass:e,makeVariable:t,linkPresetId:r}){this._baseClass=e,this._makeVariable=t,this._linkPresetId=r}inject(e,t){let r=e.querySelector("[data-zw-styles]");r||(r=Li.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const a of jM)for(const c of Object.keys(r[a])){const f=this._makeVariable({device:a,preset:r,property:c}),h=this._makeInternalVariableName(c,a);if(t+=`${h}: var(${f}, inherit);`,i&&!j0.includes(c)){const m=h.replace("preset-","");t+=`${m}: var(${h});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===xf.COMMON?"":`-${t}`;return`--zw-preset-${r}${i}`}makePresetHtmlClass(e){return this._baseClass+e.id}makePresetCssClass(e){return this.makePresetHtmlClass(e).split(" ").map(t=>`.${t}`).join("")}}class yh{static _instance;static get instance(){return this._instance??=new yh,this._instance}static query(e,t){return this.instance.query(e,t)}query(e,t){let r=null;return e.descendants(i=>{if(r)return!1;if(this.matchNode(i,t))return r=i,!1}),r?t.getMark?this.getMark(r,t.getMark):r:null}matchNode(e,t){return!(t.typeName&&t.typeName!==e.type.name||t.mark&&!this.getMark(e,t.mark))}getMark(e,t){return e.marks.find(r=>this.matchMark(r,t))||null}matchMark(e,t){return e.type.name===t.typeName}}class KN{static createWindow(){return new jp.JSDOM().window}types;parse(e){const{window:t}=new jp.JSDOM(e);return this.types=t,t.document}}exports.ContentSerializer=gh,exports.ContextWindow=Li,exports.NodeDomParser=KN;
39
+ }`;var ee=Gp(function(){return me(v,G+"return "+R).apply(t,x)});if(ee.source=R,Kc(ee))throw ee;return ee}function bx(s){return ge(s).toLowerCase()}function wx(s){return ge(s).toUpperCase()}function vx(s,l,u){if(s=ge(s),s&&(u||l===t))return td(s);if(!s||!(l=kt(l)))return s;var d=jt(s),y=jt(l),v=nd(d,y),x=rd(d,y)+1;return nr(d,v,x).join("")}function Sx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.slice(0,sd(s)+1);if(!s||!(l=kt(l)))return s;var d=jt(s),y=rd(d,jt(l))+1;return nr(d,0,y).join("")}function xx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.replace(Ka,"");if(!s||!(l=kt(l)))return s;var d=jt(s),y=nd(d,jt(l));return nr(d,y).join("")}function kx(s,l){var u=Gn,d=sn;if(Ce(l)){var y="separator"in l?l.separator:y;u="length"in l?Q(l.length):u,d="omission"in l?kt(l.omission):d}s=ge(s);var v=s.length;if(ti(s)){var x=jt(s);v=x.length}if(u>=v)return s;var E=u-ni(d);if(E<1)return d;var T=x?nr(x,0,E).join(""):s.slice(0,E);if(y===t)return T+d;if(x&&(E+=T.length-E),Gc(y)){if(s.slice(E).search(y)){var N,O=T;for(y.global||(y=ac(y.source,ge(kh.exec(y))+"g")),y.lastIndex=0;N=y.exec(O);)var R=N.index;T=T.slice(0,R===t?E:R)}}else if(s.indexOf(kt(y),E)!=E){var H=T.lastIndexOf(y);H>-1&&(T=T.slice(0,H))}return T+d}function Ex(s){return s=ge(s),s&&Py.test(s)?s.replace(vh,Qb):s}var _x=ci(function(s,l,u){return s+(u?" ":"")+l.toUpperCase()}),jc=Jd("toUpperCase");function Kp(s,l,u){return s=ge(s),l=u?t:l,l===t?qb(s)?n2(s):Fb(s):s.match(l)||[]}var Gp=ie(function(s,l){try{return St(s,t,l)}catch(u){return Kc(u)?u:new X(u)}}),Tx=_n(function(s,l){return Lt(l,function(u){u=un(u),kn(s,u,Uc(s[u],s))}),s});function Cx(s){var l=s==null?0:s.length,u=J();return s=l?_e(s,function(d){if(typeof d[1]!="function")throw new Pt(a);return[u(d[0]),d[1]]}):[],ie(function(d){for(var y=-1;++y<l;){var v=s[y];if(St(v[0],this,d))return St(v[1],this,d)}})}function Mx(s){return Q2(zt(s,p))}function Yc(s){return function(){return s}}function Ax(s,l){return s==null||s!==s?l:s}var Ix=jd(),Nx=jd(!0);function ht(s){return s}function Xc(s){return _d(typeof s=="function"?s:zt(s,p))}function Ox(s){return Cd(zt(s,p))}function Rx(s,l){return Md(s,zt(l,p))}var Lx=ie(function(s,l){return function(u){return es(u,s,l)}}),Px=ie(function(s,l){return function(u){return es(s,u,l)}});function Zc(s,l,u){var d=He(l),y=vo(l,d);u==null&&!(Ce(l)&&(y.length||!d.length))&&(u=l,l=s,s=this,y=vo(l,He(l)));var v=!(Ce(u)&&"chain"in u)||!!u.chain,x=Cn(s);return Lt(y,function(E){var T=l[E];s[E]=T,x&&(s.prototype[E]=function(){var N=this.__chain__;if(v||N){var O=s(this.__wrapped__),R=O.__actions__=ct(this.__actions__);return R.push({func:T,args:arguments,thisArg:s}),O.__chain__=N,O}return T.apply(s,Yn([this.value()],arguments))})}),s}function Dx(){return qe._===this&&(qe._=a2),this}function Qc(){}function zx(s){return s=Q(s),ie(function(l){return Ad(l,s)})}var Bx=Ic(_e),Fx=Ic(Yh),Hx=Ic(tc);function Jp(s){return zc(s)?nc(un(s)):gw(s)}function $x(s){return function(l){return s==null?t:Nr(s,l)}}var Wx=Xd(),Ux=Xd(!0);function eu(){return[]}function tu(){return!1}function Vx(){return{}}function Kx(){return""}function Gx(){return!0}function Jx(s,l){if(s=Q(s),s<1||s>qn)return[];var u=vt,d=Qe(s,vt);l=J(l),s-=vt;for(var y=sc(d,l);++u<s;)l(u);return y}function qx(s){return Z(s)?_e(s,un):Et(s)?[s]:ct(dp(ge(s)))}function jx(s){var l=++o2;return ge(s)+l}var Yx=To(function(s,l){return s+l},0),Xx=Nc("ceil"),Zx=To(function(s,l){return s/l},1),Qx=Nc("floor");function ek(s){return s&&s.length?wo(s,ht,gc):t}function tk(s,l){return s&&s.length?wo(s,J(l,2),gc):t}function nk(s){return Qh(s,ht)}function rk(s,l){return Qh(s,J(l,2))}function ik(s){return s&&s.length?wo(s,ht,vc):t}function sk(s,l){return s&&s.length?wo(s,J(l,2),vc):t}var ok=To(function(s,l){return s*l},1),lk=Nc("round"),ak=To(function(s,l){return s-l},0);function ck(s){return s&&s.length?ic(s,ht):0}function uk(s,l){return s&&s.length?ic(s,J(l,2)):0}return w.after=OS,w.ary=Ep,w.assign=w5,w.assignIn=Bp,w.assignInWith=Fo,w.assignWith=v5,w.at=S5,w.before=_p,w.bind=Uc,w.bindAll=Tx,w.bindKey=Tp,w.castArray=VS,w.chain=Sp,w.chunk=Qw,w.compact=ev,w.concat=tv,w.cond=Cx,w.conforms=Mx,w.constant=Yc,w.countBy=cS,w.create=x5,w.curry=Cp,w.curryRight=Mp,w.debounce=Ap,w.defaults=k5,w.defaultsDeep=E5,w.defer=RS,w.delay=LS,w.difference=nv,w.differenceBy=rv,w.differenceWith=iv,w.drop=sv,w.dropRight=ov,w.dropRightWhile=lv,w.dropWhile=av,w.fill=cv,w.filter=fS,w.flatMap=pS,w.flatMapDeep=mS,w.flatMapDepth=gS,w.flatten=yp,w.flattenDeep=uv,w.flattenDepth=fv,w.flip=PS,w.flow=Ix,w.flowRight=Nx,w.fromPairs=hv,w.functions=N5,w.functionsIn=O5,w.groupBy=yS,w.initial=pv,w.intersection=mv,w.intersectionBy=gv,w.intersectionWith=yv,w.invert=L5,w.invertBy=P5,w.invokeMap=wS,w.iteratee=Xc,w.keyBy=vS,w.keys=He,w.keysIn=ft,w.map=Ro,w.mapKeys=z5,w.mapValues=B5,w.matches=Ox,w.matchesProperty=Rx,w.memoize=Po,w.merge=F5,w.mergeWith=Fp,w.method=Lx,w.methodOf=Px,w.mixin=Zc,w.negate=Do,w.nthArg=zx,w.omit=H5,w.omitBy=$5,w.once=DS,w.orderBy=SS,w.over=Bx,w.overArgs=zS,w.overEvery=Fx,w.overSome=Hx,w.partial=Vc,w.partialRight=Ip,w.partition=xS,w.pick=W5,w.pickBy=Hp,w.property=Jp,w.propertyOf=$x,w.pull=Sv,w.pullAll=wp,w.pullAllBy=xv,w.pullAllWith=kv,w.pullAt=Ev,w.range=Wx,w.rangeRight=Ux,w.rearg=BS,w.reject=_S,w.remove=_v,w.rest=FS,w.reverse=$c,w.sampleSize=CS,w.set=V5,w.setWith=K5,w.shuffle=MS,w.slice=Tv,w.sortBy=NS,w.sortedUniq=Rv,w.sortedUniqBy=Lv,w.split=px,w.spread=HS,w.tail=Pv,w.take=Dv,w.takeRight=zv,w.takeRightWhile=Bv,w.takeWhile=Fv,w.tap=eS,w.throttle=$S,w.thru=Oo,w.toArray=Pp,w.toPairs=$p,w.toPairsIn=Wp,w.toPath=qx,w.toPlainObject=zp,w.transform=G5,w.unary=WS,w.union=Hv,w.unionBy=$v,w.unionWith=Wv,w.uniq=Uv,w.uniqBy=Vv,w.uniqWith=Kv,w.unset=J5,w.unzip=Wc,w.unzipWith=vp,w.update=q5,w.updateWith=j5,w.values=hi,w.valuesIn=Y5,w.without=Gv,w.words=Kp,w.wrap=US,w.xor=Jv,w.xorBy=qv,w.xorWith=jv,w.zip=Yv,w.zipObject=Xv,w.zipObjectDeep=Zv,w.zipWith=Qv,w.entries=$p,w.entriesIn=Wp,w.extend=Bp,w.extendWith=Fo,Zc(w,w),w.add=Yx,w.attempt=Gp,w.camelCase=ex,w.capitalize=Up,w.ceil=Xx,w.clamp=X5,w.clone=KS,w.cloneDeep=JS,w.cloneDeepWith=qS,w.cloneWith=GS,w.conformsTo=jS,w.deburr=Vp,w.defaultTo=Ax,w.divide=Zx,w.endsWith=tx,w.eq=Xt,w.escape=nx,w.escapeRegExp=rx,w.every=uS,w.find=hS,w.findIndex=mp,w.findKey=_5,w.findLast=dS,w.findLastIndex=gp,w.findLastKey=T5,w.floor=Qx,w.forEach=xp,w.forEachRight=kp,w.forIn=C5,w.forInRight=M5,w.forOwn=A5,w.forOwnRight=I5,w.get=Jc,w.gt=YS,w.gte=XS,w.has=R5,w.hasIn=qc,w.head=bp,w.identity=ht,w.includes=bS,w.indexOf=dv,w.inRange=Z5,w.invoke=D5,w.isArguments=Lr,w.isArray=Z,w.isArrayBuffer=ZS,w.isArrayLike=ut,w.isArrayLikeObject=Ne,w.isBoolean=QS,w.isBuffer=rr,w.isDate=e5,w.isElement=t5,w.isEmpty=n5,w.isEqual=r5,w.isEqualWith=i5,w.isError=Kc,w.isFinite=s5,w.isFunction=Cn,w.isInteger=Np,w.isLength=zo,w.isMap=Op,w.isMatch=o5,w.isMatchWith=l5,w.isNaN=a5,w.isNative=c5,w.isNil=f5,w.isNull=u5,w.isNumber=Rp,w.isObject=Ce,w.isObjectLike=Me,w.isPlainObject=ls,w.isRegExp=Gc,w.isSafeInteger=h5,w.isSet=Lp,w.isString=Bo,w.isSymbol=Et,w.isTypedArray=fi,w.isUndefined=d5,w.isWeakMap=p5,w.isWeakSet=m5,w.join=bv,w.kebabCase=ix,w.last=Ft,w.lastIndexOf=wv,w.lowerCase=sx,w.lowerFirst=ox,w.lt=g5,w.lte=y5,w.max=ek,w.maxBy=tk,w.mean=nk,w.meanBy=rk,w.min=ik,w.minBy=sk,w.stubArray=eu,w.stubFalse=tu,w.stubObject=Vx,w.stubString=Kx,w.stubTrue=Gx,w.multiply=ok,w.nth=vv,w.noConflict=Dx,w.noop=Qc,w.now=Lo,w.pad=lx,w.padEnd=ax,w.padStart=cx,w.parseInt=ux,w.random=Q5,w.reduce=kS,w.reduceRight=ES,w.repeat=fx,w.replace=hx,w.result=U5,w.round=lk,w.runInContext=_,w.sample=TS,w.size=AS,w.snakeCase=dx,w.some=IS,w.sortedIndex=Cv,w.sortedIndexBy=Mv,w.sortedIndexOf=Av,w.sortedLastIndex=Iv,w.sortedLastIndexBy=Nv,w.sortedLastIndexOf=Ov,w.startCase=mx,w.startsWith=gx,w.subtract=ak,w.sum=ck,w.sumBy=uk,w.template=yx,w.times=Jx,w.toFinite=Mn,w.toInteger=Q,w.toLength=Dp,w.toLower=bx,w.toNumber=Ht,w.toSafeInteger=b5,w.toString=ge,w.toUpper=wx,w.trim=vx,w.trimEnd=Sx,w.trimStart=xx,w.truncate=kx,w.unescape=Ex,w.uniqueId=jx,w.upperCase=_x,w.upperFirst=jc,w.each=xp,w.eachRight=kp,w.first=bp,Zc(w,function(){var s={};return an(w,function(l,u){we.call(w.prototype,u)||(s[u]=l)}),s}(),{chain:!1}),w.VERSION=r,Lt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){w[s].placeholder=w}),Lt(["drop","take"],function(s,l){oe.prototype[s]=function(u){u=u===t?1:De(Q(u),0);var d=this.__filtered__&&!l?new oe(this):this.clone();return d.__filtered__?d.__takeCount__=Qe(u,d.__takeCount__):d.__views__.push({size:Qe(u,vt),type:s+(d.__dir__<0?"Right":"")}),d},oe.prototype[s+"Right"]=function(u){return this.reverse()[s](u).reverse()}}),Lt(["filter","map","takeWhile"],function(s,l){var u=l+1,d=u==on||u==Fe;oe.prototype[s]=function(y){var v=this.clone();return v.__iteratees__.push({iteratee:J(y,3),type:u}),v.__filtered__=v.__filtered__||d,v}}),Lt(["head","last"],function(s,l){var u="take"+(l?"Right":"");oe.prototype[s]=function(){return this[u](1).value()[0]}}),Lt(["initial","tail"],function(s,l){var u="drop"+(l?"":"Right");oe.prototype[s]=function(){return this.__filtered__?new oe(this):this[u](1)}}),oe.prototype.compact=function(){return this.filter(ht)},oe.prototype.find=function(s){return this.filter(s).head()},oe.prototype.findLast=function(s){return this.reverse().find(s)},oe.prototype.invokeMap=ie(function(s,l){return typeof s=="function"?new oe(this):this.map(function(u){return es(u,s,l)})}),oe.prototype.reject=function(s){return this.filter(Do(J(s)))},oe.prototype.slice=function(s,l){s=Q(s);var u=this;return u.__filtered__&&(s>0||l<0)?new oe(u):(s<0?u=u.takeRight(-s):s&&(u=u.drop(s)),l!==t&&(l=Q(l),u=l<0?u.dropRight(-l):u.take(l-s)),u)},oe.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},oe.prototype.toArray=function(){return this.take(vt)},an(oe.prototype,function(s,l){var u=/^(?:filter|find|map|reject)|While$/.test(l),d=/^(?:head|last)$/.test(l),y=w[d?"take"+(l=="last"?"Right":""):l],v=d||/^find/.test(l);y&&(w.prototype[l]=function(){var x=this.__wrapped__,E=d?[1]:arguments,T=x instanceof oe,N=E[0],O=T||Z(x),R=function(se){var fe=y.apply(w,Yn([se],E));return d&&H?fe[0]:fe};O&&u&&typeof N=="function"&&N.length!=1&&(T=O=!1);var H=this.__chain__,G=!!this.__actions__.length,q=v&&!H,ee=T&&!G;if(!v&&O){x=ee?x:new oe(this);var j=s.apply(x,E);return j.__actions__.push({func:Oo,args:[R],thisArg:t}),new Dt(j,H)}return q&&ee?s.apply(this,E):(j=this.thru(R),q?d?j.value()[0]:j.value():j)})}),Lt(["pop","push","shift","sort","splice","unshift"],function(s){var l=ro[s],u=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",d=/^(?:pop|shift)$/.test(s);w.prototype[s]=function(){var y=arguments;if(d&&!this.__chain__){var v=this.value();return l.apply(Z(v)?v:[],y)}return this[u](function(x){return l.apply(Z(x)?x:[],y)})}}),an(oe.prototype,function(s,l){var u=w[l];if(u){var d=u.name+"";we.call(oi,d)||(oi[d]=[]),oi[d].push({name:l,func:u})}}),oi[_o(t,M).name]=[{name:"wrapper",func:t}],oe.prototype.clone=E2,oe.prototype.reverse=_2,oe.prototype.value=T2,w.prototype.at=tS,w.prototype.chain=nS,w.prototype.commit=rS,w.prototype.next=iS,w.prototype.plant=oS,w.prototype.reverse=lS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=aS,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=sS),w},ri=r2();Tr?((Tr.exports=ri)._=ri,Xa._=ri):qe._=ri}).call(QI)}($s,$s.exports)),$s.exports}var wy=eN();function ch(n){return n.type.create(wy.cloneDeep(n.attrs))}function uh({tr:n,node:e,position:t,mark:r}){return e.isText?n.removeMark(t,t+e.nodeSize,r):n.removeNodeMark(t,r)}const tN=Ie.create({name:"node_processor",addCommands(){return{setBlockAttributes:B(({commands:n,state:e},t,r,i={})=>{const o=z(n.getBlockAttributes(t))??{},{doc:a,tr:c}=e,{from:f,to:h}=c.selection;a.nodesBetween(f,h,(m,p)=>{kf.includes(m.type.name)&&c.setNodeAttribute(p,t,{...i,...o,...r})})}),getBlockAttributes:B(({editor:n},e,t)=>de(()=>{let r=Object.assign({},t||{});for(const i of kf)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:B(({commands:n},e)=>{for(const t of kf)n.resetAttributes(t,e)}),applyMark:B(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:a,schema:c}=n,{$from:f,$to:h}=o.selection,m=hn(ke.LINK,c),p=hn(t,c);if(!(p.spec.group||"").includes(At.SETTINGS))return e.setMark(t,r);if(f.pos===h.pos)return;const b=S=>{if(!i.onAppliedToParent||i.onAppliedToParent(S)===!1){const{tr:k,node:C,position:M,mark:P}=S;uh({tr:k,node:C,position:M,mark:P.type})}};a.nodesBetween(f.pos,h.pos,(S,k)=>{if(S.type.name===te.LIST)return;const C=ZI(S.marks,t),M=p.create({...C?.attrs||{},...r}),P=gy(f,h,S,k);if(!m.isInSet(S.marks)&&XI(o.doc,k,M,i.isAppliedToParent))return b({tr:o,node:S,position:k,mark:M});if(S.isText){o.addMark(P.from,P.to,M);return}jI(o.doc,o.selection,S,k)&&o.addNodeMark(k,M)})}),getMarks:B(({editor:n},e)=>{const t=gi(n,"state");return de(()=>{const{selection:r,doc:i}=z(t),{from:o,to:a}=z(r),c=[];return i.nodesBetween(o,a,f=>{for(const h of f.marks)h.type.name===e&&c.unshift(h.attrs)}),c})}),getMark:B(({commands:n},e)=>{const t=n.getMarks(e);return de(()=>z(t)[0]??null)}),hasMark:B(({commands:n},e)=>{const t=n.getMark(e);return de(()=>!!z(t))}),getCommonSettingMark:B(({commands:n},e,t)=>{const r=n.getMark(e);return de(()=>z(r)?.value??z(t))}),getDeviceSettingMark:B(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return de(()=>{for(const o of z(r)){const a=o[z(i)];if(a)return a}return z(t)})}),removeAllMarks:B(({state:n})=>{const{tr:e,doc:t}=n,{from:r,to:i}=e.selection;t.nodesBetween(r,i,(o,a)=>{for(const c of o.marks)uh({tr:e,node:o,position:a,mark:c})})}),removeMarks:B(({state:n},e)=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(a,c)=>{const f=a.marks.filter(h=>e.includes(h.type.name));for(const h of f)uh({tr:t,node:a,position:c,mark:h})})})}}}),nN=Ie.create({name:"text_processor",addCommands(){return{getSelectedText:B(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:B(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const a=gy(t,r,i,o),c=Math.max(0,t.pos-o),f=Math.max(0,r.pos-o),h=e({text:i.textContent.substring(c,f)}),m=n.schema.text(h,i.marks);n.tr.replaceWith(a.from,a.to,m)})})}}}),rN=Ie.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:B(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:B(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:B(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;return n.doc.nodesBetween(r,i,(o,a,c)=>{if(t({node:o,parent:c})){const f=o.isText?0:yy(n.doc,a);r=Math.min(r,a+f),i=Math.max(i,a+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:B(({commands:n})=>n.expandSelection(({parent:e})=>e.type.name===te.DOCUMENT))}}}),iN=Kn.create({name:"doc",topNode:!0,content:"block+"});class Ks extends $e{constructor(e,t,r,i="SetDocAttr"){super(),this.key=e,this.value=t,this.schema=r,this.stepType=i}apply(e){this.prevValue=e.attrs.meta[this.key];const t=cr.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,Re.ok(t)}invert(){return new Ks(this.key,this.prevValue,this.schema,"revertSetDocAttr")}map(){return null}toJSON(){return{stepType:this.stepType,key:this.key,value:this.value}}static fromJSON(e){return new Ks(e.key,e.value,e.stepType)}}$e.jsonID("setDocAttr",Ks);const sN=iN.extend({marks:At.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:B(({state:n},e,t)=>{n.tr.step(new Ks(e,t,n.schema))})}}}),oN=Kn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Mi(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),lN=oN.extend({marks:At.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),aN=Kn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Mi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>PM({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),cN=aN.extend({marks:At.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),uN=Ie.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[QM.create(this.editor),eA.create(this.editor)]}}),fN=()=>[sN,lN,cN,BM,qM,tN,nN,rN,uN],hN=yt.create({name:ke.FONT_FAMILY,group:At.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:B(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=z(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ke.FONT_STYLE).value;t.isItalicOnly?n.applyItalic():!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:B(({commands:n})=>{const e=z(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return de(()=>n.findFontByName(z(r))||t)}),findFontByName:B((n,e)=>z(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:B(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:B(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_family)})}},parseHTML(){const n=e=>({value:e.replace(/["']/g,"")});return[{style:"--zw-font-family",getAttrs:n},{style:"font-family",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.value?`"${n.value}"`:null;return Sr({font_family:e})}}),dN=Ie.create({name:ke.STYLE_PRESET,addGlobalAttributes(){return[{types:[te.PARAGRAPH,te.HEADING],attributes:{preset:{isRequired:!1,default:{id:z(this.options.defaultId)},parseHTML:n=>{const e=z(this.options.presets);if(n.parentElement.tagName==="LI")return null;for(const{id:t,node:r,fallbackClass:i}of e){if(i&&n.classList.contains(i))return{id:t};const o=z(this.options.styleRenderer).makePresetCssClass({id:t});if(n.matches(o))return{id:t};if(n.tagName===`H${r?.level}`)return{id:t}}return n.tagName==="P"?{id:z(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:z(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const a=t[o],c=r[o],f=!c||c.toLowerCase()==="inherit";i[o]=f?a:c}return i}return{getPresetList:B(()=>de(()=>z(this.options.presets).filter(t=>!t.hidden))),getPreset:B(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:z(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),a=t.getLinkPreset();return de(()=>{const c=n(z(i),z(r).id);if(!z(o))return c;const f=z(a);return{id:c.id,common:e(c.common,f.common),mobile:e(c.mobile,f.mobile),tablet:e(c.tablet,f.tablet),desktop:e(c.desktop,f.desktop)}})}),applyPreset:B(({commands:t,chain:r},i)=>{const o=z(t.getPresetList()),a=n(o,i),c=a.node?.type??te.PARAGRAPH,f={preset:{id:i}};a.node&&(f.level=a.node.level);for(const h of j0)f[h]=z(t.getBlockAttributes(h));r().removeList().setNode(c,f).run()}),applyDefaultPreset:B(({commands:t})=>{t.applyPreset(z(this.options.defaultId))}),removePreset:B(({commands:t})=>{t.setNode(te.PARAGRAPH,{preset:null})}),getPresetCustomization:B(({editor:t,commands:r})=>{const i=gi(t,"state");return de(()=>{const{selection:o,doc:a}=z(i),{from:c,to:f}=o;return r._getSettingCustomization(a,c,f)})}),isSettingCustomized:B(({commands:t},r)=>{const i=t.getPresetCustomization(),o=zl.includes(r)?"attributes":"marks";return de(()=>z(i)[o]?.includes(r)??!1)}),getContentCustomization:B(({editor:t,commands:r})=>{const i=gi(t,"state");return de(()=>{const{doc:o}=z(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:B((t,r,i,o)=>{const a=new Set,c=new Set;return r.nodesBetween(i,o,f=>{for(const[h,m]of Object.entries(f.attrs))zl.includes(h)&&m&&c.add(h);for(const{type:h}of f.marks)X0.includes(h.name)&&a.add(h.name)}),{attributes:Array.from(c),marks:Array.from(a)}}),removePresetCustomization:B(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(X0).resetAttributes(te.PARAGRAPH,zl).resetAttributes(te.HEADING,zl).restoreSelection().run()}),removeFormat:B(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Li.head,z(this.options.presets))}}),pN=yt.create({name:ke.FONT_WEIGHT,group:At.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:B(({commands:n},e)=>{n.applyMark(this.name,{value:e}),z(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:B(({commands:n})=>{const e=z(n.getFontWeight()),t=z(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:B(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return de(()=>{const r=z(e),i=z(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:B(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Kt("toggleBold"),"Mod-B":Kt("toggleBold")}),parseHTML(){const n=e=>e==="bold"?{value:"700"}:Number(e)?{value:e}:!1;return[{style:"--zw-font-weight",getAttrs:n},{style:"font-weight",getAttrs:n},{tag:"b",attrs:{value:"700"}},{tag:"strong",attrs:{value:"700"}}]},renderHTML({HTMLAttributes:n}){return Sr({font_weight:n.value})}}),mN=yt.create({name:ke.FONT_SIZE,group:At.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:B(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].font_size.replace("px",""))}),applyFontSize:B(({commands:n},e)=>{const t=z(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:a})=>{const c={...a.attrs,[t]:null};if(!Object.values(c).some(m=>!!m))return!1;const h=a.type.create(c);if(i.isText){r.addMark(o,o+i.nodeSize,h);return}r.addNodeMark(o,h)}})}),increaseFontSize:B(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.min(e+1,z(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:B(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.max(e-1,z(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Kt("increaseFontSize"),"Mod-Shift--":Kt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=z(this.options.wrapperRef),r=my(e,t);return String(r)};return[{tag:'[style*="--zw-font-size"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-font-size-mobile")),tablet:n(e.getPropertyValue("--zw-font-size-tablet")),desktop:n(e.getPropertyValue("--zw-font-size-desktop"))})},{style:"font-size",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:null}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return Sr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),gN=yt.create({name:ke.FONT_COLOR,group:At.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:B(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:B(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.color)}),applyFontColor:B(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:dy(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Sr({font_color:n.value})}}),yN=yt.create({name:ke.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:B(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:B(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:dy(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Sr({background_color:n.value})}}),bN=Ie.create({name:"device_manager",addCommands(){return{getDevice:B(()=>gi(this.options,"device"))}}}),wN=yt.create({name:ke.FONT_STYLE,group:At.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:B(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return de(()=>z(e)?.italic??z(t).italic)}),isItalicAvailable:B(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return de(()=>{const r=z(e),i=z(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:B(({commands:n})=>{const e=n.getPreset();return de(()=>({italic:z(e).common.font_style==="italic"}))}),toggleItalic:B(({commands:n})=>{z(n.isItalicAvailable())&&(z(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:B(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:B(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Kt("toggleItalic"),"Mod-I":Kt("toggleItalic")}),parseHTML(){const n=e=>({italic:e.includes("italic")});return[{tag:"i",attrs:{italic:!0}},{style:"--zw-font-style",getAttrs:n},{style:"font-style",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.italic?"italic":"normal";return Sr({font_style:e})}}),vN=yt.create({name:ke.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:B(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).underline)}),isStrikeThrough:B(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).strike_through)}),getTextDecoration:B(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return de(()=>{const r=z(e)??{},i=z(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:B(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return de(()=>z(e)!==z(t).underline)}),getDefaultTextDecoration:B(({commands:n})=>{const e=n.getPreset();return de(()=>{const{text_decoration:t}=z(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:B(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:B(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:B(({commands:n},e,t=null)=>{const r=z(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:B(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:B(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Kt("toggleUnderline"),"Mod-U":Kt("toggleUnderline")}),parseHTML(){const n=e=>{const t=e.includes("underline"),r=e.includes("line-through");return!t&&!r?!1:{underline:t,strike_through:r}};return[{style:"--zw-text-decoration",getAttrs:n},{style:"text-decoration-line",getAttrs:n},{style:"text-decoration",getAttrs:n},{tag:"s",attrs:{underline:!1,strike_through:!0}},{tag:"u",attrs:{underline:!0,strike_through:!1}}]},renderHTML({HTMLAttributes:n}){const e=[];return n.underline&&e.push("underline"),n.strike_through&&e.push("line-through"),e.length||e.push("none"),Sr({text_decoration:e.join(" ")})}}),SN=Ie.create({name:"case_style",addCommands(){return{applyCaseStyle:B(({commands:n},e)=>{switch(e){case Dl.CAPITALIZE:return n.applyCapitalize();case Dl.LOWERCASE:return n.applyLowerCase();case Dl.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:B(({commands:n})=>{n.transformText(({text:e})=>vA(e))}),applyLowerCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),vy={mobile:null,tablet:null,desktop:null},xN=Ie.create({name:ke.ALIGNMENT,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[ke.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=qI(n.textAlign);if(e)return{desktop:e,tablet:e,mobile:e};const t=n.getPropertyValue("--zw-alignment-mobile")||null,r=n.getPropertyValue("--zw-alignment-tablet")||null,i=n.getPropertyValue("--zw-alignment-desktop")||null;return!t&&!r&&!i?null:{desktop:i,tablet:r,mobile:t}},renderHTML(n){return n.alignment?ga({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:B(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},vy)}),removeAlignment:B(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:B(({commands:n})=>{const e=n.getBlockAttributes(this.name,vy),t=n.getDevice(),r=n.getDefaultAlignment();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultAlignment:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].alignment??yr.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Kt("applyAlignment",yr.LEFT),"Mod-Shift-e":Kt("applyAlignment",yr.CENTER),"Mod-Shift-r":Kt("applyAlignment",yr.RIGHT),"Mod-Shift-j":Kt("applyAlignment",yr.JUSTIFY)})}),Sy={mobile:null,tablet:null,desktop:null},kN=Ie.create({name:ke.LINE_HEIGHT,addGlobalAttributes(){return[{types:[te.PARAGRAPH,te.HEADING],attributes:{[ke.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=z(this.options.wrapperRef),r=KI(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?ga({line_height_mobile:n.line_height.mobile,line_height_tablet:n.line_height.tablet,line_height_desktop:n.line_height.desktop}):null}}}}]},addCommands(){return{getLineHeight:B(({commands:n})=>{const e=n.getBlockAttributes(this.name,Sy),t=n.getDevice(),r=n.getDefaultLineHeight();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultLineHeight:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].line_height)}),applyLineHeight:B(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},Sy)})}}}),EN=yt.create({name:ke.LETTER_SPACING,group:At.SETTINGS,addAttributes:()=>({mobile:{default:null},tablet:{default:null},desktop:{default:null}}),addCommands(){return{getLetterSpacing:B(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultLetterSpacing())),getDefaultLetterSpacing:B(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].letter_spacing??null)}),applyLetterSpacing:B(({commands:n},e)=>{const t=z(n.getDevice());n.applyMark(this.name,{[t]:e})})}},parseHTML(){const n=e=>{if(!e)return null;const t=z(this.options.wrapperRef);return`${GI(e,t)}px`};return[{tag:'[style*="--zw-letter-spacing"]',getAttrs:({style:e})=>({mobile:n(e.getPropertyValue("--zw-letter-spacing-mobile")),tablet:n(e.getPropertyValue("--zw-letter-spacing-tablet")),desktop:n(e.getPropertyValue("--zw-letter-spacing-desktop"))})},{style:"letter-spacing",getAttrs:e=>{const t=n(e);return{desktop:t,tablet:t,mobile:t}}}]},renderHTML({HTMLAttributes:n}){const e=t=>t?`${t}px`:null;return Sr({letter_spacing_mobile:e(n.mobile),letter_spacing_tablet:e(n.tablet),letter_spacing_desktop:e(n.desktop)})}}),_N=Kn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Mi(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),TN=_N.extend({name:te.LIST_ITEM,marks:At.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:B(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const a of r.marks)t.addNodeMark(o,ch(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===te.LIST))return t.listItemNewline()}})});function CN(n,e){if(Y0.includes(e.type)||e.type.isInSet(n.marks))return!1;for(const t of n.content.content)if(t.childCount&&(!t.marks||!e.isInSet(t.marks)))return!1;return!0}function MN(n){const e=n.selection.$from.start(),t=n.selection.$to.end();n.doc.nodesBetween(e,t,(r,i)=>{if(r.type.name===te.LIST)return;if(r.type.name!==te.LIST_ITEM)return!1;const o=[];return r.forEach(a=>{for(const c of a.marks){if(c.isInSet(o)){n.removeNodeMark(i+1,c);continue}CN(r,c)&&(n.removeNodeMark(i+1,c),n.addNodeMark(i,ch(c)),o.push(c))}}),!1})}const AN=Kn.create({name:te.LIST,content:`${te.LIST_ITEM}+`,group:"block list",marks:At.SETTINGS,addExtensions:()=>[TN],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:tn.DISC}}}),parseHTML(){const n={a:tn.ROMAN,i:tn.LATIN,1:tn.DECIMAL},e=t=>{for(const r of XM){const i=`.${z(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||tn.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||tn.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[z(this.options.baseClass)+n.bullet.type,z(this.options.presetClass)];return[ZM.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:B(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return de(()=>z(e).type??null)}),applyList:B(({commands:n,chain:e},t)=>z(n.getListType())===t?n.removeList():e().applyDefaultPreset().toggleList(te.LIST,te.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({tr:i})=>MN(i)).run()),removeList:B(({chain:n})=>n().expandSelection(({parent:e})=>e.type.name===te.LIST).command(({tr:e})=>{const t=e.selection.$from.start(),r=e.selection.$to.end();return e.doc.nodesBetween(t,r,(i,o,a)=>{if([te.LIST,te.LIST_ITEM].includes(i.type.name))return;if(a.type.name!==te.LIST_ITEM)return!1;const c=a.marks.filter(f=>!f.type.isInSet(i.marks));for(const f of c)e.addNodeMark(o,ch(f));return!1}),!0}).liftListItem(te.LIST_ITEM).run())}},addInputRules(){const n=(e,t)=>DM({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(tn.DISC,/^\s*([-+*])\s$/),n(tn.DECIMAL,/^(\d+)\.\s$/),n(tn.LATIN,/^([ivx]{1,3})\.\s$/i),n(tn.ROMAN,/^([a-z])\.\s$/i)]}});function IN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function NN(n){return new lt({key:new Ct("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(h=>h.docChanged)&&!t.doc.eq(r.doc),o=e.some(h=>h.getMeta("preventAutolink"));if(!i||o)return;const{tr:a}=r,c=iM(t.doc,[...e]);if(dM(c).forEach(({newRange:h})=>{const m=oM(r.doc,h,b=>b.isTextblock);let p,g;if(m.length>1?(p=m[0],g=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ")):m.length&&r.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(p=m[0],g=r.doc.textBetween(p.pos,h.to,void 0," ")),p&&g){const b=g.split(" ").filter(M=>M!=="");if(b.length<=0)return!1;const S=b[b.length-1],k=p.pos+g.lastIndexOf(S);if(!S)return!1;const C=ma(S).map(M=>M.toObject(n.defaultProtocol));if(!IN(C))return!1;C.filter(M=>M.isLink).map(M=>({...M,from:k+M.start+1,to:k+M.end+1})).filter(M=>r.schema.marks.code?!r.doc.rangeHasMark(M.from,M.to,r.schema.marks.code):!0).filter(M=>n.validate(M.value)).filter(M=>n.shouldAutoLink(M.value)).forEach(M=>{F0(M.from,M.to,r.doc).some(P=>P.mark.type===n.type)||a.addMark(M.from,M.to,n.type.create({href:M.href}))})}}),!!a.steps.length)return a}})}function ON(n){return new lt({key:new Ct("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let a=r.target;const c=[];for(;a.nodeName!=="DIV";)c.push(a),a=a.parentNode;if(!c.find(g=>g.nodeName==="A"))return!1;const f=uM(e.state,n.type.name),h=r.target,m=(i=h?.href)!==null&&i!==void 0?i:f.href,p=(o=h?.target)!==null&&o!==void 0?o:f.target;return h&&m?(window.open(m,p),!0):!1}}})}function RN(n){return new lt({key:new Ct("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let c="";r.content.forEach(h=>{c+=h.textContent});const f=d1(c,{defaultProtocol:n.defaultProtocol}).find(h=>h.isLink&&h.value===c);return!c||!f?!1:n.editor.commands.setMark(n.type,{href:f.href})}}})}const LN=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function qr(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(LN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const PN=yt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){h1(n);return}h1(n.scheme,n.optionalSlashes)})},onDestroy(){gA()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!qr(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!qr(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!qr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Mi(this.options.HTMLAttributes,n),0]:["a",Mi(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!qr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!qr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[zM({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=d1(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:a=>!!qr(a,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(NN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!qr(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(ON({type:this.type})),this.options.linkOnPaste&&n.push(RN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),DN=PN.extend({name:ke.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:Ef.SELF,parseHTML:n=>n.getAttribute("target")||Ef.SELF},destination:{default:Ai.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Ai.URL;const t=e.replace("#","");return z(this.options.pageBlocks).find(o=>o.id===parseInt(t))?Ai.BLOCK:Ai.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:B(({commands:e,chain:t},r)=>(e.setMeta("preventAutolink",!0),e.getSelectedText()?t().applyMark(this.name,r).expandSelectionToLink().command(({tr:i})=>(r.text&&i.insertText(r.text,i.selection.from,i.selection.to),!0)).run():e.insertContent(ky.text(r.text,[ky.mark(ke.LINK,r)])))),expandSelectionToLink:B(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:B(({commands:e})=>e.hasMark(this.name)),getLinkPreset:B(()=>de(()=>z(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),wA.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Ai.BLOCK?`#${n.href}`:n.href,t=z(this.options.basePresetClass)+z(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),zN=yt.create({name:ke.SUPERSCRIPT,addCommands(){return{applySuperscript:B(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:B(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:B(({commands:n})=>{z(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:B(({commands:n})=>{const e=n.getMark(this.name);return de(()=>!!z(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),BN=Ie.create({name:ke.MARGIN,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[ke.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?ga({margin:n.margin.value}):null}}}}]});function FN(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=yu({default:null,link:null});return kE(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),fN().concat([dN.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new VN({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),AN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),bN.configure({device:n.deviceRef}),mN.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),hN.configure({fonts:n.fonts,defaultPreset:gi(t,"default"),defaultFont:n.defaultFont}),pN,gN,yN,wN,vN,SN,zN,xN,kN.configure({wrapperRef:n.wrapperRef}),EN,DN.configure({preset:gi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),BN])}class HN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class xy{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class gn extends xy{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=gn.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const a=c=>{this._assignElementProperties(c,e,gn.BLOCK_STYLES),t.append(c)};this._assignElementProperties(e,e.parentElement,gn.BLOCK_STYLES);for(const c of r){if(this._isBlockNode(c)){a(c),i=null,o=c;continue}if(c.tagName==="BR"&&o&&o?.tagName!=="BR"){c.remove(),o=c;continue}if(c.tagName==="BR"){const f=this.dom.createElement("p");f.append(c),a(f),i=null,o=c;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(c),o=c}e.append(t),this._removeStyleProperties(e,gn.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,gn.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return gn.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return gn.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const a=c=>{this._assignElementProperties(c,e,gn.BLOCK_STYLES),t.append(c)};for(const c of r){if(c.tagName==="BR"){a(o),o=i.cloneNode();continue}o.append(c)}t.append(o),e.replaceWith(t)}_normalizeBlockTextDecoration(){const e=this.dom.querySelectorAll('[style*="text-decoration"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveTextDecorationToChildren(t)}_moveTextDecorationToChildren(e){const t=this._parseTextDecoration(e);if(e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration"),e.style.cssText||e.removeAttribute("style"),!t.none)for(const r of e.childNodes){const i=this._wrapTextNode(e,r),o=this._parseTextDecoration(i),a={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,c])=>c).map(([c])=>c.replace("_","-")).join(" ")}}_parseTextDecoration(e){const{textDecoration:t,textDecorationLine:r}=e.style,i=t||r||"";return{none:i.includes("none"),underline:i.includes("underline"),line_through:i.includes("line-through")}}_normalizeBlockBackgroundColor(){const e=this.dom.querySelectorAll('[style*="background-color"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveBackgroundColorToChildren(t)}_moveBackgroundColorToChildren(e){const t=e.style.backgroundColor;e.style.removeProperty("background-color"),e.style.cssText||e.removeAttribute("style");for(const r of e.childNodes){const i=this._wrapTextNode(e,r),o=i.style.backgroundColor||t;i.style.backgroundColor=o}}_wrapTextNode(e,t){if(t.nodeType!==this._Node.TEXT_NODE)return t;const r=this.dom.createElement("span");return r.append(t.cloneNode()),e.replaceChild(r,t),r}}class $N extends xy{normalize(){return this._iterateNodes(this._bubbleMarks),this.content}_iterateNodes(e){this._iterateChildNodes(this.content,e)}_iterateChildNodes(e,t){for(const r of e.content)r.content&&this._iterateChildNodes(r,t),t.call(this,r)}_bubbleMarks(e){if(e.content&&e.type!==te.LIST){for(const t of e.content)if(!this._isLink(t)&&t.marks)for(const r of t.marks.slice()){if(this._includesMark(e,r)){this._removeMark(t,r);continue}this._canBubbleMark(e,r)&&(this._removeMark(t,r),this._addMark(e,r))}}}_canBubbleMark(e,t){if(Y0.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===te.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>wy.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===te.TEXT&&this._includesMarkType(e,ke.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Na{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new gn({content:e,parser:t.parser||new HN})}static _buildJson(e){return new $N({content:e})}static normalize(e,t={}){return Na.build(e,t).normalize()}}class Li{static window=globalThis.window;static use(e){this.window=e}static get document(){return this.window.document}static get body(){return this.document.body}static get head(){return this.document.head}static getComputedStyle(e){return this.window.getComputedStyle(e)}}class gh{static build({config:e,nodeDomParser:t}){const r=FN({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:qo(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:qo(xf.DESKTOP),pageBlocksRef:qo([]),wrapperRef:Li.document.createElement("p")}),i=aM(r);return new gh({schema:i,domParser:bs.fromSchema(i),nodeDomParser:t})}_schema;_domParser;_nodeDomParser;constructor({schema:e,domParser:t,nodeDomParser:r}){this._schema=e,this._domParser=t,this._nodeDomParser=r}toJSON(e){const t=Na.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}function WN(n,e){return n.type===e}function UN(n){return typeof n=="string"}class ky{static doc(e){return{type:te.DOCUMENT,content:e}}static list(e,t){return{type:te.LIST,attrs:{bullet:{type:e}},content:t.map(r=>WN(r,te.LIST_ITEM)?r:this.listItem([r].flat()))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{type:te.LIST_ITEM,...t?{attrs:t}:{},...i?{marks:i}:{},content:[r].flat().map(o=>UN(o)?this.paragraph(o):o)}}static heading(e,...t){const r=this.textBlock(t);return r.attrs??={},r.attrs.level=e,{type:te.HEADING,...r}}static paragraph(...e){return{type:te.PARAGRAPH,...this.textBlock(e)}}static textBlock(e){const{attrs:t,content:r,marks:i}=this.normalizeTextBlockArgs(e);return{content:typeof r=="string"?[this.text(r)]:[r].flat(),...t?{attrs:t}:{},...i?{marks:i}:{}}}static normalizeTextBlockArgs(e){return e.length===1?{attrs:null,marks:null,content:e[0]}:e.length===2?{attrs:e[0],marks:null,content:e[1]}:{attrs:e[0],marks:e[1],content:e[2]}}static text(e,t){return{type:te.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ke.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class VN{_baseClass;_makeVariable;_linkPresetId;constructor({baseClass:e,makeVariable:t,linkPresetId:r}){this._baseClass=e,this._makeVariable=t,this._linkPresetId=r}inject(e,t){let r=e.querySelector("[data-zw-styles]");r||(r=Li.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const a of jM)for(const c of Object.keys(r[a])){const f=this._makeVariable({device:a,preset:r,property:c}),h=this._makeInternalVariableName(c,a);if(t+=`${h}: var(${f}, inherit);`,i&&!j0.includes(c)){const m=h.replace("preset-","");t+=`${m}: var(${h});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===xf.COMMON?"":`-${t}`;return`--zw-preset-${r}${i}`}makePresetHtmlClass(e){return this._baseClass+e.id}makePresetCssClass(e){return this.makePresetHtmlClass(e).split(" ").map(t=>`.${t}`).join("")}}class yh{static _instance;static get instance(){return this._instance??=new yh,this._instance}static query(e,t){return this.instance.query(e,t)}query(e,t){let r=null;return e.descendants(i=>{if(r)return!1;if(this.matchNode(i,t))return r=i,!1}),r?t.getMark?this.getMark(r,t.getMark):r:null}matchNode(e,t){return!(t.typeName&&t.typeName!==e.type.name||t.mark&&!this.getMark(e,t.mark))}getMark(e,t){return e.marks.find(r=>this.matchMark(r,t))||null}matchMark(e,t){return e.type.name===t.typeName}}class KN{static createWindow(){return new jp.JSDOM().window}types;parse(e){const{window:t}=new jp.JSDOM(e);return this.types=t,t.document}}exports.ContentSerializer=gh,exports.ContextWindow=Li,exports.NodeDomParser=KN;
package/dist/wysiwyg.css CHANGED
@@ -249,7 +249,7 @@
249
249
  --zw-range-thumb-box-shadow: 0 0 0 12px rgba(240, 240, 240, 0.15);
250
250
  }
251
251
 
252
- .zw-number-field[data-v-bc56cf43] {
252
+ .zw-number-field[data-v-962cf185] {
253
253
  --border-color: rgb(var(--zw-color-n60));
254
254
  --text-color: rgb(var(--zw-color-n85));
255
255
  --buttons-color: rgb(var(--zw-color-n70));
@@ -259,16 +259,16 @@
259
259
  align-items: stretch;
260
260
  display: flex;
261
261
  }
262
- .zw-number-field[data-v-bc56cf43]:hover {
262
+ .zw-number-field[data-v-962cf185]:hover {
263
263
  --border-color: rgb(var(--zw-color-n80));
264
264
  --text-color: rgb(var(--zw-color-n85));
265
265
  }
266
- .zw-number-field[data-v-bc56cf43]:focus,
267
- .zw-number-field[data-v-bc56cf43]:focus-within {
266
+ .zw-number-field[data-v-962cf185]:focus,
267
+ .zw-number-field[data-v-962cf185]:focus-within {
268
268
  --border-color: rgb(var(--zw-color-white));
269
269
  --text-color: rgb(var(--zw-color-white));
270
270
  }
271
- .zw-number-field__input[data-v-bc56cf43] {
271
+ .zw-number-field__input[data-v-962cf185] {
272
272
  color: var(--text-color);
273
273
  background-color: rgb(var(--zw-color-n15));
274
274
  border: 0;
@@ -279,68 +279,69 @@
279
279
  font-size: var(--zw-font-size-xs);
280
280
  -moz-appearance: textfield;
281
281
  }
282
- .zw-number-field__buttons[data-v-bc56cf43] {
282
+ .zw-number-field__buttons[data-v-962cf185] {
283
283
  display: none;
284
284
  flex-direction: column;
285
285
  height: 100%;
286
286
  }
287
- .zw-number-field:hover .zw-number-field__buttons[data-v-bc56cf43],
288
- .zw-number-field:focus .zw-number-field__buttons[data-v-bc56cf43],
289
- .zw-number-field:focus-within .zw-number-field__buttons[data-v-bc56cf43] {
287
+ .zw-number-field:hover .zw-number-field__buttons[data-v-962cf185],
288
+ .zw-number-field:focus .zw-number-field__buttons[data-v-962cf185],
289
+ .zw-number-field:focus-within .zw-number-field__buttons[data-v-962cf185] {
290
290
  display: flex;
291
291
  }
292
- .zw-number-field__input[data-v-bc56cf43]::placeholder {
292
+ .zw-number-field__input[data-v-962cf185]::placeholder {
293
293
  color: var(--text-color);
294
294
  }
295
- .zw-number-field__input[data-v-bc56cf43]::-webkit-outer-spin-button,
296
- .zw-number-field__input[data-v-bc56cf43]::-webkit-inner-spin-button {
295
+ .zw-number-field__input[data-v-962cf185]::-webkit-outer-spin-button,
296
+ .zw-number-field__input[data-v-962cf185]::-webkit-inner-spin-button {
297
297
  color: var(--text-color);
298
298
  -webkit-appearance: none;
299
299
  }
300
- .zw-number-field__controls[data-v-bc56cf43] {
300
+ .zw-number-field__controls[data-v-962cf185] {
301
301
  min-width: var(--zw-offset-sm);
302
302
  }
303
- .zw-number-field--disabled[data-v-bc56cf43] {
303
+ .zw-number-field--disabled[data-v-962cf185] {
304
304
  opacity: 0.5;
305
305
  }
306
- .zw-number-field--disabled[data-v-bc56cf43],
307
- .zw-number-field--disabled .zw-number-field__input[data-v-bc56cf43] {
306
+ .zw-number-field--disabled[data-v-962cf185],
307
+ .zw-number-field--disabled .zw-number-field__input[data-v-962cf185] {
308
308
  cursor: not-allowed;
309
309
  }
310
- .zw-number-field__increment-button[data-v-bc56cf43],
311
- .zw-number-field__decrement-button[data-v-bc56cf43] {
310
+ .zw-number-field__increment-button[data-v-962cf185],
311
+ .zw-number-field__decrement-button[data-v-962cf185] {
312
312
  width: 100%;
313
313
  height: 50%;
314
314
  display: flex;
315
315
  align-items: center;
316
316
  justify-content: center;
317
317
  }
318
- .zw-number-field__increment-button[data-v-bc56cf43]::after,
319
- .zw-number-field__decrement-button[data-v-bc56cf43]::after {
318
+ .zw-number-field__increment-button[data-v-962cf185]::after,
319
+ .zw-number-field__decrement-button[data-v-962cf185]::after {
320
320
  content: "";
321
321
  border-left: 3px solid transparent;
322
322
  border-right: 3px solid transparent;
323
323
  }
324
- .zw-number-field__increment-button[data-v-bc56cf43]::after {
324
+ .zw-number-field__increment-button[data-v-962cf185]::after {
325
325
  border-bottom: 3px solid var(--buttons-color);
326
326
  }
327
- .zw-number-field__decrement-button[data-v-bc56cf43]::after {
327
+ .zw-number-field__decrement-button[data-v-962cf185]::after {
328
328
  border-top: 3px solid var(--buttons-color);
329
329
  }
330
- .zw-number-field__increment-button[data-v-bc56cf43]:hover,
331
- .zw-number-field__decrement-button[data-v-bc56cf43]:hover {
330
+ .zw-number-field__increment-button[data-v-962cf185]:hover,
331
+ .zw-number-field__decrement-button[data-v-962cf185]:hover {
332
332
  background-color: rgb(var(--zw-color-n20));
333
333
  --buttons-color: rgb(var(--zw-color-white));
334
334
  }
335
- .zw-number-field__units[data-v-bc56cf43] {
335
+ .zw-number-field__units[data-v-962cf185] {
336
336
  color: rgb(var(--zw-color-n70));
337
337
  font-size: var(--zw-font-size-xs);
338
338
  text-align: center;
339
339
  display: inline-block;
340
340
  width: 100%;
341
+ vertical-align: middle;
341
342
  }
342
- .zw-number-field:hover .zw-number-field__units[data-v-bc56cf43],
343
- .zw-number-field:has(:focus, :active) .zw-number-field__units[data-v-bc56cf43] {
343
+ .zw-number-field:hover .zw-number-field__units[data-v-962cf185],
344
+ .zw-number-field:has(:focus, :active) .zw-number-field__units[data-v-962cf185] {
344
345
  display: none;
345
346
  }
346
347
 
package/dist/wysiwyg.mjs CHANGED
@@ -24319,7 +24319,7 @@ const LetterSpacing = Mark2.create({
24319
24319
  getDefaultLetterSpacing: createCommand(({ commands: commands2 }) => {
24320
24320
  const device = commands2.getDevice();
24321
24321
  const preset = commands2.getPreset();
24322
- return computed(() => unref(preset)[unref(device)].letter_spacing || null);
24322
+ return computed(() => unref(preset)[unref(device)].letter_spacing ?? null);
24323
24323
  }),
24324
24324
  applyLetterSpacing: createCommand(({ commands: commands2 }, value) => {
24325
24325
  const device = unref(commands2.getDevice());
@@ -26563,7 +26563,7 @@ const _sfc_main$D = {
26563
26563
  };
26564
26564
  }
26565
26565
  };
26566
- const NumberField = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-bc56cf43"]]);
26566
+ const NumberField = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-962cf185"]]);
26567
26567
  const min = Math.min;
26568
26568
  const max = Math.max;
26569
26569
  const round = Math.round;
@@ -217,6 +217,7 @@ const elementClasses = computed(() => ({
217
217
  text-align: center;
218
218
  display: inline-block;
219
219
  width: 100%;
220
+ vertical-align: middle;
220
221
  }
221
222
 
222
223
  .zw-number-field:hover .zw-number-field__units,
@@ -23,7 +23,7 @@ export const LetterSpacing = Mark.create({
23
23
  const device = commands.getDevice();
24
24
  const preset = commands.getPreset();
25
25
 
26
- return computed(() => unref(preset)[unref(device)].letter_spacing || null);
26
+ return computed(() => unref(preset)[unref(device)].letter_spacing ?? null);
27
27
  }),
28
28
 
29
29
  applyLetterSpacing: createCommand(({ commands }, value) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "4.12.0-beta.0",
3
+ "version": "4.12.0-beta.1",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "types": "dist/wysiwyg.d.ts",