@zipify/wysiwyg 4.11.1 → 4.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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 zx(o){return _e(o).toLowerCase()}function $x(o){return _e(o).toUpperCase()}function Hx(o,l,f){if(o=_e(o),o&&(f||l===t))return cd(o);if(!o||!(l=Et(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 Wx(o,l,f){if(o=_e(o),o&&(f||l===t))return o.slice(0,pd(o)+1);if(!o||!(l=Et(l)))return o;var d=en(o),b=hd(d,en(l))+1;return ir(d,0,b).join("")}function Vx(o,l,f){if(o=_e(o),o&&(f||l===t))return o.replace(Zl,"");if(!o||!(l=Et(l)))return o;var d=en(o),b=fd(d,en(l));return ir(d,b).join("")}function Ux(o,l){var f=te,d=Se;if(Me(l)){var b="separator"in l?l.separator:b;f="length"in l?ie(l.length):f,d="omission"in l?Et(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 O=f-ri(d);if(O<1)return d;var I=C?ir(C,0,O).join(""):o.slice(0,O);if(b===t)return I+d;if(C&&(O+=I.length-O),Qu(b)){if(o.slice(O).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?O:B)}}else if(o.indexOf(Et(b),O)!=O){var q=I.lastIndexOf(b);q>-1&&(I=I.slice(0,q))}return I+d}function qx(o){return o=_e(o),o&&nb.test(o)?o.replace(Oh,w2):o}var Kx=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?m2(o)?x2(o):o2(o):o.match(l)||[]}var tm=ue(function(o,l){try{return xt(o,t,l)}catch(f){return Zu(f)?f:new ne(f)}}),Gx=On(function(o,l){return Bt(l,function(f){f=dn(f),An(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 zt(a);return[f(d[0]),d[1]]}):[],ue(function(d){for(var b=-1;++b<l;){var x=o[b];if(xt(x[0],this,d))return xt(x[1],this,d)}})}function jx(o){return w_(Ht(o,m))}function rc(o){return function(){return o}}function Yx(o,l){return o==null||o!==o?l:o}var Xx=ip(),Zx=ip(!0);function mt(o){return o}function ic(o){return Ld(typeof o=="function"?o:Ht(o,m))}function Qx(o){return Dd(Ht(o,m))}function eC(o,l){return Fd(o,Ht(l,m))}var tC=ue(function(o,l){return function(f){return ts(f,o,l)}}),nC=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&&!(Me(l)&&(b.length||!d.length))&&(f=l,l=o,o=this,b=vo(l,Ve(l)));var x=!(Me(f)&&"chain"in f)||!!f.chain,C=In(o);return Bt(b,function(O){var I=l[O];o[O]=I,C&&(o.prototype[O]=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 rC(){return Xe._===this&&(Xe._=O2),this}function oc(){}function iC(o){return o=ie(o),ue(function(l){return Bd(l,o)})}var sC=Fu(Ae),oC=Fu(sd),aC=Fu(lu);function nm(o){return Uu(o)?uu(dn(o)):F_(o)}function lC(o){return function(l){return o==null?t:Nr(o,l)}}var uC=op(),cC=op(!0);function ac(){return[]}function lc(){return!1}function fC(){return{}}function hC(){return""}function dC(){return!0}function pC(o,l){if(o=ie(o),o<1||o>Yn)return[];var f=St,d=nt(o,St);l=Y(l),o-=St;for(var b=hu(d,l);++f<o;)l(f);return b}function mC(o){return re(o)?Ae(o,dn):kt(o)?[o]:ht(Sp(_e(o)))}function gC(o){var l=++A2;return _e(o)+l}var yC=Ao(function(o,l){return o+l},0),bC=Bu("ceil"),_C=Ao(function(o,l){return o/l},1),wC=Bu("floor");function vC(o){return o&&o.length?wo(o,mt,xu):t}function SC(o,l){return o&&o.length?wo(o,Y(l,2),xu):t}function xC(o){return ld(o,mt)}function CC(o,l){return ld(o,Y(l,2))}function EC(o){return o&&o.length?wo(o,mt,Au):t}function kC(o,l){return o&&o.length?wo(o,Y(l,2),Au):t}var AC=Ao(function(o,l){return o*l},1),TC=Bu("round"),OC=Ao(function(o,l){return o-l},0);function MC(o){return o&&o.length?fu(o,mt):0}function IC(o,l){return o&&o.length?fu(o,Y(l,2)):0}return w.after=Qv,w.ary=Rp,w.assign=$S,w.assignIn=Gp,w.assignInWith=$o,w.assignWith=HS,w.at=WS,w.before=Lp,w.bind=Yu,w.bindAll=Gx,w.bindKey=Pp,w.castArray=fS,w.chain=Mp,w.chunk=ww,w.compact=vw,w.concat=Sw,w.cond=Jx,w.conforms=jx,w.constant=rc,w.countBy=Mv,w.create=VS,w.curry=Dp,w.curryRight=Fp,w.debounce=Bp,w.defaults=US,w.defaultsDeep=qS,w.defer=eS,w.delay=tS,w.difference=xw,w.differenceBy=Cw,w.differenceWith=Ew,w.drop=kw,w.dropRight=Aw,w.dropRightWhile=Tw,w.dropWhile=Ow,w.fill=Mw,w.filter=Nv,w.flatMap=Pv,w.flatMapDeep=Dv,w.flatMapDepth=Fv,w.flatten=kp,w.flattenDeep=Iw,w.flattenDepth=Nw,w.flip=nS,w.flow=Xx,w.flowRight=Zx,w.fromPairs=Rw,w.functions=ZS,w.functionsIn=QS,w.groupBy=Bv,w.initial=Pw,w.intersection=Dw,w.intersectionBy=Fw,w.intersectionWith=Bw,w.invert=tx,w.invertBy=nx,w.invokeMap=$v,w.iteratee=ic,w.keyBy=Hv,w.keys=Ve,w.keysIn=pt,w.map=Lo,w.mapKeys=ix,w.mapValues=sx,w.matches=Qx,w.matchesProperty=eC,w.memoize=Do,w.merge=ox,w.mergeWith=Jp,w.method=tC,w.methodOf=nC,w.mixin=sc,w.negate=Fo,w.nthArg=iC,w.omit=ax,w.omitBy=lx,w.once=rS,w.orderBy=Wv,w.over=sC,w.overArgs=iS,w.overEvery=oC,w.overSome=aC,w.partial=Xu,w.partialRight=zp,w.partition=Vv,w.pick=ux,w.pickBy=jp,w.property=nm,w.propertyOf=lC,w.pull=Ww,w.pullAll=Tp,w.pullAllBy=Vw,w.pullAllWith=Uw,w.pullAt=qw,w.range=uC,w.rangeRight=cC,w.rearg=sS,w.reject=Kv,w.remove=Kw,w.rest=oS,w.reverse=Ju,w.sampleSize=Jv,w.set=fx,w.setWith=hx,w.shuffle=jv,w.slice=Gw,w.sortBy=Zv,w.sortedUniq=ev,w.sortedUniqBy=tv,w.split=Px,w.spread=aS,w.tail=nv,w.take=rv,w.takeRight=iv,w.takeRightWhile=sv,w.takeWhile=ov,w.tap=vv,w.throttle=lS,w.thru=Ro,w.toArray=Up,w.toPairs=Yp,w.toPairsIn=Xp,w.toPath=mC,w.toPlainObject=Kp,w.transform=dx,w.unary=uS,w.union=av,w.unionBy=lv,w.unionWith=uv,w.uniq=cv,w.uniqBy=fv,w.uniqWith=hv,w.unset=px,w.unzip=ju,w.unzipWith=Op,w.update=mx,w.updateWith=gx,w.values=di,w.valuesIn=yx,w.without=dv,w.words=em,w.wrap=cS,w.xor=pv,w.xorBy=mv,w.xorWith=gv,w.zip=yv,w.zipObject=bv,w.zipObjectDeep=_v,w.zipWith=wv,w.entries=Yp,w.entriesIn=Xp,w.extend=Gp,w.extendWith=$o,sc(w,w),w.add=yC,w.attempt=tm,w.camelCase=vx,w.capitalize=Zp,w.ceil=bC,w.clamp=bx,w.clone=hS,w.cloneDeep=pS,w.cloneDeepWith=mS,w.cloneWith=dS,w.conformsTo=gS,w.deburr=Qp,w.defaultTo=Yx,w.divide=_C,w.endsWith=Sx,w.eq=nn,w.escape=xx,w.escapeRegExp=Cx,w.every=Iv,w.find=Rv,w.findIndex=Cp,w.findKey=KS,w.findLast=Lv,w.findLastIndex=Ep,w.findLastKey=GS,w.floor=wC,w.forEach=Ip,w.forEachRight=Np,w.forIn=JS,w.forInRight=jS,w.forOwn=YS,w.forOwnRight=XS,w.get=ec,w.gt=yS,w.gte=bS,w.has=ex,w.hasIn=tc,w.head=Ap,w.identity=mt,w.includes=zv,w.indexOf=Lw,w.inRange=_x,w.invoke=rx,w.isArguments=Pr,w.isArray=re,w.isArrayBuffer=_S,w.isArrayLike=dt,w.isArrayLikeObject=Le,w.isBoolean=wS,w.isBuffer=sr,w.isDate=vS,w.isElement=SS,w.isEmpty=xS,w.isEqual=CS,w.isEqualWith=ES,w.isError=Zu,w.isFinite=kS,w.isFunction=In,w.isInteger=$p,w.isLength=Bo,w.isMap=Hp,w.isMatch=AS,w.isMatchWith=TS,w.isNaN=OS,w.isNative=MS,w.isNil=NS,w.isNull=IS,w.isNumber=Wp,w.isObject=Me,w.isObjectLike=Ie,w.isPlainObject=ls,w.isRegExp=Qu,w.isSafeInteger=RS,w.isSet=Vp,w.isString=zo,w.isSymbol=kt,w.isTypedArray=hi,w.isUndefined=LS,w.isWeakMap=PS,w.isWeakSet=DS,w.join=zw,w.kebabCase=Ex,w.last=Vt,w.lastIndexOf=$w,w.lowerCase=kx,w.lowerFirst=Ax,w.lt=FS,w.lte=BS,w.max=vC,w.maxBy=SC,w.mean=xC,w.meanBy=CC,w.min=EC,w.minBy=kC,w.stubArray=ac,w.stubFalse=lc,w.stubObject=fC,w.stubString=hC,w.stubTrue=dC,w.multiply=AC,w.nth=Hw,w.noConflict=rC,w.noop=oc,w.now=Po,w.pad=Tx,w.padEnd=Ox,w.padStart=Mx,w.parseInt=Ix,w.random=wx,w.reduce=Uv,w.reduceRight=qv,w.repeat=Nx,w.replace=Rx,w.result=cx,w.round=TC,w.runInContext=M,w.sample=Gv,w.size=Yv,w.snakeCase=Lx,w.some=Xv,w.sortedIndex=Jw,w.sortedIndexBy=jw,w.sortedIndexOf=Yw,w.sortedLastIndex=Xw,w.sortedLastIndexBy=Zw,w.sortedLastIndexOf=Qw,w.startCase=Dx,w.startsWith=Fx,w.subtract=OC,w.sum=MC,w.sumBy=IC,w.template=Bx,w.times=pC,w.toFinite=Nn,w.toInteger=ie,w.toLength=qp,w.toLower=zx,w.toNumber=Ut,w.toSafeInteger=zS,w.toString=_e,w.toUpper=$x,w.trim=Hx,w.trimEnd=Wx,w.trimStart=Vx,w.truncate=Ux,w.unescape=qx,w.uniqueId=gC,w.upperCase=Kx,w.upperFirst=nc,w.each=Ip,w.eachRight=Np,w.first=Ap,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,Bt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){w[o].placeholder=w}),Bt(["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,St),type:o+(d.__dir__<0?"Right":"")}),d},fe.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),Bt(["filter","map","takeWhile"],function(o,l){var f=l+1,d=f==Dt||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}}),Bt(["head","last"],function(o,l){var f="take"+(l?"Right":"");fe.prototype[o]=function(){return this[f](1).value()[0]}}),Bt(["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(St)},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__,O=d?[1]:arguments,I=C instanceof fe,P=O[0],D=I||re(C),B=function(ce){var me=b.apply(w,Zn([ce],O));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,O);return Z.__actions__.push({func:Ro,args:[B],thisArg:t}),new $t(Z,q)}return X&&se?o.apply(this,O):(Z=this.thru(B),X?d?Z.value()[0]:Z.value():Z)})}),Bt(["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=q2,fe.prototype.reverse=K2,fe.prototype.value=G2,w.prototype.at=Sv,w.prototype.chain=xv,w.prototype.commit=Cv,w.prototype.next=Ev,w.prototype.plant=Av,w.prototype.reverse=Tv,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=Ov,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=kv),w},ii=C2();Ar?((Ar.exports=ii)._=ii,iu._=ii):Xe._=ii}).call(II)}(Ws,Ws.exports)),Ws.exports}var Fy=NI();function bh(n){return n.type.create(Fy.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 RI=Re.create({name:"node_processor",addCommands(){return{setBlockAttributes:W(({commands:n,state:e},t,r,i={})=>{const s=V(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(Oe.LINK,u),m=mn(t,u);if(!(m.spec.group||"").includes(Gt.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=MI(S.marks,t),g=m.create({...N?.attrs||{},...r}),v=Ly(c,h,S,E);if(!p.isInSet(S.marks)&&OI(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}AI(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}=V(t),{from:s,to:a}=V(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(()=>V(t)[0]??null)}),hasMark:W(({commands:n},e)=>{const t=n.getMark(e);return ge(()=>!!V(t))}),getCommonSettingMark:W(({commands:n},e,t)=>{const r=n.getMark(e);return ge(()=>V(r)?.value??V(t))}),getDeviceSettingMark:W(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return ge(()=>{for(const s of V(r)){const a=s[V(i)];if(a)return a}return V(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})})})}}}),LI=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=Ly(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)})})}}}),PI=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:Py(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))}}}),DI=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 FI=DI.extend({marks:Gt.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))})}}}),BI=jn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Oi(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),zI=BI.extend({marks:Gt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),$I=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]}`,Oi(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=>pO({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),HI=$I.extend({marks:Gt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),WI=Re.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[NO.create(this.editor),RO.create(this.editor)]}}),VI=()=>[FI,zI,HI,yO,AO,RI,LI,PI,WI],UI=Nt.create({name:Oe.FONT_FAMILY,group:Gt.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=V(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(Oe.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:W(({commands:n})=>{const e=V(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return ge(()=>n.findFontByName(V(r))||t)}),findFontByName:W((n,e)=>V(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(()=>V(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 Jr({font_family:e})}}),qI=Re.create({name:Oe.STYLE_PRESET,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{preset:{isRequired:!1,default:{id:V(this.options.defaultId)},parseHTML:n=>{const e=V(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=V(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:V(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:V(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(()=>V(this.options.presets).filter(t=>!t.hidden))),getPreset:W(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:V(this.options.defaultId)}),i=t.getPresetList(),s=t.isLink(),a=t.getLinkPreset();return ge(()=>{const u=n(V(i),V(r).id);if(!V(s))return u;const c=V(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=V(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]=V(t.getBlockAttributes(h));r().removeList().setNode(u,c).run()}),applyDefaultPreset:W(({commands:t})=>{t.applyPreset(V(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}=V(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(()=>V(i)[s]?.includes(r)??!1)}),getContentCustomization:W(({editor:t,commands:r})=>{const i=yi(t,"state");return ge(()=>{const{doc:s}=V(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,V(this.options.presets))}}),KI=Nt.create({name:Oe.FONT_WEIGHT,group:Gt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:W(({commands:n},e)=>{n.applyMark(this.name,{value:e}),V(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:W(({commands:n})=>{const e=V(n.getFontWeight()),t=V(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=V(e),i=V(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:W(({commands:n})=>{const e=n.getPreset();return ge(()=>V(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 Jr({font_weight:n.value})}}),GI=Nt.create({name:Oe.FONT_SIZE,group:Gt.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(()=>V(t)[V(e)].font_size.replace("px",""))}),applyFontSize:W(({commands:n},e)=>{const t=V(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(V(n.getFontSize())),t=Math.min(e+1,V(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:W(({commands:n})=>{const e=Number(V(n.getFontSize())),t=Math.max(e-1,V(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=V(this.options.wrapperRef),r=Ry(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 Jr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),JI=Nt.create({name:Oe.FONT_COLOR,group:Gt.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(()=>V(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 Jr({font_color:n.value})}}),jI=Nt.create({name:Oe.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 Jr({background_color:n.value})}}),YI=Re.create({name:"device_manager",addCommands(){return{getDevice:W(()=>yi(this.options,"device"))}}}),XI=Nt.create({name:Oe.FONT_STYLE,group:Gt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return ge(()=>V(e)?.italic??V(t).italic)}),isItalicAvailable:W(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return ge(()=>{const r=V(e),i=V(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:W(({commands:n})=>{const e=n.getPreset();return ge(()=>({italic:V(e).common.font_style==="italic"}))}),toggleItalic:W(({commands:n})=>{V(n.isItalicAvailable())&&(V(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 Jr({font_style:e})}}),ZI=Nt.create({name:Oe.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>V(e).underline)}),isStrikeThrough:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>V(e).strike_through)}),getTextDecoration:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return ge(()=>{const r=V(e)??{},i=V(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(()=>V(e)!==V(t).underline)}),getDefaultTextDecoration:W(({commands:n})=>{const e=n.getPreset();return ge(()=>{const{text_decoration:t}=V(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=V(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"),Jr({text_decoration:e.join(" ")})}}),QI=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})=>QO(e))}),applyLowerCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),By={mobile:null,tablet:null,desktop:null},eN=Re.create({name:Oe.ALIGNMENT,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[Oe.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=kI(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=V(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},By)}),removeAlignment:W(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:W(({commands:n})=>{const e=n.getBlockAttributes(this.name,By),t=n.getDevice(),r=n.getDefaultAlignment();return ge(()=>V(e)?.[V(t)]??V(r))}),getDefaultAlignment:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>V(t)[V(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)})}),zy={mobile:null,tablet:null,desktop:null},tN=Re.create({name:Oe.LINE_HEIGHT,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[Oe.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=V(this.options.wrapperRef),r=CI(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,zy),t=n.getDevice(),r=n.getDefaultLineHeight();return ge(()=>V(e)?.[V(t)]??V(r))}),getDefaultLineHeight:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>V(t)[V(e)].line_height)}),applyLineHeight:W(({commands:n},e)=>{const t=V(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},zy)})}}}),nN=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",Oi(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)}}}),rN=nN.extend({name:oe.LIST_ITEM,marks:Gt.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 iN(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 sN(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}iN(r,u)&&(n.removeNodeMark(i+1,u),n.addNodeMark(i,bh(u)),s.push(u))}}),!1})}const oN=jn.create({name:oe.LIST,content:`${oe.LIST_ITEM}+`,group:"block list",marks:Gt.SETTINGS,addExtensions:()=>[rN],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 MO){const i=`.${V(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=[V(this.options.baseClass)+n.bullet.type,V(this.options.presetClass)];return[IO.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(()=>V(e).type??null)}),applyList:W(({commands:n,chain:e},t)=>V(n.getListType())===t?n.removeList():e().applyDefaultPreset().toggleList(oe.LIST,oe.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({tr:i})=>sN(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)=>mO({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 aN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function lN(n){return new ct({key:new Mt("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=FT(t.doc,[...e]);if(KT(u).forEach(({newRange:h})=>{const p=zT(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(!aN(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 uN(n){return new ct({key:new Mt("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=VT(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 cN(n){return new ct({key:new Mt("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 fN=/[\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(fN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const hN=Nt.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(){jO()},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",Oi(this.options.HTMLAttributes,n),0]:["a",Oi(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[gO({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(lN({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(uN({type:this.type})),this.options.linkOnPaste&&n.push(cN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),dN=hN.extend({name:Oe.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:Mi.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Mi.URL;const t=e.replace("#","");return V(this.options.pageBlocks).find(s=>s.id===parseInt(t))?Mi.BLOCK:Mi.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(Hy.text(r.text,[Hy.mark(Oe.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(()=>V(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),ZO.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Mi.BLOCK?`#${n.href}`:n.href,t=V(this.options.basePresetClass)+V(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),pN=Nt.create({name:Oe.SUPERSCRIPT,addCommands(){return{applySuperscript:W(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:W(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:W(({commands:n})=>{V(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:W(({commands:n})=>{const e=n.getMark(this.name);return ge(()=>!!V(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),mN=Re.create({name:Oe.MARGIN,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[Oe.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 gN(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=kc({default:null,link:null});return n5(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),VI().concat([qI.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new vN({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),oN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),YI.configure({device:n.deviceRef}),GI.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),UI.configure({fonts:n.fonts,defaultPreset:yi(t,"default"),defaultFont:n.defaultFont}),KI,JI,jI,XI,ZI,QI,pN,eN,tN.configure({wrapperRef:n.wrapperRef}),dN.configure({preset:yi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),mN])}class yN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class $y{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class _n extends $y{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 bN extends $y{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=>Fy.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,Oe.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 yN})}static _buildJson(e){return new bN({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=gN({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=HT(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 _N(n,e){return n.type===e}function wN(n){return typeof n=="string"}class Hy{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=>_N(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=>wN(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(Oe.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=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 TO)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 Wy{static createWindow(){return new sm.JSDOM().window}types;parse(e){const{window:t}=new sm.JSDOM(e);return this.types=t,t.document}}class Vy{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 SN extends Vy{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(Wy.createWindow());const i=im.resolve(process.cwd(),t),s=Eh.build({config:require(i).editor,nodeDomParser:new Wy}),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 xN="4.11.1";class CN extends Vy{name="version";description="display cli version";doCommand(){this.output(xN)}}const Uy=new VC,EN=[SN,CN];for(const n of EN)new n().install(Uy);Uy.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 zx(o){return _e(o).toLowerCase()}function $x(o){return _e(o).toUpperCase()}function Hx(o,l,f){if(o=_e(o),o&&(f||l===t))return cd(o);if(!o||!(l=Et(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 Wx(o,l,f){if(o=_e(o),o&&(f||l===t))return o.slice(0,pd(o)+1);if(!o||!(l=Et(l)))return o;var d=en(o),b=hd(d,en(l))+1;return ir(d,0,b).join("")}function Vx(o,l,f){if(o=_e(o),o&&(f||l===t))return o.replace(Zl,"");if(!o||!(l=Et(l)))return o;var d=en(o),b=fd(d,en(l));return ir(d,b).join("")}function Ux(o,l){var f=te,d=Se;if(Me(l)){var b="separator"in l?l.separator:b;f="length"in l?ie(l.length):f,d="omission"in l?Et(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 O=f-ri(d);if(O<1)return d;var I=C?ir(C,0,O).join(""):o.slice(0,O);if(b===t)return I+d;if(C&&(O+=I.length-O),Qu(b)){if(o.slice(O).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?O:B)}}else if(o.indexOf(Et(b),O)!=O){var q=I.lastIndexOf(b);q>-1&&(I=I.slice(0,q))}return I+d}function qx(o){return o=_e(o),o&&nb.test(o)?o.replace(Oh,w2):o}var Kx=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?m2(o)?x2(o):o2(o):o.match(l)||[]}var tm=ue(function(o,l){try{return xt(o,t,l)}catch(f){return Zu(f)?f:new ne(f)}}),Gx=On(function(o,l){return Bt(l,function(f){f=dn(f),An(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 zt(a);return[f(d[0]),d[1]]}):[],ue(function(d){for(var b=-1;++b<l;){var x=o[b];if(xt(x[0],this,d))return xt(x[1],this,d)}})}function jx(o){return w_(Ht(o,m))}function rc(o){return function(){return o}}function Yx(o,l){return o==null||o!==o?l:o}var Xx=ip(),Zx=ip(!0);function mt(o){return o}function ic(o){return Ld(typeof o=="function"?o:Ht(o,m))}function Qx(o){return Dd(Ht(o,m))}function eC(o,l){return Fd(o,Ht(l,m))}var tC=ue(function(o,l){return function(f){return ts(f,o,l)}}),nC=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&&!(Me(l)&&(b.length||!d.length))&&(f=l,l=o,o=this,b=vo(l,Ve(l)));var x=!(Me(f)&&"chain"in f)||!!f.chain,C=In(o);return Bt(b,function(O){var I=l[O];o[O]=I,C&&(o.prototype[O]=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 rC(){return Xe._===this&&(Xe._=O2),this}function oc(){}function iC(o){return o=ie(o),ue(function(l){return Bd(l,o)})}var sC=Fu(Ae),oC=Fu(sd),aC=Fu(lu);function nm(o){return Uu(o)?uu(dn(o)):F_(o)}function lC(o){return function(l){return o==null?t:Nr(o,l)}}var uC=op(),cC=op(!0);function ac(){return[]}function lc(){return!1}function fC(){return{}}function hC(){return""}function dC(){return!0}function pC(o,l){if(o=ie(o),o<1||o>Yn)return[];var f=St,d=nt(o,St);l=Y(l),o-=St;for(var b=hu(d,l);++f<o;)l(f);return b}function mC(o){return re(o)?Ae(o,dn):kt(o)?[o]:ht(Sp(_e(o)))}function gC(o){var l=++A2;return _e(o)+l}var yC=Ao(function(o,l){return o+l},0),bC=Bu("ceil"),_C=Ao(function(o,l){return o/l},1),wC=Bu("floor");function vC(o){return o&&o.length?wo(o,mt,xu):t}function SC(o,l){return o&&o.length?wo(o,Y(l,2),xu):t}function xC(o){return ld(o,mt)}function CC(o,l){return ld(o,Y(l,2))}function EC(o){return o&&o.length?wo(o,mt,Au):t}function kC(o,l){return o&&o.length?wo(o,Y(l,2),Au):t}var AC=Ao(function(o,l){return o*l},1),TC=Bu("round"),OC=Ao(function(o,l){return o-l},0);function MC(o){return o&&o.length?fu(o,mt):0}function IC(o,l){return o&&o.length?fu(o,Y(l,2)):0}return w.after=Qv,w.ary=Rp,w.assign=$S,w.assignIn=Gp,w.assignInWith=$o,w.assignWith=HS,w.at=WS,w.before=Lp,w.bind=Yu,w.bindAll=Gx,w.bindKey=Pp,w.castArray=fS,w.chain=Mp,w.chunk=ww,w.compact=vw,w.concat=Sw,w.cond=Jx,w.conforms=jx,w.constant=rc,w.countBy=Mv,w.create=VS,w.curry=Dp,w.curryRight=Fp,w.debounce=Bp,w.defaults=US,w.defaultsDeep=qS,w.defer=eS,w.delay=tS,w.difference=xw,w.differenceBy=Cw,w.differenceWith=Ew,w.drop=kw,w.dropRight=Aw,w.dropRightWhile=Tw,w.dropWhile=Ow,w.fill=Mw,w.filter=Nv,w.flatMap=Pv,w.flatMapDeep=Dv,w.flatMapDepth=Fv,w.flatten=kp,w.flattenDeep=Iw,w.flattenDepth=Nw,w.flip=nS,w.flow=Xx,w.flowRight=Zx,w.fromPairs=Rw,w.functions=ZS,w.functionsIn=QS,w.groupBy=Bv,w.initial=Pw,w.intersection=Dw,w.intersectionBy=Fw,w.intersectionWith=Bw,w.invert=tx,w.invertBy=nx,w.invokeMap=$v,w.iteratee=ic,w.keyBy=Hv,w.keys=Ve,w.keysIn=pt,w.map=Lo,w.mapKeys=ix,w.mapValues=sx,w.matches=Qx,w.matchesProperty=eC,w.memoize=Do,w.merge=ox,w.mergeWith=Jp,w.method=tC,w.methodOf=nC,w.mixin=sc,w.negate=Fo,w.nthArg=iC,w.omit=ax,w.omitBy=lx,w.once=rS,w.orderBy=Wv,w.over=sC,w.overArgs=iS,w.overEvery=oC,w.overSome=aC,w.partial=Xu,w.partialRight=zp,w.partition=Vv,w.pick=ux,w.pickBy=jp,w.property=nm,w.propertyOf=lC,w.pull=Ww,w.pullAll=Tp,w.pullAllBy=Vw,w.pullAllWith=Uw,w.pullAt=qw,w.range=uC,w.rangeRight=cC,w.rearg=sS,w.reject=Kv,w.remove=Kw,w.rest=oS,w.reverse=Ju,w.sampleSize=Jv,w.set=fx,w.setWith=hx,w.shuffle=jv,w.slice=Gw,w.sortBy=Zv,w.sortedUniq=ev,w.sortedUniqBy=tv,w.split=Px,w.spread=aS,w.tail=nv,w.take=rv,w.takeRight=iv,w.takeRightWhile=sv,w.takeWhile=ov,w.tap=vv,w.throttle=lS,w.thru=Ro,w.toArray=Up,w.toPairs=Yp,w.toPairsIn=Xp,w.toPath=mC,w.toPlainObject=Kp,w.transform=dx,w.unary=uS,w.union=av,w.unionBy=lv,w.unionWith=uv,w.uniq=cv,w.uniqBy=fv,w.uniqWith=hv,w.unset=px,w.unzip=ju,w.unzipWith=Op,w.update=mx,w.updateWith=gx,w.values=di,w.valuesIn=yx,w.without=dv,w.words=em,w.wrap=cS,w.xor=pv,w.xorBy=mv,w.xorWith=gv,w.zip=yv,w.zipObject=bv,w.zipObjectDeep=_v,w.zipWith=wv,w.entries=Yp,w.entriesIn=Xp,w.extend=Gp,w.extendWith=$o,sc(w,w),w.add=yC,w.attempt=tm,w.camelCase=vx,w.capitalize=Zp,w.ceil=bC,w.clamp=bx,w.clone=hS,w.cloneDeep=pS,w.cloneDeepWith=mS,w.cloneWith=dS,w.conformsTo=gS,w.deburr=Qp,w.defaultTo=Yx,w.divide=_C,w.endsWith=Sx,w.eq=nn,w.escape=xx,w.escapeRegExp=Cx,w.every=Iv,w.find=Rv,w.findIndex=Cp,w.findKey=KS,w.findLast=Lv,w.findLastIndex=Ep,w.findLastKey=GS,w.floor=wC,w.forEach=Ip,w.forEachRight=Np,w.forIn=JS,w.forInRight=jS,w.forOwn=YS,w.forOwnRight=XS,w.get=ec,w.gt=yS,w.gte=bS,w.has=ex,w.hasIn=tc,w.head=Ap,w.identity=mt,w.includes=zv,w.indexOf=Lw,w.inRange=_x,w.invoke=rx,w.isArguments=Pr,w.isArray=re,w.isArrayBuffer=_S,w.isArrayLike=dt,w.isArrayLikeObject=Le,w.isBoolean=wS,w.isBuffer=sr,w.isDate=vS,w.isElement=SS,w.isEmpty=xS,w.isEqual=CS,w.isEqualWith=ES,w.isError=Zu,w.isFinite=kS,w.isFunction=In,w.isInteger=$p,w.isLength=Bo,w.isMap=Hp,w.isMatch=AS,w.isMatchWith=TS,w.isNaN=OS,w.isNative=MS,w.isNil=NS,w.isNull=IS,w.isNumber=Wp,w.isObject=Me,w.isObjectLike=Ie,w.isPlainObject=ls,w.isRegExp=Qu,w.isSafeInteger=RS,w.isSet=Vp,w.isString=zo,w.isSymbol=kt,w.isTypedArray=hi,w.isUndefined=LS,w.isWeakMap=PS,w.isWeakSet=DS,w.join=zw,w.kebabCase=Ex,w.last=Vt,w.lastIndexOf=$w,w.lowerCase=kx,w.lowerFirst=Ax,w.lt=FS,w.lte=BS,w.max=vC,w.maxBy=SC,w.mean=xC,w.meanBy=CC,w.min=EC,w.minBy=kC,w.stubArray=ac,w.stubFalse=lc,w.stubObject=fC,w.stubString=hC,w.stubTrue=dC,w.multiply=AC,w.nth=Hw,w.noConflict=rC,w.noop=oc,w.now=Po,w.pad=Tx,w.padEnd=Ox,w.padStart=Mx,w.parseInt=Ix,w.random=wx,w.reduce=Uv,w.reduceRight=qv,w.repeat=Nx,w.replace=Rx,w.result=cx,w.round=TC,w.runInContext=M,w.sample=Gv,w.size=Yv,w.snakeCase=Lx,w.some=Xv,w.sortedIndex=Jw,w.sortedIndexBy=jw,w.sortedIndexOf=Yw,w.sortedLastIndex=Xw,w.sortedLastIndexBy=Zw,w.sortedLastIndexOf=Qw,w.startCase=Dx,w.startsWith=Fx,w.subtract=OC,w.sum=MC,w.sumBy=IC,w.template=Bx,w.times=pC,w.toFinite=Nn,w.toInteger=ie,w.toLength=qp,w.toLower=zx,w.toNumber=Ut,w.toSafeInteger=zS,w.toString=_e,w.toUpper=$x,w.trim=Hx,w.trimEnd=Wx,w.trimStart=Vx,w.truncate=Ux,w.unescape=qx,w.uniqueId=gC,w.upperCase=Kx,w.upperFirst=nc,w.each=Ip,w.eachRight=Np,w.first=Ap,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,Bt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){w[o].placeholder=w}),Bt(["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,St),type:o+(d.__dir__<0?"Right":"")}),d},fe.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),Bt(["filter","map","takeWhile"],function(o,l){var f=l+1,d=f==Dt||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}}),Bt(["head","last"],function(o,l){var f="take"+(l?"Right":"");fe.prototype[o]=function(){return this[f](1).value()[0]}}),Bt(["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(St)},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__,O=d?[1]:arguments,I=C instanceof fe,P=O[0],D=I||re(C),B=function(ce){var me=b.apply(w,Zn([ce],O));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,O);return Z.__actions__.push({func:Ro,args:[B],thisArg:t}),new $t(Z,q)}return X&&se?o.apply(this,O):(Z=this.thru(B),X?d?Z.value()[0]:Z.value():Z)})}),Bt(["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=q2,fe.prototype.reverse=K2,fe.prototype.value=G2,w.prototype.at=Sv,w.prototype.chain=xv,w.prototype.commit=Cv,w.prototype.next=Ev,w.prototype.plant=Av,w.prototype.reverse=Tv,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=Ov,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=kv),w},ii=C2();Ar?((Ar.exports=ii)._=ii,iu._=ii):Xe._=ii}).call(II)}(Ws,Ws.exports)),Ws.exports}var Fy=NI();function bh(n){return n.type.create(Fy.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 RI=Re.create({name:"node_processor",addCommands(){return{setBlockAttributes:W(({commands:n,state:e},t,r,i={})=>{const s=V(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(Oe.LINK,u),m=mn(t,u);if(!(m.spec.group||"").includes(Gt.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=MI(S.marks,t),g=m.create({...N?.attrs||{},...r}),v=Ly(c,h,S,E);if(!p.isInSet(S.marks)&&OI(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}AI(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}=V(t),{from:s,to:a}=V(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(()=>V(t)[0]??null)}),hasMark:W(({commands:n},e)=>{const t=n.getMark(e);return ge(()=>!!V(t))}),getCommonSettingMark:W(({commands:n},e,t)=>{const r=n.getMark(e);return ge(()=>V(r)?.value??V(t))}),getDeviceSettingMark:W(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return ge(()=>{for(const s of V(r)){const a=s[V(i)];if(a)return a}return V(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})})})}}}),LI=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=Ly(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)})})}}}),PI=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:Py(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))}}}),DI=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 FI=DI.extend({marks:Gt.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))})}}}),BI=jn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Oi(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),zI=BI.extend({marks:Gt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),$I=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]}`,Oi(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=>pO({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),HI=$I.extend({marks:Gt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),WI=Re.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[NO.create(this.editor),RO.create(this.editor)]}}),VI=()=>[FI,zI,HI,yO,AO,RI,LI,PI,WI],UI=Nt.create({name:Oe.FONT_FAMILY,group:Gt.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=V(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(Oe.FONT_STYLE).value;t.isItalicOnly?n.applyItalic():!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:W(({commands:n})=>{const e=V(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return ge(()=>n.findFontByName(V(r))||t)}),findFontByName:W((n,e)=>V(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(()=>V(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 Jr({font_family:e})}}),qI=Re.create({name:Oe.STYLE_PRESET,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{preset:{isRequired:!1,default:{id:V(this.options.defaultId)},parseHTML:n=>{const e=V(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=V(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:V(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:V(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(()=>V(this.options.presets).filter(t=>!t.hidden))),getPreset:W(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:V(this.options.defaultId)}),i=t.getPresetList(),s=t.isLink(),a=t.getLinkPreset();return ge(()=>{const u=n(V(i),V(r).id);if(!V(s))return u;const c=V(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=V(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]=V(t.getBlockAttributes(h));r().removeList().setNode(u,c).run()}),applyDefaultPreset:W(({commands:t})=>{t.applyPreset(V(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}=V(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(()=>V(i)[s]?.includes(r)??!1)}),getContentCustomization:W(({editor:t,commands:r})=>{const i=yi(t,"state");return ge(()=>{const{doc:s}=V(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,V(this.options.presets))}}),KI=Nt.create({name:Oe.FONT_WEIGHT,group:Gt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:W(({commands:n},e)=>{n.applyMark(this.name,{value:e}),V(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:W(({commands:n})=>{const e=V(n.getFontWeight()),t=V(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=V(e),i=V(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:W(({commands:n})=>{const e=n.getPreset();return ge(()=>V(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 Jr({font_weight:n.value})}}),GI=Nt.create({name:Oe.FONT_SIZE,group:Gt.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(()=>V(t)[V(e)].font_size.replace("px",""))}),applyFontSize:W(({commands:n},e)=>{const t=V(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(V(n.getFontSize())),t=Math.min(e+1,V(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:W(({commands:n})=>{const e=Number(V(n.getFontSize())),t=Math.max(e-1,V(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=V(this.options.wrapperRef),r=Ry(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 Jr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),JI=Nt.create({name:Oe.FONT_COLOR,group:Gt.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(()=>V(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 Jr({font_color:n.value})}}),jI=Nt.create({name:Oe.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 Jr({background_color:n.value})}}),YI=Re.create({name:"device_manager",addCommands(){return{getDevice:W(()=>yi(this.options,"device"))}}}),XI=Nt.create({name:Oe.FONT_STYLE,group:Gt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return ge(()=>V(e)?.italic??V(t).italic)}),isItalicAvailable:W(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return ge(()=>{const r=V(e),i=V(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:W(({commands:n})=>{const e=n.getPreset();return ge(()=>({italic:V(e).common.font_style==="italic"}))}),toggleItalic:W(({commands:n})=>{V(n.isItalicAvailable())&&(V(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 Jr({font_style:e})}}),ZI=Nt.create({name:Oe.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>V(e).underline)}),isStrikeThrough:W(({commands:n})=>{const e=n.getTextDecoration();return ge(()=>V(e).strike_through)}),getTextDecoration:W(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return ge(()=>{const r=V(e)??{},i=V(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(()=>V(e)!==V(t).underline)}),getDefaultTextDecoration:W(({commands:n})=>{const e=n.getPreset();return ge(()=>{const{text_decoration:t}=V(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=V(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"),Jr({text_decoration:e.join(" ")})}}),QI=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})=>QO(e))}),applyLowerCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:W(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),By={mobile:null,tablet:null,desktop:null},eN=Re.create({name:Oe.ALIGNMENT,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[Oe.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=kI(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=V(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},By)}),removeAlignment:W(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:W(({commands:n})=>{const e=n.getBlockAttributes(this.name,By),t=n.getDevice(),r=n.getDefaultAlignment();return ge(()=>V(e)?.[V(t)]??V(r))}),getDefaultAlignment:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>V(t)[V(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)})}),zy={mobile:null,tablet:null,desktop:null},tN=Re.create({name:Oe.LINE_HEIGHT,addGlobalAttributes(){return[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[Oe.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=V(this.options.wrapperRef),r=CI(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,zy),t=n.getDevice(),r=n.getDefaultLineHeight();return ge(()=>V(e)?.[V(t)]??V(r))}),getDefaultLineHeight:W(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return ge(()=>V(t)[V(e)].line_height)}),applyLineHeight:W(({commands:n},e)=>{const t=V(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},zy)})}}}),nN=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",Oi(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)}}}),rN=nN.extend({name:oe.LIST_ITEM,marks:Gt.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 iN(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 sN(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}iN(r,u)&&(n.removeNodeMark(i+1,u),n.addNodeMark(i,bh(u)),s.push(u))}}),!1})}const oN=jn.create({name:oe.LIST,content:`${oe.LIST_ITEM}+`,group:"block list",marks:Gt.SETTINGS,addExtensions:()=>[rN],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 MO){const i=`.${V(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=[V(this.options.baseClass)+n.bullet.type,V(this.options.presetClass)];return[IO.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(()=>V(e).type??null)}),applyList:W(({commands:n,chain:e},t)=>V(n.getListType())===t?n.removeList():e().applyDefaultPreset().toggleList(oe.LIST,oe.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({tr:i})=>sN(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)=>mO({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 aN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function lN(n){return new ct({key:new Mt("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=FT(t.doc,[...e]);if(KT(u).forEach(({newRange:h})=>{const p=zT(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(!aN(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 uN(n){return new ct({key:new Mt("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=VT(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 cN(n){return new ct({key:new Mt("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 fN=/[\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(fN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const hN=Nt.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(){jO()},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",Oi(this.options.HTMLAttributes,n),0]:["a",Oi(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[gO({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(lN({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(uN({type:this.type})),this.options.linkOnPaste&&n.push(cN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),dN=hN.extend({name:Oe.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:Mi.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Mi.URL;const t=e.replace("#","");return V(this.options.pageBlocks).find(s=>s.id===parseInt(t))?Mi.BLOCK:Mi.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(Hy.text(r.text,[Hy.mark(Oe.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(()=>V(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),ZO.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Mi.BLOCK?`#${n.href}`:n.href,t=V(this.options.basePresetClass)+V(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),pN=Nt.create({name:Oe.SUPERSCRIPT,addCommands(){return{applySuperscript:W(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:W(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:W(({commands:n})=>{V(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:W(({commands:n})=>{const e=n.getMark(this.name);return ge(()=>!!V(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),mN=Re.create({name:Oe.MARGIN,addGlobalAttributes:()=>[{types:[oe.PARAGRAPH,oe.HEADING],attributes:{[Oe.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 gN(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=kc({default:null,link:null});return n5(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),VI().concat([qI.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new vN({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),oN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),YI.configure({device:n.deviceRef}),GI.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),UI.configure({fonts:n.fonts,defaultPreset:yi(t,"default"),defaultFont:n.defaultFont}),KI,JI,jI,XI,ZI,QI,pN,eN,tN.configure({wrapperRef:n.wrapperRef}),dN.configure({preset:yi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),mN])}class yN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class $y{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class _n extends $y{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 bN extends $y{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=>Fy.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,Oe.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 yN})}static _buildJson(e){return new bN({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=gN({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=HT(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 _N(n,e){return n.type===e}function wN(n){return typeof n=="string"}class Hy{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=>_N(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=>wN(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(Oe.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=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 TO)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 Wy{static createWindow(){return new sm.JSDOM().window}types;parse(e){const{window:t}=new sm.JSDOM(e);return this.types=t,t.document}}class Vy{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 SN extends Vy{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(Wy.createWindow());const i=im.resolve(process.cwd(),t),s=Eh.build({config:require(i).editor,nodeDomParser:new Wy}),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 xN="4.11.2";class CN extends Vy{name="version";description="display cli version";doCommand(){this.output(xN)}}const Uy=new VC,EN=[SN,CN];for(const n of EN)new n().install(Uy);Uy.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 yx(s){return ge(s).toLowerCase()}function bx(s){return ge(s).toUpperCase()}function wx(s,l,u){if(s=ge(s),s&&(u||l===t))return td(s);if(!s||!(l=xt(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 vx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.slice(0,sd(s)+1);if(!s||!(l=xt(l)))return s;var d=jt(s),y=rd(d,jt(l))+1;return nr(d,0,y).join("")}function Sx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.replace(Ka,"");if(!s||!(l=xt(l)))return s;var d=jt(s),y=nd(d,jt(l));return nr(d,y).join("")}function xx(s,l){var u=Gn,d=sn;if(Te(l)){var y="separator"in l?l.separator:y;u="length"in l?Q(l.length):u,d="omission"in l?xt(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 C=x?nr(x,0,E).join(""):s.slice(0,E);if(y===t)return C+d;if(x&&(E+=C.length-E),Gc(y)){if(s.slice(E).search(y)){var N,O=C;for(y.global||(y=ac(y.source,ge(kh.exec(y))+"g")),y.lastIndex=0;N=y.exec(O);)var R=N.index;C=C.slice(0,R===t?E:R)}}else if(s.indexOf(xt(y),E)!=E){var H=C.lastIndexOf(y);H>-1&&(C=C.slice(0,H))}return C+d}function kx(s){return s=ge(s),s&&Ly.test(s)?s.replace(vh,Z2):s}var Ex=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?J2(s)?tb(s):z2(s):s.match(l)||[]}var Gp=ie(function(s,l){try{return vt(s,t,l)}catch(u){return Kc(u)?u:new X(u)}}),_x=_n(function(s,l){return Rt(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?Ee(s,function(d){if(typeof d[1]!="function")throw new Lt(a);return[u(d[0]),d[1]]}):[],ie(function(d){for(var y=-1;++y<l;){var v=s[y];if(vt(v[0],this,d))return vt(v[1],this,d)}})}function Tx(s){return Zb(Dt(s,p))}function Yc(s){return function(){return s}}function Mx(s,l){return s==null||s!==s?l:s}var Ax=jd(),Ix=jd(!0);function ht(s){return s}function Xc(s){return _d(typeof s=="function"?s:Dt(s,p))}function Nx(s){return Td(Dt(s,p))}function Ox(s,l){return Md(s,Dt(l,p))}var Rx=ie(function(s,l){return function(u){return es(u,s,l)}}),Lx=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&&!(Te(l)&&(y.length||!d.length))&&(u=l,l=s,s=this,y=vo(l,He(l)));var v=!(Te(u)&&"chain"in u)||!!u.chain,x=Tn(s);return Rt(y,function(E){var C=l[E];s[E]=C,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:C,args:arguments,thisArg:s}),O.__chain__=N,O}return C.apply(s,Yn([this.value()],arguments))})}),s}function Px(){return qe._===this&&(qe._=lb),this}function Qc(){}function Dx(s){return s=Q(s),ie(function(l){return Ad(l,s)})}var Bx=Ic(Ee),zx=Ic(Yh),Fx=Ic(tc);function Jp(s){return Bc(s)?nc(un(s)):mw(s)}function Hx(s){return function(l){return s==null?t:Ir(s,l)}}var $x=Xd(),Wx=Xd(!0);function eu(){return[]}function tu(){return!1}function Ux(){return{}}function Vx(){return""}function Kx(){return!0}function Gx(s,l){if(s=Q(s),s<1||s>qn)return[];var u=wt,d=Qe(s,wt);l=J(l),s-=wt;for(var y=sc(d,l);++u<s;)l(u);return y}function Jx(s){return Z(s)?Ee(s,un):kt(s)?[s]:ct(dp(ge(s)))}function qx(s){var l=++sb;return ge(s)+l}var jx=Co(function(s,l){return s+l},0),Yx=Nc("ceil"),Xx=Co(function(s,l){return s/l},1),Zx=Nc("floor");function Qx(s){return s&&s.length?wo(s,ht,gc):t}function ek(s,l){return s&&s.length?wo(s,J(l,2),gc):t}function tk(s){return Qh(s,ht)}function nk(s,l){return Qh(s,J(l,2))}function rk(s){return s&&s.length?wo(s,ht,vc):t}function ik(s,l){return s&&s.length?wo(s,J(l,2),vc):t}var sk=Co(function(s,l){return s*l},1),ok=Nc("round"),lk=Co(function(s,l){return s-l},0);function ak(s){return s&&s.length?ic(s,ht):0}function ck(s,l){return s&&s.length?ic(s,J(l,2)):0}return w.after=NS,w.ary=Ep,w.assign=b5,w.assignIn=zp,w.assignInWith=Fo,w.assignWith=w5,w.at=v5,w.before=_p,w.bind=Uc,w.bindAll=_x,w.bindKey=Cp,w.castArray=US,w.chain=Sp,w.chunk=Zw,w.compact=Qw,w.concat=ev,w.cond=Cx,w.conforms=Tx,w.constant=Yc,w.countBy=aS,w.create=S5,w.curry=Tp,w.curryRight=Mp,w.debounce=Ap,w.defaults=x5,w.defaultsDeep=k5,w.defer=OS,w.delay=RS,w.difference=tv,w.differenceBy=nv,w.differenceWith=rv,w.drop=iv,w.dropRight=sv,w.dropRightWhile=ov,w.dropWhile=lv,w.fill=av,w.filter=uS,w.flatMap=dS,w.flatMapDeep=pS,w.flatMapDepth=mS,w.flatten=yp,w.flattenDeep=cv,w.flattenDepth=uv,w.flip=LS,w.flow=Ax,w.flowRight=Ix,w.fromPairs=fv,w.functions=I5,w.functionsIn=N5,w.groupBy=gS,w.initial=dv,w.intersection=pv,w.intersectionBy=mv,w.intersectionWith=gv,w.invert=R5,w.invertBy=L5,w.invokeMap=bS,w.iteratee=Xc,w.keyBy=wS,w.keys=He,w.keysIn=ft,w.map=Ro,w.mapKeys=D5,w.mapValues=B5,w.matches=Nx,w.matchesProperty=Ox,w.memoize=Po,w.merge=z5,w.mergeWith=Fp,w.method=Rx,w.methodOf=Lx,w.mixin=Zc,w.negate=Do,w.nthArg=Dx,w.omit=F5,w.omitBy=H5,w.once=PS,w.orderBy=vS,w.over=Bx,w.overArgs=DS,w.overEvery=zx,w.overSome=Fx,w.partial=Vc,w.partialRight=Ip,w.partition=SS,w.pick=$5,w.pickBy=Hp,w.property=Jp,w.propertyOf=Hx,w.pull=vv,w.pullAll=wp,w.pullAllBy=Sv,w.pullAllWith=xv,w.pullAt=kv,w.range=$x,w.rangeRight=Wx,w.rearg=BS,w.reject=ES,w.remove=Ev,w.rest=zS,w.reverse=$c,w.sampleSize=CS,w.set=U5,w.setWith=V5,w.shuffle=TS,w.slice=_v,w.sortBy=IS,w.sortedUniq=Ov,w.sortedUniqBy=Rv,w.split=dx,w.spread=FS,w.tail=Lv,w.take=Pv,w.takeRight=Dv,w.takeRightWhile=Bv,w.takeWhile=zv,w.tap=Qv,w.throttle=HS,w.thru=Oo,w.toArray=Pp,w.toPairs=$p,w.toPairsIn=Wp,w.toPath=Jx,w.toPlainObject=Bp,w.transform=K5,w.unary=$S,w.union=Fv,w.unionBy=Hv,w.unionWith=$v,w.uniq=Wv,w.uniqBy=Uv,w.uniqWith=Vv,w.unset=G5,w.unzip=Wc,w.unzipWith=vp,w.update=J5,w.updateWith=q5,w.values=hi,w.valuesIn=j5,w.without=Kv,w.words=Kp,w.wrap=WS,w.xor=Gv,w.xorBy=Jv,w.xorWith=qv,w.zip=jv,w.zipObject=Yv,w.zipObjectDeep=Xv,w.zipWith=Zv,w.entries=$p,w.entriesIn=Wp,w.extend=zp,w.extendWith=Fo,Zc(w,w),w.add=jx,w.attempt=Gp,w.camelCase=Q5,w.capitalize=Up,w.ceil=Yx,w.clamp=Y5,w.clone=VS,w.cloneDeep=GS,w.cloneDeepWith=JS,w.cloneWith=KS,w.conformsTo=qS,w.deburr=Vp,w.defaultTo=Mx,w.divide=Xx,w.endsWith=ex,w.eq=Xt,w.escape=tx,w.escapeRegExp=nx,w.every=cS,w.find=fS,w.findIndex=mp,w.findKey=E5,w.findLast=hS,w.findLastIndex=gp,w.findLastKey=_5,w.floor=Zx,w.forEach=xp,w.forEachRight=kp,w.forIn=C5,w.forInRight=T5,w.forOwn=M5,w.forOwnRight=A5,w.get=Jc,w.gt=jS,w.gte=YS,w.has=O5,w.hasIn=qc,w.head=bp,w.identity=ht,w.includes=yS,w.indexOf=hv,w.inRange=X5,w.invoke=P5,w.isArguments=Rr,w.isArray=Z,w.isArrayBuffer=XS,w.isArrayLike=ut,w.isArrayLikeObject=Ne,w.isBoolean=ZS,w.isBuffer=rr,w.isDate=QS,w.isElement=e5,w.isEmpty=t5,w.isEqual=n5,w.isEqualWith=r5,w.isError=Kc,w.isFinite=i5,w.isFunction=Tn,w.isInteger=Np,w.isLength=Bo,w.isMap=Op,w.isMatch=s5,w.isMatchWith=o5,w.isNaN=l5,w.isNative=a5,w.isNil=u5,w.isNull=c5,w.isNumber=Rp,w.isObject=Te,w.isObjectLike=Me,w.isPlainObject=ls,w.isRegExp=Gc,w.isSafeInteger=f5,w.isSet=Lp,w.isString=zo,w.isSymbol=kt,w.isTypedArray=fi,w.isUndefined=h5,w.isWeakMap=d5,w.isWeakSet=p5,w.join=yv,w.kebabCase=rx,w.last=zt,w.lastIndexOf=bv,w.lowerCase=ix,w.lowerFirst=sx,w.lt=m5,w.lte=g5,w.max=Qx,w.maxBy=ek,w.mean=tk,w.meanBy=nk,w.min=rk,w.minBy=ik,w.stubArray=eu,w.stubFalse=tu,w.stubObject=Ux,w.stubString=Vx,w.stubTrue=Kx,w.multiply=sk,w.nth=wv,w.noConflict=Px,w.noop=Qc,w.now=Lo,w.pad=ox,w.padEnd=lx,w.padStart=ax,w.parseInt=cx,w.random=Z5,w.reduce=xS,w.reduceRight=kS,w.repeat=ux,w.replace=fx,w.result=W5,w.round=ok,w.runInContext=_,w.sample=_S,w.size=MS,w.snakeCase=hx,w.some=AS,w.sortedIndex=Cv,w.sortedIndexBy=Tv,w.sortedIndexOf=Mv,w.sortedLastIndex=Av,w.sortedLastIndexBy=Iv,w.sortedLastIndexOf=Nv,w.startCase=px,w.startsWith=mx,w.subtract=lk,w.sum=ak,w.sumBy=ck,w.template=gx,w.times=Gx,w.toFinite=Mn,w.toInteger=Q,w.toLength=Dp,w.toLower=yx,w.toNumber=Ft,w.toSafeInteger=y5,w.toString=ge,w.toUpper=bx,w.trim=wx,w.trimEnd=vx,w.trimStart=Sx,w.truncate=xx,w.unescape=kx,w.uniqueId=qx,w.upperCase=Ex,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,Rt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){w[s].placeholder=w}),Rt(["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,wt),type:s+(d.__dir__<0?"Right":"")}),d},oe.prototype[s+"Right"]=function(u){return this.reverse()[s](u).reverse()}}),Rt(["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}}),Rt(["head","last"],function(s,l){var u="take"+(l?"Right":"");oe.prototype[s]=function(){return this[u](1).value()[0]}}),Rt(["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(wt)},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,C=x instanceof oe,N=E[0],O=C||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&&(C=O=!1);var H=this.__chain__,G=!!this.__actions__.length,q=v&&!H,ee=C&&!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 Pt(j,H)}return q&&ee?s.apply(this,E):(j=this.thru(R),q?d?j.value()[0]:j.value():j)})}),Rt(["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=kb,oe.prototype.reverse=Eb,oe.prototype.value=_b,w.prototype.at=eS,w.prototype.chain=tS,w.prototype.commit=nS,w.prototype.next=rS,w.prototype.plant=sS,w.prototype.reverse=oS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=lS,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=iS),w},ri=nb();_r?((_r.exports=ri)._=ri,Xa._=ri):qe._=ri}).call(XI)}($s,$s.exports)),$s.exports}var by=ZI();function ch(n){return n.type.create(by.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 QI=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(Ce.LINK,c),p=hn(t,c);if(!(p.spec.group||"").includes(Wt.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:T,position:M,mark:P}=S;uh({tr:k,node:T,position:M,mark:P.type})}};a.nodesBetween(f.pos,h.pos,(S,k)=>{if(S.type.name===te.LIST)return;const T=YI(S.marks,t),M=p.create({...T?.attrs||{},...r}),P=my(f,h,S,k);if(!m.isInSet(S.marks)&&jI(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})})})}}}),eN=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=my(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)})})}}}),tN=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:gy(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))}}}),nN=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 rN=nN.extend({marks:Wt.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))})}}}),iN=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()}}}),sN=iN.extend({marks:Wt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),oN=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=>LM({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),lN=oN.extend({marks:Wt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),aN=Ie.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[ZM.create(this.editor),QM.create(this.editor)]}}),cN=()=>[rN,sN,lN,BM,JM,QI,eN,tN,aN],uN=Mt.create({name:Ce.FONT_FAMILY,group:Wt.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(Ce.FONT_STYLE).value;!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 Gr({font_family:e})}}),fN=Ie.create({name:Ce.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=Bl.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))Bl.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,Bl).resetAttributes(te.HEADING,Bl).restoreSelection().run()}),removeFormat:B(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Li.head,z(this.options.presets))}}),hN=Mt.create({name:Ce.FONT_WEIGHT,group:Wt.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 Gr({font_weight:n.value})}}),dN=Mt.create({name:Ce.FONT_SIZE,group:Wt.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=py(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 Gr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),pN=Mt.create({name:Ce.FONT_COLOR,group:Wt.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 Gr({font_color:n.value})}}),mN=Mt.create({name:Ce.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 Gr({background_color:n.value})}}),gN=Ie.create({name:"device_manager",addCommands(){return{getDevice:B(()=>gi(this.options,"device"))}}}),yN=Mt.create({name:Ce.FONT_STYLE,group:Wt.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 Gr({font_style:e})}}),bN=Mt.create({name:Ce.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"),Gr({text_decoration:e.join(" ")})}}),wN=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})=>wA(e))}),applyLowerCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),wy={mobile:null,tablet:null,desktop:null},vN=Ie.create({name:Ce.ALIGNMENT,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[Ce.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=GI(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},wy)}),removeAlignment:B(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:B(({commands:n})=>{const e=n.getBlockAttributes(this.name,wy),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)})}),vy={mobile:null,tablet:null,desktop:null},SN=Ie.create({name:Ce.LINE_HEIGHT,addGlobalAttributes(){return[{types:[te.PARAGRAPH,te.HEADING],attributes:{[Ce.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=VI(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,vy),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},vy)})}}}),xN=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)}}}),kN=xN.extend({name:te.LIST_ITEM,marks:Wt.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 EN(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 _N(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}EN(r,c)&&(n.removeNodeMark(i+1,c),n.addNodeMark(i,ch(c)),o.push(c))}}),!1})}const CN=Kn.create({name:te.LIST,content:`${te.LIST_ITEM}+`,group:"block list",marks:Wt.SETTINGS,addExtensions:()=>[kN],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 YM){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[XM.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})=>_N(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)=>PM({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 TN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function MN(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=rM(t.doc,[...e]);if(hM(c).forEach(({newRange:h})=>{const m=sM(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 T=ma(S).map(M=>M.toObject(n.defaultProtocol));if(!TN(T))return!1;T.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 AN(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=cM(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 IN(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 NN=/[\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(NN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const ON=Mt.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(){mA()},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[DM({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(MN({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(AN({type:this.type})),this.options.linkOnPaste&&n.push(IN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),RN=ON.extend({name:Ce.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(xy.text(r.text,[xy.mark(Ce.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(),bA.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]}}),LN=Mt.create({name:Ce.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]}}),PN=Ie.create({name:Ce.MARGIN,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[Ce.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 DN(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=yu({default:null,link:null});return xE(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),cN().concat([fN.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new $N({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),CN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),gN.configure({device:n.deviceRef}),dN.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),uN.configure({fonts:n.fonts,defaultPreset:gi(t,"default"),defaultFont:n.defaultFont}),hN,pN,mN,yN,bN,wN,LN,vN,SN.configure({wrapperRef:n.wrapperRef}),RN.configure({preset:gi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),PN])}class BN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class Sy{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class gn extends Sy{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 zN extends Sy{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=>by.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,Ce.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 BN})}static _buildJson(e){return new zN({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=DN({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=lM(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 FN(n,e){return n.type===e}function HN(n){return typeof n=="string"}class xy{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=>FN(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=>HN(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(Ce.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class $N{_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 qM)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 WN{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=WN;
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 yx(s){return ge(s).toLowerCase()}function bx(s){return ge(s).toUpperCase()}function wx(s,l,u){if(s=ge(s),s&&(u||l===t))return td(s);if(!s||!(l=xt(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 vx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.slice(0,sd(s)+1);if(!s||!(l=xt(l)))return s;var d=jt(s),y=rd(d,jt(l))+1;return nr(d,0,y).join("")}function Sx(s,l,u){if(s=ge(s),s&&(u||l===t))return s.replace(Ka,"");if(!s||!(l=xt(l)))return s;var d=jt(s),y=nd(d,jt(l));return nr(d,y).join("")}function xx(s,l){var u=Gn,d=sn;if(Te(l)){var y="separator"in l?l.separator:y;u="length"in l?Q(l.length):u,d="omission"in l?xt(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 C=x?nr(x,0,E).join(""):s.slice(0,E);if(y===t)return C+d;if(x&&(E+=C.length-E),Gc(y)){if(s.slice(E).search(y)){var N,O=C;for(y.global||(y=ac(y.source,ge(kh.exec(y))+"g")),y.lastIndex=0;N=y.exec(O);)var R=N.index;C=C.slice(0,R===t?E:R)}}else if(s.indexOf(xt(y),E)!=E){var H=C.lastIndexOf(y);H>-1&&(C=C.slice(0,H))}return C+d}function kx(s){return s=ge(s),s&&Ly.test(s)?s.replace(vh,Z2):s}var Ex=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?J2(s)?tb(s):z2(s):s.match(l)||[]}var Gp=ie(function(s,l){try{return vt(s,t,l)}catch(u){return Kc(u)?u:new X(u)}}),_x=_n(function(s,l){return Rt(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?Ee(s,function(d){if(typeof d[1]!="function")throw new Lt(a);return[u(d[0]),d[1]]}):[],ie(function(d){for(var y=-1;++y<l;){var v=s[y];if(vt(v[0],this,d))return vt(v[1],this,d)}})}function Tx(s){return Zb(Dt(s,p))}function Yc(s){return function(){return s}}function Mx(s,l){return s==null||s!==s?l:s}var Ax=jd(),Ix=jd(!0);function ht(s){return s}function Xc(s){return _d(typeof s=="function"?s:Dt(s,p))}function Nx(s){return Td(Dt(s,p))}function Ox(s,l){return Md(s,Dt(l,p))}var Rx=ie(function(s,l){return function(u){return es(u,s,l)}}),Lx=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&&!(Te(l)&&(y.length||!d.length))&&(u=l,l=s,s=this,y=vo(l,He(l)));var v=!(Te(u)&&"chain"in u)||!!u.chain,x=Tn(s);return Rt(y,function(E){var C=l[E];s[E]=C,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:C,args:arguments,thisArg:s}),O.__chain__=N,O}return C.apply(s,Yn([this.value()],arguments))})}),s}function Px(){return qe._===this&&(qe._=lb),this}function Qc(){}function Dx(s){return s=Q(s),ie(function(l){return Ad(l,s)})}var Bx=Ic(Ee),zx=Ic(Yh),Fx=Ic(tc);function Jp(s){return Bc(s)?nc(un(s)):mw(s)}function Hx(s){return function(l){return s==null?t:Ir(s,l)}}var $x=Xd(),Wx=Xd(!0);function eu(){return[]}function tu(){return!1}function Ux(){return{}}function Vx(){return""}function Kx(){return!0}function Gx(s,l){if(s=Q(s),s<1||s>qn)return[];var u=wt,d=Qe(s,wt);l=J(l),s-=wt;for(var y=sc(d,l);++u<s;)l(u);return y}function Jx(s){return Z(s)?Ee(s,un):kt(s)?[s]:ct(dp(ge(s)))}function qx(s){var l=++sb;return ge(s)+l}var jx=Co(function(s,l){return s+l},0),Yx=Nc("ceil"),Xx=Co(function(s,l){return s/l},1),Zx=Nc("floor");function Qx(s){return s&&s.length?wo(s,ht,gc):t}function ek(s,l){return s&&s.length?wo(s,J(l,2),gc):t}function tk(s){return Qh(s,ht)}function nk(s,l){return Qh(s,J(l,2))}function rk(s){return s&&s.length?wo(s,ht,vc):t}function ik(s,l){return s&&s.length?wo(s,J(l,2),vc):t}var sk=Co(function(s,l){return s*l},1),ok=Nc("round"),lk=Co(function(s,l){return s-l},0);function ak(s){return s&&s.length?ic(s,ht):0}function ck(s,l){return s&&s.length?ic(s,J(l,2)):0}return w.after=NS,w.ary=Ep,w.assign=b5,w.assignIn=zp,w.assignInWith=Fo,w.assignWith=w5,w.at=v5,w.before=_p,w.bind=Uc,w.bindAll=_x,w.bindKey=Cp,w.castArray=US,w.chain=Sp,w.chunk=Zw,w.compact=Qw,w.concat=ev,w.cond=Cx,w.conforms=Tx,w.constant=Yc,w.countBy=aS,w.create=S5,w.curry=Tp,w.curryRight=Mp,w.debounce=Ap,w.defaults=x5,w.defaultsDeep=k5,w.defer=OS,w.delay=RS,w.difference=tv,w.differenceBy=nv,w.differenceWith=rv,w.drop=iv,w.dropRight=sv,w.dropRightWhile=ov,w.dropWhile=lv,w.fill=av,w.filter=uS,w.flatMap=dS,w.flatMapDeep=pS,w.flatMapDepth=mS,w.flatten=yp,w.flattenDeep=cv,w.flattenDepth=uv,w.flip=LS,w.flow=Ax,w.flowRight=Ix,w.fromPairs=fv,w.functions=I5,w.functionsIn=N5,w.groupBy=gS,w.initial=dv,w.intersection=pv,w.intersectionBy=mv,w.intersectionWith=gv,w.invert=R5,w.invertBy=L5,w.invokeMap=bS,w.iteratee=Xc,w.keyBy=wS,w.keys=He,w.keysIn=ft,w.map=Ro,w.mapKeys=D5,w.mapValues=B5,w.matches=Nx,w.matchesProperty=Ox,w.memoize=Po,w.merge=z5,w.mergeWith=Fp,w.method=Rx,w.methodOf=Lx,w.mixin=Zc,w.negate=Do,w.nthArg=Dx,w.omit=F5,w.omitBy=H5,w.once=PS,w.orderBy=vS,w.over=Bx,w.overArgs=DS,w.overEvery=zx,w.overSome=Fx,w.partial=Vc,w.partialRight=Ip,w.partition=SS,w.pick=$5,w.pickBy=Hp,w.property=Jp,w.propertyOf=Hx,w.pull=vv,w.pullAll=wp,w.pullAllBy=Sv,w.pullAllWith=xv,w.pullAt=kv,w.range=$x,w.rangeRight=Wx,w.rearg=BS,w.reject=ES,w.remove=Ev,w.rest=zS,w.reverse=$c,w.sampleSize=CS,w.set=U5,w.setWith=V5,w.shuffle=TS,w.slice=_v,w.sortBy=IS,w.sortedUniq=Ov,w.sortedUniqBy=Rv,w.split=dx,w.spread=FS,w.tail=Lv,w.take=Pv,w.takeRight=Dv,w.takeRightWhile=Bv,w.takeWhile=zv,w.tap=Qv,w.throttle=HS,w.thru=Oo,w.toArray=Pp,w.toPairs=$p,w.toPairsIn=Wp,w.toPath=Jx,w.toPlainObject=Bp,w.transform=K5,w.unary=$S,w.union=Fv,w.unionBy=Hv,w.unionWith=$v,w.uniq=Wv,w.uniqBy=Uv,w.uniqWith=Vv,w.unset=G5,w.unzip=Wc,w.unzipWith=vp,w.update=J5,w.updateWith=q5,w.values=hi,w.valuesIn=j5,w.without=Kv,w.words=Kp,w.wrap=WS,w.xor=Gv,w.xorBy=Jv,w.xorWith=qv,w.zip=jv,w.zipObject=Yv,w.zipObjectDeep=Xv,w.zipWith=Zv,w.entries=$p,w.entriesIn=Wp,w.extend=zp,w.extendWith=Fo,Zc(w,w),w.add=jx,w.attempt=Gp,w.camelCase=Q5,w.capitalize=Up,w.ceil=Yx,w.clamp=Y5,w.clone=VS,w.cloneDeep=GS,w.cloneDeepWith=JS,w.cloneWith=KS,w.conformsTo=qS,w.deburr=Vp,w.defaultTo=Mx,w.divide=Xx,w.endsWith=ex,w.eq=Xt,w.escape=tx,w.escapeRegExp=nx,w.every=cS,w.find=fS,w.findIndex=mp,w.findKey=E5,w.findLast=hS,w.findLastIndex=gp,w.findLastKey=_5,w.floor=Zx,w.forEach=xp,w.forEachRight=kp,w.forIn=C5,w.forInRight=T5,w.forOwn=M5,w.forOwnRight=A5,w.get=Jc,w.gt=jS,w.gte=YS,w.has=O5,w.hasIn=qc,w.head=bp,w.identity=ht,w.includes=yS,w.indexOf=hv,w.inRange=X5,w.invoke=P5,w.isArguments=Rr,w.isArray=Z,w.isArrayBuffer=XS,w.isArrayLike=ut,w.isArrayLikeObject=Ne,w.isBoolean=ZS,w.isBuffer=rr,w.isDate=QS,w.isElement=e5,w.isEmpty=t5,w.isEqual=n5,w.isEqualWith=r5,w.isError=Kc,w.isFinite=i5,w.isFunction=Tn,w.isInteger=Np,w.isLength=Bo,w.isMap=Op,w.isMatch=s5,w.isMatchWith=o5,w.isNaN=l5,w.isNative=a5,w.isNil=u5,w.isNull=c5,w.isNumber=Rp,w.isObject=Te,w.isObjectLike=Me,w.isPlainObject=ls,w.isRegExp=Gc,w.isSafeInteger=f5,w.isSet=Lp,w.isString=zo,w.isSymbol=kt,w.isTypedArray=fi,w.isUndefined=h5,w.isWeakMap=d5,w.isWeakSet=p5,w.join=yv,w.kebabCase=rx,w.last=zt,w.lastIndexOf=bv,w.lowerCase=ix,w.lowerFirst=sx,w.lt=m5,w.lte=g5,w.max=Qx,w.maxBy=ek,w.mean=tk,w.meanBy=nk,w.min=rk,w.minBy=ik,w.stubArray=eu,w.stubFalse=tu,w.stubObject=Ux,w.stubString=Vx,w.stubTrue=Kx,w.multiply=sk,w.nth=wv,w.noConflict=Px,w.noop=Qc,w.now=Lo,w.pad=ox,w.padEnd=lx,w.padStart=ax,w.parseInt=cx,w.random=Z5,w.reduce=xS,w.reduceRight=kS,w.repeat=ux,w.replace=fx,w.result=W5,w.round=ok,w.runInContext=_,w.sample=_S,w.size=MS,w.snakeCase=hx,w.some=AS,w.sortedIndex=Cv,w.sortedIndexBy=Tv,w.sortedIndexOf=Mv,w.sortedLastIndex=Av,w.sortedLastIndexBy=Iv,w.sortedLastIndexOf=Nv,w.startCase=px,w.startsWith=mx,w.subtract=lk,w.sum=ak,w.sumBy=ck,w.template=gx,w.times=Gx,w.toFinite=Mn,w.toInteger=Q,w.toLength=Dp,w.toLower=yx,w.toNumber=Ft,w.toSafeInteger=y5,w.toString=ge,w.toUpper=bx,w.trim=wx,w.trimEnd=vx,w.trimStart=Sx,w.truncate=xx,w.unescape=kx,w.uniqueId=qx,w.upperCase=Ex,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,Rt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){w[s].placeholder=w}),Rt(["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,wt),type:s+(d.__dir__<0?"Right":"")}),d},oe.prototype[s+"Right"]=function(u){return this.reverse()[s](u).reverse()}}),Rt(["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}}),Rt(["head","last"],function(s,l){var u="take"+(l?"Right":"");oe.prototype[s]=function(){return this[u](1).value()[0]}}),Rt(["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(wt)},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,C=x instanceof oe,N=E[0],O=C||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&&(C=O=!1);var H=this.__chain__,G=!!this.__actions__.length,q=v&&!H,ee=C&&!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 Pt(j,H)}return q&&ee?s.apply(this,E):(j=this.thru(R),q?d?j.value()[0]:j.value():j)})}),Rt(["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=kb,oe.prototype.reverse=Eb,oe.prototype.value=_b,w.prototype.at=eS,w.prototype.chain=tS,w.prototype.commit=nS,w.prototype.next=rS,w.prototype.plant=sS,w.prototype.reverse=oS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=lS,w.prototype.first=w.prototype.head,Ji&&(w.prototype[Ji]=iS),w},ri=nb();_r?((_r.exports=ri)._=ri,Xa._=ri):qe._=ri}).call(XI)}($s,$s.exports)),$s.exports}var by=ZI();function ch(n){return n.type.create(by.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 QI=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(Ce.LINK,c),p=hn(t,c);if(!(p.spec.group||"").includes(Wt.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:T,position:M,mark:P}=S;uh({tr:k,node:T,position:M,mark:P.type})}};a.nodesBetween(f.pos,h.pos,(S,k)=>{if(S.type.name===te.LIST)return;const T=YI(S.marks,t),M=p.create({...T?.attrs||{},...r}),P=my(f,h,S,k);if(!m.isInSet(S.marks)&&jI(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})})})}}}),eN=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=my(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)})})}}}),tN=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:gy(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))}}}),nN=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 rN=nN.extend({marks:Wt.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))})}}}),iN=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()}}}),sN=iN.extend({marks:Wt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),oN=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=>LM({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),lN=oN.extend({marks:Wt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),aN=Ie.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[ZM.create(this.editor),QM.create(this.editor)]}}),cN=()=>[rN,sN,lN,BM,JM,QI,eN,tN,aN],uN=Mt.create({name:Ce.FONT_FAMILY,group:Wt.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(Ce.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 Gr({font_family:e})}}),fN=Ie.create({name:Ce.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=Bl.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))Bl.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,Bl).resetAttributes(te.HEADING,Bl).restoreSelection().run()}),removeFormat:B(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Li.head,z(this.options.presets))}}),hN=Mt.create({name:Ce.FONT_WEIGHT,group:Wt.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 Gr({font_weight:n.value})}}),dN=Mt.create({name:Ce.FONT_SIZE,group:Wt.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=py(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 Gr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),pN=Mt.create({name:Ce.FONT_COLOR,group:Wt.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 Gr({font_color:n.value})}}),mN=Mt.create({name:Ce.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 Gr({background_color:n.value})}}),gN=Ie.create({name:"device_manager",addCommands(){return{getDevice:B(()=>gi(this.options,"device"))}}}),yN=Mt.create({name:Ce.FONT_STYLE,group:Wt.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 Gr({font_style:e})}}),bN=Mt.create({name:Ce.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"),Gr({text_decoration:e.join(" ")})}}),wN=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})=>wA(e))}),applyLowerCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:B(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),wy={mobile:null,tablet:null,desktop:null},vN=Ie.create({name:Ce.ALIGNMENT,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[Ce.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=GI(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},wy)}),removeAlignment:B(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:B(({commands:n})=>{const e=n.getBlockAttributes(this.name,wy),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)})}),vy={mobile:null,tablet:null,desktop:null},SN=Ie.create({name:Ce.LINE_HEIGHT,addGlobalAttributes(){return[{types:[te.PARAGRAPH,te.HEADING],attributes:{[Ce.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=VI(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,vy),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},vy)})}}}),xN=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)}}}),kN=xN.extend({name:te.LIST_ITEM,marks:Wt.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 EN(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 _N(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}EN(r,c)&&(n.removeNodeMark(i+1,c),n.addNodeMark(i,ch(c)),o.push(c))}}),!1})}const CN=Kn.create({name:te.LIST,content:`${te.LIST_ITEM}+`,group:"block list",marks:Wt.SETTINGS,addExtensions:()=>[kN],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 YM){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[XM.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})=>_N(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)=>PM({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 TN(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function MN(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=rM(t.doc,[...e]);if(hM(c).forEach(({newRange:h})=>{const m=sM(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 T=ma(S).map(M=>M.toObject(n.defaultProtocol));if(!TN(T))return!1;T.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 AN(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=cM(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 IN(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 NN=/[\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(NN,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const ON=Mt.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(){mA()},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[DM({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(MN({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(AN({type:this.type})),this.options.linkOnPaste&&n.push(IN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),RN=ON.extend({name:Ce.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(xy.text(r.text,[xy.mark(Ce.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(),bA.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]}}),LN=Mt.create({name:Ce.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]}}),PN=Ie.create({name:Ce.MARGIN,addGlobalAttributes:()=>[{types:[te.PARAGRAPH,te.HEADING],attributes:{[Ce.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 DN(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=yu({default:null,link:null});return xE(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),cN().concat([fN.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new $N({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),CN.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),gN.configure({device:n.deviceRef}),dN.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),uN.configure({fonts:n.fonts,defaultPreset:gi(t,"default"),defaultFont:n.defaultFont}),hN,pN,mN,yN,bN,wN,LN,vN,SN.configure({wrapperRef:n.wrapperRef}),RN.configure({preset:gi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),PN])}class BN{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class Sy{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class gn extends Sy{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 zN extends Sy{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=>by.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,Ce.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 BN})}static _buildJson(e){return new zN({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=DN({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=lM(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 FN(n,e){return n.type===e}function HN(n){return typeof n=="string"}class xy{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=>FN(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=>HN(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(Ce.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class $N{_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 qM)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 WN{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=WN;
@@ -10,6 +10,7 @@ export declare class Font {
10
10
  weights: string[];
11
11
  constructor({ name, category, styles }: IFontJson);
12
12
  private getWeights;
13
+ get isItalicOnly(): boolean;
13
14
  isWeightSupported(weight: string): boolean;
14
15
  isItalicSupported(weight: string): boolean;
15
16
  isWeightItalicOnly(weight: string): boolean;
package/dist/wysiwyg.mjs CHANGED
@@ -23530,7 +23530,9 @@ const FontFamily = Mark2.create({
23530
23530
  commands2.applyFontWeight(fontWeight);
23531
23531
  }
23532
23532
  const isItalicCustomized = commands2.isSettingCustomized(TextSetting.FONT_STYLE).value;
23533
- if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
23533
+ if (font.isItalicOnly) {
23534
+ commands2.applyItalic();
23535
+ } else if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
23534
23536
  commands2.removeItalic();
23535
23537
  }
23536
23538
  }),
@@ -30230,6 +30232,9 @@ class Font {
30230
30232
  const weights = this.styles.map((style2) => style2.replace("i", ""));
30231
30233
  return Array.from(new Set(weights));
30232
30234
  }
30235
+ get isItalicOnly() {
30236
+ return this.styles.every((style2) => style2.endsWith("i"));
30237
+ }
30233
30238
  isWeightSupported(weight) {
30234
30239
  return this.weights.includes(weight);
30235
30240
  }
package/example/fonts.js CHANGED
@@ -1,35 +1,35 @@
1
1
  export const FONTS = [
2
2
  {
3
- 'name': 'Merriweather',
4
- 'styles': [
3
+ name: 'Merriweather',
4
+ styles: [
5
5
  '900i'
6
6
  ],
7
- 'category': 'Serif'
7
+ category: 'Serif'
8
8
  },
9
9
  {
10
- 'name': 'Arvo',
11
- 'styles': [
10
+ name: 'Arvo',
11
+ styles: [
12
12
  '400',
13
13
  '400i',
14
14
  '700',
15
15
  '700i'
16
16
  ],
17
- 'category': 'Serif'
17
+ category: 'Serif'
18
18
  },
19
19
  {
20
- 'name': 'BioRhyme',
21
- 'styles': [
20
+ name: 'BioRhyme',
21
+ styles: [
22
22
  '200',
23
23
  '300',
24
24
  '400',
25
25
  '700',
26
26
  '800'
27
27
  ],
28
- 'category': 'Serif'
28
+ category: 'Serif'
29
29
  },
30
30
  {
31
- 'name': 'Josefin Slab',
32
- 'styles': [
31
+ name: 'Josefin Slab',
32
+ styles: [
33
33
  '100',
34
34
  '100i',
35
35
  '300',
@@ -41,11 +41,11 @@ export const FONTS = [
41
41
  '700',
42
42
  '700i'
43
43
  ],
44
- 'category': 'Serif'
44
+ category: 'Serif'
45
45
  },
46
46
  {
47
- 'name': 'Rubik',
48
- 'styles': [
47
+ name: 'Rubik',
48
+ styles: [
49
49
  '300',
50
50
  '300i',
51
51
  '400',
@@ -57,11 +57,11 @@ export const FONTS = [
57
57
  '900',
58
58
  '900i'
59
59
  ],
60
- 'category': 'Serif'
60
+ category: 'Serif'
61
61
  },
62
62
  {
63
- 'name': 'Alegreya',
64
- 'styles': [
63
+ name: 'Alegreya',
64
+ styles: [
65
65
  '400',
66
66
  '400i',
67
67
  '500',
@@ -73,11 +73,11 @@ export const FONTS = [
73
73
  '900',
74
74
  '900i'
75
75
  ],
76
- 'category': 'Serif'
76
+ category: 'Serif'
77
77
  },
78
78
  {
79
- 'name': 'Crimson Text',
80
- 'styles': [
79
+ name: 'Crimson Text',
80
+ styles: [
81
81
  '400',
82
82
  '400i',
83
83
  '600',
@@ -85,58 +85,58 @@ export const FONTS = [
85
85
  '700',
86
86
  '700i'
87
87
  ],
88
- 'category': 'Serif'
88
+ category: 'Serif'
89
89
  },
90
90
  {
91
- 'name': 'PT Serif',
92
- 'styles': [
91
+ name: 'PT Serif',
92
+ styles: [
93
93
  '400',
94
94
  '400i',
95
95
  '700',
96
96
  '700i'
97
97
  ],
98
- 'category': 'Serif'
98
+ category: 'Serif'
99
99
  },
100
100
  {
101
- 'name': 'Anonymous Pro',
102
- 'styles': [
101
+ name: 'Anonymous Pro',
102
+ styles: [
103
103
  '400',
104
104
  '400i',
105
105
  '700',
106
106
  '700i'
107
107
  ],
108
- 'category': 'Serif'
108
+ category: 'Serif'
109
109
  },
110
110
  {
111
- 'name': 'Roboto Slab',
112
- 'styles': [
111
+ name: 'Roboto Slab',
112
+ styles: [
113
113
  '100',
114
114
  '300',
115
115
  '400',
116
116
  '700'
117
117
  ],
118
- 'category': 'Serif'
118
+ category: 'Serif'
119
119
  },
120
120
  {
121
- 'name': 'Scope One',
122
- 'styles': [
121
+ name: 'Scope One',
122
+ styles: [
123
123
  '400'
124
124
  ],
125
- 'category': 'Serif'
125
+ category: 'Serif'
126
126
  },
127
127
  {
128
- 'name': 'Droid Serif',
129
- 'styles': [
128
+ name: 'Droid Serif',
129
+ styles: [
130
130
  '400',
131
131
  '400i',
132
132
  '700',
133
133
  '700i'
134
134
  ],
135
- 'category': 'Serif'
135
+ category: 'Serif'
136
136
  },
137
137
  {
138
- 'name': 'Josefin Sans',
139
- 'styles': [
138
+ name: 'Josefin Sans',
139
+ styles: [
140
140
  '100',
141
141
  '100i',
142
142
  '300',
@@ -148,11 +148,11 @@ export const FONTS = [
148
148
  '700',
149
149
  '700i'
150
150
  ],
151
- 'category': 'Sans Serif'
151
+ category: 'Sans Serif'
152
152
  },
153
153
  {
154
- 'name': 'Work Sans',
155
- 'styles': [
154
+ name: 'Work Sans',
155
+ styles: [
156
156
  '100',
157
157
  '200',
158
158
  '300',
@@ -163,11 +163,11 @@ export const FONTS = [
163
163
  '800',
164
164
  '900'
165
165
  ],
166
- 'category': 'Sans Serif'
166
+ category: 'Sans Serif'
167
167
  },
168
168
  {
169
- 'name': 'Fira Sans',
170
- 'styles': [
169
+ name: 'Fira Sans',
170
+ styles: [
171
171
  '100',
172
172
  '100i',
173
173
  '200',
@@ -187,11 +187,11 @@ export const FONTS = [
187
187
  '900',
188
188
  '900i'
189
189
  ],
190
- 'category': 'Sans Serif'
190
+ category: 'Sans Serif'
191
191
  },
192
192
  {
193
- 'name': 'Alegreya Sans',
194
- 'styles': [
193
+ name: 'Alegreya Sans',
194
+ styles: [
195
195
  '100',
196
196
  '100i',
197
197
  '300',
@@ -207,11 +207,11 @@ export const FONTS = [
207
207
  '900',
208
208
  '900i'
209
209
  ],
210
- 'category': 'Sans Serif'
210
+ category: 'Sans Serif'
211
211
  },
212
212
  {
213
- 'name': 'Source Sans Pro',
214
- 'styles': [
213
+ name: 'Source Sans Pro',
214
+ styles: [
215
215
  '200',
216
216
  '200i',
217
217
  '300',
@@ -225,22 +225,22 @@ export const FONTS = [
225
225
  '900',
226
226
  '900i'
227
227
  ],
228
- 'category': 'Sans Serif'
228
+ category: 'Sans Serif'
229
229
  },
230
230
  {
231
- 'name': 'Rajdhani',
232
- 'styles': [
231
+ name: 'Rajdhani',
232
+ styles: [
233
233
  '300',
234
234
  '400',
235
235
  '500',
236
236
  '600',
237
237
  '700'
238
238
  ],
239
- 'category': 'Sans Serif'
239
+ category: 'Sans Serif'
240
240
  },
241
241
  {
242
- 'name': 'Ubuntu',
243
- 'styles': [
242
+ name: 'Ubuntu',
243
+ styles: [
244
244
  '300',
245
245
  '300i',
246
246
  '400',
@@ -250,11 +250,11 @@ export const FONTS = [
250
250
  '700',
251
251
  '700i'
252
252
  ],
253
- 'category': 'Sans Serif'
253
+ category: 'Sans Serif'
254
254
  },
255
255
  {
256
- 'name': 'Dosis',
257
- 'styles': [
256
+ name: 'Dosis',
257
+ styles: [
258
258
  '200',
259
259
  '300',
260
260
  '400',
@@ -263,19 +263,19 @@ export const FONTS = [
263
263
  '700',
264
264
  '800'
265
265
  ],
266
- 'category': 'Sans Serif'
266
+ category: 'Sans Serif'
267
267
  },
268
268
  {
269
- 'name': 'PT Sans Narrow',
270
- 'styles': [
269
+ name: 'PT Sans Narrow',
270
+ styles: [
271
271
  '400',
272
272
  '700'
273
273
  ],
274
- 'category': 'Sans Serif'
274
+ category: 'Sans Serif'
275
275
  },
276
276
  {
277
- 'name': 'Raleway',
278
- 'styles': [
277
+ name: 'Raleway',
278
+ styles: [
279
279
  '100',
280
280
  '100i',
281
281
  '200',
@@ -295,11 +295,11 @@ export const FONTS = [
295
295
  '900',
296
296
  '900i'
297
297
  ],
298
- 'category': 'Sans Serif'
298
+ category: 'Sans Serif'
299
299
  },
300
300
  {
301
- 'name': 'Lato',
302
- 'styles': [
301
+ name: 'Lato',
302
+ styles: [
303
303
  '100',
304
304
  '100i',
305
305
  '300',
@@ -311,11 +311,11 @@ export const FONTS = [
311
311
  '900',
312
312
  '900i'
313
313
  ],
314
- 'category': 'Sans Serif'
314
+ category: 'Sans Serif'
315
315
  },
316
316
  {
317
- 'name': 'Open Sans',
318
- 'styles': [
317
+ name: 'Open Sans',
318
+ styles: [
319
319
  '300',
320
320
  '300i',
321
321
  '400',
@@ -327,94 +327,94 @@ export const FONTS = [
327
327
  '800',
328
328
  '800i'
329
329
  ],
330
- 'category': 'Sans Serif'
330
+ category: 'Sans Serif'
331
331
  },
332
332
  {
333
- 'name': 'Bungee',
334
- 'styles': [
333
+ name: 'Bungee',
334
+ styles: [
335
335
  '400'
336
336
  ],
337
- 'category': 'Headings / Display'
337
+ category: 'Headings / Display'
338
338
  },
339
339
  {
340
- 'name': 'Abril Fatface',
341
- 'styles': [
340
+ name: 'Abril Fatface',
341
+ styles: [
342
342
  '400'
343
343
  ],
344
- 'category': 'Headings / Display'
344
+ category: 'Headings / Display'
345
345
  },
346
346
  {
347
- 'name': 'Ultra',
348
- 'styles': [
347
+ name: 'Ultra',
348
+ styles: [
349
349
  '400'
350
350
  ],
351
- 'category': 'Headings / Display'
351
+ category: 'Headings / Display'
352
352
  },
353
353
  {
354
- 'name': 'Lobster Two',
355
- 'styles': [
354
+ name: 'Lobster Two',
355
+ styles: [
356
356
  '400',
357
357
  '400i',
358
358
  '700',
359
359
  '700i'
360
360
  ],
361
- 'category': 'Headings / Display'
361
+ category: 'Headings / Display'
362
362
  },
363
363
  {
364
- 'name': 'Dancing Script',
365
- 'styles': [
364
+ name: 'Dancing Script',
365
+ styles: [
366
366
  '400',
367
367
  '700'
368
368
  ],
369
- 'category': 'Headings / Display'
369
+ category: 'Headings / Display'
370
370
  },
371
371
  {
372
- 'name': 'Caveat',
373
- 'styles': [
372
+ name: 'Caveat',
373
+ styles: [
374
374
  '400',
375
375
  '700'
376
376
  ],
377
- 'category': 'Headings / Display'
377
+ category: 'Headings / Display'
378
378
  },
379
379
  {
380
- 'name': 'Reenie Beanie',
381
- 'styles': [
380
+ name: 'Reenie Beanie',
381
+ styles: [
382
382
  '400'
383
383
  ],
384
- 'category': 'Headings / Display'
384
+ category: 'Headings / Display'
385
385
  },
386
386
  {
387
- 'name': 'Amatica SC',
388
- 'styles': [
387
+ name: 'Amatica SC',
388
+ styles: [
389
389
  '400',
390
390
  '700'
391
391
  ],
392
- 'category': 'Headings / Display'
392
+ category: 'Headings / Display'
393
393
  },
394
394
  {
395
- 'name': 'Kaushan Script',
396
- 'styles': [
395
+ name: 'Kaushan Script',
396
+ styles: [
397
397
  '400'
398
398
  ],
399
- 'category': 'Headings / Display'
399
+ category: 'Headings / Display'
400
400
  },
401
401
  {
402
- 'name': 'Just Another Hand',
403
- 'styles': [
402
+ name: 'Just Another Hand',
403
+ styles: [
404
404
  '400'
405
405
  ],
406
- 'category': 'Headings / Display'
406
+ category: 'Headings / Display'
407
407
  },
408
408
  {
409
- 'name': 'Poiret One',
410
- 'styles': [
409
+ name: 'Poiret One',
410
+ styles: [
411
411
  '400'
412
412
  ],
413
- 'category': 'Headings / Display'
413
+ category: 'Headings / Display'
414
414
  },
415
415
  {
416
- 'name': 'Montserrat',
417
- 'styles': [
416
+ name: 'Montserrat',
417
+ styles: [
418
418
  '100',
419
419
  '100i',
420
420
  '200',
@@ -434,11 +434,11 @@ export const FONTS = [
434
434
  '900',
435
435
  '900i'
436
436
  ],
437
- 'category': 'Regular'
437
+ category: 'Regular'
438
438
  },
439
439
  {
440
- 'name': 'Roboto',
441
- 'styles': [
440
+ name: 'Roboto',
441
+ styles: [
442
442
  '100',
443
443
  '100i',
444
444
  '300',
@@ -452,7 +452,7 @@ export const FONTS = [
452
452
  '900',
453
453
  '900i'
454
454
  ],
455
- 'category': 'Regular'
455
+ category: 'Regular'
456
456
  }
457
457
  ];
458
458
 
@@ -30,7 +30,9 @@ export const FontFamily = Mark.create({
30
30
 
31
31
  const isItalicCustomized = commands.isSettingCustomized(TextSetting.FONT_STYLE).value;
32
32
 
33
- if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
33
+ if (font.isItalicOnly) {
34
+ commands.applyItalic();
35
+ } else if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
34
36
  commands.removeItalic();
35
37
  }
36
38
  }),
@@ -23,6 +23,10 @@ export class Font {
23
23
  return Array.from(new Set(weights));
24
24
  }
25
25
 
26
+ get isItalicOnly(): boolean {
27
+ return this.styles.every((style) => style.endsWith('i'));
28
+ }
29
+
26
30
  isWeightSupported(weight: string): boolean {
27
31
  return this.weights.includes(weight);
28
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "4.11.1",
3
+ "version": "4.11.2",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "types": "dist/wysiwyg.d.ts",