@zipify/wysiwyg 4.4.0 → 4.5.0-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.
package/dist/cli.js CHANGED
@@ -58,4 +58,4 @@ __p += '`),ae&&(R+=`' +
58
58
  function print() { __p += __j.call(arguments, '') }
59
59
  `:`;
60
60
  `)+R+`return __p
61
- }`;var te=sp(function(){return me(_,W+"return "+R).apply(t,w)});if(te.source=R,au(te))throw te;return te}function zS(s){return ge(s).toLowerCase()}function VS(s){return ge(s).toUpperCase()}function WS(s,l,c){if(s=ge(s),s&&(c||l===t))return ph(s);if(!s||!(l=yt(l)))return s;var h=Ht(s),g=Ht(l),_=mh(h,g),w=gh(h,g)+1;return Fn(h,_,w).join("")}function US(s,l,c){if(s=ge(s),s&&(c||l===t))return s.slice(0,bh(s)+1);if(!s||!(l=yt(l)))return s;var h=Ht(s),g=gh(h,Ht(l))+1;return Fn(h,0,g).join("")}function KS(s,l,c){if(s=ge(s),s&&(c||l===t))return s.replace(aa,"");if(!s||!(l=yt(l)))return s;var h=Ht(s),g=mh(h,Ht(l));return Fn(h,g).join("")}function qS(s,l){var c=Xl,h=Hi;if(Ee(l)){var g="separator"in l?l.separator:g;c="length"in l?Q(l.length):c,h="omission"in l?yt(l.omission):h}s=ge(s);var _=s.length;if(Zr(s)){var w=Ht(s);_=w.length}if(c>=_)return s;var x=c-Qr(h);if(x<1)return h;var k=w?Fn(w,0,x).join(""):s.slice(0,x);if(g===t)return k+h;if(w&&(x+=k.length-x),uu(g)){if(s.slice(x).search(g)){var M,I=k;for(g.global||(g=ka(g.source,ge(Df.exec(g))+"g")),g.lastIndex=0;M=g.exec(I);)var R=M.index;k=k.slice(0,R===t?x:R)}}else if(s.indexOf(yt(g),x)!=x){var B=k.lastIndexOf(g);B>-1&&(k=k.slice(0,B))}return k+h}function GS(s){return s=ge(s),s&&iy.test(s)?s.replace(Rf,S1):s}var jS=oi(function(s,l,c){return s+(c?" ":"")+l.toUpperCase()}),hu=od("toUpperCase");function ip(s,l,c){return s=ge(s),l=c?t:l,l===t?y1(s)?k1(s):a1(s):s.match(l)||[]}var sp=ne(function(s,l){try{return mt(s,t,l)}catch(c){return au(c)?c:new X(c)}}),JS=vn(function(s,l){return kt(l,function(c){c=tn(c),bn(s,c,ou(s[c],s))}),s});function YS(s){var l=s==null?0:s.length,c=G();return s=l?Se(s,function(h){if(typeof h[1]!="function")throw new Ct(a);return[c(h[0]),h[1]]}):[],ne(function(h){for(var g=-1;++g<l;){var _=s[g];if(mt(_[0],this,h))return mt(_[1],this,h)}})}function XS(s){return Sb(Ot(s,m))}function du(s){return function(){return s}}function ZS(s,l){return s==null||s!==s?l:s}var QS=ad(),ex=ad(!0);function ht(s){return s}function pu(s){return $h(typeof s=="function"?s:Ot(s,m))}function tx(s){return Hh(Ot(s,m))}function nx(s,l){return zh(s,Ot(l,m))}var rx=ne(function(s,l){return function(c){return ns(c,s,l)}}),ix=ne(function(s,l){return function(c){return ns(s,c,l)}});function mu(s,l,c){var h=Fe(l),g=co(l,h);c==null&&!(Ee(l)&&(g.length||!h.length))&&(c=l,l=s,s=this,g=co(l,Fe(l)));var _=!(Ee(c)&&"chain"in c)||!!c.chain,w=Sn(s);return kt(g,function(x){var k=l[x];s[x]=k,w&&(s.prototype[x]=function(){var M=this.__chain__;if(_||M){var I=s(this.__wrapped__),R=I.__actions__=ut(this.__actions__);return R.push({func:k,args:arguments,thisArg:s}),I.__chain__=M,I}return k.apply(s,In([this.value()],arguments))})}),s}function sx(){return Ve._===this&&(Ve._=I1),this}function gu(){}function ox(s){return s=Q(s),ne(function(l){return Vh(l,s)})}var lx=Ga(Se),ax=Ga(uh),ux=Ga(ba);function op(s){return eu(s)?_a(tn(s)):Bb(s)}function cx(s){return function(l){return s==null?t:mr(s,l)}}var fx=cd(),hx=cd(!0);function yu(){return[]}function bu(){return!1}function dx(){return{}}function px(){return""}function mx(){return!0}function gx(s,l){if(s=Q(s),s<1||s>je)return[];var c=et,h=Je(s,et);l=G(l),s-=et;for(var g=Sa(h,l);++c<s;)l(c);return g}function yx(s){return Z(s)?Se(s,tn):bt(s)?[s]:ut(Cd(ge(s)))}function bx(s){var l=++T1;return ge(s)+l}var _x=yo(function(s,l){return s+l},0),vx=ja("ceil"),wx=yo(function(s,l){return s/l},1),Sx=ja("floor");function xx(s){return s&&s.length?uo(s,ht,Ra):t}function Ex(s,l){return s&&s.length?uo(s,G(l,2),Ra):t}function kx(s){return hh(s,ht)}function Cx(s,l){return hh(s,G(l,2))}function Ax(s){return s&&s.length?uo(s,ht,Fa):t}function Ox(s,l){return s&&s.length?uo(s,G(l,2),Fa):t}var Tx=yo(function(s,l){return s*l},1),Mx=ja("round"),Ix=yo(function(s,l){return s-l},0);function Nx(s){return s&&s.length?wa(s,ht):0}function Rx(s,l){return s&&s.length?wa(s,G(l,2)):0}return b.after=tw,b.ary=Fd,b.assign=Vw,b.assignIn=Xd,b.assignInWith=Mo,b.assignWith=Ww,b.at=Uw,b.before=$d,b.bind=ou,b.bindAll=JS,b.bindKey=Bd,b.castArray=dw,b.chain=Ld,b.chunk=S_,b.compact=x_,b.concat=E_,b.cond=YS,b.conforms=XS,b.constant=du,b.countBy=Nv,b.create=Kw,b.curry=Hd,b.curryRight=zd,b.debounce=Vd,b.defaults=qw,b.defaultsDeep=Gw,b.defer=nw,b.delay=rw,b.difference=k_,b.differenceBy=C_,b.differenceWith=A_,b.drop=O_,b.dropRight=T_,b.dropRightWhile=M_,b.dropWhile=I_,b.fill=N_,b.filter=Lv,b.flatMap=Fv,b.flatMapDeep=$v,b.flatMapDepth=Bv,b.flatten=Md,b.flattenDeep=R_,b.flattenDepth=L_,b.flip=iw,b.flow=QS,b.flowRight=ex,b.fromPairs=P_,b.functions=eS,b.functionsIn=tS,b.groupBy=Hv,b.initial=F_,b.intersection=$_,b.intersectionBy=B_,b.intersectionWith=H_,b.invert=rS,b.invertBy=iS,b.invokeMap=Vv,b.iteratee=pu,b.keyBy=Wv,b.keys=Fe,b.keysIn=ft,b.map=Eo,b.mapKeys=oS,b.mapValues=lS,b.matches=tx,b.matchesProperty=nx,b.memoize=Co,b.merge=aS,b.mergeWith=Zd,b.method=rx,b.methodOf=ix,b.mixin=mu,b.negate=Ao,b.nthArg=ox,b.omit=uS,b.omitBy=cS,b.once=sw,b.orderBy=Uv,b.over=lx,b.overArgs=ow,b.overEvery=ax,b.overSome=ux,b.partial=lu,b.partialRight=Wd,b.partition=Kv,b.pick=fS,b.pickBy=Qd,b.property=op,b.propertyOf=cx,b.pull=U_,b.pullAll=Nd,b.pullAllBy=K_,b.pullAllWith=q_,b.pullAt=G_,b.range=fx,b.rangeRight=hx,b.rearg=lw,b.reject=jv,b.remove=j_,b.rest=aw,b.reverse=iu,b.sampleSize=Yv,b.set=dS,b.setWith=pS,b.shuffle=Xv,b.slice=J_,b.sortBy=ew,b.sortedUniq=nv,b.sortedUniqBy=rv,b.split=FS,b.spread=uw,b.tail=iv,b.take=sv,b.takeRight=ov,b.takeRightWhile=lv,b.takeWhile=av,b.tap=xv,b.throttle=cw,b.thru=xo,b.toArray=jd,b.toPairs=ep,b.toPairsIn=tp,b.toPath=yx,b.toPlainObject=Yd,b.transform=mS,b.unary=fw,b.union=uv,b.unionBy=cv,b.unionWith=fv,b.uniq=hv,b.uniqBy=dv,b.uniqWith=pv,b.unset=gS,b.unzip=su,b.unzipWith=Rd,b.update=yS,b.updateWith=bS,b.values=ui,b.valuesIn=_S,b.without=mv,b.words=ip,b.wrap=hw,b.xor=gv,b.xorBy=yv,b.xorWith=bv,b.zip=_v,b.zipObject=vv,b.zipObjectDeep=wv,b.zipWith=Sv,b.entries=ep,b.entriesIn=tp,b.extend=Xd,b.extendWith=Mo,mu(b,b),b.add=_x,b.attempt=sp,b.camelCase=xS,b.capitalize=np,b.ceil=vx,b.clamp=vS,b.clone=pw,b.cloneDeep=gw,b.cloneDeepWith=yw,b.cloneWith=mw,b.conformsTo=bw,b.deburr=rp,b.defaultTo=ZS,b.divide=wx,b.endsWith=ES,b.eq=Vt,b.escape=kS,b.escapeRegExp=CS,b.every=Rv,b.find=Pv,b.findIndex=Od,b.findKey=jw,b.findLast=Dv,b.findLastIndex=Td,b.findLastKey=Jw,b.floor=Sx,b.forEach=Pd,b.forEachRight=Dd,b.forIn=Yw,b.forInRight=Xw,b.forOwn=Zw,b.forOwnRight=Qw,b.get=cu,b.gt=_w,b.gte=vw,b.has=nS,b.hasIn=fu,b.head=Id,b.identity=ht,b.includes=zv,b.indexOf=D_,b.inRange=wS,b.invoke=sS,b.isArguments=br,b.isArray=Z,b.isArrayBuffer=ww,b.isArrayLike=ct,b.isArrayLikeObject=Oe,b.isBoolean=Sw,b.isBuffer=$n,b.isDate=xw,b.isElement=Ew,b.isEmpty=kw,b.isEqual=Cw,b.isEqualWith=Aw,b.isError=au,b.isFinite=Ow,b.isFunction=Sn,b.isInteger=Ud,b.isLength=Oo,b.isMap=Kd,b.isMatch=Tw,b.isMatchWith=Mw,b.isNaN=Iw,b.isNative=Nw,b.isNil=Lw,b.isNull=Rw,b.isNumber=qd,b.isObject=Ee,b.isObjectLike=Ce,b.isPlainObject=us,b.isRegExp=uu,b.isSafeInteger=Pw,b.isSet=Gd,b.isString=To,b.isSymbol=bt,b.isTypedArray=ai,b.isUndefined=Dw,b.isWeakMap=Fw,b.isWeakSet=$w,b.join=z_,b.kebabCase=AS,b.last=Mt,b.lastIndexOf=V_,b.lowerCase=OS,b.lowerFirst=TS,b.lt=Bw,b.lte=Hw,b.max=xx,b.maxBy=Ex,b.mean=kx,b.meanBy=Cx,b.min=Ax,b.minBy=Ox,b.stubArray=yu,b.stubFalse=bu,b.stubObject=dx,b.stubString=px,b.stubTrue=mx,b.multiply=Tx,b.nth=W_,b.noConflict=sx,b.noop=gu,b.now=ko,b.pad=MS,b.padEnd=IS,b.padStart=NS,b.parseInt=RS,b.random=SS,b.reduce=qv,b.reduceRight=Gv,b.repeat=LS,b.replace=PS,b.result=hS,b.round=Mx,b.runInContext=E,b.sample=Jv,b.size=Zv,b.snakeCase=DS,b.some=Qv,b.sortedIndex=Y_,b.sortedIndexBy=X_,b.sortedIndexOf=Z_,b.sortedLastIndex=Q_,b.sortedLastIndexBy=ev,b.sortedLastIndexOf=tv,b.startCase=$S,b.startsWith=BS,b.subtract=Ix,b.sum=Nx,b.sumBy=Rx,b.template=HS,b.times=gx,b.toFinite=xn,b.toInteger=Q,b.toLength=Jd,b.toLower=zS,b.toNumber=It,b.toSafeInteger=zw,b.toString=ge,b.toUpper=VS,b.trim=WS,b.trimEnd=US,b.trimStart=KS,b.truncate=qS,b.unescape=GS,b.uniqueId=bx,b.upperCase=jS,b.upperFirst=hu,b.each=Pd,b.eachRight=Dd,b.first=Id,mu(b,function(){var s={};return Qt(b,function(l,c){ye.call(b.prototype,c)||(s[c]=l)}),s}(),{chain:!1}),b.VERSION=r,kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){b[s].placeholder=b}),kt(["drop","take"],function(s,l){le.prototype[s]=function(c){c=c===t?1:De(Q(c),0);var h=this.__filtered__&&!l?new le(this):this.clone();return h.__filtered__?h.__takeCount__=Je(c,h.__takeCount__):h.__views__.push({size:Je(c,et),type:s+(h.__dir__<0?"Right":"")}),h},le.prototype[s+"Right"]=function(c){return this.reverse()[s](c).reverse()}}),kt(["filter","map","takeWhile"],function(s,l){var c=l+1,h=c==ur||c==Tn;le.prototype[s]=function(g){var _=this.clone();return _.__iteratees__.push({iteratee:G(g,3),type:c}),_.__filtered__=_.__filtered__||h,_}}),kt(["head","last"],function(s,l){var c="take"+(l?"Right":"");le.prototype[s]=function(){return this[c](1).value()[0]}}),kt(["initial","tail"],function(s,l){var c="drop"+(l?"":"Right");le.prototype[s]=function(){return this.__filtered__?new le(this):this[c](1)}}),le.prototype.compact=function(){return this.filter(ht)},le.prototype.find=function(s){return this.filter(s).head()},le.prototype.findLast=function(s){return this.reverse().find(s)},le.prototype.invokeMap=ne(function(s,l){return typeof s=="function"?new le(this):this.map(function(c){return ns(c,s,l)})}),le.prototype.reject=function(s){return this.filter(Ao(G(s)))},le.prototype.slice=function(s,l){s=Q(s);var c=this;return c.__filtered__&&(s>0||l<0)?new le(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),l!==t&&(l=Q(l),c=l<0?c.dropRight(-l):c.take(l-s)),c)},le.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},le.prototype.toArray=function(){return this.take(et)},Qt(le.prototype,function(s,l){var c=/^(?:filter|find|map|reject)|While$/.test(l),h=/^(?:head|last)$/.test(l),g=b[h?"take"+(l=="last"?"Right":""):l],_=h||/^find/.test(l);g&&(b.prototype[l]=function(){var w=this.__wrapped__,x=h?[1]:arguments,k=w instanceof le,M=x[0],I=k||Z(w),R=function(re){var ae=g.apply(b,In([re],x));return h&&B?ae[0]:ae};I&&c&&typeof M=="function"&&M.length!=1&&(k=I=!1);var B=this.__chain__,W=!!this.__actions__.length,j=_&&!B,te=k&&!W;if(!_&&I){w=te?w:new le(this);var J=s.apply(w,x);return J.__actions__.push({func:xo,args:[R],thisArg:t}),new At(J,B)}return j&&te?s.apply(this,x):(J=this.thru(R),j?h?J.value()[0]:J.value():J)})}),kt(["pop","push","shift","sort","splice","unshift"],function(s){var l=js[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",h=/^(?:pop|shift)$/.test(s);b.prototype[s]=function(){var g=arguments;if(h&&!this.__chain__){var _=this.value();return l.apply(Z(_)?_:[],g)}return this[c](function(w){return l.apply(Z(w)?w:[],g)})}}),Qt(le.prototype,function(s,l){var c=b[l];if(c){var h=c.name+"";ye.call(ri,h)||(ri[h]=[]),ri[h].push({name:l,func:c})}}),ri[go(t,N).name]=[{name:"wrapper",func:t}],le.prototype.clone=G1,le.prototype.reverse=j1,le.prototype.value=J1,b.prototype.at=Ev,b.prototype.chain=kv,b.prototype.commit=Cv,b.prototype.next=Av,b.prototype.plant=Tv,b.prototype.reverse=Mv,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Iv,b.prototype.first=b.prototype.head,Ji&&(b.prototype[Ji]=Ov),b},ei=C1();cr?((cr.exports=ei)._=ei,pa._=ei):Ve._=ei}).call(cs)}(ql,ql.exports);var $0=ql.exports;function Sf(n){return n.type.create($0.cloneDeep(n.attrs))}const qM=Re.create({name:"node_processor",addCommands(){return{setBlockAttributes:P(({commands:n,state:e},t,r,i={})=>{const o=F(n.getBlockAttributes(t))??{},{doc:a,tr:u}=e,{from:f,to:d}=u.selection;a.nodesBetween(f,d,(p,m)=>{ee.blocks.includes(p.type.name)&&u.setNodeAttribute(m,t,{...i,...o,...r})})}),getBlockAttributes:P(({editor:n},e,t)=>fe(()=>{let r=Object.assign({},t||{});for(const i of ee.blocks)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:P(({commands:n},e)=>{for(const t of ee.blocks)n.resetAttributes(t,e)}),applyMark:P(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:a,schema:u}=n,{$from:f,$to:d}=o.selection,p=sn(ce.LINK,u),m=sn(t,u);if(!(m.spec.group||"").includes(Jt.SETTINGS))return e.setMark(t,r);if(f.pos===d.pos)return;const v=S=>{if(!i.onAppliedToParent||i.onAppliedToParent(S)===!1){const{tr:C,node:O,position:N,mark:q}=S;e._removeNodeMark({tr:C,node:O,position:N,mark:q.type})}};a.nodesBetween(f.pos,d.pos,(S,C)=>{if(S.type.name===ee.LIST)return;const O=KM(S.marks,t),N=m.create({...O?.attrs||{},...r}),q=D0(f,d,S,C);if(!p.isInSet(S.marks)&&UM(o.doc,C,N,i.isAppliedToParent))return v({tr:o,node:S,position:C,mark:N});if(S.isText){o.addMark(q.from,q.to,N);return}VM(o.doc,o.selection,S,C)&&o.addNodeMark(C,N)})}),getMarks:P(({editor:n},e)=>{const t=hi(n,"state");return fe(()=>{const{selection:r,doc:i}=F(t),{from:o,to:a}=F(r),u=[];return i.nodesBetween(o,a,f=>{for(const d of f.marks)d.type.name===e&&u.unshift(d.attrs)}),u})}),getMark:P(({commands:n},e)=>{const t=n.getMarks(e);return fe(()=>F(t)[0]??null)}),hasMark:P(({commands:n},e)=>{const t=n.getMark(e);return fe(()=>!!F(t))}),getCommonSettingMark:P(({commands:n},e,t)=>{const r=n.getMark(e);return fe(()=>F(r)?.value??F(t))}),getDeviceSettingMark:P(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return fe(()=>{for(const o of F(r)){const a=o[F(i)];if(a)return a}return F(t)})}),removeAllMarks:P(({state:n,commands:e})=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(a,u)=>{for(const f of a.marks)e._removeNodeMark({tr:t,node:a,position:u,mark:f})})}),removeMarks:P(({state:n,commands:e},t)=>{const{tr:r,doc:i}=n,{from:o,to:a}=r.selection;i.nodesBetween(o,a,(u,f)=>{const d=u.marks.filter(p=>t.includes(p.type.name));for(const p of d)e._removeNodeMark({tr:r,node:u,position:f,mark:p})})}),_removeNodeMark:P((n,{tr:e,node:t,position:r,mark:i})=>t.isText?e.removeMark(r,r+t.nodeSize,i):e.removeNodeMark(r,i))}}}),GM=Re.create({name:"text_processor",addCommands(){return{getSelectedText:P(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:P(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const a=D0(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)}),p=n.schema.text(d,i.marks);n.tr.replaceWith(a.from,a.to,p)})})}}}),jM=Re.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:P(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:P(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:P(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;n.doc.nodesBetween(r,i,(o,a,u)=>{if(t({node:o,parent:u})){const f=o.isText?0:F0(n.doc,a);r=Math.min(r,a+f),i=Math.max(i,a+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:P(({commands:n})=>{n.expandSelection(({parent:e})=>e.type.name===ee.DOCUMENT)})}}}),JM=On.create({name:"doc",topNode:!0,content:"block+"});class Fs extends Xe{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=Or.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,Le.ok(t)}invert(){return new Fs(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 Fs(e.key,e.value,e.stepType)}}Xe.jsonID("setDocAttr",Fs);const YM=JM.extend({marks:Jt.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:P(({state:n},e,t)=>{n.tr.step(new Fs(e,t,n.schema))})}}}),XM=On.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Ci(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ZM=XM.extend({marks:Jt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),QM=On.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]}`,Ci(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=>$T({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),eI=QM.extend({marks:Jt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),tI=Re.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[XT.create(this.editor),ZT.create(this.editor)]}}),nI=()=>[YM,ZM,eI,zT,YT,qM,GM,jM,tI],rI=xt.create({name:ce.FONT_FAMILY,group:Jt.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:P(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=F(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ce.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:P(({commands:n})=>{const e=F(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return fe(()=>n.findFontByName(F(r))||t)}),findFontByName:P((n,e)=>F(this.options.fonts).find(t=>t.name===e)),getFontFamily:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(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 $r({font_family:e})}}),iI=Re.create({name:ce.STYLE_PRESET,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{preset:{isRequired:!1,default:{id:F(this.options.defaultId)},parseHTML:n=>{const e=F(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=F(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:F(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:F(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const a=t[o],u=r[o],f=!u||u.toLowerCase()==="inherit";i[o]=f?a:u}return i}return{getPresetList:P(()=>fe(()=>F(this.options.presets).filter(t=>!t.hidden))),getPreset:P(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:F(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),a=t.getLinkPreset();return fe(()=>{const u=n(F(i),F(r).id);if(!F(o))return u;const f=F(a);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:P(({commands:t,chain:r},i)=>{const o=F(t.getPresetList()),a=n(o,i),u=a.node?.type??ee.PARAGRAPH,f={preset:{id:i}};a.node&&(f.level=a.node.level);for(const d of ce.attributes)f[d]=F(t.getBlockAttributes(d));r().removeList().setNode(u,f).run()}),applyDefaultPreset:P(({commands:t})=>{t.applyPreset(F(this.options.defaultId))}),removePreset:P(({commands:t})=>{t.setNode(ee.PARAGRAPH,{preset:null})}),getPresetCustomization:P(({editor:t,commands:r})=>{const i=hi(t,"state");return fe(()=>{const{selection:o,doc:a}=F(i),{from:u,to:f}=o;return r._getSettingCustomization(a,u,f)})}),isSettingCustomized:P(({commands:t},r)=>{const i=t.getPresetCustomization(),o=ce.presetAttributes.includes(r)?"attributes":"marks";return fe(()=>F(i)[o]?.includes(r)??!1)}),getContentCustomization:P(({editor:t,commands:r})=>{const i=hi(t,"state");return fe(()=>{const{doc:o}=F(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:P((t,r,i,o)=>{const a=new Set,u=new Set;return r.nodesBetween(i,o,f=>{for(const[d,p]of Object.entries(f.attrs))ce.presetAttributes.includes(d)&&p&&u.add(d);for(const{type:d}of f.marks)ce.marks.includes(d.name)&&a.add(d.name)}),{attributes:Array.from(u),marks:Array.from(a)}}),removePresetCustomization:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(ce.marks).resetAttributes(ee.PARAGRAPH,ce.presetAttributes).resetAttributes(ee.HEADING,ce.presetAttributes).restoreSelection().run()}),removeFormat:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Li.head,F(this.options.presets))}}),sI=xt.create({name:ce.FONT_WEIGHT,group:Jt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:P(({commands:n},e)=>{n.applyMark(this.name,{value:e}),F(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:P(({commands:n})=>{const e=F(n.getFontWeight()),t=F(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:P(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return fe(()=>{const r=F(e),i=F(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Dt("toggleBold"),"Mod-B":Dt("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 $r({font_weight:n.value})}}),oI=xt.create({name:ce.FONT_SIZE,group:Jt.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:P(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].font_size.replace("px",""))}),applyFontSize:P(({commands:n},e)=>{const t=F(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:a})=>{const u={...a.attrs,[t]:null};if(!Object.values(u).some(p=>!!p))return!1;const d=a.type.create(u);if(i.isText){r.addMark(o,o+i.nodeSize,d);return}r.addNodeMark(o,d)}})}),increaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.min(e+1,F(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.max(e-1,F(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Dt("increaseFontSize"),"Mod-Shift--":Dt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=F(this.options.wrapperRef),r=P0(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 $r({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),lI=xt.create({name:ce.FONT_COLOR,group:Jt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.color)}),applyFontColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:L0(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return $r({font_color:n.value})}}),aI=xt.create({name:ce.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:P(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:L0(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return $r({background_color:n.value})}}),uI=Re.create({name:"device_manager",addCommands(){return{getDevice:P(()=>hi(this.options,"device"))}}}),cI=xt.create({name:ce.FONT_STYLE,group:Jt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return fe(()=>F(e)?.italic??F(t).italic)}),isItalicAvailable:P(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return fe(()=>{const r=F(e),i=F(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:P(({commands:n})=>{const e=n.getPreset();return fe(()=>({italic:F(e).common.font_style==="italic"}))}),toggleItalic:P(({commands:n})=>{F(n.isItalicAvailable())&&(F(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Dt("toggleItalic"),"Mod-I":Dt("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 $r({font_style:e})}}),fI=xt.create({name:ce.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).underline)}),isStrikeThrough:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).strike_through)}),getTextDecoration:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return fe(()=>{const r=F(e)??{},i=F(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:P(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return fe(()=>F(e)!==F(t).underline)}),getDefaultTextDecoration:P(({commands:n})=>{const e=n.getPreset();return fe(()=>{const{text_decoration:t}=F(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:P(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:P(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:P(({commands:n},e,t=null)=>{const r=F(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Dt("toggleUnderline"),"Mod-U":Dt("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"),$r({text_decoration:e.join(" ")})}}),hI=Re.create({name:"case_style",addCommands(){return{applyCaseStyle:P(({commands:n},e)=>{switch(e){case jc.CAPITALIZE:return n.applyCapitalize();case jc.LOWERCASE:return n.applyLowerCase();case jc.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:P(({commands:n})=>{n.transformText(({text:e})=>_M(e))}),applyLowerCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),B0={mobile:null,tablet:null,desktop:null},dI=Re.create({name:ce.ALIGNMENT,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=zM(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?Kl({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},B0)}),removeAlignment:P(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,B0),t=n.getDevice(),r=n.getDefaultAlignment();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultAlignment:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].alignment??er.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Dt("applyAlignment",er.LEFT),"Mod-Shift-e":Dt("applyAlignment",er.CENTER),"Mod-Shift-r":Dt("applyAlignment",er.RIGHT),"Mod-Shift-j":Dt("applyAlignment",er.JUSTIFY)})}),H0={mobile:null,tablet:null,desktop:null},pI=Re.create({name:ce.LINE_HEIGHT,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=F(this.options.wrapperRef),r=BM(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?Kl({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:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,H0),t=n.getDevice(),r=n.getDefaultLineHeight();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultLineHeight:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].line_height)}),applyLineHeight:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},H0)})}}}),mI=On.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ci(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)}}}),gI=mI.extend({name:ee.LIST_ITEM,marks:Jt.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:P(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const a of r.marks)t.addNodeMark(o,Sf(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===ee.LIST))return t.listItemNewline()}})}),yI=On.create({name:ee.LIST,content:`${ee.LIST_ITEM}+`,group:"block list",marks:Jt.SETTINGS,addExtensions:()=>[gI],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:Lt.DISC}}}),parseHTML(){const n={a:Lt.ROMAN,i:Lt.LATIN,1:Lt.DECIMAL},e=t=>{for(const r of Lt.values){const i=`.${F(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||Lt.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||Lt.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[F(this.options.baseClass)+n.bullet.type,F(this.options.presetClass)];return[Lt.ordered.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:P(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return fe(()=>F(e).type??null)}),applyList:P(({commands:n,chain:e},t)=>{if(F(n.getListType())===t){n.removeList();return}return e().applyDefaultPreset().toggleList(ee.LIST,ee.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({commands:i,tr:o})=>i._bubbleListItemMarks(o)).run()}),_bubbleListItemMarks:P((n,e)=>{const{doc:t,selection:r}=e,i=r.$from.start(),o=r.$to.end();function a(u,f){if(ce.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===ee.LIST)return;if(u.type.name!==ee.LIST_ITEM)return!1;const d=[];return u.forEach(p=>{for(const m of p.marks){if(m.isInSet(d)){e.removeNodeMark(f+1,m);continue}a(u,m)&&(e.removeNodeMark(f+1,m),e.addNodeMark(f,Sf(m)),d.push(m))}}),!1})}),removeList:P(({commands:n,state:e})=>{const{tr:t,doc:r,selection:i}=e,o=i.$from.start(),a=i.$to.end();r.nodesBetween(o,a,(u,f,d)=>{if([ee.LIST,ee.LIST_ITEM].includes(u.type.name))return;if(d.type.name!==ee.LIST_ITEM)return!1;const p=d.marks.filter(function(m){return!m.type.isInSet(u.marks)});for(const m of p)t.addNodeMark(f,Sf(m));return!1}),n.liftListItem(ee.LIST_ITEM)})}},addInputRules(){const n=(e,t)=>BT({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(Lt.DISC,/^\s*([-+*])\s$/),n(Lt.DECIMAL,/^(\d+)\.\s$/),n(Lt.LATIN,/^([ivx]{1,3})\.\s$/i),n(Lt.ROMAN,/^([a-z])\.\s$/i)]}});function bI(n){return new wt({key:new Gt("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:a}=r,u=lT(t.doc,[...e]);if(gT(u).forEach(({newRange:d})=>{const p=uT(r.doc,d,v=>v.isTextblock);let m,y;if(p.length>1?(m=p[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ")):p.length&&r.doc.textBetween(d.from,d.to," "," ").endsWith(" ")&&(m=p[0],y=r.doc.textBetween(m.pos,d.to,void 0," ")),m&&y){const v=y.split(" ").filter(O=>O!=="");if(v.length<=0)return!1;const S=v[v.length-1],C=m.pos+y.lastIndexOf(S);if(!S)return!1;mf(S).filter(O=>O.isLink).map(O=>({...O,from:C+O.start+1,to:C+O.end+1})).filter(O=>r.schema.marks.code?!r.doc.rangeHasMark(O.from,O.to,r.schema.marks.code):!0).filter(O=>n.validate?n.validate(O.value):!0).forEach(O=>{t0(O.from,O.to,r.doc).some(N=>N.mark.type===n.type)||a.addMark(O.from,O.to,n.type.create({href:O.href}))})}}),!!a.steps.length)return a}})}function _I(n){return new wt({key:new Gt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||r.target.nodeName!=="A")return!1;const u=dT(e.state,n.type.name),f=r.target,d=(i=f?.href)!==null&&i!==void 0?i:u.href,p=(o=f?.target)!==null&&o!==void 0?o:u.target;return f&&d?(e.editable&&window.open(d,p),!0):!1}}})}function vI(n){return new wt({key:new Gt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:o}=e,{selection:a}=o,{empty:u}=a;if(u)return!1;let f="";r.content.forEach(S=>{f+=S.textContent});const d=mf(f).find(S=>S.isLink&&S.value===f);if(!f||!d)return!1;const p=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),m=/href="([^"]*)"/,y=p?.match(m),v=y?y[1]:d.href;return n.editor.commands.setMark(n.type,{href:v}),!0}}})}const wI=xt.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){k0(n);return}k0(n.scheme,n.optionalSlashes)})},onDestroy(){mM()},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",Ci(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Ci(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[HT({find:n=>mf(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="([^"]*)"/,a=i?.match(o);return a?{href:a[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(bI({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(_I({type:this.type})),this.options.linkOnPaste&&n.push(vI({editor:this.editor,type:this.type})),n}}),SI=wI.extend({name:ce.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:f0.SELF,parseHTML:n=>n.getAttribute("target")||f0.SELF},destination:{default:Os.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Os.URL;const t=e.replace("#","");return F(this.options.pageBlocks).find(o=>o.id===parseInt(t))?Os.BLOCK:Os.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:P(({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(V0.text(r.text,[V0.mark(ce.LINK,r)])))),expandSelectionToLink:P(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:P(({commands:e})=>e.hasMark(this.name)),getLinkPreset:P(()=>fe(()=>F(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),bM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Os.BLOCK?`#${n.href}`:n.href,t=F(this.options.basePresetClass)+F(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),xI=xt.create({name:ce.SUPERSCRIPT,addCommands(){return{applySuperscript:P(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:P(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:P(({commands:n})=>{F(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:P(({commands:n})=>{const e=n.getMark(this.name);return fe(()=>!!F(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),EI=Re.create({name:ce.MARGIN,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?Kl({margin:n.margin.value}):null}}}}]});function kI(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=Fu({default:null,link:null});return _k(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),nI().concat([iI.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new OI({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),yI.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),uI.configure({device:n.deviceRef}),oI.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),rI.configure({fonts:n.fonts,defaultPreset:hi(t,"default")}),sI,lI,aI,cI,fI,hI,xI,dI,pI.configure({wrapperRef:n.wrapperRef}),SI.configure({preset:hi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),EI])}class CI{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class z0{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class fn extends z0{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=fn.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const a=u=>{this._assignElementProperties(u,e,fn.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,fn.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){a(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),a(f),i=null,o=u;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(u),o=u}e.append(t),this._removeStyleProperties(e,fn.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,fn.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return fn.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return fn.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const a=u=>{this._assignElementProperties(u,e,fn.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){a(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),a={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,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 AI extends z0{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!==ee.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(ce.inlineMarks.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===ee.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>$0.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===ee.TEXT&&this._includesMarkType(e,ce.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Yl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new fn({content:e,parser:t.parser||new CI})}static _buildJson(e){return new AI({content:e})}static normalize(e,t={}){return Yl.build(e,t).normalize()}}class Li{static window=globalThis.window;static use(e){this.window=e}static get document(){return this.window.document}static get body(){return this.document.body}static get head(){return this.document.head}static getComputedStyle(e){return this.window.getComputedStyle(e)}}class Tf{static build({config:e,nodeDomParser:t}){const r=kI({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:Wo(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:Wo(Gc.DESKTOP),pageBlocksRef:Wo([]),wrapperRef:Li.document.createElement("p")}),i=fT(r);return new Tf({schema:i,domParser:tc.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=Yl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}class V0{static doc(e){return{type:ee.DOCUMENT,content:e}}static list(e,t){return{type:ee.LIST,attrs:{bullet:{type:e}},content:t.map(r=>r.type===ee.LIST_ITEM?r:this.listItem([].concat(r)))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{type:ee.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:ee.HEADING,...r}}static paragraph(...e){return{type:ee.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:ee.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ce.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class OI{_baseClass;_makeVariable;_linkPresetId;constructor({baseClass:e,makeVariable:t,linkPresetId:r}){this._baseClass=e,this._makeVariable=t,this._linkPresetId=r}inject(e,t){let r=e.querySelector("[data-zw-styles]");r||(r=Li.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const a of Gc.values)for(const u of Object.keys(r[a])){const f=this._makeVariable({device:a,preset:r,property:u}),d=this._makeInternalVariableName(u,a);if(t+=`${d}: var(${f}, inherit);`,i&&!ce.attributes.includes(u)){const p=d.replace("preset-","");t+=`${p}: var(${d});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===Gc.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 Mf{static _instance;static get instance(){return this._instance??=new Mf,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 W0{static createWindow(){return new ap.JSDOM().window}types;parse(e){const{window:t}=new ap.JSDOM(e);return this.types=t,t.document}}class U0{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 TI extends U0{name="to-json";description="migrate html to json";argument="<html...>";options=[{flags:"-c, --config <path>",description:"Generator config",default:_u.resolve(__dirname,"../bin/zp.config.json")},{flags:"-f, --format <type>",description:"Set output format",default:"rb"}];doCommand(e,{config:t,format:r}){Li.use(W0.createWindow());const i=_u.resolve(process.cwd(),t),o=Tf.build({config:require(i).editor,nodeDomParser:new W0}),a=e.map(d=>o.toJSON(this._formatInputHtml(d))),u=a.length===1?a[0]:a,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 MI="4.4.0";class II extends U0{name="version";description="display cli version";doCommand(){this.output(MI)}}const K0=new sE,NI=[TI,II];for(const n of NI)new n().install(K0);K0.parse();
61
+ }`;var te=sp(function(){return me(_,W+"return "+R).apply(t,w)});if(te.source=R,au(te))throw te;return te}function zS(s){return ge(s).toLowerCase()}function VS(s){return ge(s).toUpperCase()}function WS(s,l,c){if(s=ge(s),s&&(c||l===t))return ph(s);if(!s||!(l=yt(l)))return s;var h=Ht(s),g=Ht(l),_=mh(h,g),w=gh(h,g)+1;return Fn(h,_,w).join("")}function US(s,l,c){if(s=ge(s),s&&(c||l===t))return s.slice(0,bh(s)+1);if(!s||!(l=yt(l)))return s;var h=Ht(s),g=gh(h,Ht(l))+1;return Fn(h,0,g).join("")}function KS(s,l,c){if(s=ge(s),s&&(c||l===t))return s.replace(aa,"");if(!s||!(l=yt(l)))return s;var h=Ht(s),g=mh(h,Ht(l));return Fn(h,g).join("")}function qS(s,l){var c=Xl,h=Hi;if(Ee(l)){var g="separator"in l?l.separator:g;c="length"in l?Q(l.length):c,h="omission"in l?yt(l.omission):h}s=ge(s);var _=s.length;if(Zr(s)){var w=Ht(s);_=w.length}if(c>=_)return s;var x=c-Qr(h);if(x<1)return h;var k=w?Fn(w,0,x).join(""):s.slice(0,x);if(g===t)return k+h;if(w&&(x+=k.length-x),uu(g)){if(s.slice(x).search(g)){var M,I=k;for(g.global||(g=ka(g.source,ge(Df.exec(g))+"g")),g.lastIndex=0;M=g.exec(I);)var R=M.index;k=k.slice(0,R===t?x:R)}}else if(s.indexOf(yt(g),x)!=x){var B=k.lastIndexOf(g);B>-1&&(k=k.slice(0,B))}return k+h}function GS(s){return s=ge(s),s&&iy.test(s)?s.replace(Rf,S1):s}var jS=oi(function(s,l,c){return s+(c?" ":"")+l.toUpperCase()}),hu=od("toUpperCase");function ip(s,l,c){return s=ge(s),l=c?t:l,l===t?y1(s)?k1(s):a1(s):s.match(l)||[]}var sp=ne(function(s,l){try{return mt(s,t,l)}catch(c){return au(c)?c:new X(c)}}),JS=vn(function(s,l){return kt(l,function(c){c=tn(c),bn(s,c,ou(s[c],s))}),s});function YS(s){var l=s==null?0:s.length,c=G();return s=l?Se(s,function(h){if(typeof h[1]!="function")throw new Ct(a);return[c(h[0]),h[1]]}):[],ne(function(h){for(var g=-1;++g<l;){var _=s[g];if(mt(_[0],this,h))return mt(_[1],this,h)}})}function XS(s){return Sb(Ot(s,m))}function du(s){return function(){return s}}function ZS(s,l){return s==null||s!==s?l:s}var QS=ad(),ex=ad(!0);function ht(s){return s}function pu(s){return $h(typeof s=="function"?s:Ot(s,m))}function tx(s){return Hh(Ot(s,m))}function nx(s,l){return zh(s,Ot(l,m))}var rx=ne(function(s,l){return function(c){return ns(c,s,l)}}),ix=ne(function(s,l){return function(c){return ns(s,c,l)}});function mu(s,l,c){var h=Fe(l),g=co(l,h);c==null&&!(Ee(l)&&(g.length||!h.length))&&(c=l,l=s,s=this,g=co(l,Fe(l)));var _=!(Ee(c)&&"chain"in c)||!!c.chain,w=Sn(s);return kt(g,function(x){var k=l[x];s[x]=k,w&&(s.prototype[x]=function(){var M=this.__chain__;if(_||M){var I=s(this.__wrapped__),R=I.__actions__=ut(this.__actions__);return R.push({func:k,args:arguments,thisArg:s}),I.__chain__=M,I}return k.apply(s,In([this.value()],arguments))})}),s}function sx(){return Ve._===this&&(Ve._=I1),this}function gu(){}function ox(s){return s=Q(s),ne(function(l){return Vh(l,s)})}var lx=Ga(Se),ax=Ga(uh),ux=Ga(ba);function op(s){return eu(s)?_a(tn(s)):Bb(s)}function cx(s){return function(l){return s==null?t:mr(s,l)}}var fx=cd(),hx=cd(!0);function yu(){return[]}function bu(){return!1}function dx(){return{}}function px(){return""}function mx(){return!0}function gx(s,l){if(s=Q(s),s<1||s>je)return[];var c=et,h=Je(s,et);l=G(l),s-=et;for(var g=Sa(h,l);++c<s;)l(c);return g}function yx(s){return Z(s)?Se(s,tn):bt(s)?[s]:ut(Cd(ge(s)))}function bx(s){var l=++T1;return ge(s)+l}var _x=yo(function(s,l){return s+l},0),vx=ja("ceil"),wx=yo(function(s,l){return s/l},1),Sx=ja("floor");function xx(s){return s&&s.length?uo(s,ht,Ra):t}function Ex(s,l){return s&&s.length?uo(s,G(l,2),Ra):t}function kx(s){return hh(s,ht)}function Cx(s,l){return hh(s,G(l,2))}function Ax(s){return s&&s.length?uo(s,ht,Fa):t}function Ox(s,l){return s&&s.length?uo(s,G(l,2),Fa):t}var Tx=yo(function(s,l){return s*l},1),Mx=ja("round"),Ix=yo(function(s,l){return s-l},0);function Nx(s){return s&&s.length?wa(s,ht):0}function Rx(s,l){return s&&s.length?wa(s,G(l,2)):0}return b.after=tw,b.ary=Fd,b.assign=Vw,b.assignIn=Xd,b.assignInWith=Mo,b.assignWith=Ww,b.at=Uw,b.before=$d,b.bind=ou,b.bindAll=JS,b.bindKey=Bd,b.castArray=dw,b.chain=Ld,b.chunk=S_,b.compact=x_,b.concat=E_,b.cond=YS,b.conforms=XS,b.constant=du,b.countBy=Nv,b.create=Kw,b.curry=Hd,b.curryRight=zd,b.debounce=Vd,b.defaults=qw,b.defaultsDeep=Gw,b.defer=nw,b.delay=rw,b.difference=k_,b.differenceBy=C_,b.differenceWith=A_,b.drop=O_,b.dropRight=T_,b.dropRightWhile=M_,b.dropWhile=I_,b.fill=N_,b.filter=Lv,b.flatMap=Fv,b.flatMapDeep=$v,b.flatMapDepth=Bv,b.flatten=Md,b.flattenDeep=R_,b.flattenDepth=L_,b.flip=iw,b.flow=QS,b.flowRight=ex,b.fromPairs=P_,b.functions=eS,b.functionsIn=tS,b.groupBy=Hv,b.initial=F_,b.intersection=$_,b.intersectionBy=B_,b.intersectionWith=H_,b.invert=rS,b.invertBy=iS,b.invokeMap=Vv,b.iteratee=pu,b.keyBy=Wv,b.keys=Fe,b.keysIn=ft,b.map=Eo,b.mapKeys=oS,b.mapValues=lS,b.matches=tx,b.matchesProperty=nx,b.memoize=Co,b.merge=aS,b.mergeWith=Zd,b.method=rx,b.methodOf=ix,b.mixin=mu,b.negate=Ao,b.nthArg=ox,b.omit=uS,b.omitBy=cS,b.once=sw,b.orderBy=Uv,b.over=lx,b.overArgs=ow,b.overEvery=ax,b.overSome=ux,b.partial=lu,b.partialRight=Wd,b.partition=Kv,b.pick=fS,b.pickBy=Qd,b.property=op,b.propertyOf=cx,b.pull=U_,b.pullAll=Nd,b.pullAllBy=K_,b.pullAllWith=q_,b.pullAt=G_,b.range=fx,b.rangeRight=hx,b.rearg=lw,b.reject=jv,b.remove=j_,b.rest=aw,b.reverse=iu,b.sampleSize=Yv,b.set=dS,b.setWith=pS,b.shuffle=Xv,b.slice=J_,b.sortBy=ew,b.sortedUniq=nv,b.sortedUniqBy=rv,b.split=FS,b.spread=uw,b.tail=iv,b.take=sv,b.takeRight=ov,b.takeRightWhile=lv,b.takeWhile=av,b.tap=xv,b.throttle=cw,b.thru=xo,b.toArray=jd,b.toPairs=ep,b.toPairsIn=tp,b.toPath=yx,b.toPlainObject=Yd,b.transform=mS,b.unary=fw,b.union=uv,b.unionBy=cv,b.unionWith=fv,b.uniq=hv,b.uniqBy=dv,b.uniqWith=pv,b.unset=gS,b.unzip=su,b.unzipWith=Rd,b.update=yS,b.updateWith=bS,b.values=ui,b.valuesIn=_S,b.without=mv,b.words=ip,b.wrap=hw,b.xor=gv,b.xorBy=yv,b.xorWith=bv,b.zip=_v,b.zipObject=vv,b.zipObjectDeep=wv,b.zipWith=Sv,b.entries=ep,b.entriesIn=tp,b.extend=Xd,b.extendWith=Mo,mu(b,b),b.add=_x,b.attempt=sp,b.camelCase=xS,b.capitalize=np,b.ceil=vx,b.clamp=vS,b.clone=pw,b.cloneDeep=gw,b.cloneDeepWith=yw,b.cloneWith=mw,b.conformsTo=bw,b.deburr=rp,b.defaultTo=ZS,b.divide=wx,b.endsWith=ES,b.eq=Vt,b.escape=kS,b.escapeRegExp=CS,b.every=Rv,b.find=Pv,b.findIndex=Od,b.findKey=jw,b.findLast=Dv,b.findLastIndex=Td,b.findLastKey=Jw,b.floor=Sx,b.forEach=Pd,b.forEachRight=Dd,b.forIn=Yw,b.forInRight=Xw,b.forOwn=Zw,b.forOwnRight=Qw,b.get=cu,b.gt=_w,b.gte=vw,b.has=nS,b.hasIn=fu,b.head=Id,b.identity=ht,b.includes=zv,b.indexOf=D_,b.inRange=wS,b.invoke=sS,b.isArguments=br,b.isArray=Z,b.isArrayBuffer=ww,b.isArrayLike=ct,b.isArrayLikeObject=Oe,b.isBoolean=Sw,b.isBuffer=$n,b.isDate=xw,b.isElement=Ew,b.isEmpty=kw,b.isEqual=Cw,b.isEqualWith=Aw,b.isError=au,b.isFinite=Ow,b.isFunction=Sn,b.isInteger=Ud,b.isLength=Oo,b.isMap=Kd,b.isMatch=Tw,b.isMatchWith=Mw,b.isNaN=Iw,b.isNative=Nw,b.isNil=Lw,b.isNull=Rw,b.isNumber=qd,b.isObject=Ee,b.isObjectLike=Ce,b.isPlainObject=us,b.isRegExp=uu,b.isSafeInteger=Pw,b.isSet=Gd,b.isString=To,b.isSymbol=bt,b.isTypedArray=ai,b.isUndefined=Dw,b.isWeakMap=Fw,b.isWeakSet=$w,b.join=z_,b.kebabCase=AS,b.last=Mt,b.lastIndexOf=V_,b.lowerCase=OS,b.lowerFirst=TS,b.lt=Bw,b.lte=Hw,b.max=xx,b.maxBy=Ex,b.mean=kx,b.meanBy=Cx,b.min=Ax,b.minBy=Ox,b.stubArray=yu,b.stubFalse=bu,b.stubObject=dx,b.stubString=px,b.stubTrue=mx,b.multiply=Tx,b.nth=W_,b.noConflict=sx,b.noop=gu,b.now=ko,b.pad=MS,b.padEnd=IS,b.padStart=NS,b.parseInt=RS,b.random=SS,b.reduce=qv,b.reduceRight=Gv,b.repeat=LS,b.replace=PS,b.result=hS,b.round=Mx,b.runInContext=E,b.sample=Jv,b.size=Zv,b.snakeCase=DS,b.some=Qv,b.sortedIndex=Y_,b.sortedIndexBy=X_,b.sortedIndexOf=Z_,b.sortedLastIndex=Q_,b.sortedLastIndexBy=ev,b.sortedLastIndexOf=tv,b.startCase=$S,b.startsWith=BS,b.subtract=Ix,b.sum=Nx,b.sumBy=Rx,b.template=HS,b.times=gx,b.toFinite=xn,b.toInteger=Q,b.toLength=Jd,b.toLower=zS,b.toNumber=It,b.toSafeInteger=zw,b.toString=ge,b.toUpper=VS,b.trim=WS,b.trimEnd=US,b.trimStart=KS,b.truncate=qS,b.unescape=GS,b.uniqueId=bx,b.upperCase=jS,b.upperFirst=hu,b.each=Pd,b.eachRight=Dd,b.first=Id,mu(b,function(){var s={};return Qt(b,function(l,c){ye.call(b.prototype,c)||(s[c]=l)}),s}(),{chain:!1}),b.VERSION=r,kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){b[s].placeholder=b}),kt(["drop","take"],function(s,l){le.prototype[s]=function(c){c=c===t?1:De(Q(c),0);var h=this.__filtered__&&!l?new le(this):this.clone();return h.__filtered__?h.__takeCount__=Je(c,h.__takeCount__):h.__views__.push({size:Je(c,et),type:s+(h.__dir__<0?"Right":"")}),h},le.prototype[s+"Right"]=function(c){return this.reverse()[s](c).reverse()}}),kt(["filter","map","takeWhile"],function(s,l){var c=l+1,h=c==ur||c==Tn;le.prototype[s]=function(g){var _=this.clone();return _.__iteratees__.push({iteratee:G(g,3),type:c}),_.__filtered__=_.__filtered__||h,_}}),kt(["head","last"],function(s,l){var c="take"+(l?"Right":"");le.prototype[s]=function(){return this[c](1).value()[0]}}),kt(["initial","tail"],function(s,l){var c="drop"+(l?"":"Right");le.prototype[s]=function(){return this.__filtered__?new le(this):this[c](1)}}),le.prototype.compact=function(){return this.filter(ht)},le.prototype.find=function(s){return this.filter(s).head()},le.prototype.findLast=function(s){return this.reverse().find(s)},le.prototype.invokeMap=ne(function(s,l){return typeof s=="function"?new le(this):this.map(function(c){return ns(c,s,l)})}),le.prototype.reject=function(s){return this.filter(Ao(G(s)))},le.prototype.slice=function(s,l){s=Q(s);var c=this;return c.__filtered__&&(s>0||l<0)?new le(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),l!==t&&(l=Q(l),c=l<0?c.dropRight(-l):c.take(l-s)),c)},le.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},le.prototype.toArray=function(){return this.take(et)},Qt(le.prototype,function(s,l){var c=/^(?:filter|find|map|reject)|While$/.test(l),h=/^(?:head|last)$/.test(l),g=b[h?"take"+(l=="last"?"Right":""):l],_=h||/^find/.test(l);g&&(b.prototype[l]=function(){var w=this.__wrapped__,x=h?[1]:arguments,k=w instanceof le,M=x[0],I=k||Z(w),R=function(re){var ae=g.apply(b,In([re],x));return h&&B?ae[0]:ae};I&&c&&typeof M=="function"&&M.length!=1&&(k=I=!1);var B=this.__chain__,W=!!this.__actions__.length,j=_&&!B,te=k&&!W;if(!_&&I){w=te?w:new le(this);var J=s.apply(w,x);return J.__actions__.push({func:xo,args:[R],thisArg:t}),new At(J,B)}return j&&te?s.apply(this,x):(J=this.thru(R),j?h?J.value()[0]:J.value():J)})}),kt(["pop","push","shift","sort","splice","unshift"],function(s){var l=js[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",h=/^(?:pop|shift)$/.test(s);b.prototype[s]=function(){var g=arguments;if(h&&!this.__chain__){var _=this.value();return l.apply(Z(_)?_:[],g)}return this[c](function(w){return l.apply(Z(w)?w:[],g)})}}),Qt(le.prototype,function(s,l){var c=b[l];if(c){var h=c.name+"";ye.call(ri,h)||(ri[h]=[]),ri[h].push({name:l,func:c})}}),ri[go(t,N).name]=[{name:"wrapper",func:t}],le.prototype.clone=G1,le.prototype.reverse=j1,le.prototype.value=J1,b.prototype.at=Ev,b.prototype.chain=kv,b.prototype.commit=Cv,b.prototype.next=Av,b.prototype.plant=Tv,b.prototype.reverse=Mv,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Iv,b.prototype.first=b.prototype.head,Ji&&(b.prototype[Ji]=Ov),b},ei=C1();cr?((cr.exports=ei)._=ei,pa._=ei):Ve._=ei}).call(cs)}(ql,ql.exports);var $0=ql.exports;function Sf(n){return n.type.create($0.cloneDeep(n.attrs))}const qM=Re.create({name:"node_processor",addCommands(){return{setBlockAttributes:P(({commands:n,state:e},t,r,i={})=>{const o=F(n.getBlockAttributes(t))??{},{doc:a,tr:u}=e,{from:f,to:d}=u.selection;a.nodesBetween(f,d,(p,m)=>{ee.blocks.includes(p.type.name)&&u.setNodeAttribute(m,t,{...i,...o,...r})})}),getBlockAttributes:P(({editor:n},e,t)=>fe(()=>{let r=Object.assign({},t||{});for(const i of ee.blocks)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:P(({commands:n},e)=>{for(const t of ee.blocks)n.resetAttributes(t,e)}),applyMark:P(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:a,schema:u}=n,{$from:f,$to:d}=o.selection,p=sn(ce.LINK,u),m=sn(t,u);if(!(m.spec.group||"").includes(Jt.SETTINGS))return e.setMark(t,r);if(f.pos===d.pos)return;const v=S=>{if(!i.onAppliedToParent||i.onAppliedToParent(S)===!1){const{tr:C,node:O,position:N,mark:q}=S;e._removeNodeMark({tr:C,node:O,position:N,mark:q.type})}};a.nodesBetween(f.pos,d.pos,(S,C)=>{if(S.type.name===ee.LIST)return;const O=KM(S.marks,t),N=m.create({...O?.attrs||{},...r}),q=D0(f,d,S,C);if(!p.isInSet(S.marks)&&UM(o.doc,C,N,i.isAppliedToParent))return v({tr:o,node:S,position:C,mark:N});if(S.isText){o.addMark(q.from,q.to,N);return}VM(o.doc,o.selection,S,C)&&o.addNodeMark(C,N)})}),getMarks:P(({editor:n},e)=>{const t=hi(n,"state");return fe(()=>{const{selection:r,doc:i}=F(t),{from:o,to:a}=F(r),u=[];return i.nodesBetween(o,a,f=>{for(const d of f.marks)d.type.name===e&&u.unshift(d.attrs)}),u})}),getMark:P(({commands:n},e)=>{const t=n.getMarks(e);return fe(()=>F(t)[0]??null)}),hasMark:P(({commands:n},e)=>{const t=n.getMark(e);return fe(()=>!!F(t))}),getCommonSettingMark:P(({commands:n},e,t)=>{const r=n.getMark(e);return fe(()=>F(r)?.value??F(t))}),getDeviceSettingMark:P(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return fe(()=>{for(const o of F(r)){const a=o[F(i)];if(a)return a}return F(t)})}),removeAllMarks:P(({state:n,commands:e})=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(a,u)=>{for(const f of a.marks)e._removeNodeMark({tr:t,node:a,position:u,mark:f})})}),removeMarks:P(({state:n,commands:e},t)=>{const{tr:r,doc:i}=n,{from:o,to:a}=r.selection;i.nodesBetween(o,a,(u,f)=>{const d=u.marks.filter(p=>t.includes(p.type.name));for(const p of d)e._removeNodeMark({tr:r,node:u,position:f,mark:p})})}),_removeNodeMark:P((n,{tr:e,node:t,position:r,mark:i})=>t.isText?e.removeMark(r,r+t.nodeSize,i):e.removeNodeMark(r,i))}}}),GM=Re.create({name:"text_processor",addCommands(){return{getSelectedText:P(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:P(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const a=D0(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)}),p=n.schema.text(d,i.marks);n.tr.replaceWith(a.from,a.to,p)})})}}}),jM=Re.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:P(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:P(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:P(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;n.doc.nodesBetween(r,i,(o,a,u)=>{if(t({node:o,parent:u})){const f=o.isText?0:F0(n.doc,a);r=Math.min(r,a+f),i=Math.max(i,a+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:P(({commands:n})=>{n.expandSelection(({parent:e})=>e.type.name===ee.DOCUMENT)})}}}),JM=On.create({name:"doc",topNode:!0,content:"block+"});class Fs extends Xe{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=Or.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,Le.ok(t)}invert(){return new Fs(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 Fs(e.key,e.value,e.stepType)}}Xe.jsonID("setDocAttr",Fs);const YM=JM.extend({marks:Jt.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:P(({state:n},e,t)=>{n.tr.step(new Fs(e,t,n.schema))})}}}),XM=On.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Ci(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ZM=XM.extend({marks:Jt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),QM=On.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]}`,Ci(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=>$T({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),eI=QM.extend({marks:Jt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),tI=Re.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[XT.create(this.editor),ZT.create(this.editor)]}}),nI=()=>[YM,ZM,eI,zT,YT,qM,GM,jM,tI],rI=xt.create({name:ce.FONT_FAMILY,group:Jt.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:P(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=F(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ce.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:P(({commands:n})=>{const e=F(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return fe(()=>n.findFontByName(F(r))||t)}),findFontByName:P((n,e)=>F(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(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 $r({font_family:e})}}),iI=Re.create({name:ce.STYLE_PRESET,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{preset:{isRequired:!1,default:{id:F(this.options.defaultId)},parseHTML:n=>{const e=F(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=F(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:F(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:F(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const a=t[o],u=r[o],f=!u||u.toLowerCase()==="inherit";i[o]=f?a:u}return i}return{getPresetList:P(()=>fe(()=>F(this.options.presets).filter(t=>!t.hidden))),getPreset:P(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:F(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),a=t.getLinkPreset();return fe(()=>{const u=n(F(i),F(r).id);if(!F(o))return u;const f=F(a);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:P(({commands:t,chain:r},i)=>{const o=F(t.getPresetList()),a=n(o,i),u=a.node?.type??ee.PARAGRAPH,f={preset:{id:i}};a.node&&(f.level=a.node.level);for(const d of ce.attributes)f[d]=F(t.getBlockAttributes(d));r().removeList().setNode(u,f).run()}),applyDefaultPreset:P(({commands:t})=>{t.applyPreset(F(this.options.defaultId))}),removePreset:P(({commands:t})=>{t.setNode(ee.PARAGRAPH,{preset:null})}),getPresetCustomization:P(({editor:t,commands:r})=>{const i=hi(t,"state");return fe(()=>{const{selection:o,doc:a}=F(i),{from:u,to:f}=o;return r._getSettingCustomization(a,u,f)})}),isSettingCustomized:P(({commands:t},r)=>{const i=t.getPresetCustomization(),o=ce.presetAttributes.includes(r)?"attributes":"marks";return fe(()=>F(i)[o]?.includes(r)??!1)}),getContentCustomization:P(({editor:t,commands:r})=>{const i=hi(t,"state");return fe(()=>{const{doc:o}=F(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:P((t,r,i,o)=>{const a=new Set,u=new Set;return r.nodesBetween(i,o,f=>{for(const[d,p]of Object.entries(f.attrs))ce.presetAttributes.includes(d)&&p&&u.add(d);for(const{type:d}of f.marks)ce.marks.includes(d.name)&&a.add(d.name)}),{attributes:Array.from(u),marks:Array.from(a)}}),removePresetCustomization:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(ce.marks).resetAttributes(ee.PARAGRAPH,ce.presetAttributes).resetAttributes(ee.HEADING,ce.presetAttributes).restoreSelection().run()}),removeFormat:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Li.head,F(this.options.presets))}}),sI=xt.create({name:ce.FONT_WEIGHT,group:Jt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:P(({commands:n},e)=>{n.applyMark(this.name,{value:e}),F(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:P(({commands:n})=>{const e=F(n.getFontWeight()),t=F(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:P(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return fe(()=>{const r=F(e),i=F(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Dt("toggleBold"),"Mod-B":Dt("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 $r({font_weight:n.value})}}),oI=xt.create({name:ce.FONT_SIZE,group:Jt.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:P(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].font_size.replace("px",""))}),applyFontSize:P(({commands:n},e)=>{const t=F(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:a})=>{const u={...a.attrs,[t]:null};if(!Object.values(u).some(p=>!!p))return!1;const d=a.type.create(u);if(i.isText){r.addMark(o,o+i.nodeSize,d);return}r.addNodeMark(o,d)}})}),increaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.min(e+1,F(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.max(e-1,F(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Dt("increaseFontSize"),"Mod-Shift--":Dt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=F(this.options.wrapperRef),r=P0(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 $r({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),lI=xt.create({name:ce.FONT_COLOR,group:Jt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.color)}),applyFontColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:L0(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return $r({font_color:n.value})}}),aI=xt.create({name:ce.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:P(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:L0(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return $r({background_color:n.value})}}),uI=Re.create({name:"device_manager",addCommands(){return{getDevice:P(()=>hi(this.options,"device"))}}}),cI=xt.create({name:ce.FONT_STYLE,group:Jt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return fe(()=>F(e)?.italic??F(t).italic)}),isItalicAvailable:P(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return fe(()=>{const r=F(e),i=F(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:P(({commands:n})=>{const e=n.getPreset();return fe(()=>({italic:F(e).common.font_style==="italic"}))}),toggleItalic:P(({commands:n})=>{F(n.isItalicAvailable())&&(F(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Dt("toggleItalic"),"Mod-I":Dt("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 $r({font_style:e})}}),fI=xt.create({name:ce.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).underline)}),isStrikeThrough:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).strike_through)}),getTextDecoration:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return fe(()=>{const r=F(e)??{},i=F(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:P(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return fe(()=>F(e)!==F(t).underline)}),getDefaultTextDecoration:P(({commands:n})=>{const e=n.getPreset();return fe(()=>{const{text_decoration:t}=F(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:P(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:P(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:P(({commands:n},e,t=null)=>{const r=F(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Dt("toggleUnderline"),"Mod-U":Dt("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"),$r({text_decoration:e.join(" ")})}}),hI=Re.create({name:"case_style",addCommands(){return{applyCaseStyle:P(({commands:n},e)=>{switch(e){case jc.CAPITALIZE:return n.applyCapitalize();case jc.LOWERCASE:return n.applyLowerCase();case jc.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:P(({commands:n})=>{n.transformText(({text:e})=>_M(e))}),applyLowerCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),B0={mobile:null,tablet:null,desktop:null},dI=Re.create({name:ce.ALIGNMENT,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=zM(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?Kl({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},B0)}),removeAlignment:P(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,B0),t=n.getDevice(),r=n.getDefaultAlignment();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultAlignment:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].alignment??er.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Dt("applyAlignment",er.LEFT),"Mod-Shift-e":Dt("applyAlignment",er.CENTER),"Mod-Shift-r":Dt("applyAlignment",er.RIGHT),"Mod-Shift-j":Dt("applyAlignment",er.JUSTIFY)})}),H0={mobile:null,tablet:null,desktop:null},pI=Re.create({name:ce.LINE_HEIGHT,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=F(this.options.wrapperRef),r=BM(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?Kl({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:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,H0),t=n.getDevice(),r=n.getDefaultLineHeight();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultLineHeight:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].line_height)}),applyLineHeight:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},H0)})}}}),mI=On.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ci(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)}}}),gI=mI.extend({name:ee.LIST_ITEM,marks:Jt.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:P(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const a of r.marks)t.addNodeMark(o,Sf(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===ee.LIST))return t.listItemNewline()}})}),yI=On.create({name:ee.LIST,content:`${ee.LIST_ITEM}+`,group:"block list",marks:Jt.SETTINGS,addExtensions:()=>[gI],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:Lt.DISC}}}),parseHTML(){const n={a:Lt.ROMAN,i:Lt.LATIN,1:Lt.DECIMAL},e=t=>{for(const r of Lt.values){const i=`.${F(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||Lt.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||Lt.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[F(this.options.baseClass)+n.bullet.type,F(this.options.presetClass)];return[Lt.ordered.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:P(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return fe(()=>F(e).type??null)}),applyList:P(({commands:n,chain:e},t)=>{if(F(n.getListType())===t){n.removeList();return}return e().applyDefaultPreset().toggleList(ee.LIST,ee.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({commands:i,tr:o})=>i._bubbleListItemMarks(o)).run()}),_bubbleListItemMarks:P((n,e)=>{const{doc:t,selection:r}=e,i=r.$from.start(),o=r.$to.end();function a(u,f){if(ce.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===ee.LIST)return;if(u.type.name!==ee.LIST_ITEM)return!1;const d=[];return u.forEach(p=>{for(const m of p.marks){if(m.isInSet(d)){e.removeNodeMark(f+1,m);continue}a(u,m)&&(e.removeNodeMark(f+1,m),e.addNodeMark(f,Sf(m)),d.push(m))}}),!1})}),removeList:P(({commands:n,state:e})=>{const{tr:t,doc:r,selection:i}=e,o=i.$from.start(),a=i.$to.end();r.nodesBetween(o,a,(u,f,d)=>{if([ee.LIST,ee.LIST_ITEM].includes(u.type.name))return;if(d.type.name!==ee.LIST_ITEM)return!1;const p=d.marks.filter(function(m){return!m.type.isInSet(u.marks)});for(const m of p)t.addNodeMark(f,Sf(m));return!1}),n.liftListItem(ee.LIST_ITEM)})}},addInputRules(){const n=(e,t)=>BT({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(Lt.DISC,/^\s*([-+*])\s$/),n(Lt.DECIMAL,/^(\d+)\.\s$/),n(Lt.LATIN,/^([ivx]{1,3})\.\s$/i),n(Lt.ROMAN,/^([a-z])\.\s$/i)]}});function bI(n){return new wt({key:new Gt("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:a}=r,u=lT(t.doc,[...e]);if(gT(u).forEach(({newRange:d})=>{const p=uT(r.doc,d,v=>v.isTextblock);let m,y;if(p.length>1?(m=p[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ")):p.length&&r.doc.textBetween(d.from,d.to," "," ").endsWith(" ")&&(m=p[0],y=r.doc.textBetween(m.pos,d.to,void 0," ")),m&&y){const v=y.split(" ").filter(O=>O!=="");if(v.length<=0)return!1;const S=v[v.length-1],C=m.pos+y.lastIndexOf(S);if(!S)return!1;mf(S).filter(O=>O.isLink).map(O=>({...O,from:C+O.start+1,to:C+O.end+1})).filter(O=>r.schema.marks.code?!r.doc.rangeHasMark(O.from,O.to,r.schema.marks.code):!0).filter(O=>n.validate?n.validate(O.value):!0).forEach(O=>{t0(O.from,O.to,r.doc).some(N=>N.mark.type===n.type)||a.addMark(O.from,O.to,n.type.create({href:O.href}))})}}),!!a.steps.length)return a}})}function _I(n){return new wt({key:new Gt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||r.target.nodeName!=="A")return!1;const u=dT(e.state,n.type.name),f=r.target,d=(i=f?.href)!==null&&i!==void 0?i:u.href,p=(o=f?.target)!==null&&o!==void 0?o:u.target;return f&&d?(e.editable&&window.open(d,p),!0):!1}}})}function vI(n){return new wt({key:new Gt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:o}=e,{selection:a}=o,{empty:u}=a;if(u)return!1;let f="";r.content.forEach(S=>{f+=S.textContent});const d=mf(f).find(S=>S.isLink&&S.value===f);if(!f||!d)return!1;const p=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),m=/href="([^"]*)"/,y=p?.match(m),v=y?y[1]:d.href;return n.editor.commands.setMark(n.type,{href:v}),!0}}})}const wI=xt.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){k0(n);return}k0(n.scheme,n.optionalSlashes)})},onDestroy(){mM()},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",Ci(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Ci(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[HT({find:n=>mf(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="([^"]*)"/,a=i?.match(o);return a?{href:a[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(bI({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(_I({type:this.type})),this.options.linkOnPaste&&n.push(vI({editor:this.editor,type:this.type})),n}}),SI=wI.extend({name:ce.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:f0.SELF,parseHTML:n=>n.getAttribute("target")||f0.SELF},destination:{default:Os.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return Os.URL;const t=e.replace("#","");return F(this.options.pageBlocks).find(o=>o.id===parseInt(t))?Os.BLOCK:Os.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:P(({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(V0.text(r.text,[V0.mark(ce.LINK,r)])))),expandSelectionToLink:P(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:P(({commands:e})=>e.hasMark(this.name)),getLinkPreset:P(()=>fe(()=>F(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),bM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===Os.BLOCK?`#${n.href}`:n.href,t=F(this.options.basePresetClass)+F(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),xI=xt.create({name:ce.SUPERSCRIPT,addCommands(){return{applySuperscript:P(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:P(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:P(({commands:n})=>{F(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:P(({commands:n})=>{const e=n.getMark(this.name);return fe(()=>!!F(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),EI=Re.create({name:ce.MARGIN,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?Kl({margin:n.margin.value}):null}}}}]});function kI(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=Fu({default:null,link:null});return _k(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),nI().concat([iI.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new OI({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),yI.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),uI.configure({device:n.deviceRef}),oI.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),rI.configure({fonts:n.fonts,defaultPreset:hi(t,"default"),defaultFont:n.defaultFont}),sI,lI,aI,cI,fI,hI,xI,dI,pI.configure({wrapperRef:n.wrapperRef}),SI.configure({preset:hi(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),EI])}class CI{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class z0{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class fn extends z0{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=fn.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const a=u=>{this._assignElementProperties(u,e,fn.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,fn.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){a(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),a(f),i=null,o=u;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(u),o=u}e.append(t),this._removeStyleProperties(e,fn.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,fn.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return fn.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return fn.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const a=u=>{this._assignElementProperties(u,e,fn.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){a(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),a={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,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 AI extends z0{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!==ee.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(ce.inlineMarks.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===ee.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>$0.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===ee.TEXT&&this._includesMarkType(e,ce.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Yl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new fn({content:e,parser:t.parser||new CI})}static _buildJson(e){return new AI({content:e})}static normalize(e,t={}){return Yl.build(e,t).normalize()}}class Li{static window=globalThis.window;static use(e){this.window=e}static get document(){return this.window.document}static get body(){return this.document.body}static get head(){return this.document.head}static getComputedStyle(e){return this.window.getComputedStyle(e)}}class Tf{static build({config:e,nodeDomParser:t}){const r=kI({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:Wo(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:Wo(Gc.DESKTOP),pageBlocksRef:Wo([]),wrapperRef:Li.document.createElement("p")}),i=fT(r);return new Tf({schema:i,domParser:tc.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=Yl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}class V0{static doc(e){return{type:ee.DOCUMENT,content:e}}static list(e,t){return{type:ee.LIST,attrs:{bullet:{type:e}},content:t.map(r=>r.type===ee.LIST_ITEM?r:this.listItem([].concat(r)))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{type:ee.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:ee.HEADING,...r}}static paragraph(...e){return{type:ee.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:ee.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ce.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class OI{_baseClass;_makeVariable;_linkPresetId;constructor({baseClass:e,makeVariable:t,linkPresetId:r}){this._baseClass=e,this._makeVariable=t,this._linkPresetId=r}inject(e,t){let r=e.querySelector("[data-zw-styles]");r||(r=Li.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const a of Gc.values)for(const u of Object.keys(r[a])){const f=this._makeVariable({device:a,preset:r,property:u}),d=this._makeInternalVariableName(u,a);if(t+=`${d}: var(${f}, inherit);`,i&&!ce.attributes.includes(u)){const p=d.replace("preset-","");t+=`${p}: var(${d});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===Gc.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 Mf{static _instance;static get instance(){return this._instance??=new Mf,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 W0{static createWindow(){return new ap.JSDOM().window}types;parse(e){const{window:t}=new ap.JSDOM(e);return this.types=t,t.document}}class U0{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 TI extends U0{name="to-json";description="migrate html to json";argument="<html...>";options=[{flags:"-c, --config <path>",description:"Generator config",default:_u.resolve(__dirname,"../bin/zp.config.json")},{flags:"-f, --format <type>",description:"Set output format",default:"rb"}];doCommand(e,{config:t,format:r}){Li.use(W0.createWindow());const i=_u.resolve(process.cwd(),t),o=Tf.build({config:require(i).editor,nodeDomParser:new W0}),a=e.map(d=>o.toJSON(this._formatInputHtml(d))),u=a.length===1?a[0]:a,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 MI="4.5.0-0";class II extends U0{name="version";description="display cli version";doCommand(){this.output(MI)}}const K0=new sE,NI=[TI,II];for(const n of NI)new n().install(K0);K0.parse();
package/dist/node.js CHANGED
@@ -37,4 +37,4 @@ __p += '`),ae&&(R+=`' +
37
37
  function print() { __p += __j.call(arguments, '') }
38
38
  `:`;
39
39
  `)+R+`return __p
40
- }`;var te=qh(function(){return me(v,U+"return "+R).apply(t,w)});if(te.source=R,nu(te))throw te;return te}function m_(s){return ge(s).toLowerCase()}function g_(s){return ge(s).toUpperCase()}function y_(s,l,c){if(s=ge(s),s&&(c||l===t))return nd(s);if(!s||!(l=gt(l)))return s;var d=Bt(s),g=Bt(l),v=rd(d,g),w=id(d,g)+1;return Ln(d,v,w).join("")}function b_(s,l,c){if(s=ge(s),s&&(c||l===t))return s.slice(0,od(s)+1);if(!s||!(l=gt(l)))return s;var d=Bt(s),g=id(d,Bt(l))+1;return Ln(d,0,g).join("")}function v_(s,l,c){if(s=ge(s),s&&(c||l===t))return s.replace(na,"");if(!s||!(l=gt(l)))return s;var d=Bt(s),g=rd(d,Bt(l));return Ln(d,g).join("")}function S_(s,l){var c=Kl,d=Di;if(ke(l)){var g="separator"in l?l.separator:g;c="length"in l?Q(l.length):c,d="omission"in l?gt(l.omission):d}s=ge(s);var v=s.length;if(jr(s)){var w=Bt(s);v=w.length}if(c>=v)return s;var _=c-Yr(d);if(_<1)return d;var E=w?Ln(w,0,_).join(""):s.slice(0,_);if(g===t)return E+d;if(w&&(_+=E.length-_),ru(g)){if(s.slice(_).search(g)){var O,I=E;for(g.global||(g=va(g.source,ge(kf.exec(g))+"g")),g.lastIndex=0;O=g.exec(I);)var R=O.index;E=E.slice(0,R===t?_:R)}}else if(s.indexOf(gt(g),_)!=_){var z=E.lastIndexOf(g);z>-1&&(E=E.slice(0,z))}return E+d}function w_(s){return s=ge(s),s&&N0.test(s)?s.replace(wf,Yy):s}var __=ri(function(s,l,c){return s+(c?" ":"")+l.toUpperCase()}),ou=Jd("toUpperCase");function Gh(s,l,c){return s=ge(s),l=c?t:l,l===t?Ky(s)?Qy(s):Dy(s):s.match(l)||[]}var qh=ne(function(s,l){try{return pt(s,t,l)}catch(c){return nu(c)?c:new X(c)}}),x_=bn(function(s,l){return kt(l,function(c){c=Qt(c),gn(s,c,eu(s[c],s))}),s});function k_(s){var l=s==null?0:s.length,c=q();return s=l?_e(s,function(d){if(typeof d[1]!="function")throw new Et(a);return[c(d[0]),d[1]]}):[],ne(function(d){for(var g=-1;++g<l;){var v=s[g];if(pt(v[0],this,d))return pt(v[1],this,d)}})}function E_(s){return Y1(Ct(s,p))}function lu(s){return function(){return s}}function T_(s,l){return s==null||s!==s?l:s}var C_=Yd(),A_=Yd(!0);function ft(s){return s}function au(s){return Td(typeof s=="function"?s:Ct(s,p))}function M_(s){return Ad(Ct(s,p))}function O_(s,l){return Md(s,Ct(l,p))}var I_=ne(function(s,l){return function(c){return Zi(c,s,l)}}),N_=ne(function(s,l){return function(c){return Zi(s,c,l)}});function uu(s,l,c){var d=De(l),g=so(l,d);c==null&&!(ke(l)&&(g.length||!d.length))&&(c=l,l=s,s=this,g=so(l,De(l)));var v=!(ke(c)&&"chain"in c)||!!c.chain,w=Sn(s);return kt(g,function(_){var E=l[_];s[_]=E,w&&(s.prototype[_]=function(){var O=this.__chain__;if(v||O){var I=s(this.__wrapped__),R=I.__actions__=at(this.__actions__);return R.push({func:E,args:arguments,thisArg:s}),I.__chain__=O,I}return E.apply(s,An([this.value()],arguments))})}),s}function R_(){return $e._===this&&($e._=s1),this}function cu(){}function L_(s){return s=Q(s),ne(function(l){return Od(l,s)})}var P_=$a(_e),D_=$a(Xf),F_=$a(da);function Jh(s){return Ja(s)?ha(Qt(s)):hb(s)}function B_(s){return function(l){return s==null?t:dr(s,l)}}var z_=Zd(),H_=Zd(!0);function fu(){return[]}function du(){return!1}function $_(){return{}}function W_(){return""}function U_(){return!0}function V_(s,l){if(s=Q(s),s<1||s>qe)return[];var c=Qe,d=Je(s,Qe);l=q(l),s-=Qe;for(var g=ga(d,l);++c<s;)l(c);return g}function K_(s){return Z(s)?_e(s,Qt):yt(s)?[s]:at(ph(ge(s)))}function G_(s){var l=++r1;return ge(s)+l}var q_=fo(function(s,l){return s+l},0),J_=Wa("ceil"),j_=fo(function(s,l){return s/l},1),Y_=Wa("floor");function X_(s){return s&&s.length?io(s,ft,Ca):t}function Z_(s,l){return s&&s.length?io(s,q(l,2),Ca):t}function Q_(s){return ed(s,ft)}function ex(s,l){return ed(s,q(l,2))}function tx(s){return s&&s.length?io(s,ft,Ia):t}function nx(s,l){return s&&s.length?io(s,q(l,2),Ia):t}var rx=fo(function(s,l){return s*l},1),ix=Wa("round"),sx=fo(function(s,l){return s-l},0);function ox(s){return s&&s.length?ma(s,ft):0}function lx(s,l){return s&&s.length?ma(s,q(l,2)):0}return y.after=MS,y.ary=Eh,y.assign=gw,y.assignIn=zh,y.assignInWith=Eo,y.assignWith=yw,y.at=bw,y.before=Th,y.bind=eu,y.bindAll=x_,y.bindKey=Ch,y.castArray=$S,y.chain=_h,y.chunk=Yb,y.compact=Xb,y.concat=Zb,y.cond=k_,y.conforms=E_,y.constant=lu,y.countBy=oS,y.create=vw,y.curry=Ah,y.curryRight=Mh,y.debounce=Oh,y.defaults=Sw,y.defaultsDeep=ww,y.defer=OS,y.delay=IS,y.difference=Qb,y.differenceBy=ev,y.differenceWith=tv,y.drop=nv,y.dropRight=rv,y.dropRightWhile=iv,y.dropWhile=sv,y.fill=ov,y.filter=aS,y.flatMap=fS,y.flatMapDeep=dS,y.flatMapDepth=hS,y.flatten=bh,y.flattenDeep=lv,y.flattenDepth=av,y.flip=NS,y.flow=C_,y.flowRight=A_,y.fromPairs=uv,y.functions=Aw,y.functionsIn=Mw,y.groupBy=pS,y.initial=fv,y.intersection=dv,y.intersectionBy=hv,y.intersectionWith=pv,y.invert=Iw,y.invertBy=Nw,y.invokeMap=gS,y.iteratee=au,y.keyBy=yS,y.keys=De,y.keysIn=ct,y.map=vo,y.mapKeys=Lw,y.mapValues=Pw,y.matches=M_,y.matchesProperty=O_,y.memoize=wo,y.merge=Dw,y.mergeWith=Hh,y.method=I_,y.methodOf=N_,y.mixin=uu,y.negate=_o,y.nthArg=L_,y.omit=Fw,y.omitBy=Bw,y.once=RS,y.orderBy=bS,y.over=P_,y.overArgs=LS,y.overEvery=D_,y.overSome=F_,y.partial=tu,y.partialRight=Ih,y.partition=vS,y.pick=zw,y.pickBy=$h,y.property=Jh,y.propertyOf=B_,y.pull=bv,y.pullAll=Sh,y.pullAllBy=vv,y.pullAllWith=Sv,y.pullAt=wv,y.range=z_,y.rangeRight=H_,y.rearg=PS,y.reject=_S,y.remove=_v,y.rest=DS,y.reverse=Za,y.sampleSize=kS,y.set=$w,y.setWith=Ww,y.shuffle=ES,y.slice=xv,y.sortBy=AS,y.sortedUniq=Ov,y.sortedUniqBy=Iv,y.split=f_,y.spread=FS,y.tail=Nv,y.take=Rv,y.takeRight=Lv,y.takeRightWhile=Pv,y.takeWhile=Dv,y.tap=Xv,y.throttle=BS,y.thru=bo,y.toArray=Dh,y.toPairs=Wh,y.toPairsIn=Uh,y.toPath=K_,y.toPlainObject=Bh,y.transform=Uw,y.unary=zS,y.union=Fv,y.unionBy=Bv,y.unionWith=zv,y.uniq=Hv,y.uniqBy=$v,y.uniqWith=Wv,y.unset=Vw,y.unzip=Qa,y.unzipWith=wh,y.update=Kw,y.updateWith=Gw,y.values=oi,y.valuesIn=qw,y.without=Uv,y.words=Gh,y.wrap=HS,y.xor=Vv,y.xorBy=Kv,y.xorWith=Gv,y.zip=qv,y.zipObject=Jv,y.zipObjectDeep=jv,y.zipWith=Yv,y.entries=Wh,y.entriesIn=Uh,y.extend=zh,y.extendWith=Eo,uu(y,y),y.add=q_,y.attempt=qh,y.camelCase=Xw,y.capitalize=Vh,y.ceil=J_,y.clamp=Jw,y.clone=WS,y.cloneDeep=VS,y.cloneDeepWith=KS,y.cloneWith=US,y.conformsTo=GS,y.deburr=Kh,y.defaultTo=T_,y.divide=j_,y.endsWith=Zw,y.eq=Ht,y.escape=Qw,y.escapeRegExp=e_,y.every=lS,y.find=uS,y.findIndex=gh,y.findKey=_w,y.findLast=cS,y.findLastIndex=yh,y.findLastKey=xw,y.floor=Y_,y.forEach=xh,y.forEachRight=kh,y.forIn=kw,y.forInRight=Ew,y.forOwn=Tw,y.forOwnRight=Cw,y.get=iu,y.gt=qS,y.gte=JS,y.has=Ow,y.hasIn=su,y.head=vh,y.identity=ft,y.includes=mS,y.indexOf=cv,y.inRange=jw,y.invoke=Rw,y.isArguments=mr,y.isArray=Z,y.isArrayBuffer=jS,y.isArrayLike=ut,y.isArrayLikeObject=Ce,y.isBoolean=YS,y.isBuffer=Pn,y.isDate=XS,y.isElement=ZS,y.isEmpty=QS,y.isEqual=ew,y.isEqualWith=tw,y.isError=nu,y.isFinite=nw,y.isFunction=Sn,y.isInteger=Nh,y.isLength=xo,y.isMap=Rh,y.isMatch=rw,y.isMatchWith=iw,y.isNaN=sw,y.isNative=ow,y.isNil=aw,y.isNull=lw,y.isNumber=Lh,y.isObject=ke,y.isObjectLike=Te,y.isPlainObject=is,y.isRegExp=ru,y.isSafeInteger=uw,y.isSet=Ph,y.isString=ko,y.isSymbol=yt,y.isTypedArray=si,y.isUndefined=cw,y.isWeakMap=fw,y.isWeakSet=dw,y.join=mv,y.kebabCase=t_,y.last=Mt,y.lastIndexOf=gv,y.lowerCase=n_,y.lowerFirst=r_,y.lt=hw,y.lte=pw,y.max=X_,y.maxBy=Z_,y.mean=Q_,y.meanBy=ex,y.min=tx,y.minBy=nx,y.stubArray=fu,y.stubFalse=du,y.stubObject=$_,y.stubString=W_,y.stubTrue=U_,y.multiply=rx,y.nth=yv,y.noConflict=R_,y.noop=cu,y.now=So,y.pad=i_,y.padEnd=s_,y.padStart=o_,y.parseInt=l_,y.random=Yw,y.reduce=SS,y.reduceRight=wS,y.repeat=a_,y.replace=u_,y.result=Hw,y.round=ix,y.runInContext=k,y.sample=xS,y.size=TS,y.snakeCase=c_,y.some=CS,y.sortedIndex=kv,y.sortedIndexBy=Ev,y.sortedIndexOf=Tv,y.sortedLastIndex=Cv,y.sortedLastIndexBy=Av,y.sortedLastIndexOf=Mv,y.startCase=d_,y.startsWith=h_,y.subtract=sx,y.sum=ox,y.sumBy=lx,y.template=p_,y.times=V_,y.toFinite=wn,y.toInteger=Q,y.toLength=Fh,y.toLower=m_,y.toNumber=Ot,y.toSafeInteger=mw,y.toString=ge,y.toUpper=g_,y.trim=y_,y.trimEnd=b_,y.trimStart=v_,y.truncate=S_,y.unescape=w_,y.uniqueId=G_,y.upperCase=__,y.upperFirst=ou,y.each=xh,y.eachRight=kh,y.first=vh,uu(y,function(){var s={};return Xt(y,function(l,c){ye.call(y.prototype,c)||(s[c]=l)}),s}(),{chain:!1}),y.VERSION=r,kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){y[s].placeholder=y}),kt(["drop","take"],function(s,l){le.prototype[s]=function(c){c=c===t?1:Pe(Q(c),0);var d=this.__filtered__&&!l?new le(this):this.clone();return d.__filtered__?d.__takeCount__=Je(c,d.__takeCount__):d.__views__.push({size:Je(c,Qe),type:s+(d.__dir__<0?"Right":"")}),d},le.prototype[s+"Right"]=function(c){return this.reverse()[s](c).reverse()}}),kt(["filter","map","takeWhile"],function(s,l){var c=l+1,d=c==or||c==Tn;le.prototype[s]=function(g){var v=this.clone();return v.__iteratees__.push({iteratee:q(g,3),type:c}),v.__filtered__=v.__filtered__||d,v}}),kt(["head","last"],function(s,l){var c="take"+(l?"Right":"");le.prototype[s]=function(){return this[c](1).value()[0]}}),kt(["initial","tail"],function(s,l){var c="drop"+(l?"":"Right");le.prototype[s]=function(){return this.__filtered__?new le(this):this[c](1)}}),le.prototype.compact=function(){return this.filter(ft)},le.prototype.find=function(s){return this.filter(s).head()},le.prototype.findLast=function(s){return this.reverse().find(s)},le.prototype.invokeMap=ne(function(s,l){return typeof s=="function"?new le(this):this.map(function(c){return Zi(c,s,l)})}),le.prototype.reject=function(s){return this.filter(_o(q(s)))},le.prototype.slice=function(s,l){s=Q(s);var c=this;return c.__filtered__&&(s>0||l<0)?new le(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),l!==t&&(l=Q(l),c=l<0?c.dropRight(-l):c.take(l-s)),c)},le.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},le.prototype.toArray=function(){return this.take(Qe)},Xt(le.prototype,function(s,l){var c=/^(?:filter|find|map|reject)|While$/.test(l),d=/^(?:head|last)$/.test(l),g=y[d?"take"+(l=="last"?"Right":""):l],v=d||/^find/.test(l);g&&(y.prototype[l]=function(){var w=this.__wrapped__,_=d?[1]:arguments,E=w instanceof le,O=_[0],I=E||Z(w),R=function(re){var ae=g.apply(y,An([re],_));return d&&z?ae[0]:ae};I&&c&&typeof O=="function"&&O.length!=1&&(E=I=!1);var z=this.__chain__,U=!!this.__actions__.length,J=v&&!z,te=E&&!U;if(!v&&I){w=te?w:new le(this);var j=s.apply(w,_);return j.__actions__.push({func:bo,args:[R],thisArg:t}),new Tt(j,z)}return J&&te?s.apply(this,_):(j=this.thru(R),J?d?j.value()[0]:j.value():j)})}),kt(["pop","push","shift","sort","splice","unshift"],function(s){var l=Us[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",d=/^(?:pop|shift)$/.test(s);y.prototype[s]=function(){var g=arguments;if(d&&!this.__chain__){var v=this.value();return l.apply(Z(v)?v:[],g)}return this[c](function(w){return l.apply(Z(w)?w:[],g)})}}),Xt(le.prototype,function(s,l){var c=y[l];if(c){var d=c.name+"";ye.call(ei,d)||(ei[d]=[]),ei[d].push({name:l,func:c})}}),ei[co(t,N).name]=[{name:"wrapper",func:t}],le.prototype.clone=w1,le.prototype.reverse=_1,le.prototype.value=x1,y.prototype.at=Zv,y.prototype.chain=Qv,y.prototype.commit=eS,y.prototype.next=tS,y.prototype.plant=rS,y.prototype.reverse=iS,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=sS,y.prototype.first=y.prototype.head,Ki&&(y.prototype[Ki]=nS),y},Xr=e1();lr?((lr.exports=Xr)._=Xr,aa._=Xr):$e._=Xr}).call(Os)}(Hl,Hl.exports);var g0=Hl.exports;function cf(n){return n.type.create(g0.cloneDeep(n.attrs))}const JM=Ne.create({name:"node_processor",addCommands(){return{setBlockAttributes:P(({commands:n,state:e},t,r,i={})=>{const o=F(n.getBlockAttributes(t))??{},{doc:a,tr:u}=e,{from:f,to:h}=u.selection;a.nodesBetween(f,h,(m,p)=>{ee.blocks.includes(m.type.name)&&u.setNodeAttribute(p,t,{...i,...o,...r})})}),getBlockAttributes:P(({editor:n},e,t)=>fe(()=>{let r=Object.assign({},t||{});for(const i of ee.blocks)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:P(({commands:n},e)=>{for(const t of ee.blocks)n.resetAttributes(t,e)}),applyMark:P(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:a,schema:u}=n,{$from:f,$to:h}=o.selection,m=nn(ce.LINK,u),p=nn(t,u);if(!(p.spec.group||"").includes(qt.SETTINGS))return e.setMark(t,r);if(f.pos===h.pos)return;const S=x=>{if(!i.onAppliedToParent||i.onAppliedToParent(x)===!1){const{tr:C,node:A,position:N,mark:G}=x;e._removeNodeMark({tr:C,node:A,position:N,mark:G.type})}};a.nodesBetween(f.pos,h.pos,(x,C)=>{if(x.type.name===ee.LIST)return;const A=qM(x.marks,t),N=p.create({...A?.attrs||{},...r}),G=p0(f,h,x,C);if(!m.isInSet(x.marks)&&GM(o.doc,C,N,i.isAppliedToParent))return S({tr:o,node:x,position:C,mark:N});if(x.isText){o.addMark(G.from,G.to,N);return}VM(o.doc,o.selection,x,C)&&o.addNodeMark(C,N)})}),getMarks:P(({editor:n},e)=>{const t=ai(n,"state");return fe(()=>{const{selection:r,doc:i}=F(t),{from:o,to:a}=F(r),u=[];return i.nodesBetween(o,a,f=>{for(const h of f.marks)h.type.name===e&&u.unshift(h.attrs)}),u})}),getMark:P(({commands:n},e)=>{const t=n.getMarks(e);return fe(()=>F(t)[0]??null)}),hasMark:P(({commands:n},e)=>{const t=n.getMark(e);return fe(()=>!!F(t))}),getCommonSettingMark:P(({commands:n},e,t)=>{const r=n.getMark(e);return fe(()=>F(r)?.value??F(t))}),getDeviceSettingMark:P(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return fe(()=>{for(const o of F(r)){const a=o[F(i)];if(a)return a}return F(t)})}),removeAllMarks:P(({state:n,commands:e})=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(a,u)=>{for(const f of a.marks)e._removeNodeMark({tr:t,node:a,position:u,mark:f})})}),removeMarks:P(({state:n,commands:e},t)=>{const{tr:r,doc:i}=n,{from:o,to:a}=r.selection;i.nodesBetween(o,a,(u,f)=>{const h=u.marks.filter(m=>t.includes(m.type.name));for(const m of h)e._removeNodeMark({tr:r,node:u,position:f,mark:m})})}),_removeNodeMark:P((n,{tr:e,node:t,position:r,mark:i})=>t.isText?e.removeMark(r,r+t.nodeSize,i):e.removeNodeMark(r,i))}}}),jM=Ne.create({name:"text_processor",addCommands(){return{getSelectedText:P(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:P(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const a=p0(t,r,i,o),u=Math.max(0,t.pos-o),f=Math.max(0,r.pos-o),h=e({text:i.textContent.substring(u,f)}),m=n.schema.text(h,i.marks);n.tr.replaceWith(a.from,a.to,m)})})}}}),YM=Ne.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:P(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:P(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:P(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;n.doc.nodesBetween(r,i,(o,a,u)=>{if(t({node:o,parent:u})){const f=o.isText?0:m0(n.doc,a);r=Math.min(r,a+f),i=Math.max(i,a+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:P(({commands:n})=>{n.expandSelection(({parent:e})=>e.type.name===ee.DOCUMENT)})}}}),XM=En.create({name:"doc",topNode:!0,content:"block+"});class Ns extends Ye{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=Er.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,Re.ok(t)}invert(){return new Ns(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 Ns(e.key,e.value,e.stepType)}}Ye.jsonID("setDocAttr",Ns);const ZM=XM.extend({marks:qt.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:P(({state:n},e,t)=>{n.tr.step(new Ns(e,t,n.schema))})}}}),QM=En.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",_i(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),eO=QM.extend({marks:qt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),tO=En.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]}`,_i(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=>HA({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),nO=tO.extend({marks:qt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),rO=Ne.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[QA.create(this.editor),eM.create(this.editor)]}}),iO=()=>[ZM,eO,nO,UA,ZA,JM,jM,YM,rO],sO=_t.create({name:ce.FONT_FAMILY,group:qt.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:P(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=F(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ce.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:P(({commands:n})=>{const e=F(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return fe(()=>n.findFontByName(F(r))||t)}),findFontByName:P((n,e)=>F(this.options.fonts).find(t=>t.name===e)),getFontFamily:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(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 Pr({font_family:e})}}),oO=Ne.create({name:ce.STYLE_PRESET,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{preset:{isRequired:!1,default:{id:F(this.options.defaultId)},parseHTML:n=>{const e=F(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=F(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:F(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:F(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const a=t[o],u=r[o],f=!u||u.toLowerCase()==="inherit";i[o]=f?a:u}return i}return{getPresetList:P(()=>fe(()=>F(this.options.presets).filter(t=>!t.hidden))),getPreset:P(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:F(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),a=t.getLinkPreset();return fe(()=>{const u=n(F(i),F(r).id);if(!F(o))return u;const f=F(a);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:P(({commands:t,chain:r},i)=>{const o=F(t.getPresetList()),a=n(o,i),u=a.node?.type??ee.PARAGRAPH,f={preset:{id:i}};a.node&&(f.level=a.node.level);for(const h of ce.attributes)f[h]=F(t.getBlockAttributes(h));r().removeList().setNode(u,f).run()}),applyDefaultPreset:P(({commands:t})=>{t.applyPreset(F(this.options.defaultId))}),removePreset:P(({commands:t})=>{t.setNode(ee.PARAGRAPH,{preset:null})}),getPresetCustomization:P(({editor:t,commands:r})=>{const i=ai(t,"state");return fe(()=>{const{selection:o,doc:a}=F(i),{from:u,to:f}=o;return r._getSettingCustomization(a,u,f)})}),isSettingCustomized:P(({commands:t},r)=>{const i=t.getPresetCustomization(),o=ce.presetAttributes.includes(r)?"attributes":"marks";return fe(()=>F(i)[o]?.includes(r)??!1)}),getContentCustomization:P(({editor:t,commands:r})=>{const i=ai(t,"state");return fe(()=>{const{doc:o}=F(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:P((t,r,i,o)=>{const a=new Set,u=new Set;return r.nodesBetween(i,o,f=>{for(const[h,m]of Object.entries(f.attrs))ce.presetAttributes.includes(h)&&m&&u.add(h);for(const{type:h}of f.marks)ce.marks.includes(h.name)&&a.add(h.name)}),{attributes:Array.from(u),marks:Array.from(a)}}),removePresetCustomization:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(ce.marks).resetAttributes(ee.PARAGRAPH,ce.presetAttributes).resetAttributes(ee.HEADING,ce.presetAttributes).restoreSelection().run()}),removeFormat:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Oi.head,F(this.options.presets))}}),lO=_t.create({name:ce.FONT_WEIGHT,group:qt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:P(({commands:n},e)=>{n.applyMark(this.name,{value:e}),F(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:P(({commands:n})=>{const e=F(n.getFontWeight()),t=F(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:P(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return fe(()=>{const r=F(e),i=F(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Lt("toggleBold"),"Mod-B":Lt("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 Pr({font_weight:n.value})}}),aO=_t.create({name:ce.FONT_SIZE,group:qt.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:P(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].font_size.replace("px",""))}),applyFontSize:P(({commands:n},e)=>{const t=F(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:a})=>{const u={...a.attrs,[t]:null};if(!Object.values(u).some(m=>!!m))return!1;const h=a.type.create(u);if(i.isText){r.addMark(o,o+i.nodeSize,h);return}r.addNodeMark(o,h)}})}),increaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.min(e+1,F(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.max(e-1,F(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Lt("increaseFontSize"),"Mod-Shift--":Lt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=F(this.options.wrapperRef),r=h0(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 Pr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),uO=_t.create({name:ce.FONT_COLOR,group:qt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.color)}),applyFontColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:d0(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Pr({font_color:n.value})}}),cO=_t.create({name:ce.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:P(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:d0(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Pr({background_color:n.value})}}),fO=Ne.create({name:"device_manager",addCommands(){return{getDevice:P(()=>ai(this.options,"device"))}}}),dO=_t.create({name:ce.FONT_STYLE,group:qt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return fe(()=>F(e)?.italic??F(t).italic)}),isItalicAvailable:P(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return fe(()=>{const r=F(e),i=F(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:P(({commands:n})=>{const e=n.getPreset();return fe(()=>({italic:F(e).common.font_style==="italic"}))}),toggleItalic:P(({commands:n})=>{F(n.isItalicAvailable())&&(F(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Lt("toggleItalic"),"Mod-I":Lt("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 Pr({font_style:e})}}),hO=_t.create({name:ce.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).underline)}),isStrikeThrough:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).strike_through)}),getTextDecoration:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return fe(()=>{const r=F(e)??{},i=F(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:P(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return fe(()=>F(e)!==F(t).underline)}),getDefaultTextDecoration:P(({commands:n})=>{const e=n.getPreset();return fe(()=>{const{text_decoration:t}=F(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:P(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:P(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:P(({commands:n},e,t=null)=>{const r=F(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Lt("toggleUnderline"),"Mod-U":Lt("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"),Pr({text_decoration:e.join(" ")})}}),pO=Ne.create({name:"case_style",addCommands(){return{applyCaseStyle:P(({commands:n},e)=>{switch(e){case Dc.CAPITALIZE:return n.applyCapitalize();case Dc.LOWERCASE:return n.applyLowerCase();case Dc.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:P(({commands:n})=>{n.transformText(({text:e})=>wM(e))}),applyLowerCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),y0={mobile:null,tablet:null,desktop:null},mO=Ne.create({name:ce.ALIGNMENT,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=UM(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?zl({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},y0)}),removeAlignment:P(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,y0),t=n.getDevice(),r=n.getDefaultAlignment();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultAlignment:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].alignment??Xn.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Lt("applyAlignment",Xn.LEFT),"Mod-Shift-e":Lt("applyAlignment",Xn.CENTER),"Mod-Shift-r":Lt("applyAlignment",Xn.RIGHT),"Mod-Shift-j":Lt("applyAlignment",Xn.JUSTIFY)})}),b0={mobile:null,tablet:null,desktop:null},gO=Ne.create({name:ce.LINE_HEIGHT,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=F(this.options.wrapperRef),r=$M(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?zl({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:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,b0),t=n.getDevice(),r=n.getDefaultLineHeight();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultLineHeight:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].line_height)}),applyLineHeight:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},b0)})}}}),yO=En.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",_i(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)}}}),bO=yO.extend({name:ee.LIST_ITEM,marks:qt.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:P(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const a of r.marks)t.addNodeMark(o,cf(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===ee.LIST))return t.listItemNewline()}})}),vO=En.create({name:ee.LIST,content:`${ee.LIST_ITEM}+`,group:"block list",marks:qt.SETTINGS,addExtensions:()=>[bO],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:Nt.DISC}}}),parseHTML(){const n={a:Nt.ROMAN,i:Nt.LATIN,1:Nt.DECIMAL},e=t=>{for(const r of Nt.values){const i=`.${F(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||Nt.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||Nt.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[F(this.options.baseClass)+n.bullet.type,F(this.options.presetClass)];return[Nt.ordered.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:P(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return fe(()=>F(e).type??null)}),applyList:P(({commands:n,chain:e},t)=>{if(F(n.getListType())===t){n.removeList();return}return e().applyDefaultPreset().toggleList(ee.LIST,ee.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({commands:i,tr:o})=>i._bubbleListItemMarks(o)).run()}),_bubbleListItemMarks:P((n,e)=>{const{doc:t,selection:r}=e,i=r.$from.start(),o=r.$to.end();function a(u,f){if(ce.inlineMarks.includes(f.type)||f.type.isInSet(u.marks))return!1;for(const h of u.content.content)if(h.childCount&&(!h.marks||!f.isInSet(h.marks)))return!1;return!0}t.nodesBetween(i,o,(u,f)=>{if(u.type.name===ee.LIST)return;if(u.type.name!==ee.LIST_ITEM)return!1;const h=[];return u.forEach(m=>{for(const p of m.marks){if(p.isInSet(h)){e.removeNodeMark(f+1,p);continue}a(u,p)&&(e.removeNodeMark(f+1,p),e.addNodeMark(f,cf(p)),h.push(p))}}),!1})}),removeList:P(({commands:n,state:e})=>{const{tr:t,doc:r,selection:i}=e,o=i.$from.start(),a=i.$to.end();r.nodesBetween(o,a,(u,f,h)=>{if([ee.LIST,ee.LIST_ITEM].includes(u.type.name))return;if(h.type.name!==ee.LIST_ITEM)return!1;const m=h.marks.filter(function(p){return!p.type.isInSet(u.marks)});for(const p of m)t.addNodeMark(f,cf(p));return!1}),n.liftListItem(ee.LIST_ITEM)})}},addInputRules(){const n=(e,t)=>$A({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(Nt.DISC,/^\s*([-+*])\s$/),n(Nt.DECIMAL,/^(\d+)\.\s$/),n(Nt.LATIN,/^([ivx]{1,3})\.\s$/i),n(Nt.ROMAN,/^([a-z])\.\s$/i)]}});function SO(n){return new St({key:new Kt("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(h=>h.docChanged)&&!t.doc.eq(r.doc),o=e.some(h=>h.getMeta("preventAutolink"));if(!i||o)return;const{tr:a}=r,u=uA(t.doc,[...e]);if(bA(u).forEach(({newRange:h})=>{const m=fA(r.doc,h,S=>S.isTextblock);let p,b;if(m.length>1?(p=m[0],b=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ")):m.length&&r.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(p=m[0],b=r.doc.textBetween(p.pos,h.to,void 0," ")),p&&b){const S=b.split(" ").filter(A=>A!=="");if(S.length<=0)return!1;const x=S[S.length-1],C=p.pos+b.lastIndexOf(x);if(!x)return!1;nf(x).filter(A=>A.isLink).map(A=>({...A,from:C+A.start+1,to:C+A.end+1})).filter(A=>r.schema.marks.code?!r.doc.rangeHasMark(A.from,A.to,r.schema.marks.code):!0).filter(A=>n.validate?n.validate(A.value):!0).forEach(A=>{Rg(A.from,A.to,r.doc).some(N=>N.mark.type===n.type)||a.addMark(A.from,A.to,n.type.create({href:A.href}))})}}),!!a.steps.length)return a}})}function wO(n){return new St({key:new Kt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||r.target.nodeName!=="A")return!1;const u=mA(e.state,n.type.name),f=r.target,h=(i=f?.href)!==null&&i!==void 0?i:u.href,m=(o=f?.target)!==null&&o!==void 0?o:u.target;return f&&h?(e.editable&&window.open(h,m),!0):!1}}})}function _O(n){return new St({key:new Kt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:o}=e,{selection:a}=o,{empty:u}=a;if(u)return!1;let f="";r.content.forEach(x=>{f+=x.textContent});const h=nf(f).find(x=>x.isLink&&x.value===f);if(!f||!h)return!1;const m=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),p=/href="([^"]*)"/,b=m?.match(p),S=b?b[1]:h.href;return n.editor.commands.setMark(n.type,{href:S}),!0}}})}const xO=_t.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){r0(n);return}r0(n.scheme,n.optionalSlashes)})},onDestroy(){yM()},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",_i(this.options.HTMLAttributes,{...n,href:""}),0]:["a",_i(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[WA({find:n=>nf(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="([^"]*)"/,a=i?.match(o);return a?{href:a[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(SO({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(wO({type:this.type})),this.options.linkOnPaste&&n.push(_O({editor:this.editor,type:this.type})),n}}),kO=xO.extend({name:ce.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:Ug.SELF,parseHTML:n=>n.getAttribute("target")||Ug.SELF},destination:{default:_s.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return _s.URL;const t=e.replace("#","");return F(this.options.pageBlocks).find(o=>o.id===parseInt(t))?_s.BLOCK:_s.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:P(({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(S0.text(r.text,[S0.mark(ce.LINK,r)])))),expandSelectionToLink:P(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:P(({commands:e})=>e.hasMark(this.name)),getLinkPreset:P(()=>fe(()=>F(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),SM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===_s.BLOCK?`#${n.href}`:n.href,t=F(this.options.basePresetClass)+F(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),EO=_t.create({name:ce.SUPERSCRIPT,addCommands(){return{applySuperscript:P(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:P(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:P(({commands:n})=>{F(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:P(({commands:n})=>{const e=n.getMark(this.name);return fe(()=>!!F(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),TO=Ne.create({name:ce.MARGIN,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?zl({margin:n.margin.value}):null}}}}]});function CO(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=Eu({default:null,link:null});return wk(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),iO().concat([oO.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new OO({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),vO.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),fO.configure({device:n.deviceRef}),aO.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),sO.configure({fonts:n.fonts,defaultPreset:ai(t,"default")}),lO,uO,cO,dO,hO,pO,EO,mO,gO.configure({wrapperRef:n.wrapperRef}),kO.configure({preset:ai(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),TO])}class AO{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class v0{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class un extends v0{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=un.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const a=u=>{this._assignElementProperties(u,e,un.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,un.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){a(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),a(f),i=null,o=u;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(u),o=u}e.append(t),this._removeStyleProperties(e,un.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,un.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return un.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return un.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const a=u=>{this._assignElementProperties(u,e,un.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){a(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),a={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,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 MO extends v0{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!==ee.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(ce.inlineMarks.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===ee.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>g0.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===ee.TEXT&&this._includesMarkType(e,ce.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Vl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new un({content:e,parser:t.parser||new AO})}static _buildJson(e){return new MO({content:e})}static normalize(e,t={}){return Vl.build(e,t).normalize()}}class Oi{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 yf{static build({config:e,nodeDomParser:t}){const r=CO({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:Fo(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:Fo(Pc.DESKTOP),pageBlocksRef:Fo([]),wrapperRef:Oi.document.createElement("p")}),i=hA(r);return new yf({schema:i,domParser:Uu.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=Vl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}class S0{static doc(e){return{type:ee.DOCUMENT,content:e}}static list(e,t){return{type:ee.LIST,attrs:{bullet:{type:e}},content:t.map(r=>r.type===ee.LIST_ITEM?r:this.listItem([].concat(r)))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{type:ee.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:ee.HEADING,...r}}static paragraph(...e){return{type:ee.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:ee.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ce.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class OO{_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=Oi.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const a of Pc.values)for(const u of Object.keys(r[a])){const f=this._makeVariable({device:a,preset:r,property:u}),h=this._makeInternalVariableName(u,a);if(t+=`${h}: var(${f}, inherit);`,i&&!ce.attributes.includes(u)){const m=h.replace("preset-","");t+=`${m}: var(${h});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===Pc.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 bf{static _instance;static get instance(){return this._instance??=new bf,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 IO{static createWindow(){return new Yh.JSDOM().window}types;parse(e){const{window:t}=new Yh.JSDOM(e);return this.types=t,t.document}}exports.ContentSerializer=yf,exports.ContextWindow=Oi,exports.NodeDomParser=IO;
40
+ }`;var te=qh(function(){return me(v,U+"return "+R).apply(t,w)});if(te.source=R,nu(te))throw te;return te}function m_(s){return ge(s).toLowerCase()}function g_(s){return ge(s).toUpperCase()}function y_(s,l,c){if(s=ge(s),s&&(c||l===t))return nd(s);if(!s||!(l=gt(l)))return s;var d=Bt(s),g=Bt(l),v=rd(d,g),w=id(d,g)+1;return Ln(d,v,w).join("")}function b_(s,l,c){if(s=ge(s),s&&(c||l===t))return s.slice(0,od(s)+1);if(!s||!(l=gt(l)))return s;var d=Bt(s),g=id(d,Bt(l))+1;return Ln(d,0,g).join("")}function v_(s,l,c){if(s=ge(s),s&&(c||l===t))return s.replace(na,"");if(!s||!(l=gt(l)))return s;var d=Bt(s),g=rd(d,Bt(l));return Ln(d,g).join("")}function S_(s,l){var c=Kl,d=Di;if(ke(l)){var g="separator"in l?l.separator:g;c="length"in l?Q(l.length):c,d="omission"in l?gt(l.omission):d}s=ge(s);var v=s.length;if(jr(s)){var w=Bt(s);v=w.length}if(c>=v)return s;var _=c-Yr(d);if(_<1)return d;var E=w?Ln(w,0,_).join(""):s.slice(0,_);if(g===t)return E+d;if(w&&(_+=E.length-_),ru(g)){if(s.slice(_).search(g)){var O,I=E;for(g.global||(g=va(g.source,ge(kf.exec(g))+"g")),g.lastIndex=0;O=g.exec(I);)var R=O.index;E=E.slice(0,R===t?_:R)}}else if(s.indexOf(gt(g),_)!=_){var z=E.lastIndexOf(g);z>-1&&(E=E.slice(0,z))}return E+d}function w_(s){return s=ge(s),s&&N0.test(s)?s.replace(wf,Yy):s}var __=ri(function(s,l,c){return s+(c?" ":"")+l.toUpperCase()}),ou=Jd("toUpperCase");function Gh(s,l,c){return s=ge(s),l=c?t:l,l===t?Ky(s)?Qy(s):Dy(s):s.match(l)||[]}var qh=ne(function(s,l){try{return pt(s,t,l)}catch(c){return nu(c)?c:new X(c)}}),x_=bn(function(s,l){return kt(l,function(c){c=Qt(c),gn(s,c,eu(s[c],s))}),s});function k_(s){var l=s==null?0:s.length,c=q();return s=l?_e(s,function(d){if(typeof d[1]!="function")throw new Et(a);return[c(d[0]),d[1]]}):[],ne(function(d){for(var g=-1;++g<l;){var v=s[g];if(pt(v[0],this,d))return pt(v[1],this,d)}})}function E_(s){return Y1(Ct(s,p))}function lu(s){return function(){return s}}function T_(s,l){return s==null||s!==s?l:s}var C_=Yd(),A_=Yd(!0);function ft(s){return s}function au(s){return Td(typeof s=="function"?s:Ct(s,p))}function M_(s){return Ad(Ct(s,p))}function O_(s,l){return Md(s,Ct(l,p))}var I_=ne(function(s,l){return function(c){return Zi(c,s,l)}}),N_=ne(function(s,l){return function(c){return Zi(s,c,l)}});function uu(s,l,c){var d=De(l),g=so(l,d);c==null&&!(ke(l)&&(g.length||!d.length))&&(c=l,l=s,s=this,g=so(l,De(l)));var v=!(ke(c)&&"chain"in c)||!!c.chain,w=Sn(s);return kt(g,function(_){var E=l[_];s[_]=E,w&&(s.prototype[_]=function(){var O=this.__chain__;if(v||O){var I=s(this.__wrapped__),R=I.__actions__=at(this.__actions__);return R.push({func:E,args:arguments,thisArg:s}),I.__chain__=O,I}return E.apply(s,An([this.value()],arguments))})}),s}function R_(){return $e._===this&&($e._=s1),this}function cu(){}function L_(s){return s=Q(s),ne(function(l){return Od(l,s)})}var P_=$a(_e),D_=$a(Xf),F_=$a(da);function Jh(s){return Ja(s)?ha(Qt(s)):hb(s)}function B_(s){return function(l){return s==null?t:dr(s,l)}}var z_=Zd(),H_=Zd(!0);function fu(){return[]}function du(){return!1}function $_(){return{}}function W_(){return""}function U_(){return!0}function V_(s,l){if(s=Q(s),s<1||s>qe)return[];var c=Qe,d=Je(s,Qe);l=q(l),s-=Qe;for(var g=ga(d,l);++c<s;)l(c);return g}function K_(s){return Z(s)?_e(s,Qt):yt(s)?[s]:at(ph(ge(s)))}function G_(s){var l=++r1;return ge(s)+l}var q_=fo(function(s,l){return s+l},0),J_=Wa("ceil"),j_=fo(function(s,l){return s/l},1),Y_=Wa("floor");function X_(s){return s&&s.length?io(s,ft,Ca):t}function Z_(s,l){return s&&s.length?io(s,q(l,2),Ca):t}function Q_(s){return ed(s,ft)}function ex(s,l){return ed(s,q(l,2))}function tx(s){return s&&s.length?io(s,ft,Ia):t}function nx(s,l){return s&&s.length?io(s,q(l,2),Ia):t}var rx=fo(function(s,l){return s*l},1),ix=Wa("round"),sx=fo(function(s,l){return s-l},0);function ox(s){return s&&s.length?ma(s,ft):0}function lx(s,l){return s&&s.length?ma(s,q(l,2)):0}return y.after=MS,y.ary=Eh,y.assign=gw,y.assignIn=zh,y.assignInWith=Eo,y.assignWith=yw,y.at=bw,y.before=Th,y.bind=eu,y.bindAll=x_,y.bindKey=Ch,y.castArray=$S,y.chain=_h,y.chunk=Yb,y.compact=Xb,y.concat=Zb,y.cond=k_,y.conforms=E_,y.constant=lu,y.countBy=oS,y.create=vw,y.curry=Ah,y.curryRight=Mh,y.debounce=Oh,y.defaults=Sw,y.defaultsDeep=ww,y.defer=OS,y.delay=IS,y.difference=Qb,y.differenceBy=ev,y.differenceWith=tv,y.drop=nv,y.dropRight=rv,y.dropRightWhile=iv,y.dropWhile=sv,y.fill=ov,y.filter=aS,y.flatMap=fS,y.flatMapDeep=dS,y.flatMapDepth=hS,y.flatten=bh,y.flattenDeep=lv,y.flattenDepth=av,y.flip=NS,y.flow=C_,y.flowRight=A_,y.fromPairs=uv,y.functions=Aw,y.functionsIn=Mw,y.groupBy=pS,y.initial=fv,y.intersection=dv,y.intersectionBy=hv,y.intersectionWith=pv,y.invert=Iw,y.invertBy=Nw,y.invokeMap=gS,y.iteratee=au,y.keyBy=yS,y.keys=De,y.keysIn=ct,y.map=vo,y.mapKeys=Lw,y.mapValues=Pw,y.matches=M_,y.matchesProperty=O_,y.memoize=wo,y.merge=Dw,y.mergeWith=Hh,y.method=I_,y.methodOf=N_,y.mixin=uu,y.negate=_o,y.nthArg=L_,y.omit=Fw,y.omitBy=Bw,y.once=RS,y.orderBy=bS,y.over=P_,y.overArgs=LS,y.overEvery=D_,y.overSome=F_,y.partial=tu,y.partialRight=Ih,y.partition=vS,y.pick=zw,y.pickBy=$h,y.property=Jh,y.propertyOf=B_,y.pull=bv,y.pullAll=Sh,y.pullAllBy=vv,y.pullAllWith=Sv,y.pullAt=wv,y.range=z_,y.rangeRight=H_,y.rearg=PS,y.reject=_S,y.remove=_v,y.rest=DS,y.reverse=Za,y.sampleSize=kS,y.set=$w,y.setWith=Ww,y.shuffle=ES,y.slice=xv,y.sortBy=AS,y.sortedUniq=Ov,y.sortedUniqBy=Iv,y.split=f_,y.spread=FS,y.tail=Nv,y.take=Rv,y.takeRight=Lv,y.takeRightWhile=Pv,y.takeWhile=Dv,y.tap=Xv,y.throttle=BS,y.thru=bo,y.toArray=Dh,y.toPairs=Wh,y.toPairsIn=Uh,y.toPath=K_,y.toPlainObject=Bh,y.transform=Uw,y.unary=zS,y.union=Fv,y.unionBy=Bv,y.unionWith=zv,y.uniq=Hv,y.uniqBy=$v,y.uniqWith=Wv,y.unset=Vw,y.unzip=Qa,y.unzipWith=wh,y.update=Kw,y.updateWith=Gw,y.values=oi,y.valuesIn=qw,y.without=Uv,y.words=Gh,y.wrap=HS,y.xor=Vv,y.xorBy=Kv,y.xorWith=Gv,y.zip=qv,y.zipObject=Jv,y.zipObjectDeep=jv,y.zipWith=Yv,y.entries=Wh,y.entriesIn=Uh,y.extend=zh,y.extendWith=Eo,uu(y,y),y.add=q_,y.attempt=qh,y.camelCase=Xw,y.capitalize=Vh,y.ceil=J_,y.clamp=Jw,y.clone=WS,y.cloneDeep=VS,y.cloneDeepWith=KS,y.cloneWith=US,y.conformsTo=GS,y.deburr=Kh,y.defaultTo=T_,y.divide=j_,y.endsWith=Zw,y.eq=Ht,y.escape=Qw,y.escapeRegExp=e_,y.every=lS,y.find=uS,y.findIndex=gh,y.findKey=_w,y.findLast=cS,y.findLastIndex=yh,y.findLastKey=xw,y.floor=Y_,y.forEach=xh,y.forEachRight=kh,y.forIn=kw,y.forInRight=Ew,y.forOwn=Tw,y.forOwnRight=Cw,y.get=iu,y.gt=qS,y.gte=JS,y.has=Ow,y.hasIn=su,y.head=vh,y.identity=ft,y.includes=mS,y.indexOf=cv,y.inRange=jw,y.invoke=Rw,y.isArguments=mr,y.isArray=Z,y.isArrayBuffer=jS,y.isArrayLike=ut,y.isArrayLikeObject=Ce,y.isBoolean=YS,y.isBuffer=Pn,y.isDate=XS,y.isElement=ZS,y.isEmpty=QS,y.isEqual=ew,y.isEqualWith=tw,y.isError=nu,y.isFinite=nw,y.isFunction=Sn,y.isInteger=Nh,y.isLength=xo,y.isMap=Rh,y.isMatch=rw,y.isMatchWith=iw,y.isNaN=sw,y.isNative=ow,y.isNil=aw,y.isNull=lw,y.isNumber=Lh,y.isObject=ke,y.isObjectLike=Te,y.isPlainObject=is,y.isRegExp=ru,y.isSafeInteger=uw,y.isSet=Ph,y.isString=ko,y.isSymbol=yt,y.isTypedArray=si,y.isUndefined=cw,y.isWeakMap=fw,y.isWeakSet=dw,y.join=mv,y.kebabCase=t_,y.last=Mt,y.lastIndexOf=gv,y.lowerCase=n_,y.lowerFirst=r_,y.lt=hw,y.lte=pw,y.max=X_,y.maxBy=Z_,y.mean=Q_,y.meanBy=ex,y.min=tx,y.minBy=nx,y.stubArray=fu,y.stubFalse=du,y.stubObject=$_,y.stubString=W_,y.stubTrue=U_,y.multiply=rx,y.nth=yv,y.noConflict=R_,y.noop=cu,y.now=So,y.pad=i_,y.padEnd=s_,y.padStart=o_,y.parseInt=l_,y.random=Yw,y.reduce=SS,y.reduceRight=wS,y.repeat=a_,y.replace=u_,y.result=Hw,y.round=ix,y.runInContext=k,y.sample=xS,y.size=TS,y.snakeCase=c_,y.some=CS,y.sortedIndex=kv,y.sortedIndexBy=Ev,y.sortedIndexOf=Tv,y.sortedLastIndex=Cv,y.sortedLastIndexBy=Av,y.sortedLastIndexOf=Mv,y.startCase=d_,y.startsWith=h_,y.subtract=sx,y.sum=ox,y.sumBy=lx,y.template=p_,y.times=V_,y.toFinite=wn,y.toInteger=Q,y.toLength=Fh,y.toLower=m_,y.toNumber=Ot,y.toSafeInteger=mw,y.toString=ge,y.toUpper=g_,y.trim=y_,y.trimEnd=b_,y.trimStart=v_,y.truncate=S_,y.unescape=w_,y.uniqueId=G_,y.upperCase=__,y.upperFirst=ou,y.each=xh,y.eachRight=kh,y.first=vh,uu(y,function(){var s={};return Xt(y,function(l,c){ye.call(y.prototype,c)||(s[c]=l)}),s}(),{chain:!1}),y.VERSION=r,kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){y[s].placeholder=y}),kt(["drop","take"],function(s,l){le.prototype[s]=function(c){c=c===t?1:Pe(Q(c),0);var d=this.__filtered__&&!l?new le(this):this.clone();return d.__filtered__?d.__takeCount__=Je(c,d.__takeCount__):d.__views__.push({size:Je(c,Qe),type:s+(d.__dir__<0?"Right":"")}),d},le.prototype[s+"Right"]=function(c){return this.reverse()[s](c).reverse()}}),kt(["filter","map","takeWhile"],function(s,l){var c=l+1,d=c==or||c==Tn;le.prototype[s]=function(g){var v=this.clone();return v.__iteratees__.push({iteratee:q(g,3),type:c}),v.__filtered__=v.__filtered__||d,v}}),kt(["head","last"],function(s,l){var c="take"+(l?"Right":"");le.prototype[s]=function(){return this[c](1).value()[0]}}),kt(["initial","tail"],function(s,l){var c="drop"+(l?"":"Right");le.prototype[s]=function(){return this.__filtered__?new le(this):this[c](1)}}),le.prototype.compact=function(){return this.filter(ft)},le.prototype.find=function(s){return this.filter(s).head()},le.prototype.findLast=function(s){return this.reverse().find(s)},le.prototype.invokeMap=ne(function(s,l){return typeof s=="function"?new le(this):this.map(function(c){return Zi(c,s,l)})}),le.prototype.reject=function(s){return this.filter(_o(q(s)))},le.prototype.slice=function(s,l){s=Q(s);var c=this;return c.__filtered__&&(s>0||l<0)?new le(c):(s<0?c=c.takeRight(-s):s&&(c=c.drop(s)),l!==t&&(l=Q(l),c=l<0?c.dropRight(-l):c.take(l-s)),c)},le.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},le.prototype.toArray=function(){return this.take(Qe)},Xt(le.prototype,function(s,l){var c=/^(?:filter|find|map|reject)|While$/.test(l),d=/^(?:head|last)$/.test(l),g=y[d?"take"+(l=="last"?"Right":""):l],v=d||/^find/.test(l);g&&(y.prototype[l]=function(){var w=this.__wrapped__,_=d?[1]:arguments,E=w instanceof le,O=_[0],I=E||Z(w),R=function(re){var ae=g.apply(y,An([re],_));return d&&z?ae[0]:ae};I&&c&&typeof O=="function"&&O.length!=1&&(E=I=!1);var z=this.__chain__,U=!!this.__actions__.length,J=v&&!z,te=E&&!U;if(!v&&I){w=te?w:new le(this);var j=s.apply(w,_);return j.__actions__.push({func:bo,args:[R],thisArg:t}),new Tt(j,z)}return J&&te?s.apply(this,_):(j=this.thru(R),J?d?j.value()[0]:j.value():j)})}),kt(["pop","push","shift","sort","splice","unshift"],function(s){var l=Us[s],c=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",d=/^(?:pop|shift)$/.test(s);y.prototype[s]=function(){var g=arguments;if(d&&!this.__chain__){var v=this.value();return l.apply(Z(v)?v:[],g)}return this[c](function(w){return l.apply(Z(w)?w:[],g)})}}),Xt(le.prototype,function(s,l){var c=y[l];if(c){var d=c.name+"";ye.call(ei,d)||(ei[d]=[]),ei[d].push({name:l,func:c})}}),ei[co(t,N).name]=[{name:"wrapper",func:t}],le.prototype.clone=w1,le.prototype.reverse=_1,le.prototype.value=x1,y.prototype.at=Zv,y.prototype.chain=Qv,y.prototype.commit=eS,y.prototype.next=tS,y.prototype.plant=rS,y.prototype.reverse=iS,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=sS,y.prototype.first=y.prototype.head,Ki&&(y.prototype[Ki]=nS),y},Xr=e1();lr?((lr.exports=Xr)._=Xr,aa._=Xr):$e._=Xr}).call(Os)}(Hl,Hl.exports);var g0=Hl.exports;function cf(n){return n.type.create(g0.cloneDeep(n.attrs))}const JM=Ne.create({name:"node_processor",addCommands(){return{setBlockAttributes:P(({commands:n,state:e},t,r,i={})=>{const o=F(n.getBlockAttributes(t))??{},{doc:a,tr:u}=e,{from:f,to:h}=u.selection;a.nodesBetween(f,h,(m,p)=>{ee.blocks.includes(m.type.name)&&u.setNodeAttribute(p,t,{...i,...o,...r})})}),getBlockAttributes:P(({editor:n},e,t)=>fe(()=>{let r=Object.assign({},t||{});for(const i of ee.blocks)Object.assign(r,n.getAttributes(i)?.[e]||{});return Object.keys(r).length?r:null})),removeBlockAttributes:P(({commands:n},e)=>{for(const t of ee.blocks)n.resetAttributes(t,e)}),applyMark:P(({state:n,commands:e},t,r,i={})=>{const{tr:o,doc:a,schema:u}=n,{$from:f,$to:h}=o.selection,m=nn(ce.LINK,u),p=nn(t,u);if(!(p.spec.group||"").includes(qt.SETTINGS))return e.setMark(t,r);if(f.pos===h.pos)return;const S=x=>{if(!i.onAppliedToParent||i.onAppliedToParent(x)===!1){const{tr:C,node:A,position:N,mark:G}=x;e._removeNodeMark({tr:C,node:A,position:N,mark:G.type})}};a.nodesBetween(f.pos,h.pos,(x,C)=>{if(x.type.name===ee.LIST)return;const A=qM(x.marks,t),N=p.create({...A?.attrs||{},...r}),G=p0(f,h,x,C);if(!m.isInSet(x.marks)&&GM(o.doc,C,N,i.isAppliedToParent))return S({tr:o,node:x,position:C,mark:N});if(x.isText){o.addMark(G.from,G.to,N);return}VM(o.doc,o.selection,x,C)&&o.addNodeMark(C,N)})}),getMarks:P(({editor:n},e)=>{const t=ai(n,"state");return fe(()=>{const{selection:r,doc:i}=F(t),{from:o,to:a}=F(r),u=[];return i.nodesBetween(o,a,f=>{for(const h of f.marks)h.type.name===e&&u.unshift(h.attrs)}),u})}),getMark:P(({commands:n},e)=>{const t=n.getMarks(e);return fe(()=>F(t)[0]??null)}),hasMark:P(({commands:n},e)=>{const t=n.getMark(e);return fe(()=>!!F(t))}),getCommonSettingMark:P(({commands:n},e,t)=>{const r=n.getMark(e);return fe(()=>F(r)?.value??F(t))}),getDeviceSettingMark:P(({commands:n},e,t)=>{const r=n.getMarks(e),i=n.getDevice();return fe(()=>{for(const o of F(r)){const a=o[F(i)];if(a)return a}return F(t)})}),removeAllMarks:P(({state:n,commands:e})=>{const{tr:t,doc:r}=n,{from:i,to:o}=t.selection;r.nodesBetween(i,o,(a,u)=>{for(const f of a.marks)e._removeNodeMark({tr:t,node:a,position:u,mark:f})})}),removeMarks:P(({state:n,commands:e},t)=>{const{tr:r,doc:i}=n,{from:o,to:a}=r.selection;i.nodesBetween(o,a,(u,f)=>{const h=u.marks.filter(m=>t.includes(m.type.name));for(const m of h)e._removeNodeMark({tr:r,node:u,position:f,mark:m})})}),_removeNodeMark:P((n,{tr:e,node:t,position:r,mark:i})=>t.isText?e.removeMark(r,r+t.nodeSize,i):e.removeNodeMark(r,i))}}}),jM=Ne.create({name:"text_processor",addCommands(){return{getSelectedText:P(({state:n})=>{const{from:e,to:t}=n.selection;return n.doc.textBetween(e,t," ")}),transformText:P(({state:n},e)=>{const{$from:t,$to:r}=n.tr.selection;t.pos!==r.pos&&n.doc.nodesBetween(t.pos,r.pos,(i,o)=>{if(!i.isText)return;const a=p0(t,r,i,o),u=Math.max(0,t.pos-o),f=Math.max(0,r.pos-o),h=e({text:i.textContent.substring(u,f)}),m=n.schema.text(h,i.marks);n.tr.replaceWith(a.from,a.to,m)})})}}}),YM=Ne.create({name:"selection_processor",addStorage:()=>({selection:null}),addCommands(){return{storeSelection:P(({state:n})=>{this.storage.selection=n.selection}),restoreSelection:P(({commands:n})=>{this.storage.selection&&n.setTextSelection(this.storage.selection)}),expandSelection:P(({tr:n,commands:e},t)=>{let r=n.selection.from,i=n.selection.to;n.doc.nodesBetween(r,i,(o,a,u)=>{if(t({node:o,parent:u})){const f=o.isText?0:m0(n.doc,a);r=Math.min(r,a+f),i=Math.max(i,a+o.nodeSize-f)}}),e.setTextSelection({from:r,to:i})}),expandSelectionToBlock:P(({commands:n})=>{n.expandSelection(({parent:e})=>e.type.name===ee.DOCUMENT)})}}}),XM=En.create({name:"doc",topNode:!0,content:"block+"});class Ns extends Ye{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=Er.fromJSON(this.schema,e.toJSON());return t.attrs.meta[this.key]=this.value,Re.ok(t)}invert(){return new Ns(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 Ns(e.key,e.value,e.stepType)}}Ye.jsonID("setDocAttr",Ns);const ZM=XM.extend({marks:qt.SETTINGS,addAttributes:()=>({meta:{default:{}}}),onCreate(){this.editor.view.dom.addEventListener("click",n=>{n.target.closest("a")&&n.preventDefault()})},addCommands(){return{setDocMetaAttributes:P(({state:n},e,t)=>{n.tr.step(new Ns(e,t,n.schema))})}}}),QM=En.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",_i(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),eO=QM.extend({marks:qt.ALL,addOptions:()=>({HTMLAttributes:{class:"zw-style"}})}),tO=En.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]}`,_i(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=>HA({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),nO=tO.extend({marks:qt.ALL,addOptions:()=>({levels:[1,2,3,4],HTMLAttributes:{class:"zw-style"}})}),rO=Ne.create({name:"prose_mirror_plugins",addProseMirrorPlugins(){return[QA.create(this.editor),eM.create(this.editor)]}}),iO=()=>[ZM,eO,nO,UA,ZA,JM,jM,YM,rO],sO=_t.create({name:ce.FONT_FAMILY,group:qt.SETTINGS,addOptions:()=>({fonts:[]}),addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontFamily:P(({commands:n},e)=>{n.applyMark(this.name,{value:e});const t=n.findFontByName(e);let r=F(n.getFontWeight());t.isWeightSupported(r)||(r=t.findClosestWeight(r),n.applyFontWeight(r));const i=n.isSettingCustomized(ce.FONT_STYLE).value;!t.isItalicSupported(r)&&i&&n.removeItalic()}),getFont:P(({commands:n})=>{const e=F(this.options.defaultPreset),t=n.findFontByName(e.common.font_family),r=n.getFontFamily();return fe(()=>n.findFontByName(F(r))||t)}),findFontByName:P((n,e)=>F(this.options.fonts).find(t=>t.name===e)??this.options.defaultFont),getFontFamily:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontFamily())),getDefaultFontFamily:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(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 Pr({font_family:e})}}),oO=Ne.create({name:ce.STYLE_PRESET,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{preset:{isRequired:!1,default:{id:F(this.options.defaultId)},parseHTML:n=>{const e=F(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=F(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:F(this.options.defaultId)}:null},renderHTML:n=>n.preset?{class:F(this.options.styleRenderer).makePresetHtmlClass(n.preset)}:null}}}]},addCommands(){function n(t,r){return t.find(i=>r===i.id)}function e(t,r){const i={};for(const o of Object.keys(t)){const a=t[o],u=r[o],f=!u||u.toLowerCase()==="inherit";i[o]=f?a:u}return i}return{getPresetList:P(()=>fe(()=>F(this.options.presets).filter(t=>!t.hidden))),getPreset:P(({commands:t})=>{const r=t.getBlockAttributes("preset",{id:F(this.options.defaultId)}),i=t.getPresetList(),o=t.isLink(),a=t.getLinkPreset();return fe(()=>{const u=n(F(i),F(r).id);if(!F(o))return u;const f=F(a);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:P(({commands:t,chain:r},i)=>{const o=F(t.getPresetList()),a=n(o,i),u=a.node?.type??ee.PARAGRAPH,f={preset:{id:i}};a.node&&(f.level=a.node.level);for(const h of ce.attributes)f[h]=F(t.getBlockAttributes(h));r().removeList().setNode(u,f).run()}),applyDefaultPreset:P(({commands:t})=>{t.applyPreset(F(this.options.defaultId))}),removePreset:P(({commands:t})=>{t.setNode(ee.PARAGRAPH,{preset:null})}),getPresetCustomization:P(({editor:t,commands:r})=>{const i=ai(t,"state");return fe(()=>{const{selection:o,doc:a}=F(i),{from:u,to:f}=o;return r._getSettingCustomization(a,u,f)})}),isSettingCustomized:P(({commands:t},r)=>{const i=t.getPresetCustomization(),o=ce.presetAttributes.includes(r)?"attributes":"marks";return fe(()=>F(i)[o]?.includes(r)??!1)}),getContentCustomization:P(({editor:t,commands:r})=>{const i=ai(t,"state");return fe(()=>{const{doc:o}=F(i);return r._getSettingCustomization(o,0,o.content.size)})}),_getSettingCustomization:P((t,r,i,o)=>{const a=new Set,u=new Set;return r.nodesBetween(i,o,f=>{for(const[h,m]of Object.entries(f.attrs))ce.presetAttributes.includes(h)&&m&&u.add(h);for(const{type:h}of f.marks)ce.marks.includes(h.name)&&a.add(h.name)}),{attributes:Array.from(u),marks:Array.from(a)}}),removePresetCustomization:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeMarks(ce.marks).resetAttributes(ee.PARAGRAPH,ce.presetAttributes).resetAttributes(ee.HEADING,ce.presetAttributes).restoreSelection().run()}),removeFormat:P(({chain:t})=>{t().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run()})}},onCreate(){this.options.styleRenderer.inject(Oi.head,F(this.options.presets))}}),lO=_t.create({name:ce.FONT_WEIGHT,group:qt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{applyFontWeight:P(({commands:n},e)=>{n.applyMark(this.name,{value:e}),F(n.getFont()).isItalicSupported(e)||n.removeItalic()}),toggleBold:P(({commands:n})=>{const e=F(n.getFontWeight()),t=F(n.getFont()),i=Number(e)>=600?"400":"700",o=t.findClosestWeight(i);n.applyFontWeight(o)}),getFontWeight:P(({commands:n})=>{const e=n.getCommonSettingMark(this.name,n.getDefaultFontWeight()),t=n.getFont();return fe(()=>{const r=F(e),i=F(t);return i.isWeightSupported(r)?r:i.findClosestWeight(r)})}),getDefaultFontWeight:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.font_weight)})}},addKeyboardShortcuts:()=>({"Mod-b":Lt("toggleBold"),"Mod-B":Lt("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 Pr({font_weight:n.value})}}),aO=_t.create({name:ce.FONT_SIZE,group:qt.SETTINGS,addOptions:()=>({minSize:1,maxSize:100}),addAttributes(){return{mobile:{default:null},tablet:{default:null},desktop:{default:null}}},addCommands(){return{getFontSize:P(({commands:n})=>n.getDeviceSettingMark(this.name,n.getDefaultFontSize())),getDefaultFontSize:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].font_size.replace("px",""))}),applyFontSize:P(({commands:n},e)=>{const t=F(n.getDevice());n.applyMark(this.name,{[t]:e},{isAppliedToParent:(r,i)=>r.type.name!==i.type.name?!1:r.attrs[t]===i.attrs[t],onAppliedToParent:({tr:r,node:i,position:o,mark:a})=>{const u={...a.attrs,[t]:null};if(!Object.values(u).some(m=>!!m))return!1;const h=a.type.create(u);if(i.isText){r.addMark(o,o+i.nodeSize,h);return}r.addNodeMark(o,h)}})}),increaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.min(e+1,F(this.options.maxSize));n.applyFontSize(String(t))}),decreaseFontSize:P(({commands:n})=>{const e=Number(F(n.getFontSize())),t=Math.max(e-1,F(this.options.minSize));n.applyFontSize(String(t))})}},addKeyboardShortcuts:()=>({"Mod-Shift-=":Lt("increaseFontSize"),"Mod-Shift--":Lt("decreaseFontSize")}),parseHTML(){const n=e=>{if(!e)return null;const t=F(this.options.wrapperRef),r=h0(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 Pr({font_size_mobile:e(n.mobile),font_size_tablet:e(n.tablet),font_size_desktop:e(n.desktop)})}}),uO=_t.create({name:ce.FONT_COLOR,group:qt.SETTINGS,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getFontColor:P(({commands:n})=>n.getCommonSettingMark(this.name,n.getDefaultFontColor())),getDefaultFontColor:P(({commands:n})=>{const e=n.getPreset();return fe(()=>F(e).common.color)}),applyFontColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:d0(e)});return[{style:"--zw-font-color",getAttrs:n},{style:"color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Pr({font_color:n.value})}}),cO=_t.create({name:ce.BACKGROUND_COLOR,addAttributes:()=>({value:{required:!0}}),addCommands(){return{getBackgroundColor:P(({commands:n})=>n.getCommonSettingMark(this.name,"rgba(255, 255, 255, 0%)")),applyBackgroundColor:P(({commands:n},e)=>{n.applyMark(this.name,{value:e})})}},parseHTML(){const n=e=>({value:d0(e)});return[{style:"--zw-background-color",getAttrs:n},{style:"background-color",getAttrs:n}]},renderHTML({HTMLAttributes:n}){return Pr({background_color:n.value})}}),fO=Ne.create({name:"device_manager",addCommands(){return{getDevice:P(()=>ai(this.options,"device"))}}}),dO=_t.create({name:ce.FONT_STYLE,group:qt.SETTINGS,addAttributes:()=>({italic:{required:!0}}),addCommands(){return{isItalic:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultFontStyle();return fe(()=>F(e)?.italic??F(t).italic)}),isItalicAvailable:P(({commands:n})=>{const e=n.getFont(),t=n.getFontWeight();return fe(()=>{const r=F(e),i=F(t);return r.isItalicSupported(i)&&!r.isWeightItalicOnly(i)})}),getDefaultFontStyle:P(({commands:n})=>{const e=n.getPreset();return fe(()=>({italic:F(e).common.font_style==="italic"}))}),toggleItalic:P(({commands:n})=>{F(n.isItalicAvailable())&&(F(n.isItalic())?n.removeItalic():n.applyItalic())}),applyItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!0})}),removeItalic:P(({commands:n})=>{n.applyMark(this.name,{italic:!1})})}},addKeyboardShortcuts:()=>({"Mod-i":Lt("toggleItalic"),"Mod-I":Lt("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 Pr({font_style:e})}}),hO=_t.create({name:ce.TEXT_DECORATION,priority:1e3,addAttributes:()=>({underline:{default:!1},strike_through:{default:!1}}),addCommands(){return{isUnderline:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).underline)}),isStrikeThrough:P(({commands:n})=>{const e=n.getTextDecoration();return fe(()=>F(e).strike_through)}),getTextDecoration:P(({commands:n})=>{const e=n.getMark(this.name),t=n.getDefaultTextDecoration();return fe(()=>{const r=F(e)??{},i=F(t);return{underline:r.underline||i.underline,strike_through:r.strike_through||i.strike_through}})}),isUnderlineCustomized:P(({commands:n})=>{const e=n.isUnderline(),t=n.getDefaultTextDecoration();return fe(()=>F(e)!==F(t).underline)}),getDefaultTextDecoration:P(({commands:n})=>{const e=n.getPreset();return fe(()=>{const{text_decoration:t}=F(e).common;return{underline:t.includes("underline"),strike_through:t.includes("line-through")}})}),toggleUnderline:P(({commands:n})=>{n.toggleTextDecoration("underline")}),toggleStrikeThrough:P(({commands:n})=>{n.toggleTextDecoration("strike_through")}),toggleTextDecoration:P(({commands:n},e,t=null)=>{const r=F(n.getTextDecoration()),i=t??!r[e];n.applyMark(this.name,{[e]:i})}),applyTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!0)}),removeTextDecoration:P(({commands:n},e)=>{n.toggleTextDecoration(e,!1)})}},addKeyboardShortcuts:()=>({"Mod-u":Lt("toggleUnderline"),"Mod-U":Lt("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"),Pr({text_decoration:e.join(" ")})}}),pO=Ne.create({name:"case_style",addCommands(){return{applyCaseStyle:P(({commands:n},e)=>{switch(e){case Dc.CAPITALIZE:return n.applyCapitalize();case Dc.LOWERCASE:return n.applyLowerCase();case Dc.UPPERCASE:return n.applyUpperCase()}}),applyCapitalize:P(({commands:n})=>{n.transformText(({text:e})=>wM(e))}),applyLowerCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toLowerCase())}),applyUpperCase:P(({commands:n})=>{n.transformText(({text:e})=>e.toUpperCase())})}}}),y0={mobile:null,tablet:null,desktop:null},mO=Ne.create({name:ce.ALIGNMENT,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.ALIGNMENT]:{isRequired:!1,parseHTML({style:n}){const e=UM(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?zl({alignment_mobile:n.alignment.mobile,alignment_tablet:n.alignment.tablet,alignment_desktop:n.alignment.desktop}):null}}}}],addCommands(){return{applyAlignment:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},y0)}),removeAlignment:P(({commands:n})=>n.removeBlockAttributes(this.name)),getAlignment:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,y0),t=n.getDevice(),r=n.getDefaultAlignment();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultAlignment:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].alignment??Xn.LEFT)})}},addKeyboardShortcuts:()=>({"Mod-Shift-l":Lt("applyAlignment",Xn.LEFT),"Mod-Shift-e":Lt("applyAlignment",Xn.CENTER),"Mod-Shift-r":Lt("applyAlignment",Xn.RIGHT),"Mod-Shift-j":Lt("applyAlignment",Xn.JUSTIFY)})}),b0={mobile:null,tablet:null,desktop:null},gO=Ne.create({name:ce.LINE_HEIGHT,addGlobalAttributes(){return[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.LINE_HEIGHT]:{isRequired:!1,parseHTML:n=>{if(n.matches('[style*="--zw-line-height"]')){const o=n.style.getPropertyValue("--zw-line-height-tablet")||null,a=n.style.getPropertyValue("--zw-line-height-desktop")||null;return{mobile:null,tablet:o,desktop:a}}const e=n.style.lineHeight;if(!e)return null;const t=F(this.options.wrapperRef),r=$M(e,n,t);return r?{desktop:r,tablet:r,mobile:null}:null},renderHTML(n){return n.line_height?zl({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:P(({commands:n})=>{const e=n.getBlockAttributes(this.name,b0),t=n.getDevice(),r=n.getDefaultLineHeight();return fe(()=>F(e)?.[F(t)]??F(r))}),getDefaultLineHeight:P(({commands:n})=>{const e=n.getDevice(),t=n.getPreset();return fe(()=>F(t)[F(e)].line_height)}),applyLineHeight:P(({commands:n},e)=>{const t=F(n.getDevice());n.setBlockAttributes(this.name,{[t]:e},b0)})}}}),yO=En.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",_i(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)}}}),bO=yO.extend({name:ee.LIST_ITEM,marks:qt.SETTINGS,addCommands(){const n=({selection:e})=>e.$cursor.before(e.$cursor.depth-1);return{listItemNewline:P(({commands:e,tr:t})=>{const r=t.doc.nodeAt(n(t));if(!t.selection.$cursor.node().textContent)return!1;e.splitListItem(this.name);const o=n(t);for(const a of r.marks)t.addNodeMark(o,cf(a));return!0})}},addOptions:()=>({HTMLAttributes:{class:"zw-style"}}),addKeyboardShortcuts:()=>({Enter:n=>{const{state:e,commands:t}=n.editor;if(e.selection.$cursor?.path.some(i=>i.type?.name===ee.LIST))return t.listItemNewline()}})}),vO=En.create({name:ee.LIST,content:`${ee.LIST_ITEM}+`,group:"block list",marks:qt.SETTINGS,addExtensions:()=>[bO],addOptions:()=>({baseClass:"",presetClass:""}),addAttributes:()=>({bullet:{default:{type:Nt.DISC}}}),parseHTML(){const n={a:Nt.ROMAN,i:Nt.LATIN,1:Nt.DECIMAL},e=t=>{for(const r of Nt.values){const i=`.${F(this.options.baseClass)}${r}`;if(t.matches(i)||n[t.type.toLowerCase()]===r)return r}};return[{tag:"ol",getAttrs:t=>({bullet:{type:e(t)||Nt.DECIMAL}})},{tag:"ul",getAttrs:t=>({bullet:{type:e(t)||Nt.DISC}})}]},renderHTML({HTMLAttributes:n}){const e=[F(this.options.baseClass)+n.bullet.type,F(this.options.presetClass)];return[Nt.ordered.includes(n.bullet.type)?"ol":"ul",{class:e.join(" ")},0]},addCommands(){return{getListType:P(({commands:n})=>{const e=n.getBlockAttributes("bullet",{type:null});return fe(()=>F(e).type??null)}),applyList:P(({commands:n,chain:e},t)=>{if(F(n.getListType())===t){n.removeList();return}return e().applyDefaultPreset().toggleList(ee.LIST,ee.LIST_ITEM).setBlockAttributes("bullet",{type:t}).command(({commands:i,tr:o})=>i._bubbleListItemMarks(o)).run()}),_bubbleListItemMarks:P((n,e)=>{const{doc:t,selection:r}=e,i=r.$from.start(),o=r.$to.end();function a(u,f){if(ce.inlineMarks.includes(f.type)||f.type.isInSet(u.marks))return!1;for(const h of u.content.content)if(h.childCount&&(!h.marks||!f.isInSet(h.marks)))return!1;return!0}t.nodesBetween(i,o,(u,f)=>{if(u.type.name===ee.LIST)return;if(u.type.name!==ee.LIST_ITEM)return!1;const h=[];return u.forEach(m=>{for(const p of m.marks){if(p.isInSet(h)){e.removeNodeMark(f+1,p);continue}a(u,p)&&(e.removeNodeMark(f+1,p),e.addNodeMark(f,cf(p)),h.push(p))}}),!1})}),removeList:P(({commands:n,state:e})=>{const{tr:t,doc:r,selection:i}=e,o=i.$from.start(),a=i.$to.end();r.nodesBetween(o,a,(u,f,h)=>{if([ee.LIST,ee.LIST_ITEM].includes(u.type.name))return;if(h.type.name!==ee.LIST_ITEM)return!1;const m=h.marks.filter(function(p){return!p.type.isInSet(u.marks)});for(const p of m)t.addNodeMark(f,cf(p));return!1}),n.liftListItem(ee.LIST_ITEM)})}},addInputRules(){const n=(e,t)=>$A({find:t,type:this.type,getAttributes:{bullet:{type:e}},joinPredicate:(r,{attrs:i})=>i.bullet.type===e});return[n(Nt.DISC,/^\s*([-+*])\s$/),n(Nt.DECIMAL,/^(\d+)\.\s$/),n(Nt.LATIN,/^([ivx]{1,3})\.\s$/i),n(Nt.ROMAN,/^([a-z])\.\s$/i)]}});function SO(n){return new St({key:new Kt("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(h=>h.docChanged)&&!t.doc.eq(r.doc),o=e.some(h=>h.getMeta("preventAutolink"));if(!i||o)return;const{tr:a}=r,u=uA(t.doc,[...e]);if(bA(u).forEach(({newRange:h})=>{const m=fA(r.doc,h,S=>S.isTextblock);let p,b;if(m.length>1?(p=m[0],b=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ")):m.length&&r.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(p=m[0],b=r.doc.textBetween(p.pos,h.to,void 0," ")),p&&b){const S=b.split(" ").filter(A=>A!=="");if(S.length<=0)return!1;const x=S[S.length-1],C=p.pos+b.lastIndexOf(x);if(!x)return!1;nf(x).filter(A=>A.isLink).map(A=>({...A,from:C+A.start+1,to:C+A.end+1})).filter(A=>r.schema.marks.code?!r.doc.rangeHasMark(A.from,A.to,r.schema.marks.code):!0).filter(A=>n.validate?n.validate(A.value):!0).forEach(A=>{Rg(A.from,A.to,r.doc).some(N=>N.mark.type===n.type)||a.addMark(A.from,A.to,n.type.create({href:A.href}))})}}),!!a.steps.length)return a}})}function wO(n){return new St({key:new Kt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||r.target.nodeName!=="A")return!1;const u=mA(e.state,n.type.name),f=r.target,h=(i=f?.href)!==null&&i!==void 0?i:u.href,m=(o=f?.target)!==null&&o!==void 0?o:u.target;return f&&h?(e.editable&&window.open(h,m),!0):!1}}})}function _O(n){return new St({key:new Kt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{var i;const{state:o}=e,{selection:a}=o,{empty:u}=a;if(u)return!1;let f="";r.content.forEach(x=>{f+=x.textContent});const h=nf(f).find(x=>x.isLink&&x.value===f);if(!f||!h)return!1;const m=(i=t.clipboardData)===null||i===void 0?void 0:i.getData("text/html"),p=/href="([^"]*)"/,b=m?.match(p),S=b?b[1]:h.href;return n.editor.commands.setMark(n.type,{href:S}),!0}}})}const xO=_t.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){r0(n);return}r0(n.scheme,n.optionalSlashes)})},onDestroy(){yM()},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",_i(this.options.HTMLAttributes,{...n,href:""}),0]:["a",_i(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[WA({find:n=>nf(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="([^"]*)"/,a=i?.match(o);return a?{href:a[1]}:{href:(r=n.data)===null||r===void 0?void 0:r.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(SO({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(wO({type:this.type})),this.options.linkOnPaste&&n.push(_O({editor:this.editor,type:this.type})),n}}),kO=xO.extend({name:ce.LINK,addOptions(){return{...this.parent?.(),openOnClick:!1,linkOnPaste:!1}},addAttributes(){return{href:{default:null,parseHTML:n=>{const e=n.getAttribute("href");return e.startsWith("#")?parseFloat(n.getAttribute("href").replace("#","")):e}},target:{default:Ug.SELF,parseHTML:n=>n.getAttribute("target")||Ug.SELF},destination:{default:_s.URL,parseHTML:n=>{const e=n.getAttribute("href");if(!e.startsWith("#"))return _s.URL;const t=e.replace("#","");return F(this.options.pageBlocks).find(o=>o.id===parseInt(t))?_s.BLOCK:_s.URL}}}},addCommands(){const{unsetLink:n}=this.parent();return{removeLink:n,applyLink:P(({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(S0.text(r.text,[S0.mark(ce.LINK,r)])))),expandSelectionToLink:P(({commands:e})=>{e.expandSelection(({node:t})=>this.type.isInSet(t.marks))}),isLink:P(({commands:e})=>e.hasMark(this.name)),getLinkPreset:P(()=>fe(()=>F(this.options.preset)))}},addProseMirrorPlugins(){return[...this.parent(),SM.create(this.editor)]},renderHTML({HTMLAttributes:n}){const e=n.destination===_s.BLOCK?`#${n.href}`:n.href,t=F(this.options.basePresetClass)+F(this.options.preset).id;return["a",{href:e,target:n.target,class:`${t} zw-style`},0]}}),EO=_t.create({name:ce.SUPERSCRIPT,addCommands(){return{applySuperscript:P(({commands:n})=>{n.setMark(this.name)}),removeSuperscript:P(({commands:n})=>{n.unsetMark(this.name)}),toggleSuperscript:P(({commands:n})=>{F(n.isSuperscript())?n.removeSuperscript():n.applySuperscript()}),isSuperscript:P(({commands:n})=>{const e=n.getMark(this.name);return fe(()=>!!F(e))})}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs:n=>n!=="super"?!1:null}]},renderHTML(){return["sup",{class:"zw-superscript"},0]}}),TO=Ne.create({name:ce.MARGIN,addGlobalAttributes:()=>[{types:[ee.PARAGRAPH,ee.HEADING],attributes:{[ce.MARGIN]:{isRequired:!1,parseHTML(n){const{margin:e,marginTop:t,marginRight:r,marginBottom:i,marginLeft:o}=n.style;return[e,t,r,i,o].some(f=>!!f)?e?{value:e}:{value:[t||0,r||0,i||0,o||0].join(" ")}:null},renderHTML(n){return n.margin?zl({margin:n.margin.value}):null}}}}]});function CO(n){const e=r=>n.presetsRef.value.find(i=>i.id===r),t=Eu({default:null,link:null});return wk(n.presetsRef,()=>{t.default=e(n.defaultPresetId),t.link=e(n.linkPresetId)},{immediate:!0,deep:!0}),iO().concat([oO.configure({presets:n.presetsRef,defaultId:n.defaultPresetId,styleRenderer:new OO({baseClass:n.basePresetClass,makeVariable:n.makePresetVariable,linkPresetId:n.linkPresetId})}),vO.configure({baseClass:n.baseListClass,presetClass:n.basePresetClass+n.defaultPresetId}),fO.configure({device:n.deviceRef}),aO.configure({minSize:n.minFontSize,maxSize:n.maxFontSize,wrapperRef:n.wrapperRef}),sO.configure({fonts:n.fonts,defaultPreset:ai(t,"default"),defaultFont:n.defaultFont}),lO,uO,cO,dO,hO,pO,EO,mO,gO.configure({wrapperRef:n.wrapperRef}),kO.configure({preset:ai(t,"link"),basePresetClass:n.basePresetClass,pageBlocks:n.pageBlocksRef}),TO])}class AO{_domParser=new DOMParser;types=window;parse(e){return this._domParser.parseFromString(e,"text/html")}}class v0{content;constructor({content:e}){this.content=e}normalize(){throw new Error("Implement abstract method")}}class un extends v0{static BLOCK_NODE_NAMES=["P","H1","H2","H3","H4"];static ROOT_NODE_NAMES=un.BLOCK_NODE_NAMES.concat("UL","OL");static BLOCK_STYLES=["text-align","line-height","margin","margin-top","margin-bottom","margin-left","margin-right"];_parser;constructor({content:e,parser:t}){super({content:e}),this._parser=t,this.dom=null}normalize(){return this.normalizeHTML(),this.normalizedHTML}normalizeHTML(){this.dom=this._parser.parse(this.content.replace(/(\r)?\n/g,"")),this._removeComments(),this._normalizeRootTags(),this._iterateNodes(this._normalizeBreakLines,e=>e.tagName==="BR"),this._iterateNodes(this._removeEmptyNodes,this._isBlockNode),this._iterateNodes(this._normalizeListItems,e=>e.tagName==="LI"),this._normalizeBlockTextDecoration(),this._normalizeBlockBackgroundColor()}get normalizedHTML(){return this.dom.body.innerHTML}get _NodeFilter(){return this._parser.types.NodeFilter}get _Node(){return this._parser.types.Node}_removeComments(){const e=this._createNodeIterator(this._NodeFilter.SHOW_COMMENT);this._runIterator(e,t=>t.remove())}_normalizeRootTags(){const e=Array.from(this.dom.body.childNodes),t=this.dom.createDocumentFragment();let r;for(const i of e){if(this._isRootNode(i)){t.append(i),r=null;continue}r||(r=this.dom.createElement("p"),t.append(r)),r.append(i)}this.dom.body.innerHTML="",this.dom.body.append(t)}_createNodeIterator(e,t){return this.dom.createNodeIterator(this.dom.body,e,t)}_iterateNodes(e,t=()=>!0){const r=o=>o.tagName!=="BODY"&&t.call(this,o),i=this._createNodeIterator(this._NodeFilter.SHOW_ELEMENT,{acceptNode:o=>r(o)?this._NodeFilter.FILTER_ACCEPT:this._NodeFilter.FILTER_REJECT});this._runIterator(i,e)}_runIterator(e,t){let r=e.nextNode();for(;r;)t.call(this,r),r=e.nextNode()}_removeEmptyNodes(e){e.innerHTML.trim()||e.remove()}_normalizeListItems(e){const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes);let i,o;const a=u=>{this._assignElementProperties(u,e,un.BLOCK_STYLES),t.append(u)};this._assignElementProperties(e,e.parentElement,un.BLOCK_STYLES);for(const u of r){if(this._isBlockNode(u)){a(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),a(f),i=null,o=u;continue}i||(i=this.dom.createElement("p"),a(i)),i.append(u),o=u}e.append(t),this._removeStyleProperties(e,un.BLOCK_STYLES),this._removeStyleProperties(e.parentElement,un.BLOCK_STYLES),this._assignElementProperties(e,e.parentElement),e.parentElement.lastElementChild===e&&this._removeStyleProperties(e.parentElement)}_isBlockNode(e){return un.BLOCK_NODE_NAMES.includes(e.tagName)}_isRootNode(e){return un.ROOT_NODE_NAMES.includes(e.tagName)}_assignElementProperties(e,t,r=Array.from(t.style)){for(const i of r){const o=t.style.getPropertyValue(i);o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}}_removeStyleProperties(e,t=Array.from(e.style)){for(const r of t)e.style.removeProperty(r);e.style.length===0&&e.removeAttribute("style")}_normalizeBreakLines({parentElement:e}){if(!this._isBlockNode(e)||!e.textContent)return;const t=this.dom.createDocumentFragment(),r=Array.from(e.childNodes),i=e.cloneNode(!0);i.innerHTML="";let o=i.cloneNode();const a=u=>{this._assignElementProperties(u,e,un.BLOCK_STYLES),t.append(u)};for(const u of r){if(u.tagName==="BR"){a(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),a={underline:o.underline||t.underline,line_through:o.line_through||t.line_through};i.style.removeProperty("text-decoration-line"),i.style.removeProperty("text-decoration"),i.style.textDecoration=Object.entries(a).filter(([,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 MO extends v0{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!==ee.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(ce.inlineMarks.includes(t.type)||this._includesMarkType(e,t.type))return!1;for(const r of e.content)if(!(!r.content&&e.type===ee.LIST_ITEM)&&(!r.marks||!this._includesMark(r,t)))return!1;return!0}_includesMark(e,t){return e.marks?.some(r=>g0.isEqual(r,t))??!1}_includesMarkType(e,t){return e.marks?.some(r=>r.type===t)??!1}_isLink(e){return e.type===ee.TEXT&&this._includesMarkType(e,ce.LINK)}_removeMark(e,t){if(!e.marks)return;const r=this._findMarkIndexByType(e,t.type);r>=0&&e.marks.splice(r,1),e.marks.length||delete e.marks}_addMark(e,t){this._removeMark(e,t),e.marks??=[],e.marks.push(t)}_findMarkIndexByType(e,t){return e.marks?.findIndex(r=>r.type===t)??null}}class Vl{static build(e,t={}){return typeof e=="string"?this._buildHtml(e,t):this._buildJson(e)}static _buildHtml(e,t){return new un({content:e,parser:t.parser||new AO})}static _buildJson(e){return new MO({content:e})}static normalize(e,t={}){return Vl.build(e,t).normalize()}}class Oi{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 yf{static build({config:e,nodeDomParser:t}){const r=CO({fonts:e.fonts,minFontSize:0,maxFontSize:0,presetsRef:Fo(e.presets),defaultPresetId:e.defaultPresetId,linkPresetId:e.linkPresetId,makePresetVariable:()=>"",basePresetClass:e.basePresetClass,baseListClass:e.baseListClass,deviceRef:Fo(Pc.DESKTOP),pageBlocksRef:Fo([]),wrapperRef:Oi.document.createElement("p")}),i=hA(r);return new yf({schema:i,domParser:Uu.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=Vl.build(e,{parser:this._nodeDomParser});return t.normalizeHTML(),this._domParser.parse(t.dom.body).toJSON()}}class S0{static doc(e){return{type:ee.DOCUMENT,content:e}}static list(e,t){return{type:ee.LIST,attrs:{bullet:{type:e}},content:t.map(r=>r.type===ee.LIST_ITEM?r:this.listItem([].concat(r)))}}static listItem(...e){const{attrs:t,content:r,marks:i}=this._normalizeTextBlockArgs(e);return{type:ee.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:ee.HEADING,...r}}static paragraph(...e){return{type:ee.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:ee.TEXT,...t?{marks:t}:{},text:e}}static link(e,t,r=[]){return this.text(e,[this.mark(ce.LINK,t),...r])}static mark(e,t){return{type:e,attrs:t}}static populateAllDevices(e){return{mobile:e,tablet:e,desktop:e}}}class OO{_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=Oi.document.createElement("style"),r.dataset.zwStyles="",r.innerHTML=this.render(t),e.append(r))}render(e){let t="";for(const r of e){const i=r.id===this._linkPresetId,o=this.makePresetCssClass(r);t+=` ${o} {`;for(const a of Pc.values)for(const u of Object.keys(r[a])){const f=this._makeVariable({device:a,preset:r,property:u}),h=this._makeInternalVariableName(u,a);if(t+=`${h}: var(${f}, inherit);`,i&&!ce.attributes.includes(u)){const m=h.replace("preset-","");t+=`${m}: var(${h});`}}t+="}"}return t}_makeInternalVariableName(e,t){const r=e==="color"?"font-color":e.replace(/_/i,"-"),i=t===Pc.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 bf{static _instance;static get instance(){return this._instance??=new bf,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 IO{static createWindow(){return new Yh.JSDOM().window}types;parse(e){const{window:t}=new Yh.JSDOM(e);return this.types=t,t.document}}exports.ContentSerializer=yf,exports.ContextWindow=Oi,exports.NodeDomParser=IO;
@@ -77,6 +77,11 @@ declare const _default: import("vue").DefineComponent<{
77
77
  required: false;
78
78
  default: null;
79
79
  };
80
+ defaultFont: {
81
+ type: PropType<IFontJson>;
82
+ required: false;
83
+ default: null;
84
+ };
80
85
  }, {
81
86
  getContentCustomization: () => any;
82
87
  getContent: () => JSONContent;
@@ -160,10 +165,16 @@ declare const _default: import("vue").DefineComponent<{
160
165
  required: false;
161
166
  default: null;
162
167
  };
168
+ defaultFont: {
169
+ type: PropType<IFontJson>;
170
+ required: false;
171
+ default: null;
172
+ };
163
173
  }>> & {
164
174
  "onUpdate-favorite-colors"?: ((...args: any[]) => any) | undefined;
165
175
  "onUpdate:modelValue"?: ((modelValue: Content) => any) | undefined;
166
176
  }, {
177
+ defaultFont: IFontJson;
167
178
  device: string;
168
179
  favoriteColors: unknown[];
169
180
  toolbarOffsets: unknown[];
package/dist/wysiwyg.css CHANGED
@@ -23,7 +23,7 @@
23
23
  padding: var(--zw-offset-xxs) var(--zw-offset-xs);
24
24
  }
25
25
 
26
- .zw-button[data-v-b2d5d74a] {
26
+ .zw-button[data-v-9ea2a71b] {
27
27
  display: inline-flex;
28
28
  align-items: center;
29
29
  vertical-align: middle;
@@ -43,21 +43,21 @@
43
43
  transition: 0.1s opacity ease-out;
44
44
  will-change: opacity;
45
45
  }
46
- .zw-button[data-v-b2d5d74a]::-moz-focus-inner {
46
+ .zw-button[data-v-9ea2a71b]::-moz-focus-inner {
47
47
  border: 0 !important;
48
48
  }
49
- .zw-button[data-v-b2d5d74a]:hover,
50
- .zw-button[data-v-b2d5d74a]:focus {
49
+ .zw-button[data-v-9ea2a71b]:hover,
50
+ .zw-button[data-v-9ea2a71b]:focus {
51
51
  text-decoration: none;
52
52
  outline: none;
53
53
  }
54
- .zw-button[data-v-b2d5d74a]:disabled {
54
+ .zw-button[data-v-9ea2a71b]:disabled {
55
55
  user-select: none;
56
56
  box-shadow: none;
57
57
  cursor: not-allowed;
58
58
  opacity: 0.35;
59
59
  }
60
- .zw-button--toolbar[data-v-b2d5d74a] {
60
+ .zw-button--toolbar[data-v-9ea2a71b] {
61
61
  border-radius: 1px;
62
62
  min-height: 28px;
63
63
  font-weight: var(--zw-font-weight-semibold);
@@ -67,33 +67,33 @@
67
67
  transition-property: background-color, color, opacity;
68
68
  will-change: background-color, color, opacity;
69
69
  }
70
- .zw-button--primary[data-v-b2d5d74a] {
71
- background-color: rgb(var(--zw-color-green));
70
+ .zw-button--primary[data-v-9ea2a71b] {
71
+ background-color: rgb(var(--zw-color-n500));
72
72
  color: rgb(var(--zw-color-white));
73
73
  padding: var(--zw-offset-xxs) var(--zw-offset-sm);
74
74
  line-height: var(--zw-line-height-md);
75
75
  }
76
- .zw-button--primary[data-v-b2d5d74a],
77
- .zw-button--secondary[data-v-b2d5d74a] {
76
+ .zw-button--primary[data-v-9ea2a71b],
77
+ .zw-button--secondary[data-v-9ea2a71b] {
78
78
  color: rgb(var(--zw-color-white));
79
79
  padding: var(--zw-offset-xxs) var(--zw-offset-sm);
80
80
  font-weight: 600;
81
81
  font-size: var(--zw-font-size-xs);
82
82
  }
83
- .zw-button--primary[data-v-b2d5d74a]:not(:disabled):hover,
84
- .zw-button--secondary[data-v-b2d5d74a]:not(:disabled):hover {
83
+ .zw-button--primary[data-v-9ea2a71b]:not(:disabled):hover,
84
+ .zw-button--secondary[data-v-9ea2a71b]:not(:disabled):hover {
85
85
  opacity: 0.9;
86
86
  }
87
- .zw-button--toolbar[data-v-b2d5d74a]:not(.zw-button--icon) {
87
+ .zw-button--toolbar[data-v-9ea2a71b]:not(.zw-button--icon) {
88
88
  padding: var(--zw-offset-xxs) var(--zw-offset-xs);
89
89
  }
90
- .zw-button--toolbar[data-v-b2d5d74a]:not(:disabled):hover,
91
- .zw-button--toolbar[data-v-b2d5d74a]:not(:disabled):focus,
92
- .zw-button--toolbar.zw-button--active[data-v-b2d5d74a]:not(:disabled) {
90
+ .zw-button--toolbar[data-v-9ea2a71b]:not(:disabled):hover,
91
+ .zw-button--toolbar[data-v-9ea2a71b]:not(:disabled):focus,
92
+ .zw-button--toolbar.zw-button--active[data-v-9ea2a71b]:not(:disabled) {
93
93
  color: rgb(var(--zw-color-white));
94
94
  background-color: rgb(var(--zw-color-n5));
95
95
  }
96
- [data-v-b2d5d74a] .zw-button__customized-indicator {
96
+ [data-v-9ea2a71b] .zw-button__customized-indicator {
97
97
  width: 4px;
98
98
  height: 4px;
99
99
  background-color: rgb(var(--zw-color-y300));
@@ -421,29 +421,29 @@
421
421
  color: rgb(var(--zw-color-red));
422
422
  }
423
423
 
424
- .zw-checkbox[data-v-6e170d87] {
424
+ .zw-checkbox[data-v-94a6bca2] {
425
425
  display: inline-flex;
426
426
  align-items: center;
427
427
  position: relative;
428
428
  cursor: pointer;
429
429
  padding: var(--zw-offset-xxs) var(--zw-offset-xxs) var(--zw-offset-xxs) 0;
430
430
  }
431
- .zw-checkbox__field + .zw-checkbox__indicator[data-v-6e170d87] {
431
+ .zw-checkbox__field + .zw-checkbox__indicator[data-v-94a6bca2] {
432
432
  color: var(--zw-color-n200);
433
433
  box-shadow: inset 0 0 0 2px currentColor;
434
434
  }
435
- .zw-checkbox:hover .zw-checkbox__indicator[data-v-6e170d87],
436
- .zw-checkbox:focus .zw-checkbox__indicator[data-v-6e170d87],
437
- .zw-checkbox:focus-within .zw-checkbox__indicator[data-v-6e170d87] {
438
- box-shadow: inset 0 0 0 2px rgb(var(--zw-color-green));
435
+ .zw-checkbox:hover .zw-checkbox__indicator[data-v-94a6bca2],
436
+ .zw-checkbox:focus .zw-checkbox__indicator[data-v-94a6bca2],
437
+ .zw-checkbox:focus-within .zw-checkbox__indicator[data-v-94a6bca2] {
438
+ box-shadow: inset 0 0 0 2px rgb(var(--zw-color-b200));
439
439
  }
440
- .zw-checkbox__field:checked + .zw-checkbox__indicator[data-v-6e170d87] {
441
- color: rgb(var(--zw-color-green))
440
+ .zw-checkbox__field:checked + .zw-checkbox__indicator[data-v-94a6bca2] {
441
+ color: rgb(var(--zw-color-b200))
442
442
  }
443
- .zw-checkbox .zw-checkbox__field:checked + .zw-checkbox__indicator[data-v-6e170d87] {
444
- background-color: rgb(var(--zw-color-green));
443
+ .zw-checkbox .zw-checkbox__field:checked + .zw-checkbox__indicator[data-v-94a6bca2] {
444
+ background-color: rgb(var(--zw-color-b200));
445
445
  }
446
- .zw-checkbox .zw-checkbox__indicator[data-v-6e170d87]::after {
446
+ .zw-checkbox .zw-checkbox__indicator[data-v-94a6bca2]::after {
447
447
  content: "";
448
448
  display: block;
449
449
  height: 16px;
@@ -455,16 +455,16 @@
455
455
  background-size: 16px;
456
456
  background-position: center center;
457
457
  }
458
- .zw-checkbox__field:not(:checked) + .zw-checkbox__indicator[data-v-6e170d87]::after {
458
+ .zw-checkbox__field:not(:checked) + .zw-checkbox__indicator[data-v-94a6bca2]::after {
459
459
  transform: scale(0);
460
460
  }
461
- .zw-checkbox__field[data-v-6e170d87] {
461
+ .zw-checkbox__field[data-v-94a6bca2] {
462
462
  position: absolute;
463
463
  opacity: 0;
464
464
  height: 0;
465
465
  width: 0;
466
466
  }
467
- .zw-checkbox__label[data-v-6e170d87] {
467
+ .zw-checkbox__label[data-v-94a6bca2] {
468
468
  font-size: var(--zw-font-size-xs);
469
469
  }
470
470
 
@@ -724,21 +724,22 @@
724
724
  opacity: 0;
725
725
  }
726
726
  .zw-wysiwyg {
727
- --zw-color-n5: 13, 13, 13; /* #0D0D0D; */
728
- --zw-color-n15: 38, 38, 38; /* #262626; */
729
- --zw-color-n20: 59, 59, 59; /* #3B3B3B; */
730
- --zw-color-n30: 77, 77, 77; /* #4D4D4D; */
727
+ --zw-color-n5: 13, 13, 13; /* #0D0D0D */
728
+ --zw-color-n15: 38, 38, 38; /* #262626 */
729
+ --zw-color-n20: 59, 59, 59; /* #3B3B3B */
730
+ --zw-color-n30: 77, 77, 77; /* #4D4D4D */
731
731
  --zw-color-n60: 153, 153, 153; /* #999999 */
732
732
  --zw-color-n70: 179, 179, 179; /* #B3B3B3 */
733
733
  --zw-color-n80: 196, 196, 196; /* #C4C4C4 */
734
734
  --zw-color-n85: 217, 217, 217; /* #D9D9D9 */
735
735
  --zw-color-n90: 230, 230, 230; /* #E6E6E6 */
736
- --zw-color-n200: 194, 200, 209; /* #C2C8D1 */
737
- --zw-color-y300: 255, 171, 0; /* #FFAB00 */
736
+ --zw-color-n200: 194, 200, 209; /* #C2C8D1 */
737
+ --zw-color-n500: 54, 64, 76; /* #36404C */
738
+ --zw-color-y300: 255, 171, 0; /* #FFAB00 */
739
+ --zw-color-b200: 38, 132, 255; /* #0065FF */
738
740
  --zw-color-black: 0, 0, 0;
739
741
  --zw-color-white: 255, 255, 255;
740
- --zw-color-green: 59, 180, 74; /* #3BB44A */
741
- --zw-color-red: 234, 58, 58; /* #EA3A3A */
742
+ --zw-color-red: 234, 58, 58; /* #EA3A3A */
742
743
 
743
744
  --zw-offset-xxs: 4px;
744
745
  --zw-offset-xs: 8px;
package/dist/wysiwyg.mjs CHANGED
@@ -21366,7 +21366,7 @@ const FontFamily = Mark2.create({
21366
21366
  return computed(() => commands2.findFontByName(unref(fontFamily)) || defaultFont);
21367
21367
  }),
21368
21368
  findFontByName: createCommand((_, name) => {
21369
- return unref(this.options.fonts).find((font) => font.name === name);
21369
+ return unref(this.options.fonts).find((font) => font.name === name) ?? this.options.defaultFont;
21370
21370
  }),
21371
21371
  getFontFamily: createCommand(({ commands: commands2 }) => {
21372
21372
  return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontFamily());
@@ -22730,7 +22730,8 @@ function buildExtensions(options) {
22730
22730
  }),
22731
22731
  FontFamily.configure({
22732
22732
  fonts: options.fonts,
22733
- defaultPreset: toRef(presetsMap, "default")
22733
+ defaultPreset: toRef(presetsMap, "default"),
22734
+ defaultFont: options.defaultFont
22734
22735
  }),
22735
22736
  FontWeight,
22736
22737
  FontColor,
@@ -23746,7 +23747,7 @@ const _sfc_main$I = {
23746
23747
  };
23747
23748
  }
23748
23749
  };
23749
- const Button = /* @__PURE__ */ _export_sfc(_sfc_main$I, [["__scopeId", "data-v-b2d5d74a"]]);
23750
+ const Button = /* @__PURE__ */ _export_sfc(_sfc_main$I, [["__scopeId", "data-v-9ea2a71b"]]);
23750
23751
  const _hoisted_1$m = { class: "zw-button-toggle" };
23751
23752
  const _sfc_main$H = {
23752
23753
  __name: "ButtonToggle",
@@ -25824,7 +25825,7 @@ const _sfc_main$z = {
25824
25825
  }
25825
25826
  };
25826
25827
  const TextField = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-dfa0d6f0"]]);
25827
- const _withScopeId$2 = (n) => (pushScopeId("data-v-6e170d87"), n = n(), popScopeId(), n);
25828
+ const _withScopeId$2 = (n) => (pushScopeId("data-v-94a6bca2"), n = n(), popScopeId(), n);
25828
25829
  const _hoisted_1$g = { class: "zw-checkbox" };
25829
25830
  const _hoisted_2$5 = ["checked"];
25830
25831
  const _hoisted_3$1 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ createElementVNode("span", { class: "zw-checkbox__indicator zw-margin-right--xs" }, null, -1));
@@ -25861,7 +25862,7 @@ const _sfc_main$y = {
25861
25862
  };
25862
25863
  }
25863
25864
  };
25864
- const Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-6e170d87"]]);
25865
+ const Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-94a6bca2"]]);
25865
25866
  const InjectionTokens = Object.freeze({
25866
25867
  ACTIVE_MANAGER: Symbol("dropdownActiveManager"),
25867
25868
  TOGGLER: Symbol("dropdownToggler"),
@@ -27974,6 +27975,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
27974
27975
  type: Object,
27975
27976
  required: false,
27976
27977
  default: null
27978
+ },
27979
+ defaultFont: {
27980
+ type: Object,
27981
+ required: false,
27982
+ default: null
27977
27983
  }
27978
27984
  }, {
27979
27985
  "modelValue": {
@@ -28002,6 +28008,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
28002
28008
  isReadonlyRef: toRef(props, "readonly"),
28003
28009
  extensions: buildExtensions({
28004
28010
  fonts,
28011
+ defaultFont: props.defaultFont ? new Font(props.defaultFont) : null,
28005
28012
  minFontSize: MIN_FONT_SIZE,
28006
28013
  maxFontSize: MAX_FONT_SIZE,
28007
28014
  presetsRef: toRef(props, "presets"),
package/lib/Wysiwyg.vue CHANGED
@@ -115,6 +115,12 @@ const props = defineProps({
115
115
  type: Object,
116
116
  required: false,
117
117
  default: null
118
+ },
119
+
120
+ defaultFont: {
121
+ type: Object as PropType<IFontJson>,
122
+ required: false,
123
+ default: null
118
124
  }
119
125
  });
120
126
 
@@ -148,6 +154,7 @@ const { editor, getContent } = useEditor({
148
154
 
149
155
  extensions: buildExtensions({
150
156
  fonts,
157
+ defaultFont: props.defaultFont ? new Font(props.defaultFont) : null,
151
158
  minFontSize: MIN_FONT_SIZE,
152
159
  maxFontSize: MAX_FONT_SIZE,
153
160
  presetsRef: toRef(props, 'presets'),
@@ -100,7 +100,7 @@ const classes = computed(() => ({
100
100
  }
101
101
 
102
102
  .zw-button--primary {
103
- background-color: rgb(var(--zw-color-green));
103
+ background-color: rgb(var(--zw-color-n500));
104
104
  color: rgb(var(--zw-color-white));
105
105
  padding: var(--zw-offset-xxs) var(--zw-offset-sm);
106
106
  line-height: var(--zw-line-height-md);
@@ -42,15 +42,15 @@ const onCheckedChanged = () => emit('input', !props.value);
42
42
  .zw-checkbox:hover .zw-checkbox__indicator,
43
43
  .zw-checkbox:focus .zw-checkbox__indicator,
44
44
  .zw-checkbox:focus-within .zw-checkbox__indicator {
45
- box-shadow: inset 0 0 0 2px rgb(var(--zw-color-green));
45
+ box-shadow: inset 0 0 0 2px rgb(var(--zw-color-b200));
46
46
  }
47
47
 
48
48
  .zw-checkbox__field:checked + .zw-checkbox__indicator {
49
- color: rgb(var(--zw-color-green))
49
+ color: rgb(var(--zw-color-b200))
50
50
  }
51
51
 
52
52
  .zw-checkbox .zw-checkbox__field:checked + .zw-checkbox__indicator {
53
- background-color: rgb(var(--zw-color-green));
53
+ background-color: rgb(var(--zw-color-b200));
54
54
  }
55
55
 
56
56
  .zw-checkbox .zw-checkbox__indicator::after {
@@ -44,7 +44,7 @@ export const FontFamily = Mark.create({
44
44
  }),
45
45
 
46
46
  findFontByName: createCommand((_, name) => {
47
- return unref(this.options.fonts).find((font) => font.name === name);
47
+ return unref(this.options.fonts).find((font) => font.name === name) ?? this.options.defaultFont;
48
48
  }),
49
49
 
50
50
  getFontFamily: createCommand(({ commands }) => {
@@ -52,7 +52,8 @@ export function buildExtensions(options) {
52
52
  }),
53
53
  FontFamily.configure({
54
54
  fonts: options.fonts,
55
- defaultPreset: toRef(presetsMap, 'default')
55
+ defaultPreset: toRef(presetsMap, 'default'),
56
+ defaultFont: options.defaultFont
56
57
  }),
57
58
  FontWeight,
58
59
  FontColor,
@@ -1,19 +1,20 @@
1
1
  .zw-wysiwyg {
2
- --zw-color-n5: 13, 13, 13; /* #0D0D0D; */
3
- --zw-color-n15: 38, 38, 38; /* #262626; */
4
- --zw-color-n20: 59, 59, 59; /* #3B3B3B; */
5
- --zw-color-n30: 77, 77, 77; /* #4D4D4D; */
2
+ --zw-color-n5: 13, 13, 13; /* #0D0D0D */
3
+ --zw-color-n15: 38, 38, 38; /* #262626 */
4
+ --zw-color-n20: 59, 59, 59; /* #3B3B3B */
5
+ --zw-color-n30: 77, 77, 77; /* #4D4D4D */
6
6
  --zw-color-n60: 153, 153, 153; /* #999999 */
7
7
  --zw-color-n70: 179, 179, 179; /* #B3B3B3 */
8
8
  --zw-color-n80: 196, 196, 196; /* #C4C4C4 */
9
9
  --zw-color-n85: 217, 217, 217; /* #D9D9D9 */
10
10
  --zw-color-n90: 230, 230, 230; /* #E6E6E6 */
11
- --zw-color-n200: 194, 200, 209; /* #C2C8D1 */
12
- --zw-color-y300: 255, 171, 0; /* #FFAB00 */
11
+ --zw-color-n200: 194, 200, 209; /* #C2C8D1 */
12
+ --zw-color-n500: 54, 64, 76; /* #36404C */
13
+ --zw-color-y300: 255, 171, 0; /* #FFAB00 */
14
+ --zw-color-b200: 38, 132, 255; /* #0065FF */
13
15
  --zw-color-black: 0, 0, 0;
14
16
  --zw-color-white: 255, 255, 255;
15
- --zw-color-green: 59, 180, 74; /* #3BB44A */
16
- --zw-color-red: 234, 58, 58; /* #EA3A3A */
17
+ --zw-color-red: 234, 58, 58; /* #EA3A3A */
17
18
 
18
19
  --zw-offset-xxs: 4px;
19
20
  --zw-offset-xs: 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "4.4.0",
3
+ "version": "4.5.0-0",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "types": "dist/wysiwyg.d.ts",