basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 6.33 kB
JavaScript
import{_ as t,cA as e,e as n,Z as i,N as a,bk as o,bV as r,h as l,bQ as p,bY as s,cB as u,X as h,b8 as c,bm as f,a9 as g,cn as d,E as v,bB as m,D as y,u as x,bU as _,a3 as b,aa as C,U as w,ad as O,I,bP as M,cC as T,g as A,G as P,a8 as U,d as G}from"./index.js";import{i as z,b as E,s as N,d as $,u as k,e as B,f as D,a as V}from"./customGraphicKeyframeAnimation.js";function j(t,e){var i;return n(e,(function(e){null!=t[e]&&"auto"!==t[e]&&(i=!0)})),i}var K=["transition","enterFrom","leaveTo"],S=K.concat(["enterAnimation","updateAnimation","leaveAnimation"]);function Z(t,e,n){if(n&&(!t[n]&&e[n]&&(t[n]={}),t=t[n],e=e[n]),t&&e)for(var i=n?K:S,a=0;a<i.length;a++){var o=i[a];null==t[o]&&null!=e[o]&&(t[o]=e[o])}}var F=function(r){function h(){var t=null!==r&&r.apply(this,arguments)||this;return t.type=h.type,t.preventAutoZ=!0,t}return t(h,r),h.prototype.mergeOption=function(t,e){var n=this.option.elements;this.option.elements=null,r.prototype.mergeOption.call(this,t,e),this.option.elements=n},h.prototype.optionUpdated=function(t,r){var h=this.option,c=(r?h:t).elements,f=h.elements=r?[]:h.elements,g=[];this._flatten(c,g,null);var d=e(f,g,"normalMerge"),v=this._elOptionsToUpdate=[];n(d,(function(t,e){var n=t.newOption;i(a(n)||t.existing,"Empty graphic option definition"),n&&(v.push(n),function(t,e){var n=t.existing;if(e.id=t.keyInfo.id,!e.type&&n&&(e.type=n.type),null==e.parentId){var i=e.parentOption;i?e.parentId=i.id:n&&(e.parentId=n.parentId)}e.parentOption=null}(t,n),function(t,e,n){var a=l({},n),o=t[e],r=n.$action||"merge";if("merge"===r)if(o){var h=n.type;i(!h||o.type===h,'Please set $action: "replace" to change `type`'),p(o,a,!0),s(o,a,{ignoreSize:!0}),u(n,o),Z(n,o),Z(n,o,"shape"),Z(n,o,"style"),Z(n,o,"extra"),n.clipPath=o.clipPath}else t[e]=a;else"replace"===r?t[e]=a:"remove"===r&&o&&(t[e]=null)}(f,e,n),function(t,e){if(t&&(t.hv=e.hv=[j(e,["left","right"]),j(e,["top","bottom"])],"group"===t.type)){var n=t,i=e;null==n.width&&(n.width=i.width=0),null==n.height&&(n.height=i.height=0)}}(f[e],n))}),this),h.elements=o(f,(function(t){return t&&delete t.$action,null!=t}))},h.prototype._flatten=function(t,e,i){n(t,(function(t){if(t){i&&(t.parentOption=i),e.push(t);var n=t.children;n&&n.length&&this._flatten(n,e,t),delete t.children}}),this)},h.prototype.useElOptionsToUpdate=function(){var t=this._elOptionsToUpdate;return this._elOptionsToUpdate=null,t},h.type="graphic",h.defaultOption={elements:[]},h}(r),H={path:null,compoundPath:null,group:P,image:U,text:g},Q=h(),W=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=a.type,t}return t(a,e),a.prototype.init=function(){this._elMap=c()},a.prototype.render=function(t,e,n){t!==this._lastGraphicModel&&this._clear(),this._lastGraphicModel=t,this._updateElements(t),this._relocate(t,n)},a.prototype._updateElements=function(t){var e=t.useElOptionsToUpdate();if(e){var a=this._elMap,o=this.group,r=t.get("z"),p=t.get("zlevel");n(e,(function(e){var s=f(e.id,null),u=null!=s?a.get(s):null,h=f(e.parentId,null),c=null!=h?a.get(h):o,v=e.type,m=e.style;"text"===v&&m&&e.hv&&e.hv[1]&&(m.textVerticalAlign=m.textBaseline=m.verticalAlign=m.align=null);var y=e.textContent,x=e.textConfig;if(m&&z(m,v,!!x,!!y)){var _=E(m,v,!0);!x&&_.textConfig&&(x=e.textConfig=_.textConfig),!y&&_.textContent&&(y=_.textContent)}var b=function(t){return t=l({},t),n(["id","parentId","$action","hv","bounding","textContent","clipPath"].concat(T),(function(e){delete t[e]})),t}(e);u&&i(c===u.parent,"Changing parent is not supported.");var C=e.$action||"merge",w="merge"===C,O="replace"===C;if(w){var I=u;(j=!u)?I=Y(s,c,e.type,a):(I&&(Q(I).isNew=!1),N(I)),I&&($(I,b,t,{isInit:j}),J(I,e,r,p))}else if(O){q(u,e,a,t);var M=Y(s,c,e.type,a);M&&($(M,b,t,{isInit:!0}),J(M,e,r,p))}else"remove"===C&&(k(u,e),q(u,e,a,t));var P=a.get(s);if(P&&y)if(w){var U=P.getTextContent();U?U.attr(y):P.setTextContent(new g(y))}else O&&P.setTextContent(new g(y));if(P){var G=e.clipPath;if(G){var D=G.type,V=void 0,j=!1;if(w){var K=P.getClipPath();V=(j=!K||Q(K).type!==D)?X(D):K}else O&&(j=!0,V=X(D));P.setClipPath(V),$(V,G,t,{isInit:j}),B(V,G.keyframeAnimation,t)}var S=Q(P);P.setTextConfig(x),S.option=e,function(t,e,n){var i=A(t).eventData;t.silent||t.ignore||i||(i=A(t).eventData={componentType:"graphic",componentIndex:e.componentIndex,name:t.name});i&&(i.info=n.info)}(P,t,e),d({el:P,componentModel:t,itemName:P.name,itemTooltipOption:e.tooltip}),B(P,e.keyframeAnimation,t)}}))}},a.prototype._relocate=function(t,e){for(var n=t.option.elements,i=this.group,a=this._elMap,o=e.getWidth(),r=e.getHeight(),l=["x","y"],p=0;p<n.length;p++){var s=n[p];if((d=null!=(g=f(s.id,null))?a.get(g):null)&&d.isGroup){var u=(_=d.parent)===i,h=Q(d),c=Q(_);h.width=v(h.option.width,u?o:c.width)||0,h.height=v(h.option.height,u?r:c.height)||0}}for(p=n.length-1;p>=0;p--){var g,d;s=n[p];if(d=null!=(g=f(s.id,null))?a.get(g):null){var _=d.parent,b=(c=Q(_),_===i?{width:o,height:r}:{width:c.width,height:c.height}),C={},w=m(d,s,b,null,{hv:s.hv,boundingMode:s.bounding},C);if(!Q(d).isNew&&w){for(var O=s.transition,I={},M=0;M<l.length;M++){var T=l[M],A=C[T];O&&(D(O)||y(O,T)>=0)?I[T]=A:d[T]=A}x(d,I,t,0)}else d.attr(C)}}},a.prototype._clear=function(){var t=this,e=this._elMap;e.each((function(n){q(n,Q(n).option,e,t._lastGraphicModel)})),this._elMap=c()},a.prototype.dispose=function(){this._clear()},a.type="graphic",a}(_);function X(t){i(t,"graphic type MUST be set");var e=b(H,t)?H[t]:C(t);i(e,"graphic type "+t+" can not be found");var n=new e({});return Q(n).type=t,n}function Y(t,e,n,i){var a=X(n);return e.add(a),i.set(t,a),Q(a).id=t,Q(a).isNew=!0,a}function q(t,e,n,i){t&&t.parent&&("group"===t.type&&t.traverse((function(t){q(t,e,n,i)})),V(t,e,i),n.removeKey(Q(t).id))}function J(t,e,i,a){t.isGroup||n([["cursor",O.prototype.cursor],["zlevel",a||0],["z",i||0],["z2",0]],(function(n){var i=n[0];b(e,i)?t[i]=w(e[i],n[1]):null==t[i]&&(t[i]=n[1])})),n(M(e),(function(n){if(0===n.indexOf("on")){var i=e[n];t[n]=I(i)?i:null}})),b(e,"draggable")&&(t.draggable=e.draggable),null!=e.name&&(t.name=e.name),null!=e.id&&(t.id=e.id)}function L(t){t.registerComponentModel(F),t.registerComponentView(W),t.registerPreprocessor((function(t){var e=t.graphic;G(e)?e[0]&&e[0].elements?t.graphic=[t.graphic[0]]:t.graphic=[{elements:e}]:e&&!e.elements&&(t.graphic=[{elements:[e]}])}))}export{L as install};