@zipify/wysiwyg 4.7.0-0 → 4.7.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -56,4 +56,4 @@ __p += '`),fe&&(F+=`' +
56
56
  function print() { __p += __j.call(arguments, '') }
57
57
  `:`;
58
58
  `)+F+`return __p
59
- }`;var se=up(function(){return ge(w,j+"return "+F).apply(t,E)});if(se.source=F,du(se))throw se;return se}function BS(s){return ye(s).toLowerCase()}function HS(s){return ye(s).toUpperCase()}function $S(s,a,c){if(s=ye(s),s&&(c||a===t))return bh(s);if(!s||!(a=vt(a)))return s;var h=Kt(s),y=Kt(a),w=_h(h,y),E=vh(h,y)+1;return Kn(h,w,E).join("")}function zS(s,a,c){if(s=ye(s),s&&(c||a===t))return s.slice(0,Sh(s)+1);if(!s||!(a=vt(a)))return s;var h=Kt(s),y=vh(h,Kt(a))+1;return Kn(h,0,y).join("")}function VS(s,a,c){if(s=ye(s),s&&(c||a===t))return s.replace(dl,"");if(!s||!(a=vt(a)))return s;var h=Kt(s),y=_h(h,Kt(a));return Kn(h,y).join("")}function WS(s,a){var c=rn,h=Fn;if(Ae(a)){var y="separator"in a?a.separator:y;c="length"in a?re(a.length):c,h="omission"in a?vt(a.omission):h}s=ye(s);var w=s.length;if(Qr(s)){var E=Kt(s);w=E.length}if(c>=w)return s;var C=c-ei(h);if(C<1)return h;var M=E?Kn(E,0,C).join(""):s.slice(0,C);if(y===t)return M+h;if(E&&(C+=M.length-C),pu(y)){if(s.slice(C).search(y)){var L,P=M;for(y.global||(y=Ml(y.source,ye($f.exec(y))+"g")),y.lastIndex=0;L=y.exec(P);)var F=L.index;M=M.slice(0,F===t?C:F)}}else if(s.indexOf(vt(y),C)!=C){var V=M.lastIndexOf(y);V>-1&&(M=M.slice(0,V))}return M+h}function US(s){return s=ye(s),s&&ty.test(s)?s.replace(Ff,_1):s}var qS=ai(function(s,a,c){return s+(c?" ":"")+a.toUpperCase()}),yu=cd("toUpperCase");function lp(s,a,c){return s=ye(s),a=c?t:a,a===t?p1(s)?S1(s):s1(s):s.match(a)||[]}var up=oe(function(s,a){try{return bt(s,t,a)}catch(c){return du(c)?c:new te(c)}}),KS=Cn(function(s,a){return Mt(a,function(c){c=ln(c),En(s,c,fu(s[c],s))}),s});function GS(s){var a=s==null?0:s.length,c=Y();return s=a?ke(s,function(h){if(typeof h[1]!="function")throw new It(l);return[c(h[0]),h[1]]}):[],oe(function(h){for(var y=-1;++y<a;){var w=s[y];if(bt(w[0],this,h))return bt(w[1],this,h)}})}function jS(s){return _b(Rt(s,p))}function bu(s){return function(){return s}}function JS(s,a){return s==null||s!==s?a:s}var YS=hd(),XS=hd(!0);function mt(s){return s}function _u(s){return Vh(typeof s=="function"?s:Rt(s,p))}function ZS(s){return Uh(Rt(s,p))}function QS(s,a){return qh(s,Rt(a,p))}var ex=oe(function(s,a){return function(c){return ns(c,s,a)}}),tx=oe(function(s,a){return function(c){return ns(s,c,a)}});function vu(s,a,c){var h=He(a),y=ho(a,h);c==null&&!(Ae(a)&&(y.length||!h.length))&&(c=a,a=s,s=this,y=ho(a,He(a)));var w=!(Ae(c)&&"chain"in c)||!!c.chain,E=On(s);return Mt(y,function(C){var M=a[C];s[C]=M,E&&(s.prototype[C]=function(){var L=this.__chain__;if(w||L){var P=s(this.__wrapped__),F=P.__actions__=ht(this.__actions__);return F.push({func:M,args:arguments,thisArg:s}),P.__chain__=L,P}return M.apply(s,$n([this.value()],arguments))})}),s}function nx(){return qe._===this&&(qe._=O1),this}function wu(){}function rx(s){return s=re(s),oe(function(a){return Kh(a,s)})}var ix=Zl(ke),sx=Zl(dh),ox=Zl(xl);function cp(s){return su(s)?El(ln(s)):Db(s)}function ax(s){return function(a){return s==null?t:_r(s,a)}}var lx=pd(),ux=pd(!0);function Su(){return[]}function xu(){return!1}function cx(){return{}}function fx(){return""}function hx(){return!0}function dx(s,a){if(s=re(s),s<1||s>Ze)return[];var c=it,h=Qe(s,it);a=Y(a),s-=it;for(var y=Al(h,a);++c<s;)a(c);return y}function px(s){return ne(s)?ke(s,ln):wt(s)?[s]:ht(Md(ye(s)))}function mx(s){var a=++C1;return ye(s)+a}var gx=_o(function(s,a){return s+a},0),yx=Ql("ceil"),bx=_o(function(s,a){return s/a},1),_x=Ql("floor");function vx(s){return s&&s.length?fo(s,mt,Bl):t}function wx(s,a){return s&&s.length?fo(s,Y(a,2),Bl):t}function Sx(s){return gh(s,mt)}function xx(s,a){return gh(s,Y(a,2))}function Ex(s){return s&&s.length?fo(s,mt,Vl):t}function kx(s,a){return s&&s.length?fo(s,Y(a,2),Vl):t}var Cx=_o(function(s,a){return s*a},1),Ax=Ql("round"),Ox=_o(function(s,a){return s-a},0);function Tx(s){return s&&s.length?Cl(s,mt):0}function Mx(s,a){return s&&s.length?Cl(s,Y(a,2)):0}return v.after=Zv,v.ary=zd,v.assign=Hw,v.assignIn=tp,v.assignInWith=No,v.assignWith=$w,v.at=zw,v.before=Vd,v.bind=fu,v.bindAll=KS,v.bindKey=Wd,v.castArray=cw,v.chain=Bd,v.chunk=__,v.compact=v_,v.concat=w_,v.cond=GS,v.conforms=jS,v.constant=bu,v.countBy=Tv,v.create=Vw,v.curry=Ud,v.curryRight=qd,v.debounce=Kd,v.defaults=Ww,v.defaultsDeep=Uw,v.defer=Qv,v.delay=ew,v.difference=S_,v.differenceBy=x_,v.differenceWith=E_,v.drop=k_,v.dropRight=C_,v.dropRightWhile=A_,v.dropWhile=O_,v.fill=T_,v.filter=Iv,v.flatMap=Lv,v.flatMapDeep=Pv,v.flatMapDepth=Dv,v.flatten=Ld,v.flattenDeep=M_,v.flattenDepth=I_,v.flip=tw,v.flow=YS,v.flowRight=XS,v.fromPairs=N_,v.functions=Xw,v.functionsIn=Zw,v.groupBy=Fv,v.initial=L_,v.intersection=P_,v.intersectionBy=D_,v.intersectionWith=F_,v.invert=eS,v.invertBy=tS,v.invokeMap=Hv,v.iteratee=_u,v.keyBy=$v,v.keys=He,v.keysIn=pt,v.map=Co,v.mapKeys=rS,v.mapValues=iS,v.matches=ZS,v.matchesProperty=QS,v.memoize=Oo,v.merge=sS,v.mergeWith=np,v.method=ex,v.methodOf=tx,v.mixin=vu,v.negate=To,v.nthArg=rx,v.omit=oS,v.omitBy=aS,v.once=nw,v.orderBy=zv,v.over=ix,v.overArgs=rw,v.overEvery=sx,v.overSome=ox,v.partial=hu,v.partialRight=Gd,v.partition=Vv,v.pick=lS,v.pickBy=rp,v.property=cp,v.propertyOf=ax,v.pull=z_,v.pullAll=Dd,v.pullAllBy=V_,v.pullAllWith=W_,v.pullAt=U_,v.range=lx,v.rangeRight=ux,v.rearg=iw,v.reject=qv,v.remove=q_,v.rest=sw,v.reverse=uu,v.sampleSize=Gv,v.set=cS,v.setWith=fS,v.shuffle=jv,v.slice=K_,v.sortBy=Xv,v.sortedUniq=Q_,v.sortedUniqBy=ev,v.split=LS,v.spread=ow,v.tail=tv,v.take=nv,v.takeRight=rv,v.takeRightWhile=iv,v.takeWhile=sv,v.tap=vv,v.throttle=aw,v.thru=ko,v.toArray=Zd,v.toPairs=ip,v.toPairsIn=sp,v.toPath=px,v.toPlainObject=ep,v.transform=hS,v.unary=lw,v.union=ov,v.unionBy=av,v.unionWith=lv,v.uniq=uv,v.uniqBy=cv,v.uniqWith=fv,v.unset=dS,v.unzip=cu,v.unzipWith=Fd,v.update=pS,v.updateWith=mS,v.values=ci,v.valuesIn=gS,v.without=hv,v.words=lp,v.wrap=uw,v.xor=dv,v.xorBy=pv,v.xorWith=mv,v.zip=gv,v.zipObject=yv,v.zipObjectDeep=bv,v.zipWith=_v,v.entries=ip,v.entriesIn=sp,v.extend=tp,v.extendWith=No,vu(v,v),v.add=gx,v.attempt=up,v.camelCase=vS,v.capitalize=op,v.ceil=yx,v.clamp=yS,v.clone=fw,v.cloneDeep=dw,v.cloneDeepWith=pw,v.cloneWith=hw,v.conformsTo=mw,v.deburr=ap,v.defaultTo=JS,v.divide=bx,v.endsWith=wS,v.eq=jt,v.escape=SS,v.escapeRegExp=xS,v.every=Mv,v.find=Nv,v.findIndex=Nd,v.findKey=qw,v.findLast=Rv,v.findLastIndex=Rd,v.findLastKey=Kw,v.floor=_x,v.forEach=Hd,v.forEachRight=$d,v.forIn=Gw,v.forInRight=jw,v.forOwn=Jw,v.forOwnRight=Yw,v.get=mu,v.gt=gw,v.gte=yw,v.has=Qw,v.hasIn=gu,v.head=Pd,v.identity=mt,v.includes=Bv,v.indexOf=R_,v.inRange=bS,v.invoke=nS,v.isArguments=Sr,v.isArray=ne,v.isArrayBuffer=bw,v.isArrayLike=dt,v.isArrayLikeObject=Ie,v.isBoolean=_w,v.isBuffer=Gn,v.isDate=vw,v.isElement=ww,v.isEmpty=Sw,v.isEqual=xw,v.isEqualWith=Ew,v.isError=du,v.isFinite=kw,v.isFunction=On,v.isInteger=jd,v.isLength=Mo,v.isMap=Jd,v.isMatch=Cw,v.isMatchWith=Aw,v.isNaN=Ow,v.isNative=Tw,v.isNil=Iw,v.isNull=Mw,v.isNumber=Yd,v.isObject=Ae,v.isObjectLike=Me,v.isPlainObject=us,v.isRegExp=pu,v.isSafeInteger=Nw,v.isSet=Xd,v.isString=Io,v.isSymbol=wt,v.isTypedArray=ui,v.isUndefined=Rw,v.isWeakMap=Lw,v.isWeakSet=Pw,v.join=B_,v.kebabCase=ES,v.last=Pt,v.lastIndexOf=H_,v.lowerCase=kS,v.lowerFirst=CS,v.lt=Dw,v.lte=Fw,v.max=vx,v.maxBy=wx,v.mean=Sx,v.meanBy=xx,v.min=Ex,v.minBy=kx,v.stubArray=Su,v.stubFalse=xu,v.stubObject=cx,v.stubString=fx,v.stubTrue=hx,v.multiply=Cx,v.nth=$_,v.noConflict=nx,v.noop=wu,v.now=Ao,v.pad=AS,v.padEnd=OS,v.padStart=TS,v.parseInt=MS,v.random=_S,v.reduce=Wv,v.reduceRight=Uv,v.repeat=IS,v.replace=NS,v.result=uS,v.round=Ax,v.runInContext=T,v.sample=Kv,v.size=Jv,v.snakeCase=RS,v.some=Yv,v.sortedIndex=G_,v.sortedIndexBy=j_,v.sortedIndexOf=J_,v.sortedLastIndex=Y_,v.sortedLastIndexBy=X_,v.sortedLastIndexOf=Z_,v.startCase=PS,v.startsWith=DS,v.subtract=Ox,v.sum=Tx,v.sumBy=Mx,v.template=FS,v.times=dx,v.toFinite=Tn,v.toInteger=re,v.toLength=Qd,v.toLower=BS,v.toNumber=Dt,v.toSafeInteger=Bw,v.toString=ye,v.toUpper=HS,v.trim=$S,v.trimEnd=zS,v.trimStart=VS,v.truncate=WS,v.unescape=US,v.uniqueId=mx,v.upperCase=qS,v.upperFirst=yu,v.each=Hd,v.eachRight=$d,v.first=Pd,vu(v,function(){var s={};return on(v,function(a,c){_e.call(v.prototype,c)||(s[c]=a)}),s}(),{chain:!1}),v.VERSION=r,Mt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){v[s].placeholder=v}),Mt(["drop","take"],function(s,a){ue.prototype[s]=function(c){c=c===t?1:Be(re(c),0);var h=this.__filtered__&&!a?new ue(this):this.clone();return h.__filtered__?h.__takeCount__=Qe(c,h.__takeCount__):h.__views__.push({size:Qe(c,it),type:s+(h.__dir__<0?"Right":"")}),h},ue.prototype[s+"Right"]=function(c){return this.reverse()[s](c).reverse()}}),Mt(["filter","map","takeWhile"],function(s,a){var c=a+1,h=c==dr||c==Bn;ue.prototype[s]=function(y){var w=this.clone();return w.__iteratees__.push({iteratee:Y(y,3),type:c}),w.__filtered__=w.__filtered__||h,w}}),Mt(["head","last"],function(s,a){var c="take"+(a?"Right":"");ue.prototype[s]=function(){return this[c](1).value()[0]}}),Mt(["initial","tail"],function(s,a){var c="drop"+(a?"":"Right");ue.prototype[s]=function(){return this.__filtered__?new ue(this):this[c](1)}}),ue.prototype.compact=function(){return this.filter(mt)},ue.prototype.find=function(s){return this.filter(s).head()},ue.prototype.findLast=function(s){return this.reverse().find(s)},ue.prototype.invokeMap=oe(function(s,a){return typeof s=="function"?new ue(this):this.map(function(c){return ns(c,s,a)})}),ue.prototype.reject=function(s){return this.filter(To(Y(s)))},ue.prototype.slice=function(s,a){s=re(s);var c=this;return c.__filtered__&&(s>0||a<0)?new ue(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),a!==t&&(a=re(a),c=a<0?c.dropRight(-a):c.take(a-s)),c)},ue.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},ue.prototype.toArray=function(){return this.take(it)},on(ue.prototype,function(s,a){var c=/^(?:filter|find|map|reject)|While$/.test(a),h=/^(?:head|last)$/.test(a),y=v[h?"take"+(a=="last"?"Right":""):a],w=h||/^find/.test(a);y&&(v.prototype[a]=function(){var E=this.__wrapped__,C=h?[1]:arguments,M=E instanceof ue,L=C[0],P=M||ne(E),F=function(ae){var fe=y.apply(v,$n([ae],C));return h&&V?fe[0]:fe};P&&c&&typeof L=="function"&&L.length!=1&&(M=P=!1);var V=this.__chain__,j=!!this.__actions__.length,X=w&&!V,se=M&&!j;if(!w&&P){E=se?E:new ue(this);var Z=s.apply(E,C);return Z.__actions__.push({func:ko,args:[F],thisArg:t}),new Nt(Z,V)}return X&&se?s.apply(this,C):(Z=this.thru(F),X?h?Z.value()[0]:Z.value():Z)})}),Mt(["pop","push","shift","sort","splice","unshift"],function(s){var a=Ys[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",h=/^(?:pop|shift)$/.test(s);v.prototype[s]=function(){var y=arguments;if(h&&!this.__chain__){var w=this.value();return a.apply(ne(w)?w:[],y)}return this[c](function(E){return a.apply(ne(E)?E:[],y)})}}),on(ue.prototype,function(s,a){var c=v[a];if(c){var h=c.name+"";_e.call(ii,h)||(ii[h]=[]),ii[h].push({name:a,func:c})}}),ii[bo(t,x).name]=[{name:"wrapper",func:t}],ue.prototype.clone=U1,ue.prototype.reverse=q1,ue.prototype.value=K1,v.prototype.at=wv,v.prototype.chain=Sv,v.prototype.commit=xv,v.prototype.next=Ev,v.prototype.plant=Cv,v.prototype.reverse=Av,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=Ov,v.prototype.first=v.prototype.head,Ji&&(v.prototype[Ji]=kv),v},ti=x1();pr?((pr.exports=ti)._=ti,_l._=ti):qe._=ti}).call(IM)}(Fs,Fs.exports)),Fs.exports}var D0=NM();function Cf(n){return n.type.create(D0.cloneDeep(n.attrs))}const RM=Pe.create({name:"node_processor",addCommands(){return{setBlockAttributes:H(({commands:n,state:e},t,r,i={})=>{const o=z(n.getBlockAttributes(t))??{},{doc:l,tr:u}=e,{from:f,to:d}=u.selection;l.nodesBetween(f,d,(g,p)=>{ie.blocks.includes(g.type.name)&&u.setNodeAttribute(p,t,{...i,...o,...r})})}),getBlockAttributes:H(({editor:n},e,t)=>de(()=>{let r=Object.assign({},t||{});for(const i of ie.blocks)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:H(({commands:n},e)=>{for(const t of ie.blocks)n.resetAttributes(t,e)}),applyMark:H(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:l,schema:u}=n,{$from:f,$to:d}=o.selection,g=cn(he.LINK,u),p=cn(t,u);if(!(p.spec.group||"").includes(en.SETTINGS))return e.setMark(t,r);if(f.pos===d.pos)return;const S=k=>{if(!i.onAppliedToParent||i.onAppliedToParent(k)===!1){const{tr:m,node:b,position:x,mark:A}=k;e._removeNodeMark({tr:m,node:b,position:x,mark:A.type})}};l.nodesBetween(f.pos,d.pos,(k,m)=>{if(k.type.name===ie.LIST)return;const b=MM(k.marks,t),x=p.create({...b?.attrs||{},...r}),A=R0(f,d,k,m);if(!g.isInSet(k.marks)&&TM(o.doc,m,x,i.isAppliedToParent))return S({tr:o,node:k,position:m,mark:x});if(k.isText){o.addMark(A.from,A.to,x);return}AM(o.doc,o.selection,k,m)&&o.addNodeMark(m,x)})}),getMarks:H(({editor:n},e)=>{const t=pi(n,"state");return de(()=>{const{selection:r,doc:i}=z(t),{from:o,to:l}=z(r),u=[];return i.nodesBetween(o,l,f=>{for(const d of f.marks)d.type.name===e&&u.unshift(d.attrs)}),u})}),getMark:H(({commands:n},e)=>{const t=n.getMarks(e);return de(()=>z(t)[0]??null)}),hasMark:H(({commands:n},e)=>{const t=n.getMark(e);return de(()=>!!z(t))}),getCommonSettingMark:H(({commands:n},e,t)=>{const r=n.getMark(e);return de(()=>z(r)?.value??z(t))}),getDeviceSettingMark:H(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return de(()=>{for(const o of z(r)){const l=o[z(i)];if(l)return l}return z(t)})}),removeAllMarks:H(({state:n,commands:e})=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(l,u)=>{for(const f of l.marks)e._removeNodeMark({tr:t,node:l,position:u,mark:f})})}),removeMarks:H(({state:n,commands:e},t)=>{const{tr:r,doc:i}=n,{from:o,to:l}=r.selection;i.nodesBetween(o,l,(u,f)=>{const d=u.marks.filter(g=>t.includes(g.type.name));for(const g of d)e._removeNodeMark({tr:r,node:u,position:f,mark:g})})}),_removeNodeMark:H((n,{tr:e,node:t,position:r,mark:i})=>t.isText?e.removeMark(r,r+t.nodeSize,i):e.removeNodeMark(r,i))}}}),LM=Pe.create({name:"text_processor",addCommands(){return{getSelectedText:H(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:H(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const l=R0(t,r,i,o),u=Math.max(0,t.pos-o),f=Math.max(0,r.pos-o),d=e({text:i.textContent.substring(u,f)}),g=n.schema.text(d,i.marks);n.tr.replaceWith(l.from,l.to,g)})})}}}),PM=Pe.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:H(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:H(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:H(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;n.doc.nodesBetween(r,i,(o,l,u)=>{if(t({node:o,parent:u})){const f=o.isText?0:L0(n.doc,l);r=Math.min(r,l+f),i=Math.max(i,l+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:H(({commands:n})=>{n.expandSelection(({parent:e})=>e.type.name===ie.DOCUMENT)})}}}),DM=Dn.create({name:"doc",topNode:!0,content:"block+"});class Hs extends tt{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=Tr.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,De.ok(t)}invert(){return new Hs(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 Hs(e.key,e.value,e.stepType)}}tt.jsonID("setDocAttr",Hs);const FM=DM.extend({marks:en.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:H(({state:n},e,t)=>{n.tr.step(new Hs(e,t,n.schema))})}}}),BM=Dn.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()}}}),HM=BM.extend({marks:en.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),$M=Dn.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=>xT({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),zM=$M.extend({marks:en.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),VM=Pe.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[DT.create(this.editor),FT.create(this.editor)]}}),WM=()=>[FM,HM,zM,CT,PT,RM,LM,PM,VM],UM=Ot.create({name:he.FONT_FAMILY,group:en.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:H(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=z(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(he.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:H(({commands:n})=>{const e=z(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return de(()=>n.findFontByName(z(r))||t)}),findFontByName:H((n,e)=>z(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:H(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:H(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_family)})}},parseHTML(){const n=e=>({value:e.replace(/["']/g,"")});return[{style:"--zw-font-family",getAttrs:n},{style:"font-family",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.value?`"${n.value}"`:null;return Hr({font_family:e})}}),qM=Pe.create({name:he.STYLE_PRESET,addGlobalAttributes(){return[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{preset:{isRequired:!1,default:{id:z(this.options.defaultId)},parseHTML:n=>{const e=z(this.options.presets);if(n.parentElement.tagName==="LI")return null;for(const{id:t,node:r,fallbackClass:i}of e){if(i&&n.classList.contains(i))return{id:t};const o=z(this.options.styleRenderer).makePresetCssClass({id:t});if(n.matches(o))return{id:t};if(n.tagName===`H${r?.level}`)return{id:t}}return n.tagName==="P"?{id:z(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:z(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const l=t[o],u=r[o],f=!u||u.toLowerCase()==="inherit";i[o]=f?l:u}return i}return{getPresetList:H(()=>de(()=>z(this.options.presets).filter(t=>!t.hidden))),getPreset:H(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:z(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),l=t.getLinkPreset();return de(()=>{const u=n(z(i),z(r).id);if(!z(o))return u;const f=z(l);return{id:u.id,common:e(u.common,f.common),mobile:e(u.mobile,f.mobile),tablet:e(u.tablet,f.tablet),desktop:e(u.desktop,f.desktop)}})}),applyPreset:H(({commands:t,chain:r},i)=>{const o=z(t.getPresetList()),l=n(o,i),u=l.node?.type??ie.PARAGRAPH,f={preset:{id:i}};l.node&&(f.level=l.node.level);for(const d of he.attributes)f[d]=z(t.getBlockAttributes(d));r().removeList().setNode(u,f).run()}),applyDefaultPreset:H(({commands:t})=>{t.applyPreset(z(this.options.defaultId))}),removePreset:H(({commands:t})=>{t.setNode(ie.PARAGRAPH,{preset:null})}),getPresetCustomization:H(({editor:t,commands:r})=>{const i=pi(t,"state");return de(()=>{const{selection:o,doc:l}=z(i),{from:u,to:f}=o;return r._getSettingCustomization(l,u,f)})}),isSettingCustomized:H(({commands:t},r)=>{const i=t.getPresetCustomization(),o=he.presetAttributes.includes(r)?"attributes":"marks";return de(()=>z(i)[o]?.includes(r)??!1)}),getContentCustomization:H(({editor:t,commands:r})=>{const i=pi(t,"state");return de(()=>{const{doc:o}=z(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:H((t,r,i,o)=>{const l=new Set,u=new Set;return r.nodesBetween(i,o,f=>{for(const[d,g]of Object.entries(f.attrs))he.presetAttributes.includes(d)&&g&&u.add(d);for(const{type:d}of f.marks)he.marks.includes(d.name)&&l.add(d.name)}),{attributes:Array.from(u),marks:Array.from(l)}}),removePresetCustomization:H(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(he.marks).resetAttributes(ie.PARAGRAPH,he.presetAttributes).resetAttributes(ie.HEADING,he.presetAttributes).restoreSelection().run()}),removeFormat:H(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Di.head,z(this.options.presets))}}),KM=Ot.create({name:he.FONT_WEIGHT,group:en.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:H(({commands:n},e)=>{n.applyMark(this.name,{value:e}),z(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:H(({commands:n})=>{const e=z(n.getFontWeight()),t=z(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:H(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return de(()=>{const r=z(e),i=z(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:H(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Vt("toggleBold"),"Mod-B":Vt("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 Hr({font_weight:n.value})}}),GM=Ot.create({name:he.FONT_SIZE,group:en.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:H(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:H(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].font_size.replace("px",""))}),applyFontSize:H(({commands:n},e)=>{const t=z(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:l})=>{const u={...l.attrs,[t]:null};if(!Object.values(u).some(g=>!!g))return!1;const d=l.type.create(u);if(i.isText){r.addMark(o,o+i.nodeSize,d);return}r.addNodeMark(o,d)}})}),increaseFontSize:H(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.min(e+1,z(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:H(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.max(e-1,z(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Vt("increaseFontSize"),"Mod-Shift--":Vt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=z(this.options.wrapperRef),r=N0(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 Hr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),jM=Ot.create({name:he.FONT_COLOR,group:en.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:H(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:H(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.color)}),applyFontColor:H(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:I0(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Hr({font_color:n.value})}}),JM=Ot.create({name:he.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:H(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:H(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:I0(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Hr({background_color:n.value})}}),YM=Pe.create({name:"device_manager",addCommands(){return{getDevice:H(()=>pi(this.options,"device"))}}}),XM=Ot.create({name:he.FONT_STYLE,group:en.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:H(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return de(()=>z(e)?.italic??z(t).italic)}),isItalicAvailable:H(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return de(()=>{const r=z(e),i=z(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:H(({commands:n})=>{const e=n.getPreset();return de(()=>({italic:z(e).common.font_style==="italic"}))}),toggleItalic:H(({commands:n})=>{z(n.isItalicAvailable())&&(z(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:H(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:H(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Vt("toggleItalic"),"Mod-I":Vt("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 Hr({font_style:e})}}),ZM=Ot.create({name:he.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:H(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).underline)}),isStrikeThrough:H(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).strike_through)}),getTextDecoration:H(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return de(()=>{const r=z(e)??{},i=z(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:H(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return de(()=>z(e)!==z(t).underline)}),getDefaultTextDecoration:H(({commands:n})=>{const e=n.getPreset();return de(()=>{const{text_decoration:t}=z(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:H(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:H(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:H(({commands:n},e,t=null)=>{const r=z(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:H(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:H(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Vt("toggleUnderline"),"Mod-U":Vt("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"),Hr({text_decoration:e.join(" ")})}}),QM=Pe.create({name:"case_style",addCommands(){return{applyCaseStyle:H(({commands:n},e)=>{switch(e){case Zc.CAPITALIZE:return n.applyCapitalize();case Zc.LOWERCASE:return n.applyLowerCase();case Zc.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:H(({commands:n})=>{n.transformText(({text:e})=>iM(e))}),applyLowerCase:H(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:H(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),F0={mobile:null,tablet:null,desktop:null},eI=Pe.create({name:he.ALIGNMENT,addGlobalAttributes:()=>[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{[he.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=CM(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?Za({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:H(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},F0)}),removeAlignment:H(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:H(({commands:n})=>{const e=n.getBlockAttributes(this.name,F0),t=n.getDevice(),r=n.getDefaultAlignment();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultAlignment:H(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].alignment??sr.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Vt("applyAlignment",sr.LEFT),"Mod-Shift-e":Vt("applyAlignment",sr.CENTER),"Mod-Shift-r":Vt("applyAlignment",sr.RIGHT),"Mod-Shift-j":Vt("applyAlignment",sr.JUSTIFY)})}),B0={mobile:null,tablet:null,desktop:null},tI=Pe.create({name:he.LINE_HEIGHT,addGlobalAttributes(){return[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{[he.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,l=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:l}}const e=n.style.lineHeight;if(!e)return null;const t=z(this.options.wrapperRef),r=EM(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?Za({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:H(({commands:n})=>{const e=n.getBlockAttributes(this.name,B0),t=n.getDevice(),r=n.getDefaultLineHeight();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultLineHeight:H(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].line_height)}),applyLineHeight:H(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},B0)})}}}),nI=Dn.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)}}}),rI=nI.extend({name:ie.LIST_ITEM,marks:en.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:H(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const l of r.marks)t.addNodeMark(o,Cf(l));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===ie.LIST))return t.listItemNewline()}})}),iI=Dn.create({name:ie.LIST,content:`${ie.LIST_ITEM}+`,group:"block list",marks:en.SETTINGS,addExtensions:()=>[rI],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:$t.DISC}}}),parseHTML(){const n={a:$t.ROMAN,i:$t.LATIN,1:$t.DECIMAL},e=t=>{for(const r of $t.values){const i=`.${z(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||$t.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||$t.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[z(this.options.baseClass)+n.bullet.type,z(this.options.presetClass)];return[$t.ordered.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:H(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return de(()=>z(e).type??null)}),applyList:H(({commands:n,chain:e},t)=>{if(z(n.getListType())===t){n.removeList();return}return e().applyDefaultPreset().toggleList(ie.LIST,ie.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({commands:i,tr:o})=>i._bubbleListItemMarks(o)).run()}),_bubbleListItemMarks:H((n,e)=>{const{doc:t,selection:r}=e,i=r.$from.start(),o=r.$to.end();function l(u,f){if(he.inlineMarks.includes(f.type)||f.type.isInSet(u.marks))return!1;for(const d of u.content.content)if(d.childCount&&(!d.marks||!f.isInSet(d.marks)))return!1;return!0}t.nodesBetween(i,o,(u,f)=>{if(u.type.name===ie.LIST)return;if(u.type.name!==ie.LIST_ITEM)return!1;const d=[];return u.forEach(g=>{for(const p of g.marks){if(p.isInSet(d)){e.removeNodeMark(f+1,p);continue}l(u,p)&&(e.removeNodeMark(f+1,p),e.addNodeMark(f,Cf(p)),d.push(p))}}),!1})}),removeList:H(({commands:n,state:e})=>{const{tr:t,doc:r,selection:i}=e,o=i.$from.start(),l=i.$to.end();r.nodesBetween(o,l,(u,f,d)=>{if([ie.LIST,ie.LIST_ITEM].includes(u.type.name))return;if(d.type.name!==ie.LIST_ITEM)return!1;const g=d.marks.filter(function(p){return!p.type.isInSet(u.marks)});for(const p of g)t.addNodeMark(f,Cf(p));return!1}),n.liftListItem(ie.LIST_ITEM)})}},addInputRules(){const n=(e,t)=>ET({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n($t.DISC,/^\s*([-+*])\s$/),n($t.DECIMAL,/^(\d+)\.\s$/),n($t.LATIN,/^([ivx]{1,3})\.\s$/i),n($t.ROMAN,/^([a-z])\.\s$/i)]}});function sI(n){return new Ct({key:new Zt("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(d=>d.docChanged)&&!t.doc.eq(r.doc),o=e.some(d=>d.getMeta("preventAutolink"));if(!i||o)return;const{tr:l}=r,u=KO(t.doc,[...e]);if(tT(u).forEach(({newRange:d})=>{const g=jO(r.doc,d,S=>S.isTextblock);let p,_;if(g.length>1?(p=g[0],_=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ")):g.length&&r.doc.textBetween(d.from,d.to," "," ").endsWith(" ")&&(p=g[0],_=r.doc.textBetween(p.pos,d.to,void 0," ")),p&&_){const S=_.split(" ").filter(b=>b!=="");if(S.length<=0)return!1;const k=S[S.length-1],m=p.pos+_.lastIndexOf(k);if(!k)return!1;_f(k).filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate?n.validate(b.value):!0).forEach(b=>{Zg(b.from,b.to,r.doc).some(x=>x.mark.type===n.type)||l.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!l.steps.length)return l}})}function oI(n){return new Ct({key:new Zt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||r.target.nodeName!=="A")return!1;const u=ZO(e.state,n.type.name),f=r.target,d=(i=f?.href)!==null&&i!==void 0?i:u.href,g=(o=f?.target)!==null&&o!==void 0?o:u.target;return f&&d?(e.editable&&window.open(d,g),!0):!1}}})}function aI(n){return new Ct({key:new Zt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:o}=e,{selection:l}=o,{empty:u}=l;if(u)return!1;let f="";r.content.forEach(k=>{f+=k.textContent});const d=_f(f).find(k=>k.isLink&&k.value===f);if(!f||!d)return!1;const g=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),p=/href="([^"]*)"/,_=g?.match(p),S=_?_[1]:d.href;return n.editor.commands.setMark(n.type,{href:S}),!0}}})}const lI=Ot.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){S0(n);return}S0(n.scheme,n.optionalSlashes)})},onDestroy(){eM()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Oi(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Oi(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[kT({find:n=>_f(n).filter(e=>this.options.validate?this.options.validate(e.value):!0).filter(e=>e.isLink).map(e=>({text:e.value,index:e.start,data:e})),type:this.type,getAttributes:(n,e)=>{var t,r;const i=(t=e?.clipboardData)===null||t===void 0?void 0:t.getData("text/html"),o=/href="([^"]*)"/,l=i?.match(o);return l?{href:l[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(sI({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(oI({type:this.type})),this.options.linkOnPaste&&n.push(aI({editor:this.editor,type:this.type})),n}}),uI=lI.extend({name:he.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:l0.SELF,parseHTML:n=>n.getAttribute("target")||l0.SELF},destination:{default:Ts.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Ts.URL;const t=e.replace("#","");return z(this.options.pageBlocks).find(o=>o.id===parseInt(t))?Ts.BLOCK:Ts.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:H(({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($0.text(r.text,[$0.mark(he.LINK,r)])))),expandSelectionToLink:H(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:H(({commands:e})=>e.hasMark(this.name)),getLinkPreset:H(()=>de(()=>z(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),rM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Ts.BLOCK?`#${n.href}`:n.href,t=z(this.options.basePresetClass)+z(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),cI=Ot.create({name:he.SUPERSCRIPT,addCommands(){return{applySuperscript:H(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:H(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:H(({commands:n})=>{z(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:H(({commands:n})=>{const e=n.getMark(this.name);return de(()=>!!z(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),fI=Pe.create({name:he.MARGIN,addGlobalAttributes:()=>[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{[he.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?Za({margin:n.margin.value}):null}}}}]});function hI(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=Wu({default:null,link:null});return fk(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),WM().concat([qM.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new mI({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),iI.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),YM.configure({device:n.deviceRef}),GM.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),UM.configure({fonts:n.fonts,defaultPreset:pi(t,"default"),defaultFont:n.defaultFont}),KM,jM,JM,XM,ZM,QM,cI,eI,tI.configure({wrapperRef:n.wrapperRef}),uI.configure({preset:pi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),fI])}class dI{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class H0{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class gn extends H0{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=gn.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const l=u=>{this._assignElementProperties(u,e,gn.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,gn.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){l(u),i=null,o=u;continue}if(u.tagName==="BR"&&o&&o?.tagName!=="BR"){u.remove(),o=u;continue}if(u.tagName==="BR"){const f=this.dom.createElement("p");f.append(u),l(f),i=null,o=u;continue}i||(i=this.dom.createElement("p"),l(i)),i.append(u),o=u}e.append(t),this._removeStyleProperties(e,gn.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,gn.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return gn.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return gn.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const l=u=>{this._assignElementProperties(u,e,gn.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){l(o),o=i.cloneNode();continue}o.append(u)}t.append(o),e.replaceWith(t)}_normalizeBlockTextDecoration(){const e=this.dom.querySelectorAll('[style*="text-decoration"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveTextDecorationToChildren(t)}_moveTextDecorationToChildren(e){const t=this._parseTextDecoration(e);if(e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration"),e.style.cssText||e.removeAttribute("style"),!t.none)for(const r of e.childNodes){const i=this._wrapTextNode(e,r),o=this._parseTextDecoration(i),l={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(l).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),o=i.style.backgroundColor||t;i.style.backgroundColor=o}}_wrapTextNode(e,t){if(t.nodeType!==this._Node.TEXT_NODE)return t;const r=this.dom.createElement("span");return r.append(t.cloneNode()),e.replaceChild(r,t),r}}class pI extends H0{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!==ie.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(he.inlineMarks.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===ie.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>D0.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===ie.TEXT&&this._includesMarkType(e,he.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 nl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new gn({content:e,parser:t.parser||new dI})}static _buildJson(e){return new pI({content:e})}static normalize(e,t={}){return nl.build(e,t).normalize()}}class Di{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 Rf{static build({config:e,nodeDomParser:t}){const r=hI({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:Go(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:Go(Xc.DESKTOP),pageBlocksRef:Go([]),wrapperRef:Di.document.createElement("p")}),i=YO(r);return new Rf({schema:i,domParser:sc.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=nl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}class $0{static doc(e){return{type:ie.DOCUMENT,content:e}}static list(e,t){return{type:ie.LIST,attrs:{bullet:{type:e}},content:t.map(r=>r.type===ie.LIST_ITEM?r:this.listItem([].concat(r)))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{type:ie.LIST_ITEM,...t?{attrs:t}:{},...i?{marks:i}:{},content:[].concat(r).map(o=>typeof o=="string"?this.paragraph(o):o)}}static heading(e,...t){const r=this._textBlock(t,this.text);return r.attrs??={},r.attrs.level=e,{type:ie.HEADING,...r}}static paragraph(...e){return{type:ie.PARAGRAPH,...this._textBlock(e,this.text)}}static _textBlock(e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{content:typeof r=="string"?[this.text(r)]:r,...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:ie.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(he.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class mI{_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=Di.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const l of Xc.values)for(const u of Object.keys(r[l])){const f=this._makeVariable({device:l,preset:r,property:u}),d=this._makeInternalVariableName(u,l);if(t+=`${d}: var(${f}, inherit);`,i&&!he.attributes.includes(u)){const g=d.replace("preset-","");t+=`${g}: var(${d});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===Xc.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 Lf{static _instance;static get instance(){return this._instance??=new Lf,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 z0{static createWindow(){return new dp.JSDOM().window}types;parse(e){const{window:t}=new dp.JSDOM(e);return this.types=t,t.document}}class V0{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){console.log(e)}}class gI extends V0{name="to-json";description="migrate html to json";argument="<html...>";options=[{flags:"-c, --config <path>",description:"Generator config",default:hp.resolve(__dirname,"../bin/zp.config.json")},{flags:"-f, --format <type>",description:"Set output format",default:"rb"}];doCommand(e,{config:t,format:r}){Di.use(z0.createWindow());const i=hp.resolve(process.cwd(),t),o=Rf.build({config:require(i).editor,nodeDomParser:new z0}),l=e.map(d=>o.toJSON(this._formatInputHtml(d))),u=l.length===1?l[0]:l,f=this._stringifyContent(u);this.output(r==="rb"?this._formatOutputRb(f):f)}_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 yI="4.7.0-0";class bI extends V0{name="version";description="display cli version";doCommand(){this.output(yI)}}const W0=new Vx,_I=[gI,bI];for(const n of _I)new n().install(W0);W0.parse();
59
+ }`;var se=up(function(){return ge(w,j+"return "+F).apply(t,E)});if(se.source=F,du(se))throw se;return se}function BS(s){return ye(s).toLowerCase()}function HS(s){return ye(s).toUpperCase()}function $S(s,a,c){if(s=ye(s),s&&(c||a===t))return bh(s);if(!s||!(a=vt(a)))return s;var h=Kt(s),y=Kt(a),w=_h(h,y),E=vh(h,y)+1;return Kn(h,w,E).join("")}function zS(s,a,c){if(s=ye(s),s&&(c||a===t))return s.slice(0,Sh(s)+1);if(!s||!(a=vt(a)))return s;var h=Kt(s),y=vh(h,Kt(a))+1;return Kn(h,0,y).join("")}function VS(s,a,c){if(s=ye(s),s&&(c||a===t))return s.replace(dl,"");if(!s||!(a=vt(a)))return s;var h=Kt(s),y=_h(h,Kt(a));return Kn(h,y).join("")}function WS(s,a){var c=rn,h=Fn;if(Ae(a)){var y="separator"in a?a.separator:y;c="length"in a?re(a.length):c,h="omission"in a?vt(a.omission):h}s=ye(s);var w=s.length;if(Qr(s)){var E=Kt(s);w=E.length}if(c>=w)return s;var C=c-ei(h);if(C<1)return h;var M=E?Kn(E,0,C).join(""):s.slice(0,C);if(y===t)return M+h;if(E&&(C+=M.length-C),pu(y)){if(s.slice(C).search(y)){var L,P=M;for(y.global||(y=Ml(y.source,ye($f.exec(y))+"g")),y.lastIndex=0;L=y.exec(P);)var F=L.index;M=M.slice(0,F===t?C:F)}}else if(s.indexOf(vt(y),C)!=C){var V=M.lastIndexOf(y);V>-1&&(M=M.slice(0,V))}return M+h}function US(s){return s=ye(s),s&&ty.test(s)?s.replace(Ff,_1):s}var qS=ai(function(s,a,c){return s+(c?" ":"")+a.toUpperCase()}),yu=cd("toUpperCase");function lp(s,a,c){return s=ye(s),a=c?t:a,a===t?p1(s)?S1(s):s1(s):s.match(a)||[]}var up=oe(function(s,a){try{return bt(s,t,a)}catch(c){return du(c)?c:new te(c)}}),KS=Cn(function(s,a){return Mt(a,function(c){c=ln(c),En(s,c,fu(s[c],s))}),s});function GS(s){var a=s==null?0:s.length,c=Y();return s=a?ke(s,function(h){if(typeof h[1]!="function")throw new It(l);return[c(h[0]),h[1]]}):[],oe(function(h){for(var y=-1;++y<a;){var w=s[y];if(bt(w[0],this,h))return bt(w[1],this,h)}})}function jS(s){return _b(Rt(s,p))}function bu(s){return function(){return s}}function JS(s,a){return s==null||s!==s?a:s}var YS=hd(),XS=hd(!0);function mt(s){return s}function _u(s){return Vh(typeof s=="function"?s:Rt(s,p))}function ZS(s){return Uh(Rt(s,p))}function QS(s,a){return qh(s,Rt(a,p))}var ex=oe(function(s,a){return function(c){return ns(c,s,a)}}),tx=oe(function(s,a){return function(c){return ns(s,c,a)}});function vu(s,a,c){var h=He(a),y=ho(a,h);c==null&&!(Ae(a)&&(y.length||!h.length))&&(c=a,a=s,s=this,y=ho(a,He(a)));var w=!(Ae(c)&&"chain"in c)||!!c.chain,E=On(s);return Mt(y,function(C){var M=a[C];s[C]=M,E&&(s.prototype[C]=function(){var L=this.__chain__;if(w||L){var P=s(this.__wrapped__),F=P.__actions__=ht(this.__actions__);return F.push({func:M,args:arguments,thisArg:s}),P.__chain__=L,P}return M.apply(s,$n([this.value()],arguments))})}),s}function nx(){return qe._===this&&(qe._=O1),this}function wu(){}function rx(s){return s=re(s),oe(function(a){return Kh(a,s)})}var ix=Zl(ke),sx=Zl(dh),ox=Zl(xl);function cp(s){return su(s)?El(ln(s)):Db(s)}function ax(s){return function(a){return s==null?t:_r(s,a)}}var lx=pd(),ux=pd(!0);function Su(){return[]}function xu(){return!1}function cx(){return{}}function fx(){return""}function hx(){return!0}function dx(s,a){if(s=re(s),s<1||s>Ze)return[];var c=it,h=Qe(s,it);a=Y(a),s-=it;for(var y=Al(h,a);++c<s;)a(c);return y}function px(s){return ne(s)?ke(s,ln):wt(s)?[s]:ht(Md(ye(s)))}function mx(s){var a=++C1;return ye(s)+a}var gx=_o(function(s,a){return s+a},0),yx=Ql("ceil"),bx=_o(function(s,a){return s/a},1),_x=Ql("floor");function vx(s){return s&&s.length?fo(s,mt,Bl):t}function wx(s,a){return s&&s.length?fo(s,Y(a,2),Bl):t}function Sx(s){return gh(s,mt)}function xx(s,a){return gh(s,Y(a,2))}function Ex(s){return s&&s.length?fo(s,mt,Vl):t}function kx(s,a){return s&&s.length?fo(s,Y(a,2),Vl):t}var Cx=_o(function(s,a){return s*a},1),Ax=Ql("round"),Ox=_o(function(s,a){return s-a},0);function Tx(s){return s&&s.length?Cl(s,mt):0}function Mx(s,a){return s&&s.length?Cl(s,Y(a,2)):0}return v.after=Zv,v.ary=zd,v.assign=Hw,v.assignIn=tp,v.assignInWith=No,v.assignWith=$w,v.at=zw,v.before=Vd,v.bind=fu,v.bindAll=KS,v.bindKey=Wd,v.castArray=cw,v.chain=Bd,v.chunk=__,v.compact=v_,v.concat=w_,v.cond=GS,v.conforms=jS,v.constant=bu,v.countBy=Tv,v.create=Vw,v.curry=Ud,v.curryRight=qd,v.debounce=Kd,v.defaults=Ww,v.defaultsDeep=Uw,v.defer=Qv,v.delay=ew,v.difference=S_,v.differenceBy=x_,v.differenceWith=E_,v.drop=k_,v.dropRight=C_,v.dropRightWhile=A_,v.dropWhile=O_,v.fill=T_,v.filter=Iv,v.flatMap=Lv,v.flatMapDeep=Pv,v.flatMapDepth=Dv,v.flatten=Ld,v.flattenDeep=M_,v.flattenDepth=I_,v.flip=tw,v.flow=YS,v.flowRight=XS,v.fromPairs=N_,v.functions=Xw,v.functionsIn=Zw,v.groupBy=Fv,v.initial=L_,v.intersection=P_,v.intersectionBy=D_,v.intersectionWith=F_,v.invert=eS,v.invertBy=tS,v.invokeMap=Hv,v.iteratee=_u,v.keyBy=$v,v.keys=He,v.keysIn=pt,v.map=Co,v.mapKeys=rS,v.mapValues=iS,v.matches=ZS,v.matchesProperty=QS,v.memoize=Oo,v.merge=sS,v.mergeWith=np,v.method=ex,v.methodOf=tx,v.mixin=vu,v.negate=To,v.nthArg=rx,v.omit=oS,v.omitBy=aS,v.once=nw,v.orderBy=zv,v.over=ix,v.overArgs=rw,v.overEvery=sx,v.overSome=ox,v.partial=hu,v.partialRight=Gd,v.partition=Vv,v.pick=lS,v.pickBy=rp,v.property=cp,v.propertyOf=ax,v.pull=z_,v.pullAll=Dd,v.pullAllBy=V_,v.pullAllWith=W_,v.pullAt=U_,v.range=lx,v.rangeRight=ux,v.rearg=iw,v.reject=qv,v.remove=q_,v.rest=sw,v.reverse=uu,v.sampleSize=Gv,v.set=cS,v.setWith=fS,v.shuffle=jv,v.slice=K_,v.sortBy=Xv,v.sortedUniq=Q_,v.sortedUniqBy=ev,v.split=LS,v.spread=ow,v.tail=tv,v.take=nv,v.takeRight=rv,v.takeRightWhile=iv,v.takeWhile=sv,v.tap=vv,v.throttle=aw,v.thru=ko,v.toArray=Zd,v.toPairs=ip,v.toPairsIn=sp,v.toPath=px,v.toPlainObject=ep,v.transform=hS,v.unary=lw,v.union=ov,v.unionBy=av,v.unionWith=lv,v.uniq=uv,v.uniqBy=cv,v.uniqWith=fv,v.unset=dS,v.unzip=cu,v.unzipWith=Fd,v.update=pS,v.updateWith=mS,v.values=ci,v.valuesIn=gS,v.without=hv,v.words=lp,v.wrap=uw,v.xor=dv,v.xorBy=pv,v.xorWith=mv,v.zip=gv,v.zipObject=yv,v.zipObjectDeep=bv,v.zipWith=_v,v.entries=ip,v.entriesIn=sp,v.extend=tp,v.extendWith=No,vu(v,v),v.add=gx,v.attempt=up,v.camelCase=vS,v.capitalize=op,v.ceil=yx,v.clamp=yS,v.clone=fw,v.cloneDeep=dw,v.cloneDeepWith=pw,v.cloneWith=hw,v.conformsTo=mw,v.deburr=ap,v.defaultTo=JS,v.divide=bx,v.endsWith=wS,v.eq=jt,v.escape=SS,v.escapeRegExp=xS,v.every=Mv,v.find=Nv,v.findIndex=Nd,v.findKey=qw,v.findLast=Rv,v.findLastIndex=Rd,v.findLastKey=Kw,v.floor=_x,v.forEach=Hd,v.forEachRight=$d,v.forIn=Gw,v.forInRight=jw,v.forOwn=Jw,v.forOwnRight=Yw,v.get=mu,v.gt=gw,v.gte=yw,v.has=Qw,v.hasIn=gu,v.head=Pd,v.identity=mt,v.includes=Bv,v.indexOf=R_,v.inRange=bS,v.invoke=nS,v.isArguments=Sr,v.isArray=ne,v.isArrayBuffer=bw,v.isArrayLike=dt,v.isArrayLikeObject=Ie,v.isBoolean=_w,v.isBuffer=Gn,v.isDate=vw,v.isElement=ww,v.isEmpty=Sw,v.isEqual=xw,v.isEqualWith=Ew,v.isError=du,v.isFinite=kw,v.isFunction=On,v.isInteger=jd,v.isLength=Mo,v.isMap=Jd,v.isMatch=Cw,v.isMatchWith=Aw,v.isNaN=Ow,v.isNative=Tw,v.isNil=Iw,v.isNull=Mw,v.isNumber=Yd,v.isObject=Ae,v.isObjectLike=Me,v.isPlainObject=us,v.isRegExp=pu,v.isSafeInteger=Nw,v.isSet=Xd,v.isString=Io,v.isSymbol=wt,v.isTypedArray=ui,v.isUndefined=Rw,v.isWeakMap=Lw,v.isWeakSet=Pw,v.join=B_,v.kebabCase=ES,v.last=Pt,v.lastIndexOf=H_,v.lowerCase=kS,v.lowerFirst=CS,v.lt=Dw,v.lte=Fw,v.max=vx,v.maxBy=wx,v.mean=Sx,v.meanBy=xx,v.min=Ex,v.minBy=kx,v.stubArray=Su,v.stubFalse=xu,v.stubObject=cx,v.stubString=fx,v.stubTrue=hx,v.multiply=Cx,v.nth=$_,v.noConflict=nx,v.noop=wu,v.now=Ao,v.pad=AS,v.padEnd=OS,v.padStart=TS,v.parseInt=MS,v.random=_S,v.reduce=Wv,v.reduceRight=Uv,v.repeat=IS,v.replace=NS,v.result=uS,v.round=Ax,v.runInContext=T,v.sample=Kv,v.size=Jv,v.snakeCase=RS,v.some=Yv,v.sortedIndex=G_,v.sortedIndexBy=j_,v.sortedIndexOf=J_,v.sortedLastIndex=Y_,v.sortedLastIndexBy=X_,v.sortedLastIndexOf=Z_,v.startCase=PS,v.startsWith=DS,v.subtract=Ox,v.sum=Tx,v.sumBy=Mx,v.template=FS,v.times=dx,v.toFinite=Tn,v.toInteger=re,v.toLength=Qd,v.toLower=BS,v.toNumber=Dt,v.toSafeInteger=Bw,v.toString=ye,v.toUpper=HS,v.trim=$S,v.trimEnd=zS,v.trimStart=VS,v.truncate=WS,v.unescape=US,v.uniqueId=mx,v.upperCase=qS,v.upperFirst=yu,v.each=Hd,v.eachRight=$d,v.first=Pd,vu(v,function(){var s={};return on(v,function(a,c){_e.call(v.prototype,c)||(s[c]=a)}),s}(),{chain:!1}),v.VERSION=r,Mt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){v[s].placeholder=v}),Mt(["drop","take"],function(s,a){ue.prototype[s]=function(c){c=c===t?1:Be(re(c),0);var h=this.__filtered__&&!a?new ue(this):this.clone();return h.__filtered__?h.__takeCount__=Qe(c,h.__takeCount__):h.__views__.push({size:Qe(c,it),type:s+(h.__dir__<0?"Right":"")}),h},ue.prototype[s+"Right"]=function(c){return this.reverse()[s](c).reverse()}}),Mt(["filter","map","takeWhile"],function(s,a){var c=a+1,h=c==dr||c==Bn;ue.prototype[s]=function(y){var w=this.clone();return w.__iteratees__.push({iteratee:Y(y,3),type:c}),w.__filtered__=w.__filtered__||h,w}}),Mt(["head","last"],function(s,a){var c="take"+(a?"Right":"");ue.prototype[s]=function(){return this[c](1).value()[0]}}),Mt(["initial","tail"],function(s,a){var c="drop"+(a?"":"Right");ue.prototype[s]=function(){return this.__filtered__?new ue(this):this[c](1)}}),ue.prototype.compact=function(){return this.filter(mt)},ue.prototype.find=function(s){return this.filter(s).head()},ue.prototype.findLast=function(s){return this.reverse().find(s)},ue.prototype.invokeMap=oe(function(s,a){return typeof s=="function"?new ue(this):this.map(function(c){return ns(c,s,a)})}),ue.prototype.reject=function(s){return this.filter(To(Y(s)))},ue.prototype.slice=function(s,a){s=re(s);var c=this;return c.__filtered__&&(s>0||a<0)?new ue(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),a!==t&&(a=re(a),c=a<0?c.dropRight(-a):c.take(a-s)),c)},ue.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},ue.prototype.toArray=function(){return this.take(it)},on(ue.prototype,function(s,a){var c=/^(?:filter|find|map|reject)|While$/.test(a),h=/^(?:head|last)$/.test(a),y=v[h?"take"+(a=="last"?"Right":""):a],w=h||/^find/.test(a);y&&(v.prototype[a]=function(){var E=this.__wrapped__,C=h?[1]:arguments,M=E instanceof ue,L=C[0],P=M||ne(E),F=function(ae){var fe=y.apply(v,$n([ae],C));return h&&V?fe[0]:fe};P&&c&&typeof L=="function"&&L.length!=1&&(M=P=!1);var V=this.__chain__,j=!!this.__actions__.length,X=w&&!V,se=M&&!j;if(!w&&P){E=se?E:new ue(this);var Z=s.apply(E,C);return Z.__actions__.push({func:ko,args:[F],thisArg:t}),new Nt(Z,V)}return X&&se?s.apply(this,C):(Z=this.thru(F),X?h?Z.value()[0]:Z.value():Z)})}),Mt(["pop","push","shift","sort","splice","unshift"],function(s){var a=Ys[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",h=/^(?:pop|shift)$/.test(s);v.prototype[s]=function(){var y=arguments;if(h&&!this.__chain__){var w=this.value();return a.apply(ne(w)?w:[],y)}return this[c](function(E){return a.apply(ne(E)?E:[],y)})}}),on(ue.prototype,function(s,a){var c=v[a];if(c){var h=c.name+"";_e.call(ii,h)||(ii[h]=[]),ii[h].push({name:a,func:c})}}),ii[bo(t,x).name]=[{name:"wrapper",func:t}],ue.prototype.clone=U1,ue.prototype.reverse=q1,ue.prototype.value=K1,v.prototype.at=wv,v.prototype.chain=Sv,v.prototype.commit=xv,v.prototype.next=Ev,v.prototype.plant=Cv,v.prototype.reverse=Av,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=Ov,v.prototype.first=v.prototype.head,Ji&&(v.prototype[Ji]=kv),v},ti=x1();pr?((pr.exports=ti)._=ti,_l._=ti):qe._=ti}).call(IM)}(Fs,Fs.exports)),Fs.exports}var D0=NM();function Cf(n){return n.type.create(D0.cloneDeep(n.attrs))}const RM=Pe.create({name:"node_processor",addCommands(){return{setBlockAttributes:H(({commands:n,state:e},t,r,i={})=>{const o=z(n.getBlockAttributes(t))??{},{doc:l,tr:u}=e,{from:f,to:d}=u.selection;l.nodesBetween(f,d,(g,p)=>{ie.blocks.includes(g.type.name)&&u.setNodeAttribute(p,t,{...i,...o,...r})})}),getBlockAttributes:H(({editor:n},e,t)=>de(()=>{let r=Object.assign({},t||{});for(const i of ie.blocks)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:H(({commands:n},e)=>{for(const t of ie.blocks)n.resetAttributes(t,e)}),applyMark:H(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:l,schema:u}=n,{$from:f,$to:d}=o.selection,g=cn(he.LINK,u),p=cn(t,u);if(!(p.spec.group||"").includes(en.SETTINGS))return e.setMark(t,r);if(f.pos===d.pos)return;const S=k=>{if(!i.onAppliedToParent||i.onAppliedToParent(k)===!1){const{tr:m,node:b,position:x,mark:A}=k;e._removeNodeMark({tr:m,node:b,position:x,mark:A.type})}};l.nodesBetween(f.pos,d.pos,(k,m)=>{if(k.type.name===ie.LIST)return;const b=MM(k.marks,t),x=p.create({...b?.attrs||{},...r}),A=R0(f,d,k,m);if(!g.isInSet(k.marks)&&TM(o.doc,m,x,i.isAppliedToParent))return S({tr:o,node:k,position:m,mark:x});if(k.isText){o.addMark(A.from,A.to,x);return}AM(o.doc,o.selection,k,m)&&o.addNodeMark(m,x)})}),getMarks:H(({editor:n},e)=>{const t=pi(n,"state");return de(()=>{const{selection:r,doc:i}=z(t),{from:o,to:l}=z(r),u=[];return i.nodesBetween(o,l,f=>{for(const d of f.marks)d.type.name===e&&u.unshift(d.attrs)}),u})}),getMark:H(({commands:n},e)=>{const t=n.getMarks(e);return de(()=>z(t)[0]??null)}),hasMark:H(({commands:n},e)=>{const t=n.getMark(e);return de(()=>!!z(t))}),getCommonSettingMark:H(({commands:n},e,t)=>{const r=n.getMark(e);return de(()=>z(r)?.value??z(t))}),getDeviceSettingMark:H(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return de(()=>{for(const o of z(r)){const l=o[z(i)];if(l)return l}return z(t)})}),removeAllMarks:H(({state:n,commands:e})=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(l,u)=>{for(const f of l.marks)e._removeNodeMark({tr:t,node:l,position:u,mark:f})})}),removeMarks:H(({state:n,commands:e},t)=>{const{tr:r,doc:i}=n,{from:o,to:l}=r.selection;i.nodesBetween(o,l,(u,f)=>{const d=u.marks.filter(g=>t.includes(g.type.name));for(const g of d)e._removeNodeMark({tr:r,node:u,position:f,mark:g})})}),_removeNodeMark:H((n,{tr:e,node:t,position:r,mark:i})=>t.isText?e.removeMark(r,r+t.nodeSize,i):e.removeNodeMark(r,i))}}}),LM=Pe.create({name:"text_processor",addCommands(){return{getSelectedText:H(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:H(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const l=R0(t,r,i,o),u=Math.max(0,t.pos-o),f=Math.max(0,r.pos-o),d=e({text:i.textContent.substring(u,f)}),g=n.schema.text(d,i.marks);n.tr.replaceWith(l.from,l.to,g)})})}}}),PM=Pe.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:H(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:H(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:H(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;n.doc.nodesBetween(r,i,(o,l,u)=>{if(t({node:o,parent:u})){const f=o.isText?0:L0(n.doc,l);r=Math.min(r,l+f),i=Math.max(i,l+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:H(({commands:n})=>{n.expandSelection(({parent:e})=>e.type.name===ie.DOCUMENT)})}}}),DM=Dn.create({name:"doc",topNode:!0,content:"block+"});class Hs extends tt{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=Tr.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,De.ok(t)}invert(){return new Hs(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 Hs(e.key,e.value,e.stepType)}}tt.jsonID("setDocAttr",Hs);const FM=DM.extend({marks:en.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:H(({state:n},e,t)=>{n.tr.step(new Hs(e,t,n.schema))})}}}),BM=Dn.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()}}}),HM=BM.extend({marks:en.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),$M=Dn.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=>xT({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),zM=$M.extend({marks:en.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),VM=Pe.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[DT.create(this.editor),FT.create(this.editor)]}}),WM=()=>[FM,HM,zM,CT,PT,RM,LM,PM,VM],UM=Ot.create({name:he.FONT_FAMILY,group:en.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:H(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=z(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(he.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:H(({commands:n})=>{const e=z(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return de(()=>n.findFontByName(z(r))||t)}),findFontByName:H((n,e)=>z(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:H(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:H(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_family)})}},parseHTML(){const n=e=>({value:e.replace(/["']/g,"")});return[{style:"--zw-font-family",getAttrs:n},{style:"font-family",getAttrs:n}]},renderHTML({HTMLAttributes:n}){const e=n.value?`"${n.value}"`:null;return Hr({font_family:e})}}),qM=Pe.create({name:he.STYLE_PRESET,addGlobalAttributes(){return[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{preset:{isRequired:!1,default:{id:z(this.options.defaultId)},parseHTML:n=>{const e=z(this.options.presets);if(n.parentElement.tagName==="LI")return null;for(const{id:t,node:r,fallbackClass:i}of e){if(i&&n.classList.contains(i))return{id:t};const o=z(this.options.styleRenderer).makePresetCssClass({id:t});if(n.matches(o))return{id:t};if(n.tagName===`H${r?.level}`)return{id:t}}return n.tagName==="P"?{id:z(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:z(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const l=t[o],u=r[o],f=!u||u.toLowerCase()==="inherit";i[o]=f?l:u}return i}return{getPresetList:H(()=>de(()=>z(this.options.presets).filter(t=>!t.hidden))),getPreset:H(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:z(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),l=t.getLinkPreset();return de(()=>{const u=n(z(i),z(r).id);if(!z(o))return u;const f=z(l);return{id:u.id,common:e(u.common,f.common),mobile:e(u.mobile,f.mobile),tablet:e(u.tablet,f.tablet),desktop:e(u.desktop,f.desktop)}})}),applyPreset:H(({commands:t,chain:r},i)=>{const o=z(t.getPresetList()),l=n(o,i),u=l.node?.type??ie.PARAGRAPH,f={preset:{id:i}};l.node&&(f.level=l.node.level);for(const d of he.attributes)f[d]=z(t.getBlockAttributes(d));r().removeList().setNode(u,f).run()}),applyDefaultPreset:H(({commands:t})=>{t.applyPreset(z(this.options.defaultId))}),removePreset:H(({commands:t})=>{t.setNode(ie.PARAGRAPH,{preset:null})}),getPresetCustomization:H(({editor:t,commands:r})=>{const i=pi(t,"state");return de(()=>{const{selection:o,doc:l}=z(i),{from:u,to:f}=o;return r._getSettingCustomization(l,u,f)})}),isSettingCustomized:H(({commands:t},r)=>{const i=t.getPresetCustomization(),o=he.presetAttributes.includes(r)?"attributes":"marks";return de(()=>z(i)[o]?.includes(r)??!1)}),getContentCustomization:H(({editor:t,commands:r})=>{const i=pi(t,"state");return de(()=>{const{doc:o}=z(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:H((t,r,i,o)=>{const l=new Set,u=new Set;return r.nodesBetween(i,o,f=>{for(const[d,g]of Object.entries(f.attrs))he.presetAttributes.includes(d)&&g&&u.add(d);for(const{type:d}of f.marks)he.marks.includes(d.name)&&l.add(d.name)}),{attributes:Array.from(u),marks:Array.from(l)}}),removePresetCustomization:H(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(he.marks).resetAttributes(ie.PARAGRAPH,he.presetAttributes).resetAttributes(ie.HEADING,he.presetAttributes).restoreSelection().run()}),removeFormat:H(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Di.head,z(this.options.presets))}}),KM=Ot.create({name:he.FONT_WEIGHT,group:en.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:H(({commands:n},e)=>{n.applyMark(this.name,{value:e}),z(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:H(({commands:n})=>{const e=z(n.getFontWeight()),t=z(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:H(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return de(()=>{const r=z(e),i=z(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:H(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Vt("toggleBold"),"Mod-B":Vt("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 Hr({font_weight:n.value})}}),GM=Ot.create({name:he.FONT_SIZE,group:en.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:H(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:H(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].font_size.replace("px",""))}),applyFontSize:H(({commands:n},e)=>{const t=z(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:l})=>{const u={...l.attrs,[t]:null};if(!Object.values(u).some(g=>!!g))return!1;const d=l.type.create(u);if(i.isText){r.addMark(o,o+i.nodeSize,d);return}r.addNodeMark(o,d)}})}),increaseFontSize:H(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.min(e+1,z(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:H(({commands:n})=>{const e=Number(z(n.getFontSize())),t=Math.max(e-1,z(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Vt("increaseFontSize"),"Mod-Shift--":Vt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=z(this.options.wrapperRef),r=N0(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 Hr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),jM=Ot.create({name:he.FONT_COLOR,group:en.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:H(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:H(({commands:n})=>{const e=n.getPreset();return de(()=>z(e).common.color)}),applyFontColor:H(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:I0(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Hr({font_color:n.value})}}),JM=Ot.create({name:he.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:H(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:H(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:I0(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Hr({background_color:n.value})}}),YM=Pe.create({name:"device_manager",addCommands(){return{getDevice:H(()=>pi(this.options,"device"))}}}),XM=Ot.create({name:he.FONT_STYLE,group:en.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:H(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return de(()=>z(e)?.italic??z(t).italic)}),isItalicAvailable:H(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return de(()=>{const r=z(e),i=z(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:H(({commands:n})=>{const e=n.getPreset();return de(()=>({italic:z(e).common.font_style==="italic"}))}),toggleItalic:H(({commands:n})=>{z(n.isItalicAvailable())&&(z(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:H(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:H(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Vt("toggleItalic"),"Mod-I":Vt("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 Hr({font_style:e})}}),ZM=Ot.create({name:he.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:H(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).underline)}),isStrikeThrough:H(({commands:n})=>{const e=n.getTextDecoration();return de(()=>z(e).strike_through)}),getTextDecoration:H(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return de(()=>{const r=z(e)??{},i=z(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:H(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return de(()=>z(e)!==z(t).underline)}),getDefaultTextDecoration:H(({commands:n})=>{const e=n.getPreset();return de(()=>{const{text_decoration:t}=z(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:H(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:H(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:H(({commands:n},e,t=null)=>{const r=z(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:H(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:H(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Vt("toggleUnderline"),"Mod-U":Vt("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"),Hr({text_decoration:e.join(" ")})}}),QM=Pe.create({name:"case_style",addCommands(){return{applyCaseStyle:H(({commands:n},e)=>{switch(e){case Zc.CAPITALIZE:return n.applyCapitalize();case Zc.LOWERCASE:return n.applyLowerCase();case Zc.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:H(({commands:n})=>{n.transformText(({text:e})=>iM(e))}),applyLowerCase:H(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:H(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),F0={mobile:null,tablet:null,desktop:null},eI=Pe.create({name:he.ALIGNMENT,addGlobalAttributes:()=>[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{[he.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=CM(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?Za({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:H(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},F0)}),removeAlignment:H(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:H(({commands:n})=>{const e=n.getBlockAttributes(this.name,F0),t=n.getDevice(),r=n.getDefaultAlignment();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultAlignment:H(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].alignment??sr.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Vt("applyAlignment",sr.LEFT),"Mod-Shift-e":Vt("applyAlignment",sr.CENTER),"Mod-Shift-r":Vt("applyAlignment",sr.RIGHT),"Mod-Shift-j":Vt("applyAlignment",sr.JUSTIFY)})}),B0={mobile:null,tablet:null,desktop:null},tI=Pe.create({name:he.LINE_HEIGHT,addGlobalAttributes(){return[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{[he.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,l=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:l}}const e=n.style.lineHeight;if(!e)return null;const t=z(this.options.wrapperRef),r=EM(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?Za({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:H(({commands:n})=>{const e=n.getBlockAttributes(this.name,B0),t=n.getDevice(),r=n.getDefaultLineHeight();return de(()=>z(e)?.[z(t)]??z(r))}),getDefaultLineHeight:H(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return de(()=>z(t)[z(e)].line_height)}),applyLineHeight:H(({commands:n},e)=>{const t=z(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},B0)})}}}),nI=Dn.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)}}}),rI=nI.extend({name:ie.LIST_ITEM,marks:en.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:H(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const l of r.marks)t.addNodeMark(o,Cf(l));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===ie.LIST))return t.listItemNewline()}})}),iI=Dn.create({name:ie.LIST,content:`${ie.LIST_ITEM}+`,group:"block list",marks:en.SETTINGS,addExtensions:()=>[rI],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:$t.DISC}}}),parseHTML(){const n={a:$t.ROMAN,i:$t.LATIN,1:$t.DECIMAL},e=t=>{for(const r of $t.values){const i=`.${z(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||$t.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||$t.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[z(this.options.baseClass)+n.bullet.type,z(this.options.presetClass)];return[$t.ordered.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:H(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return de(()=>z(e).type??null)}),applyList:H(({commands:n,chain:e},t)=>{if(z(n.getListType())===t){n.removeList();return}return e().applyDefaultPreset().toggleList(ie.LIST,ie.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({commands:i,tr:o})=>i._bubbleListItemMarks(o)).run()}),_bubbleListItemMarks:H((n,e)=>{const{doc:t,selection:r}=e,i=r.$from.start(),o=r.$to.end();function l(u,f){if(he.inlineMarks.includes(f.type)||f.type.isInSet(u.marks))return!1;for(const d of u.content.content)if(d.childCount&&(!d.marks||!f.isInSet(d.marks)))return!1;return!0}t.nodesBetween(i,o,(u,f)=>{if(u.type.name===ie.LIST)return;if(u.type.name!==ie.LIST_ITEM)return!1;const d=[];return u.forEach(g=>{for(const p of g.marks){if(p.isInSet(d)){e.removeNodeMark(f+1,p);continue}l(u,p)&&(e.removeNodeMark(f+1,p),e.addNodeMark(f,Cf(p)),d.push(p))}}),!1})}),removeList:H(({commands:n,state:e})=>{const{tr:t,doc:r,selection:i}=e,o=i.$from.start(),l=i.$to.end();r.nodesBetween(o,l,(u,f,d)=>{if([ie.LIST,ie.LIST_ITEM].includes(u.type.name))return;if(d.type.name!==ie.LIST_ITEM)return!1;const g=d.marks.filter(function(p){return!p.type.isInSet(u.marks)});for(const p of g)t.addNodeMark(f,Cf(p));return!1}),n.liftListItem(ie.LIST_ITEM)})}},addInputRules(){const n=(e,t)=>ET({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n($t.DISC,/^\s*([-+*])\s$/),n($t.DECIMAL,/^(\d+)\.\s$/),n($t.LATIN,/^([ivx]{1,3})\.\s$/i),n($t.ROMAN,/^([a-z])\.\s$/i)]}});function sI(n){return new Ct({key:new Zt("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(d=>d.docChanged)&&!t.doc.eq(r.doc),o=e.some(d=>d.getMeta("preventAutolink"));if(!i||o)return;const{tr:l}=r,u=KO(t.doc,[...e]);if(tT(u).forEach(({newRange:d})=>{const g=jO(r.doc,d,S=>S.isTextblock);let p,_;if(g.length>1?(p=g[0],_=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ")):g.length&&r.doc.textBetween(d.from,d.to," "," ").endsWith(" ")&&(p=g[0],_=r.doc.textBetween(p.pos,d.to,void 0," ")),p&&_){const S=_.split(" ").filter(b=>b!=="");if(S.length<=0)return!1;const k=S[S.length-1],m=p.pos+_.lastIndexOf(k);if(!k)return!1;_f(k).filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate?n.validate(b.value):!0).forEach(b=>{Zg(b.from,b.to,r.doc).some(x=>x.mark.type===n.type)||l.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!l.steps.length)return l}})}function oI(n){return new Ct({key:new Zt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||r.target.nodeName!=="A")return!1;const u=ZO(e.state,n.type.name),f=r.target,d=(i=f?.href)!==null&&i!==void 0?i:u.href,g=(o=f?.target)!==null&&o!==void 0?o:u.target;return f&&d?(e.editable&&window.open(d,g),!0):!1}}})}function aI(n){return new Ct({key:new Zt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:o}=e,{selection:l}=o,{empty:u}=l;if(u)return!1;let f="";r.content.forEach(k=>{f+=k.textContent});const d=_f(f).find(k=>k.isLink&&k.value===f);if(!f||!d)return!1;const g=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),p=/href="([^"]*)"/,_=g?.match(p),S=_?_[1]:d.href;return n.editor.commands.setMark(n.type,{href:S}),!0}}})}const lI=Ot.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){S0(n);return}S0(n.scheme,n.optionalSlashes)})},onDestroy(){eM()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Oi(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Oi(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[kT({find:n=>_f(n).filter(e=>this.options.validate?this.options.validate(e.value):!0).filter(e=>e.isLink).map(e=>({text:e.value,index:e.start,data:e})),type:this.type,getAttributes:(n,e)=>{var t,r;const i=(t=e?.clipboardData)===null||t===void 0?void 0:t.getData("text/html"),o=/href="([^"]*)"/,l=i?.match(o);return l?{href:l[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(sI({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(oI({type:this.type})),this.options.linkOnPaste&&n.push(aI({editor:this.editor,type:this.type})),n}}),uI=lI.extend({name:he.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:l0.SELF,parseHTML:n=>n.getAttribute("target")||l0.SELF},destination:{default:Ts.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Ts.URL;const t=e.replace("#","");return z(this.options.pageBlocks).find(o=>o.id===parseInt(t))?Ts.BLOCK:Ts.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:H(({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($0.text(r.text,[$0.mark(he.LINK,r)])))),expandSelectionToLink:H(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:H(({commands:e})=>e.hasMark(this.name)),getLinkPreset:H(()=>de(()=>z(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),rM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Ts.BLOCK?`#${n.href}`:n.href,t=z(this.options.basePresetClass)+z(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),cI=Ot.create({name:he.SUPERSCRIPT,addCommands(){return{applySuperscript:H(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:H(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:H(({commands:n})=>{z(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:H(({commands:n})=>{const e=n.getMark(this.name);return de(()=>!!z(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),fI=Pe.create({name:he.MARGIN,addGlobalAttributes:()=>[{types:[ie.PARAGRAPH,ie.HEADING],attributes:{[he.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?Za({margin:n.margin.value}):null}}}}]});function hI(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=Wu({default:null,link:null});return fk(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),WM().concat([qM.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new mI({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),iI.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),YM.configure({device:n.deviceRef}),GM.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),UM.configure({fonts:n.fonts,defaultPreset:pi(t,"default"),defaultFont:n.defaultFont}),KM,jM,JM,XM,ZM,QM,cI,eI,tI.configure({wrapperRef:n.wrapperRef}),uI.configure({preset:pi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),fI])}class dI{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class H0{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class gn extends H0{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=gn.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const l=u=>{this._assignElementProperties(u,e,gn.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,gn.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){l(u),i=null,o=u;continue}if(u.tagName==="BR"&&o&&o?.tagName!=="BR"){u.remove(),o=u;continue}if(u.tagName==="BR"){const f=this.dom.createElement("p");f.append(u),l(f),i=null,o=u;continue}i||(i=this.dom.createElement("p"),l(i)),i.append(u),o=u}e.append(t),this._removeStyleProperties(e,gn.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,gn.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return gn.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return gn.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const l=u=>{this._assignElementProperties(u,e,gn.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){l(o),o=i.cloneNode();continue}o.append(u)}t.append(o),e.replaceWith(t)}_normalizeBlockTextDecoration(){const e=this.dom.querySelectorAll('[style*="text-decoration"]:where(p, h1, h2, h3, h4, li)');for(const t of e)this._moveTextDecorationToChildren(t)}_moveTextDecorationToChildren(e){const t=this._parseTextDecoration(e);if(e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration"),e.style.cssText||e.removeAttribute("style"),!t.none)for(const r of e.childNodes){const i=this._wrapTextNode(e,r),o=this._parseTextDecoration(i),l={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(l).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),o=i.style.backgroundColor||t;i.style.backgroundColor=o}}_wrapTextNode(e,t){if(t.nodeType!==this._Node.TEXT_NODE)return t;const r=this.dom.createElement("span");return r.append(t.cloneNode()),e.replaceChild(r,t),r}}class pI extends H0{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!==ie.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(he.inlineMarks.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===ie.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>D0.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===ie.TEXT&&this._includesMarkType(e,he.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 nl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new gn({content:e,parser:t.parser||new dI})}static _buildJson(e){return new pI({content:e})}static normalize(e,t={}){return nl.build(e,t).normalize()}}class Di{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 Rf{static build({config:e,nodeDomParser:t}){const r=hI({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:Go(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:Go(Xc.DESKTOP),pageBlocksRef:Go([]),wrapperRef:Di.document.createElement("p")}),i=YO(r);return new Rf({schema:i,domParser:sc.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=nl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}class $0{static doc(e){return{type:ie.DOCUMENT,content:e}}static list(e,t){return{type:ie.LIST,attrs:{bullet:{type:e}},content:t.map(r=>r.type===ie.LIST_ITEM?r:this.listItem([].concat(r)))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{type:ie.LIST_ITEM,...t?{attrs:t}:{},...i?{marks:i}:{},content:[].concat(r).map(o=>typeof o=="string"?this.paragraph(o):o)}}static heading(e,...t){const r=this._textBlock(t,this.text);return r.attrs??={},r.attrs.level=e,{type:ie.HEADING,...r}}static paragraph(...e){return{type:ie.PARAGRAPH,...this._textBlock(e,this.text)}}static _textBlock(e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{content:typeof r=="string"?[this.text(r)]:r,...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:ie.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(he.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class mI{_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=Di.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const l of Xc.values)for(const u of Object.keys(r[l])){const f=this._makeVariable({device:l,preset:r,property:u}),d=this._makeInternalVariableName(u,l);if(t+=`${d}: var(${f}, inherit);`,i&&!he.attributes.includes(u)){const g=d.replace("preset-","");t+=`${g}: var(${d});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===Xc.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 Lf{static _instance;static get instance(){return this._instance??=new Lf,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 z0{static createWindow(){return new dp.JSDOM().window}types;parse(e){const{window:t}=new dp.JSDOM(e);return this.types=t,t.document}}class V0{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){console.log(e)}}class gI extends V0{name="to-json";description="migrate html to json";argument="<html...>";options=[{flags:"-c, --config <path>",description:"Generator config",default:hp.resolve(__dirname,"../bin/zp.config.json")},{flags:"-f, --format <type>",description:"Set output format",default:"rb"}];doCommand(e,{config:t,format:r}){Di.use(z0.createWindow());const i=hp.resolve(process.cwd(),t),o=Rf.build({config:require(i).editor,nodeDomParser:new z0}),l=e.map(d=>o.toJSON(this._formatInputHtml(d))),u=l.length===1?l[0]:l,f=this._stringifyContent(u);this.output(r==="rb"?this._formatOutputRb(f):f)}_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 yI="4.7.0";class bI extends V0{name="version";description="display cli version";doCommand(){this.output(yI)}}const W0=new Vx,_I=[gI,bI];for(const n of _I)new n().install(W0);W0.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "4.7.0-0",
3
+ "version": "4.7.0",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "types": "dist/wysiwyg.d.ts",
@@ -86,7 +86,7 @@
86
86
  "@vue/test-utils": "^2.4.6",
87
87
  "@vue/tsconfig": "^0.5.1",
88
88
  "@vue/vue3-jest": "^29.2.6",
89
- "@zipify/colorpicker": "^3.3.0-0",
89
+ "@zipify/colorpicker": "^3.3.0",
90
90
  "@zipify/eslint-config": "^1.5.1",
91
91
  "babel-jest": "^29.7.0",
92
92
  "esbuild-jest": "^0.5.0",