@zipify/wysiwyg 4.11.2 → 4.11.5
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.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();
|
|
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.5";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/wysiwyg.mjs
CHANGED
|
@@ -28536,7 +28536,7 @@ function usePickerApi({ pickerRef, colorRef, onChange, onClosed, onBeforeOpened
|
|
|
28536
28536
|
}
|
|
28537
28537
|
function close2() {
|
|
28538
28538
|
var _a;
|
|
28539
|
-
(_a = pickerRef.value) == null ? void 0 : _a.close(colorRef.value);
|
|
28539
|
+
(_a = pickerRef.value) == null ? void 0 : _a.close(initialColor === colorRef.value ? void 0 : colorRef.value);
|
|
28540
28540
|
onClosed();
|
|
28541
28541
|
}
|
|
28542
28542
|
function toggle() {
|
|
@@ -28621,7 +28621,7 @@ const _sfc_main$r = {
|
|
|
28621
28621
|
const favoriteColors = computed(() => unref(favoriteColorsService.listRef));
|
|
28622
28622
|
const updateFavoriteColors = (colors) => favoriteColorsService.triggerUpdate(colors);
|
|
28623
28623
|
return (_ctx, _cache) => {
|
|
28624
|
-
return
|
|
28624
|
+
return openBlock(), createBlock(unref(ColorPicker), {
|
|
28625
28625
|
ref_key: "pickerRef",
|
|
28626
28626
|
ref: pickerRef,
|
|
28627
28627
|
placement: "bottom-end",
|
|
@@ -28630,8 +28630,9 @@ const _sfc_main$r = {
|
|
|
28630
28630
|
window: unref(ContextWindow).window,
|
|
28631
28631
|
"model-value": unref(api).editingColor,
|
|
28632
28632
|
"has-gradient": false,
|
|
28633
|
-
|
|
28634
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(api).editingColor = $event)
|
|
28633
|
+
"onUpdate:favoriteColors": updateFavoriteColors,
|
|
28634
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(api).editingColor = $event),
|
|
28635
|
+
onOutsideClick: unref(api).close
|
|
28635
28636
|
}, {
|
|
28636
28637
|
activator: withCtx(() => [
|
|
28637
28638
|
renderSlot(_ctx.$slots, "activator", {
|
|
@@ -28642,9 +28643,7 @@ const _sfc_main$r = {
|
|
|
28642
28643
|
})
|
|
28643
28644
|
]),
|
|
28644
28645
|
_: 3
|
|
28645
|
-
}, 8, ["favorite-colors", "window", "model-value"])
|
|
28646
|
-
[unref(outClick), { onOutClick: unref(api).close, isDisabled: !unref(api).isOpened }]
|
|
28647
|
-
]);
|
|
28646
|
+
}, 8, ["favorite-colors", "window", "model-value", "onOutsideClick"]);
|
|
28648
28647
|
};
|
|
28649
28648
|
}
|
|
28650
28649
|
};
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
:window="ContextWindow.window"
|
|
8
8
|
:model-value="api.editingColor"
|
|
9
9
|
:has-gradient="false"
|
|
10
|
-
@
|
|
10
|
+
@update:favorite-colors="updateFavoriteColors"
|
|
11
11
|
@update:model-value="api.editingColor = $event"
|
|
12
|
-
|
|
12
|
+
@outside-click="api.close"
|
|
13
13
|
>
|
|
14
14
|
<template #activator>
|
|
15
15
|
<slot
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
<script setup>
|
|
27
27
|
import { ColorPicker } from '@zipify/colorpicker';
|
|
28
28
|
import { computed, inject, ref, toRef, unref } from 'vue';
|
|
29
|
-
import { outClick as vOutClick } from '../../../directives';
|
|
30
29
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
31
30
|
import { ContextWindow } from '../../../services';
|
|
32
31
|
import { usePickerApi, usePickerHotkeys } from './composables';
|
|
@@ -11,7 +11,7 @@ export function usePickerApi({ pickerRef, colorRef, onChange, onClosed, onBefore
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function close() {
|
|
14
|
-
pickerRef.value?.close(colorRef.value);
|
|
14
|
+
pickerRef.value?.close(initialColor === colorRef.value ? undefined : colorRef.value);
|
|
15
15
|
onClosed();
|
|
16
16
|
}
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.5",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"types": "dist/wysiwyg.d.ts",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@vue/test-utils": "^2.4.6",
|
|
89
89
|
"@vue/tsconfig": "^0.7.0",
|
|
90
90
|
"@vue/vue3-jest": "^29.2.6",
|
|
91
|
-
"@zipify/colorpicker": "^4.1.
|
|
91
|
+
"@zipify/colorpicker": "^4.1.5",
|
|
92
92
|
"@zipify/eslint-config": "^3.0.8",
|
|
93
93
|
"babel-jest": "^29.7.0",
|
|
94
94
|
"esbuild-jest-transform": "^2.0.1",
|