@ones-editor/editor 0.0.3-beta.189 → 0.0.3-beta.190

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/index.js CHANGED
@@ -744,7 +744,7 @@ __p += '`),zt&&(X+=`' +
744
744
  function print() { __p += __j.call(arguments, '') }
745
745
  `:`;
746
746
  `)+X+`return __p
747
- }`;var Ot=gB(function(){return Vt(I,Ct+"return "+X).apply(e,O)});if(Ot.source=X,R5(Ot))throw Ot;return Ot}function KX(c){return Jt(c).toLowerCase()}function XX(c){return Jt(c).toUpperCase()}function ttt(c,u,f){if(c=Jt(c),c&&(f||u===e))return ai(c);if(!c||!(u=to(u)))return c;var C=Xn(c),y=Xn(u),I=Cl(C,y),O=Cd(C,y)+1;return gs(C,I,O).join("")}function ett(c,u,f){if(c=Jt(c),c&&(f||u===e))return c.slice(0,Kc(c)+1);if(!c||!(u=to(u)))return c;var C=Xn(c),y=Cd(C,Xn(u))+1;return gs(C,0,y).join("")}function ntt(c,u,f){if(c=Jt(c),c&&(f||u===e))return c.replace(Yu,"");if(!c||!(u=to(u)))return c;var C=Xn(c),y=Cl(C,Xn(u));return gs(C,y).join("")}function ott(c,u){var f=Ut,C=ne;if(be(u)){var y="separator"in u?u.separator:y;f="length"in u?Rt(u.length):f,C="omission"in u?to(u.omission):C}c=Jt(c);var I=c.length;if(ui(c)){var O=Xn(c);I=O.length}if(f>=I)return c;var P=f-us(C);if(P<1)return C;var $=O?gs(O,0,P).join(""):c.slice(0,P);if(y===e)return $+C;if(O&&(P+=$.length-P),O5(y)){if(c.slice(P).search(y)){var Q,Y=$;for(y.global||(y=na(y.source,Jt(Pc.exec(y))+"g")),y.lastIndex=0;Q=y.exec(Y);)var X=Q.index;$=$.slice(0,X===e?P:X)}}else if(c.indexOf(to(y),P)!=P){var dt=$.lastIndexOf(y);dt>-1&&($=$.slice(0,dt))}return $+C}function rtt(c){return c=Jt(c),c&&i3.test(c)?c.replace(h1,Xc):c}var itt=ra(function(c,u,f){return c+(f?" ":"")+u.toUpperCase()}),P5=pw("toUpperCase");function mB(c,u,f){return c=Jt(c),u=f?e:u,u===e?Qc(c)?O1(c):Jn(c):c.match(u)||[]}var gB=_t(function(c,u){try{return yn(c,e,u)}catch(f){return R5(f)?f:new Et(f)}}),stt=wi(function(c,u){return _n(u,function(f){f=Mr(f),yi(c,f,L5(c[f],c))}),c});function ltt(c){var u=c==null?0:c.length,f=vt();return c=u?ue(c,function(C){if(typeof C[1]!="function")throw new kn(s);return[f(C[0]),C[1]]}):[],_t(function(C){for(var y=-1;++y<u;){var I=c[y];if(yn(I[0],this,C))return yn(I[1],this,C)}})}function ctt(c){return RQ(yo(c,p))}function N5(c){return function(){return c}}function att(c,u){return c==null||c!==c?u:c}var utt=Aw(),dtt=Aw(!0);function jn(c){return c}function $5(c){return Zk(typeof c=="function"?c:yo(c,p))}function htt(c){return Yk(yo(c,p))}function ftt(c,u){return Jk(c,yo(u,p))}var mtt=_t(function(c,u){return function(f){return Id(f,c,u)}}),gtt=_t(function(c,u){return function(f){return Id(c,f,u)}});function H5(c,u,f){var C=Ke(u),y=W1(u,C);f==null&&!(be(u)&&(y.length||!C.length))&&(f=u,u=c,c=this,y=W1(u,Ke(u)));var I=!(be(f)&&"chain"in f)||!!f.chain,O=Ei(c);return _n(y,function(P){var $=u[P];c[P]=$,O&&(c.prototype[P]=function(){var Q=this.__chain__;if(I||Q){var Y=c(this.__wrapped__),X=Y.__actions__=Nn(this.__actions__);return X.push({func:$,args:arguments,thisArg:c}),Y.__chain__=Q,Y}return $.apply(c,Ir([this.value()],arguments))})}),c}function ptt(){return Ge._===this&&(Ge._=F1),this}function j5(){}function Ctt(c){return c=Rt(c),_t(function(u){return Kk(u,c)})}var Att=A5(ue),btt=A5(x1),vtt=A5(md);function pB(c){return E5(c)?qc(Mr(c)):YQ(c)}function ytt(c){return function(u){return c==null?e:_l(c,u)}}var ktt=vw(),wtt=vw(!0);function U5(){return[]}function z5(){return!1}function Btt(){return{}}function Ett(){return""}function xtt(){return!0}function Itt(c,u){if(c=Rt(c),c<1||c>an)return[];var f=po,C=L(c,po);u=vt(u),c-=po;for(var y=Zc(C,u);++f<c;)u(f);return y}function Ttt(c){return St(c)?ue(c,Mr):eo(c)?[c]:Nn(Fw(Jt(c)))}function Dtt(c){var u=++_1;return Jt(c)+u}var Stt=J1(function(c,u){return c+u},0),Ltt=b5("ceil"),Mtt=J1(function(c,u){return c/u},1),Rtt=b5("floor");function Ott(c){return c&&c.length?V1(c,jn,r5):e}function _tt(c,u){return c&&c.length?V1(c,vt(u,2),r5):e}function Ftt(c){return Wc(c,jn)}function Ptt(c,u){return Wc(c,vt(u,2))}function Ntt(c){return c&&c.length?V1(c,jn,c5):e}function $tt(c,u){return c&&c.length?V1(c,vt(u,2),c5):e}var Htt=J1(function(c,u){return c*u},1),jtt=b5("round"),Utt=J1(function(c,u){return c-u},0);function ztt(c){return c&&c.length?Gc(c,jn):0}function Vtt(c,u){return c&&c.length?Gc(c,vt(u,2)):0}return E.after=hK,E.ary=Gw,E.assign=XK,E.assignIn=lB,E.assignInWith=um,E.assignWith=tX,E.at=eX,E.before=Zw,E.bind=L5,E.bindAll=stt,E.bindKey=Qw,E.castArray=BK,E.chain=Vw,E.chunk=RY,E.compact=OY,E.concat=_Y,E.cond=ltt,E.conforms=ctt,E.constant=N5,E.countBy=zJ,E.create=nX,E.curry=Yw,E.curryRight=Jw,E.debounce=Kw,E.defaults=oX,E.defaultsDeep=rX,E.defer=fK,E.delay=mK,E.difference=FY,E.differenceBy=PY,E.differenceWith=NY,E.drop=$Y,E.dropRight=HY,E.dropRightWhile=jY,E.dropWhile=UY,E.fill=zY,E.filter=WJ,E.flatMap=ZJ,E.flatMapDeep=QJ,E.flatMapDepth=YJ,E.flatten=Hw,E.flattenDeep=VY,E.flattenDepth=WY,E.flip=gK,E.flow=utt,E.flowRight=dtt,E.fromPairs=qY,E.functions=dX,E.functionsIn=hX,E.groupBy=JJ,E.initial=ZY,E.intersection=QY,E.intersectionBy=YY,E.intersectionWith=JY,E.invert=mX,E.invertBy=gX,E.invokeMap=XJ,E.iteratee=$5,E.keyBy=tK,E.keys=Ke,E.keysIn=Hn,E.map=rm,E.mapKeys=CX,E.mapValues=AX,E.matches=htt,E.matchesProperty=ftt,E.memoize=sm,E.merge=bX,E.mergeWith=cB,E.method=mtt,E.methodOf=gtt,E.mixin=H5,E.negate=lm,E.nthArg=Ctt,E.omit=vX,E.omitBy=yX,E.once=pK,E.orderBy=eK,E.over=Att,E.overArgs=CK,E.overEvery=btt,E.overSome=vtt,E.partial=M5,E.partialRight=Xw,E.partition=nK,E.pick=kX,E.pickBy=aB,E.property=pB,E.propertyOf=ytt,E.pull=eJ,E.pullAll=Uw,E.pullAllBy=nJ,E.pullAllWith=oJ,E.pullAt=rJ,E.range=ktt,E.rangeRight=wtt,E.rearg=AK,E.reject=iK,E.remove=iJ,E.rest=bK,E.reverse=D5,E.sampleSize=lK,E.set=BX,E.setWith=EX,E.shuffle=cK,E.slice=sJ,E.sortBy=dK,E.sortedUniq=fJ,E.sortedUniqBy=mJ,E.split=ZX,E.spread=vK,E.tail=gJ,E.take=pJ,E.takeRight=CJ,E.takeRightWhile=AJ,E.takeWhile=bJ,E.tap=OJ,E.throttle=yK,E.thru=om,E.toArray=rB,E.toPairs=uB,E.toPairsIn=dB,E.toPath=Ttt,E.toPlainObject=sB,E.transform=xX,E.unary=kK,E.union=vJ,E.unionBy=yJ,E.unionWith=kJ,E.uniq=wJ,E.uniqBy=BJ,E.uniqWith=EJ,E.unset=IX,E.unzip=S5,E.unzipWith=zw,E.update=TX,E.updateWith=DX,E.values=la,E.valuesIn=SX,E.without=xJ,E.words=mB,E.wrap=wK,E.xor=IJ,E.xorBy=TJ,E.xorWith=DJ,E.zip=SJ,E.zipObject=LJ,E.zipObjectDeep=MJ,E.zipWith=RJ,E.entries=uB,E.entriesIn=dB,E.extend=lB,E.extendWith=um,H5(E,E),E.add=Stt,E.attempt=gB,E.camelCase=OX,E.capitalize=hB,E.ceil=Ltt,E.clamp=LX,E.clone=EK,E.cloneDeep=IK,E.cloneDeepWith=TK,E.cloneWith=xK,E.conformsTo=DK,E.deburr=fB,E.defaultTo=att,E.divide=Mtt,E.endsWith=_X,E.eq=tr,E.escape=FX,E.escapeRegExp=PX,E.every=VJ,E.find=qJ,E.findIndex=Nw,E.findKey=iX,E.findLast=GJ,E.findLastIndex=$w,E.findLastKey=sX,E.floor=Rtt,E.forEach=Ww,E.forEachRight=qw,E.forIn=lX,E.forInRight=cX,E.forOwn=aX,E.forOwnRight=uX,E.get=_5,E.gt=SK,E.gte=LK,E.has=fX,E.hasIn=F5,E.head=jw,E.identity=jn,E.includes=KJ,E.indexOf=GY,E.inRange=MX,E.invoke=pX,E.isArguments=Nl,E.isArray=St,E.isArrayBuffer=MK,E.isArrayLike=$n,E.isArrayLikeObject=Te,E.isBoolean=RK,E.isBuffer=ps,E.isDate=OK,E.isElement=_K,E.isEmpty=FK,E.isEqual=PK,E.isEqualWith=NK,E.isError=R5,E.isFinite=$K,E.isFunction=Ei,E.isInteger=tB,E.isLength=cm,E.isMap=eB,E.isMatch=HK,E.isMatchWith=jK,E.isNaN=UK,E.isNative=zK,E.isNil=WK,E.isNull=VK,E.isNumber=nB,E.isObject=be,E.isObjectLike=Be,E.isPlainObject=Rd,E.isRegExp=O5,E.isSafeInteger=qK,E.isSet=oB,E.isString=am,E.isSymbol=eo,E.isTypedArray=sa,E.isUndefined=GK,E.isWeakMap=ZK,E.isWeakSet=QK,E.join=KY,E.kebabCase=NX,E.last=wo,E.lastIndexOf=XY,E.lowerCase=$X,E.lowerFirst=HX,E.lt=YK,E.lte=JK,E.max=Ott,E.maxBy=_tt,E.mean=Ftt,E.meanBy=Ptt,E.min=Ntt,E.minBy=$tt,E.stubArray=U5,E.stubFalse=z5,E.stubObject=Btt,E.stubString=Ett,E.stubTrue=xtt,E.multiply=Htt,E.nth=tJ,E.noConflict=ptt,E.noop=j5,E.now=im,E.pad=jX,E.padEnd=UX,E.padStart=zX,E.parseInt=VX,E.random=RX,E.reduce=oK,E.reduceRight=rK,E.repeat=WX,E.replace=qX,E.result=wX,E.round=jtt,E.runInContext=N,E.sample=sK,E.size=aK,E.snakeCase=GX,E.some=uK,E.sortedIndex=lJ,E.sortedIndexBy=cJ,E.sortedIndexOf=aJ,E.sortedLastIndex=uJ,E.sortedLastIndexBy=dJ,E.sortedLastIndexOf=hJ,E.startCase=QX,E.startsWith=YX,E.subtract=Utt,E.sum=ztt,E.sumBy=Vtt,E.template=JX,E.times=Itt,E.toFinite=xi,E.toInteger=Rt,E.toLength=iB,E.toLower=KX,E.toNumber=Bo,E.toSafeInteger=KK,E.toString=Jt,E.toUpper=XX,E.trim=ttt,E.trimEnd=ett,E.trimStart=ntt,E.truncate=ott,E.unescape=rtt,E.uniqueId=Dtt,E.upperCase=itt,E.upperFirst=P5,E.each=Ww,E.eachRight=qw,E.first=jw,H5(E,function(){var c={};return Sr(E,function(u,f){Wt.call(E.prototype,f)||(c[f]=u)}),c}(),{chain:!1}),E.VERSION=o,_n(["bind","bindKey","curry","curryRight","partial","partialRight"],function(c){E[c].placeholder=E}),_n(["drop","take"],function(c,u){Pt.prototype[c]=function(f){f=f===e?1:T(Rt(f),0);var C=this.__filtered__&&!u?new Pt(this):this.clone();return C.__filtered__?C.__takeCount__=L(f,C.__takeCount__):C.__views__.push({size:L(f,po),type:c+(C.__dir__<0?"Right":"")}),C},Pt.prototype[c+"Right"]=function(f){return this.reverse()[c](f).reverse()}}),_n(["filter","map","takeWhile"],function(c,u){var f=u+1,C=f==$e||f==kr;Pt.prototype[c]=function(y){var I=this.clone();return I.__iteratees__.push({iteratee:vt(y,3),type:f}),I.__filtered__=I.__filtered__||C,I}}),_n(["head","last"],function(c,u){var f="take"+(u?"Right":"");Pt.prototype[c]=function(){return this[f](1).value()[0]}}),_n(["initial","tail"],function(c,u){var f="drop"+(u?"":"Right");Pt.prototype[c]=function(){return this.__filtered__?new Pt(this):this[f](1)}}),Pt.prototype.compact=function(){return this.filter(jn)},Pt.prototype.find=function(c){return this.filter(c).head()},Pt.prototype.findLast=function(c){return this.reverse().find(c)},Pt.prototype.invokeMap=_t(function(c,u){return typeof c=="function"?new Pt(this):this.map(function(f){return Id(f,c,u)})}),Pt.prototype.reject=function(c){return this.filter(lm(vt(c)))},Pt.prototype.slice=function(c,u){c=Rt(c);var f=this;return f.__filtered__&&(c>0||u<0)?new Pt(f):(c<0?f=f.takeRight(-c):c&&(f=f.drop(c)),u!==e&&(u=Rt(u),f=u<0?f.dropRight(-u):f.take(u-c)),f)},Pt.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},Pt.prototype.toArray=function(){return this.take(po)},Sr(Pt.prototype,function(c,u){var f=/^(?:filter|find|map|reject)|While$/.test(u),C=/^(?:head|last)$/.test(u),y=E[C?"take"+(u=="last"?"Right":""):u],I=C||/^find/.test(u);!y||(E.prototype[u]=function(){var O=this.__wrapped__,P=C?[1]:arguments,$=O instanceof Pt,Q=P[0],Y=$||St(O),X=function($t){var zt=y.apply(E,Ir([$t],P));return C&&dt?zt[0]:zt};Y&&f&&typeof Q=="function"&&Q.length!=1&&($=Y=!1);var dt=this.__chain__,Ct=!!this.__actions__.length,yt=I&&!dt,Ot=$&&!Ct;if(!I&&Y){O=Ot?O:new Pt(this);var kt=c.apply(O,P);return kt.__actions__.push({func:om,args:[X],thisArg:e}),new Pn(kt,dt)}return yt&&Ot?c.apply(this,P):(kt=this.thru(X),yt?C?kt.value()[0]:kt.value():kt)})}),_n(["pop","push","shift","sort","splice","unshift"],function(c){var u=yl[c],f=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",C=/^(?:pop|shift)$/.test(c);E.prototype[c]=function(){var y=arguments;if(C&&!this.__chain__){var I=this.value();return u.apply(St(I)?I:[],y)}return this[f](function(O){return u.apply(St(O)?O:[],y)})}}),Sr(Pt.prototype,function(c,u){var f=E[u];if(f){var C=f.name+"";Wt.call(en,C)||(en[C]=[]),en[C].push({name:u,func:f})}}),en[Y1(e,_).name]=[{name:"wrapper",func:e}],Pt.prototype.clone=rQ,Pt.prototype.reverse=iQ,Pt.prototype.value=sQ,E.prototype.at=_J,E.prototype.chain=FJ,E.prototype.commit=PJ,E.prototype.next=NJ,E.prototype.plant=HJ,E.prototype.reverse=jJ,E.prototype.toJSON=E.prototype.valueOf=E.prototype.value=UJ,E.prototype.first=E.prototype.head,Tl&&(E.prototype[Tl]=$J),E},fi=ea();li?((li.exports=fi)._=fi,sd._=fi):Ge._=fi}).call(ar)})(V2,V2.exports);const qq={mermaid:"https://mermaid-js.github.io/mermaid/",flowchart:"https://flowchart.js.org/",plantuml:"https://plantuml.com/"};class Gq extends E2{constructor(e,o,r,i){super(e,o,i);m(this,"group","hovering-toolbar");m(this,"_commands",[{id:"edit",name:R.t("graph.edit"),icon:Sp},{id:"add-comment",name:R.t("graph.comment"),icon:eu},{id:"separator",type:"separator",name:""},{id:"help",name:R.t("graph.help"),icon:uv}]);this.editor=e,this.block=o,this.graphType=r,this.properties=i}executeCommand(e,o,r){var i,s;(s=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&s.call(i,e,o,r)||r.id==="edit"||r.id==="help"&&window.open(qq[this.graphType])}}function Zq(n,t,e,o){return{blockCommands:{"hovering-toolbar":new Gq(n,t,e,o)},abstract:V2.exports.capitalize(e)}}class W2{constructor(t,e,o){m(this,"editor");m(this,"logger");m(this,"editing",!1);this.graphType=e,this.codeEmbedDataKey=o,this.editor=t,this.logger=S(`embed-block-${this.graphType}`)}i18nt(t,e){return R.t(`graph.${t}`,e||{})}getContent(t){g(this.logger,t,"embed-element does not exist");const e=t.parentElement;return g(this.logger,e,"content-element does not exist"),e}getEmbed(t){const e=t.childNodes[0];return g(this.logger,e,"embed-element does not exist"),e}async uploadResource(t){const e=new Blob([t]),o=new File([e],`${this.graphType}.svg`,{type:"image/svg+xml"});try{const r=await this.editor.doc.uploadResource(o);g(this.logger,r,"uploadResource failed");const{resourceId:i}=r;return this.editor.doc.buildResourceUrl(i)}catch(r){return this.logger.error(r),null}}createEmbedContent(t,e){const o=w("div",["graph-embed"],t),{embedData:r}=e,i=r[`${this.codeEmbedDataKey}`],s=r.src,l=w("div",["embed-graph-img-content"],o),a=w("img",["graph-embed-image"],l);a.draggable=!1,this.updateImage(o,i,s,null)}updateEmbedContent(t,e){const{embedData:o}=e,r=o[this.codeEmbedDataKey],i=o.src,s=t.querySelector(".graph-embed");this.updateImage(s,r,i,null)}async updateImage(t,e,o,r){const i=t.querySelector("img.graph-embed-image");let s=this.editor.doc.buildResourceUrl(o||"");if(!s&&!r&&e)try{s=await this.code2ObjectUrl(e)}catch(l){this.updateImage(t,e,o,l);return}this.updateClasses(t,e,r),i.onerror=()=>{this.updateImage(t,e,o,new Error("image load failed"))},s&&(i.src=s,i.onerror=()=>{this.errorBoundary(t,e,o)})}errorBoundary(t,e,o){t.innerHTML="";const r=w("div",["graph-error-content"],t),i=w("div",["graph-error-brand-icon"],r);i.innerHTML=Cv,w("div",["graph-error-title"],r,R.t("graph.errorTips",{EmbedName:this.graphType}));const s=w("div",["graph-error-sub-title"],r);w("span",[],s,R.t("graph.errorSubTips"));const l=w("span",["graph-error-retry-button"],s,R.t("graph.retry"));l.onclick=()=>{t.innerHTML="";const a=w("div",["embed-graph-img-content"],t),d=w("img",["graph-embed-image"],a);d.draggable=!1,this.updateImage(t,e,o,null)}}updateClasses(t,e,o){const r=t.querySelector("img.graph-embed-image"),i=et(t);if(o&&i){const s=r.src;r.remove(),this.errorBoundary(t,e,s);return}if(!e){r.src="";const s=this.i18nt("empty",{EmbedName:this.graphType});t.setAttribute("data-empty-tips",s),W(t,"empty-embed")}}editGraph(t){this.editing=!0;const e=et(t);g(this.logger,e,`${this.graphType} block does not exist`),Y0(this.editor,e);const o=t.querySelector(".graph-embed"),r=l=>{this.updateImage(o,l,null,null)},i=async l=>{try{if(this.editing=!1,J0(this.editor,e),r(l),!this.hasChanged(e,l))return;const d={src:await this.code2ResourceId(l),[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,d)}catch(a){this.updateClasses(o,l,a);const d={src:"",[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,d)}},s=this.editor.getBlockData(e);Wq(this.editor,e,{onChange:r,onEnd:i,codeValue:s.embedData[`${this.codeEmbedDataKey}`]})}getBlockProperties(t,e){return this.editing?{}:Zq(this.editor,t,this.graphType,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){if(!o.isBlockWritable(r))return!0;const s=Lt(r);return this.editGraph(s),!0}return i.id==="add-comment"?(o.readonly||Xf(o,r),!0):!1}})}hasChanged(t,e){return this.editor.getBlockData(t).embedData[`${this.codeEmbedDataKey}`]!==e}}const Qq="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js",Yq=["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js","//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"],Jq="https://www.plantuml.com/plantuml/svg",Kq=S("mermaid-helper"),Xq="wiz-editor-mermaid";async function ck(n,t){var B;const o=((B=(n.getComponentOptions("mermaid")||{}).cdn)==null?void 0:B.mermaid)||Qq;await vs(o,Xq);const r=window.mermaid;g(Kq,r,"Resource load failed: Mermaid javaScript resource injection failed");const i=K(),l=await new Promise((D,x)=>{try{r.mermaidAPI.render(i,t,_=>{setTimeout(()=>{D(_)})})}catch(_){_.message=_.str,x(_)}}),h=new DOMParser().parseFromString(l,"image/svg+xml").firstChild,p=h.style.maxWidth;return p&&h.setAttribute("width",p),new XMLSerializer().serializeToString(h)}async function tG(n,t){const e=await ck(n,t);return Sm(e,"image/svg+xml",`${K()}.svg`)}async function eG(n,t){const e=await ck(n,t),o=new Blob([e]),r=new File([o],`${K()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class Mc extends W2{constructor(t){super(t,"mermaid","mermaidText")}static get(t,e){return t.addCustom(`mermaid-${e.id}`,()=>new Mc(t))}code2ObjectUrl(t){return tG(this.editor,t)}code2ResourceId(t){return eG(this.editor,t)}destroy(){}}const nG={graph:{invalid:"\u65E0\u6548\u7684 {EmbedName} \u5185\u5BB9\uFF1A{message}",empty:"\u7A7A\u7684 {EmbedName}",edit:"\u7F16\u8F91",comment:"\u6279\u6CE8",help:"\u5E2E\u52A9",errorTips:"{EmbedName}\u52A0\u8F7D\u5931\u8D25",errorSubTips:"\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5",retry:"\u91CD\u8BD5"}},oG={graph:{invalid:"Invalid {EmbedName} content: {message}",empty:"Empty {EmbedName}",edit:"Edit",comment:"Annotation",help:"Help",errorTips:"{EmbedName} loading failed",errorSubTips:"The network service is abnormal, you can",retry:"Try again"}},rG={graph:{invalid:"\u7121\u52B9\u306A{EmbedName}\uFF1A{message}",empty:"\u7A7A\u306E {EmbedName}",edit:"\u7DE8\u96C6",comment:"\u6CE8\u91C8",help:"\u30D8\u30EB\u30D7",errorTips:"{EmbedName} \u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F",errorSubTips:"\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 ",retry:"\u518D\u8A66\u884C"}};R.mergeLang({"zh-CN":nG,"en-US":oG,"ja-JP":rG});function iG(n,t,e){Mc.get(n,e).createEmbedContent(t,e)}function sG(n,t,e){const o=Mc.get(n,n.getBlockData(t)),r=Lt(t);return o.updateEmbedContent(r,e),!0}function lG(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="mermaid"||r!=="```mermaid"||!tt(n,t))return null;const i={src:"",mermaidText:""};return{blockData:{id:K(),type:"embed",embedType:"mermaid",embedData:i},onConverted:(a,d)=>{Mc.get(a,a.getBlockData(d)).editGraph(Lt(d))}}}function cG(n,t){return Mc.get(n,n.getBlockData(t)).getBlockProperties(t)}function aG(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.mermaidText?`<div class="mermaid">${i.mermaidText}</div>`:"<p>[mermaid]</p>";if(o==="markdown"){if(i.src)return`![mermaid](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`;if(i.mermaidText)return`\`\`\`mermaid\`\`\`
747
+ }`;var Ot=gB(function(){return Vt(I,Ct+"return "+X).apply(e,O)});if(Ot.source=X,R5(Ot))throw Ot;return Ot}function KX(c){return Jt(c).toLowerCase()}function XX(c){return Jt(c).toUpperCase()}function ttt(c,u,f){if(c=Jt(c),c&&(f||u===e))return ai(c);if(!c||!(u=to(u)))return c;var C=Xn(c),y=Xn(u),I=Cl(C,y),O=Cd(C,y)+1;return gs(C,I,O).join("")}function ett(c,u,f){if(c=Jt(c),c&&(f||u===e))return c.slice(0,Kc(c)+1);if(!c||!(u=to(u)))return c;var C=Xn(c),y=Cd(C,Xn(u))+1;return gs(C,0,y).join("")}function ntt(c,u,f){if(c=Jt(c),c&&(f||u===e))return c.replace(Yu,"");if(!c||!(u=to(u)))return c;var C=Xn(c),y=Cl(C,Xn(u));return gs(C,y).join("")}function ott(c,u){var f=Ut,C=ne;if(be(u)){var y="separator"in u?u.separator:y;f="length"in u?Rt(u.length):f,C="omission"in u?to(u.omission):C}c=Jt(c);var I=c.length;if(ui(c)){var O=Xn(c);I=O.length}if(f>=I)return c;var P=f-us(C);if(P<1)return C;var $=O?gs(O,0,P).join(""):c.slice(0,P);if(y===e)return $+C;if(O&&(P+=$.length-P),O5(y)){if(c.slice(P).search(y)){var Q,Y=$;for(y.global||(y=na(y.source,Jt(Pc.exec(y))+"g")),y.lastIndex=0;Q=y.exec(Y);)var X=Q.index;$=$.slice(0,X===e?P:X)}}else if(c.indexOf(to(y),P)!=P){var dt=$.lastIndexOf(y);dt>-1&&($=$.slice(0,dt))}return $+C}function rtt(c){return c=Jt(c),c&&i3.test(c)?c.replace(h1,Xc):c}var itt=ra(function(c,u,f){return c+(f?" ":"")+u.toUpperCase()}),P5=pw("toUpperCase");function mB(c,u,f){return c=Jt(c),u=f?e:u,u===e?Qc(c)?O1(c):Jn(c):c.match(u)||[]}var gB=_t(function(c,u){try{return yn(c,e,u)}catch(f){return R5(f)?f:new Et(f)}}),stt=wi(function(c,u){return _n(u,function(f){f=Mr(f),yi(c,f,L5(c[f],c))}),c});function ltt(c){var u=c==null?0:c.length,f=vt();return c=u?ue(c,function(C){if(typeof C[1]!="function")throw new kn(s);return[f(C[0]),C[1]]}):[],_t(function(C){for(var y=-1;++y<u;){var I=c[y];if(yn(I[0],this,C))return yn(I[1],this,C)}})}function ctt(c){return RQ(yo(c,p))}function N5(c){return function(){return c}}function att(c,u){return c==null||c!==c?u:c}var utt=Aw(),dtt=Aw(!0);function jn(c){return c}function $5(c){return Zk(typeof c=="function"?c:yo(c,p))}function htt(c){return Yk(yo(c,p))}function ftt(c,u){return Jk(c,yo(u,p))}var mtt=_t(function(c,u){return function(f){return Id(f,c,u)}}),gtt=_t(function(c,u){return function(f){return Id(c,f,u)}});function H5(c,u,f){var C=Ke(u),y=W1(u,C);f==null&&!(be(u)&&(y.length||!C.length))&&(f=u,u=c,c=this,y=W1(u,Ke(u)));var I=!(be(f)&&"chain"in f)||!!f.chain,O=Ei(c);return _n(y,function(P){var $=u[P];c[P]=$,O&&(c.prototype[P]=function(){var Q=this.__chain__;if(I||Q){var Y=c(this.__wrapped__),X=Y.__actions__=Nn(this.__actions__);return X.push({func:$,args:arguments,thisArg:c}),Y.__chain__=Q,Y}return $.apply(c,Ir([this.value()],arguments))})}),c}function ptt(){return Ge._===this&&(Ge._=F1),this}function j5(){}function Ctt(c){return c=Rt(c),_t(function(u){return Kk(u,c)})}var Att=A5(ue),btt=A5(x1),vtt=A5(md);function pB(c){return E5(c)?qc(Mr(c)):YQ(c)}function ytt(c){return function(u){return c==null?e:_l(c,u)}}var ktt=vw(),wtt=vw(!0);function U5(){return[]}function z5(){return!1}function Btt(){return{}}function Ett(){return""}function xtt(){return!0}function Itt(c,u){if(c=Rt(c),c<1||c>an)return[];var f=po,C=L(c,po);u=vt(u),c-=po;for(var y=Zc(C,u);++f<c;)u(f);return y}function Ttt(c){return St(c)?ue(c,Mr):eo(c)?[c]:Nn(Fw(Jt(c)))}function Dtt(c){var u=++_1;return Jt(c)+u}var Stt=J1(function(c,u){return c+u},0),Ltt=b5("ceil"),Mtt=J1(function(c,u){return c/u},1),Rtt=b5("floor");function Ott(c){return c&&c.length?V1(c,jn,r5):e}function _tt(c,u){return c&&c.length?V1(c,vt(u,2),r5):e}function Ftt(c){return Wc(c,jn)}function Ptt(c,u){return Wc(c,vt(u,2))}function Ntt(c){return c&&c.length?V1(c,jn,c5):e}function $tt(c,u){return c&&c.length?V1(c,vt(u,2),c5):e}var Htt=J1(function(c,u){return c*u},1),jtt=b5("round"),Utt=J1(function(c,u){return c-u},0);function ztt(c){return c&&c.length?Gc(c,jn):0}function Vtt(c,u){return c&&c.length?Gc(c,vt(u,2)):0}return E.after=hK,E.ary=Gw,E.assign=XK,E.assignIn=lB,E.assignInWith=um,E.assignWith=tX,E.at=eX,E.before=Zw,E.bind=L5,E.bindAll=stt,E.bindKey=Qw,E.castArray=BK,E.chain=Vw,E.chunk=RY,E.compact=OY,E.concat=_Y,E.cond=ltt,E.conforms=ctt,E.constant=N5,E.countBy=zJ,E.create=nX,E.curry=Yw,E.curryRight=Jw,E.debounce=Kw,E.defaults=oX,E.defaultsDeep=rX,E.defer=fK,E.delay=mK,E.difference=FY,E.differenceBy=PY,E.differenceWith=NY,E.drop=$Y,E.dropRight=HY,E.dropRightWhile=jY,E.dropWhile=UY,E.fill=zY,E.filter=WJ,E.flatMap=ZJ,E.flatMapDeep=QJ,E.flatMapDepth=YJ,E.flatten=Hw,E.flattenDeep=VY,E.flattenDepth=WY,E.flip=gK,E.flow=utt,E.flowRight=dtt,E.fromPairs=qY,E.functions=dX,E.functionsIn=hX,E.groupBy=JJ,E.initial=ZY,E.intersection=QY,E.intersectionBy=YY,E.intersectionWith=JY,E.invert=mX,E.invertBy=gX,E.invokeMap=XJ,E.iteratee=$5,E.keyBy=tK,E.keys=Ke,E.keysIn=Hn,E.map=rm,E.mapKeys=CX,E.mapValues=AX,E.matches=htt,E.matchesProperty=ftt,E.memoize=sm,E.merge=bX,E.mergeWith=cB,E.method=mtt,E.methodOf=gtt,E.mixin=H5,E.negate=lm,E.nthArg=Ctt,E.omit=vX,E.omitBy=yX,E.once=pK,E.orderBy=eK,E.over=Att,E.overArgs=CK,E.overEvery=btt,E.overSome=vtt,E.partial=M5,E.partialRight=Xw,E.partition=nK,E.pick=kX,E.pickBy=aB,E.property=pB,E.propertyOf=ytt,E.pull=eJ,E.pullAll=Uw,E.pullAllBy=nJ,E.pullAllWith=oJ,E.pullAt=rJ,E.range=ktt,E.rangeRight=wtt,E.rearg=AK,E.reject=iK,E.remove=iJ,E.rest=bK,E.reverse=D5,E.sampleSize=lK,E.set=BX,E.setWith=EX,E.shuffle=cK,E.slice=sJ,E.sortBy=dK,E.sortedUniq=fJ,E.sortedUniqBy=mJ,E.split=ZX,E.spread=vK,E.tail=gJ,E.take=pJ,E.takeRight=CJ,E.takeRightWhile=AJ,E.takeWhile=bJ,E.tap=OJ,E.throttle=yK,E.thru=om,E.toArray=rB,E.toPairs=uB,E.toPairsIn=dB,E.toPath=Ttt,E.toPlainObject=sB,E.transform=xX,E.unary=kK,E.union=vJ,E.unionBy=yJ,E.unionWith=kJ,E.uniq=wJ,E.uniqBy=BJ,E.uniqWith=EJ,E.unset=IX,E.unzip=S5,E.unzipWith=zw,E.update=TX,E.updateWith=DX,E.values=la,E.valuesIn=SX,E.without=xJ,E.words=mB,E.wrap=wK,E.xor=IJ,E.xorBy=TJ,E.xorWith=DJ,E.zip=SJ,E.zipObject=LJ,E.zipObjectDeep=MJ,E.zipWith=RJ,E.entries=uB,E.entriesIn=dB,E.extend=lB,E.extendWith=um,H5(E,E),E.add=Stt,E.attempt=gB,E.camelCase=OX,E.capitalize=hB,E.ceil=Ltt,E.clamp=LX,E.clone=EK,E.cloneDeep=IK,E.cloneDeepWith=TK,E.cloneWith=xK,E.conformsTo=DK,E.deburr=fB,E.defaultTo=att,E.divide=Mtt,E.endsWith=_X,E.eq=tr,E.escape=FX,E.escapeRegExp=PX,E.every=VJ,E.find=qJ,E.findIndex=Nw,E.findKey=iX,E.findLast=GJ,E.findLastIndex=$w,E.findLastKey=sX,E.floor=Rtt,E.forEach=Ww,E.forEachRight=qw,E.forIn=lX,E.forInRight=cX,E.forOwn=aX,E.forOwnRight=uX,E.get=_5,E.gt=SK,E.gte=LK,E.has=fX,E.hasIn=F5,E.head=jw,E.identity=jn,E.includes=KJ,E.indexOf=GY,E.inRange=MX,E.invoke=pX,E.isArguments=Nl,E.isArray=St,E.isArrayBuffer=MK,E.isArrayLike=$n,E.isArrayLikeObject=Te,E.isBoolean=RK,E.isBuffer=ps,E.isDate=OK,E.isElement=_K,E.isEmpty=FK,E.isEqual=PK,E.isEqualWith=NK,E.isError=R5,E.isFinite=$K,E.isFunction=Ei,E.isInteger=tB,E.isLength=cm,E.isMap=eB,E.isMatch=HK,E.isMatchWith=jK,E.isNaN=UK,E.isNative=zK,E.isNil=WK,E.isNull=VK,E.isNumber=nB,E.isObject=be,E.isObjectLike=Be,E.isPlainObject=Rd,E.isRegExp=O5,E.isSafeInteger=qK,E.isSet=oB,E.isString=am,E.isSymbol=eo,E.isTypedArray=sa,E.isUndefined=GK,E.isWeakMap=ZK,E.isWeakSet=QK,E.join=KY,E.kebabCase=NX,E.last=wo,E.lastIndexOf=XY,E.lowerCase=$X,E.lowerFirst=HX,E.lt=YK,E.lte=JK,E.max=Ott,E.maxBy=_tt,E.mean=Ftt,E.meanBy=Ptt,E.min=Ntt,E.minBy=$tt,E.stubArray=U5,E.stubFalse=z5,E.stubObject=Btt,E.stubString=Ett,E.stubTrue=xtt,E.multiply=Htt,E.nth=tJ,E.noConflict=ptt,E.noop=j5,E.now=im,E.pad=jX,E.padEnd=UX,E.padStart=zX,E.parseInt=VX,E.random=RX,E.reduce=oK,E.reduceRight=rK,E.repeat=WX,E.replace=qX,E.result=wX,E.round=jtt,E.runInContext=N,E.sample=sK,E.size=aK,E.snakeCase=GX,E.some=uK,E.sortedIndex=lJ,E.sortedIndexBy=cJ,E.sortedIndexOf=aJ,E.sortedLastIndex=uJ,E.sortedLastIndexBy=dJ,E.sortedLastIndexOf=hJ,E.startCase=QX,E.startsWith=YX,E.subtract=Utt,E.sum=ztt,E.sumBy=Vtt,E.template=JX,E.times=Itt,E.toFinite=xi,E.toInteger=Rt,E.toLength=iB,E.toLower=KX,E.toNumber=Bo,E.toSafeInteger=KK,E.toString=Jt,E.toUpper=XX,E.trim=ttt,E.trimEnd=ett,E.trimStart=ntt,E.truncate=ott,E.unescape=rtt,E.uniqueId=Dtt,E.upperCase=itt,E.upperFirst=P5,E.each=Ww,E.eachRight=qw,E.first=jw,H5(E,function(){var c={};return Sr(E,function(u,f){Wt.call(E.prototype,f)||(c[f]=u)}),c}(),{chain:!1}),E.VERSION=o,_n(["bind","bindKey","curry","curryRight","partial","partialRight"],function(c){E[c].placeholder=E}),_n(["drop","take"],function(c,u){Pt.prototype[c]=function(f){f=f===e?1:T(Rt(f),0);var C=this.__filtered__&&!u?new Pt(this):this.clone();return C.__filtered__?C.__takeCount__=L(f,C.__takeCount__):C.__views__.push({size:L(f,po),type:c+(C.__dir__<0?"Right":"")}),C},Pt.prototype[c+"Right"]=function(f){return this.reverse()[c](f).reverse()}}),_n(["filter","map","takeWhile"],function(c,u){var f=u+1,C=f==$e||f==kr;Pt.prototype[c]=function(y){var I=this.clone();return I.__iteratees__.push({iteratee:vt(y,3),type:f}),I.__filtered__=I.__filtered__||C,I}}),_n(["head","last"],function(c,u){var f="take"+(u?"Right":"");Pt.prototype[c]=function(){return this[f](1).value()[0]}}),_n(["initial","tail"],function(c,u){var f="drop"+(u?"":"Right");Pt.prototype[c]=function(){return this.__filtered__?new Pt(this):this[f](1)}}),Pt.prototype.compact=function(){return this.filter(jn)},Pt.prototype.find=function(c){return this.filter(c).head()},Pt.prototype.findLast=function(c){return this.reverse().find(c)},Pt.prototype.invokeMap=_t(function(c,u){return typeof c=="function"?new Pt(this):this.map(function(f){return Id(f,c,u)})}),Pt.prototype.reject=function(c){return this.filter(lm(vt(c)))},Pt.prototype.slice=function(c,u){c=Rt(c);var f=this;return f.__filtered__&&(c>0||u<0)?new Pt(f):(c<0?f=f.takeRight(-c):c&&(f=f.drop(c)),u!==e&&(u=Rt(u),f=u<0?f.dropRight(-u):f.take(u-c)),f)},Pt.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},Pt.prototype.toArray=function(){return this.take(po)},Sr(Pt.prototype,function(c,u){var f=/^(?:filter|find|map|reject)|While$/.test(u),C=/^(?:head|last)$/.test(u),y=E[C?"take"+(u=="last"?"Right":""):u],I=C||/^find/.test(u);!y||(E.prototype[u]=function(){var O=this.__wrapped__,P=C?[1]:arguments,$=O instanceof Pt,Q=P[0],Y=$||St(O),X=function($t){var zt=y.apply(E,Ir([$t],P));return C&&dt?zt[0]:zt};Y&&f&&typeof Q=="function"&&Q.length!=1&&($=Y=!1);var dt=this.__chain__,Ct=!!this.__actions__.length,yt=I&&!dt,Ot=$&&!Ct;if(!I&&Y){O=Ot?O:new Pt(this);var kt=c.apply(O,P);return kt.__actions__.push({func:om,args:[X],thisArg:e}),new Pn(kt,dt)}return yt&&Ot?c.apply(this,P):(kt=this.thru(X),yt?C?kt.value()[0]:kt.value():kt)})}),_n(["pop","push","shift","sort","splice","unshift"],function(c){var u=yl[c],f=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",C=/^(?:pop|shift)$/.test(c);E.prototype[c]=function(){var y=arguments;if(C&&!this.__chain__){var I=this.value();return u.apply(St(I)?I:[],y)}return this[f](function(O){return u.apply(St(O)?O:[],y)})}}),Sr(Pt.prototype,function(c,u){var f=E[u];if(f){var C=f.name+"";Wt.call(en,C)||(en[C]=[]),en[C].push({name:u,func:f})}}),en[Y1(e,_).name]=[{name:"wrapper",func:e}],Pt.prototype.clone=rQ,Pt.prototype.reverse=iQ,Pt.prototype.value=sQ,E.prototype.at=_J,E.prototype.chain=FJ,E.prototype.commit=PJ,E.prototype.next=NJ,E.prototype.plant=HJ,E.prototype.reverse=jJ,E.prototype.toJSON=E.prototype.valueOf=E.prototype.value=UJ,E.prototype.first=E.prototype.head,Tl&&(E.prototype[Tl]=$J),E},fi=ea();li?((li.exports=fi)._=fi,sd._=fi):Ge._=fi}).call(ar)})(V2,V2.exports);const qq={mermaid:"https://mermaid-js.github.io/mermaid/",flowchart:"https://flowchart.js.org/",plantuml:"https://plantuml.com/"};class Gq extends E2{constructor(e,o,r,i){super(e,o,i);m(this,"group","hovering-toolbar");m(this,"_commands",[{id:"edit",name:R.t("graph.edit"),icon:Sp},{id:"add-comment",name:R.t("graph.comment"),icon:eu},{id:"separator",type:"separator",name:""},{id:"help",name:R.t("graph.help"),icon:uv}]);this.editor=e,this.block=o,this.graphType=r,this.properties=i}executeCommand(e,o,r){var i,s;(s=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&s.call(i,e,o,r)||r.id==="edit"||r.id==="help"&&window.open(qq[this.graphType])}}function Zq(n,t,e,o){return{blockCommands:{"hovering-toolbar":new Gq(n,t,e,o)},abstract:V2.exports.capitalize(e)}}class W2{constructor(t,e,o){m(this,"editor");m(this,"logger");m(this,"editing",!1);this.graphType=e,this.codeEmbedDataKey=o,this.editor=t,this.logger=S(`embed-block-${this.graphType}`)}i18nt(t,e){return R.t(`graph.${t}`,e||{})}getContent(t){g(this.logger,t,"embed-element does not exist");const e=t.parentElement;return g(this.logger,e,"content-element does not exist"),e}getEmbed(t){const e=t.childNodes[0];return g(this.logger,e,"embed-element does not exist"),e}async uploadResource(t){const e=new Blob([t]),o=new File([e],`${this.graphType}.svg`,{type:"image/svg+xml"});try{const r=await this.editor.doc.uploadResource(o);g(this.logger,r,"uploadResource failed");const{resourceId:i}=r;return this.editor.doc.buildResourceUrl(i)}catch(r){return this.logger.error(r),null}}createEmbedContent(t,e){const o=w("div",["graph-embed"],t),{embedData:r}=e,i=r[`${this.codeEmbedDataKey}`],s=r.src,l=w("div",["embed-graph-img-content"],o),a=w("img",["graph-embed-image"],l);a.draggable=!1,this.updateImage(o,i,s,null)}updateEmbedContent(t,e){const{embedData:o}=e,r=o[this.codeEmbedDataKey],i=o.src,s=t.querySelector(".graph-embed");this.updateImage(s,r,i,null)}async updateImage(t,e,o,r){const i=t.querySelector("img.graph-embed-image");let s=this.editor.doc.buildResourceUrl(o||"");if(!s&&!r&&e)try{s=await this.code2ObjectUrl(e)}catch(l){this.updateImage(t,e,o,l);return}this.updateClasses(t,e,r),i.onerror=()=>{this.updateImage(t,e,o,new Error("image load failed"))},s&&(i.src=s,i.onerror=()=>{this.errorBoundary(t,e,o)})}errorBoundary(t,e,o){t.innerHTML="";const r=w("div",["graph-error-content"],t),i=w("div",["graph-error-brand-icon"],r);i.innerHTML=Cv,w("div",["graph-error-title"],r,R.t("graph.errorTips",{EmbedName:this.graphType}));const s=w("div",["graph-error-sub-title"],r);w("span",[],s,R.t("graph.errorSubTips"));const l=w("span",["graph-error-retry-button"],s,R.t("graph.retry"));l.onclick=()=>{t.innerHTML="";const a=w("div",["embed-graph-img-content"],t),d=w("img",["graph-embed-image"],a);d.draggable=!1,this.updateImage(t,e,o,null)}}updateClasses(t,e,o){const r=t.querySelector("img.graph-embed-image"),i=et(t);if(o&&i&&e){const s=r.src;r.remove(),this.errorBoundary(t,e,s);return}if(!e){r.src="";const s=this.i18nt("empty",{EmbedName:this.graphType});t.setAttribute("data-empty-tips",s),W(t,"empty-embed")}}editGraph(t){this.editing=!0;const e=et(t);g(this.logger,e,`${this.graphType} block does not exist`),Y0(this.editor,e);const o=t.querySelector(".graph-embed"),r=l=>{this.updateImage(o,l,null,null)},i=async l=>{try{if(this.editing=!1,J0(this.editor,e),r(l),!this.hasChanged(e,l))return;const d={src:await this.code2ResourceId(l),[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,d)}catch(a){this.updateClasses(o,l,a);const d={src:"",[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,d)}},s=this.editor.getBlockData(e);Wq(this.editor,e,{onChange:r,onEnd:i,codeValue:s.embedData[`${this.codeEmbedDataKey}`]})}getBlockProperties(t,e){return this.editing?{}:Zq(this.editor,t,this.graphType,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){if(!o.isBlockWritable(r))return!0;const s=Lt(r);return this.editGraph(s),!0}return i.id==="add-comment"?(o.readonly||Xf(o,r),!0):!1}})}hasChanged(t,e){return this.editor.getBlockData(t).embedData[`${this.codeEmbedDataKey}`]!==e}}const Qq="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js",Yq=["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js","//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"],Jq="https://www.plantuml.com/plantuml/svg",Kq=S("mermaid-helper"),Xq="wiz-editor-mermaid";async function ck(n,t){var B;const o=((B=(n.getComponentOptions("mermaid")||{}).cdn)==null?void 0:B.mermaid)||Qq;await vs(o,Xq);const r=window.mermaid;g(Kq,r,"Resource load failed: Mermaid javaScript resource injection failed");const i=K(),l=await new Promise((D,x)=>{try{r.mermaidAPI.render(i,t,_=>{setTimeout(()=>{D(_)})})}catch(_){_.message=_.str,x(_)}}),h=new DOMParser().parseFromString(l,"image/svg+xml").firstChild,p=h.style.maxWidth;return p&&h.setAttribute("width",p),new XMLSerializer().serializeToString(h)}async function tG(n,t){const e=await ck(n,t);return Sm(e,"image/svg+xml",`${K()}.svg`)}async function eG(n,t){const e=await ck(n,t),o=new Blob([e]),r=new File([o],`${K()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class Mc extends W2{constructor(t){super(t,"mermaid","mermaidText")}static get(t,e){return t.addCustom(`mermaid-${e.id}`,()=>new Mc(t))}code2ObjectUrl(t){return tG(this.editor,t)}code2ResourceId(t){return eG(this.editor,t)}destroy(){}}const nG={graph:{invalid:"\u65E0\u6548\u7684 {EmbedName} \u5185\u5BB9\uFF1A{message}",empty:"\u7A7A\u7684 {EmbedName}",edit:"\u7F16\u8F91",comment:"\u6279\u6CE8",help:"\u5E2E\u52A9",errorTips:"{EmbedName}\u52A0\u8F7D\u5931\u8D25",errorSubTips:"\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5",retry:"\u91CD\u8BD5"}},oG={graph:{invalid:"Invalid {EmbedName} content: {message}",empty:"Empty {EmbedName}",edit:"Edit",comment:"Annotation",help:"Help",errorTips:"{EmbedName} loading failed",errorSubTips:"The network service is abnormal, you can",retry:"Try again"}},rG={graph:{invalid:"\u7121\u52B9\u306A{EmbedName}\uFF1A{message}",empty:"\u7A7A\u306E {EmbedName}",edit:"\u7DE8\u96C6",comment:"\u6CE8\u91C8",help:"\u30D8\u30EB\u30D7",errorTips:"{EmbedName} \u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F",errorSubTips:"\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 ",retry:"\u518D\u8A66\u884C"}};R.mergeLang({"zh-CN":nG,"en-US":oG,"ja-JP":rG});function iG(n,t,e){Mc.get(n,e).createEmbedContent(t,e)}function sG(n,t,e){const o=Mc.get(n,n.getBlockData(t)),r=Lt(t);return o.updateEmbedContent(r,e),!0}function lG(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="mermaid"||r!=="```mermaid"||!tt(n,t))return null;const i={src:"",mermaidText:""};return{blockData:{id:K(),type:"embed",embedType:"mermaid",embedData:i},onConverted:(a,d)=>{Mc.get(a,a.getBlockData(d)).editGraph(Lt(d))}}}function cG(n,t){return Mc.get(n,n.getBlockData(t)).getBlockProperties(t)}function aG(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.mermaidText?`<div class="mermaid">${i.mermaidText}</div>`:"<p>[mermaid]</p>";if(o==="markdown"){if(i.src)return`![mermaid](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`;if(i.mermaidText)return`\`\`\`mermaid\`\`\`
748
748
  ${i.mermaidText}
749
749
  \`\`\`\`\`\``}return"[mermaid]"}const ak={embedType:"mermaid",convertFrom:lG,handleUpdateBlock:sG,createEmbedContent:iG,getBlockProperties:cG,convertTo:aG},uk=S("flowchart-helper");async function uG(n){var o;const t=n.getComponentOptions("flowchart")||{},e=((o=t==null?void 0:t.cdn)==null?void 0:o.flowchart)||Yq;for(let r=0;r<e.length;r+=1){const i=e[r];await vs(i,`flowchart-scripts-${r}`)}}async function dk(n,t){const e=w("div",["flowchart-chart-container"],document.body);e.id=`flowchart-${K()}`,await uG(n);const o=window.flowchart;g(uk,o,"flowchart resource does not exist"),o.parse(t).drawSVG(e.id);const i=e.firstElementChild;g(uk,i,"svg element non-existent");const l=new XMLSerializer().serializeToString(i);return e.remove(),l}async function dG(n,t){const e=await dk(n,t);return Sm(e,"image/svg+xml",`${Date.now()}.svg`)}async function hG(n,t){const e=await dk(n,t),o=new Blob([e]),r=new File([o],`${K()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class Rc extends W2{constructor(t){super(t,"flowchart","flowchartText")}static get(t,e){return t.addCustom(`flowchart-${e.id}`,()=>new Rc(t))}code2ObjectUrl(t){return dG(this.editor,t)}code2ResourceId(t){return hG(this.editor,t)}destroy(){}}function fG(n,t,e){Rc.get(n,e).createEmbedContent(t,e)}function mG(n,t,e){const o=Rc.get(n,e),r=Lt(t);return o.updateEmbedContent(r,e),!0}function gG(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="flowchart"||r!=="```flowchart"||!tt(n,t))return null;const i={src:"",flowchartText:""};return{blockData:{id:K(),type:"embed",embedType:"flowchart",embedData:i},onConverted:(a,d)=>{Rc.get(a,a.getBlockData(d)).editGraph(Lt(d))}}}function pG(n,t){return Rc.get(n,n.getBlockData(t)).getBlockProperties(t)}function CG(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.flowchartText?`<div>${i.flowchartText}</div>`:"<p>[flowchart]</p>";if(o==="markdown"){if(i.src)return`![flowchart](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`;if(i.flowchartText)return`\`\`\`flowchart\`\`\`
750
750
  ${i.flowchartText}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "0.0.3-beta.189",
3
+ "version": "0.0.3-beta.190",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",